Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force reconstruct of review tab for fresh results on model change #712

Merged
merged 1 commit into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions neuroscout/frontend/src/analysis_builder/Builder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1219,12 +1219,12 @@ export default class AnalysisBuilder extends Reflux.Component<any, BuilderProps
<br/>
</TabPane>}
<TabPane tab="Review" key="review" disabled={((!reviewActive || !analysis.analysisId) && isDraft)}>
{this.state.model &&
{this.state.model && this.state.activeTab === ('review' as TabName) &&
<div>
<Report
analysisId={analysis.analysisId}
runIds={analysis.runIds}
postReports={this.state.postReports}
postReports={this.state.activeTab === ('review' as TabName)}
defaultVisible={this.state.doTooltip && this.state.activeTab === ('review' as TabName)}
/>
<Review
Expand Down
21 changes: 14 additions & 7 deletions neuroscout/frontend/src/analysis_builder/Report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class Plots extends React.Component<{plots: any[], corr_plots: any[]}, {}> {
this.props.plots.map((x, i) => {
let spec = x;
display.push(
<TabPane tab="First run" key={'' + i}>
<TabPane tab={'First Run'} key={'' + i}>
<Collapse bordered={false} defaultActiveKey={['dm']}>
<Panel header="Design Matrix" key="dm">
<VegaPlot spec={spec}/>
<VegaPlot spec={this.props.plots[i]}/>
</Panel>
<Panel header="Correlation Matrix" key="cm">
<VegaPlot spec={this.props.corr_plots[i]}/>
Expand Down Expand Up @@ -138,13 +138,15 @@ export class Report extends React.Component<ReportProps, ReportState> {
if (this.state.reportsLoaded === true) {
return;
}

let state = {...this.state};
jwtFetch(`${domainRoot}/api/analyses/${id}/report`)
jwtFetch(`${domainRoot}/api/analyses/${id}/report?run_id=${this.state.selectedRunIds}`)
.then((res) => {
if (res.status === 'OK') {
if (res.result === undefined) {
return;
}

state.matrices = res.result.design_matrix;
state.plots = res.result.design_matrix_plot;
state.corr_plots = res.result.design_matrix_corrplot;
Expand All @@ -156,13 +158,15 @@ export class Report extends React.Component<ReportProps, ReportState> {
}
} else if (res.status === 'FAILED') {
state.reportTraceback = res.traceback;
this.setState({reportsPosted: true});
} else if (res.statusCode === 404 && !this.state.reportsPosted) {
this.generateReport();
this.setState({reportsPosted: true});
this.setState({reportsPosted: true, reportsLoaded: false});
return;
} else {
return;
}

state.reportsLoaded = true;
this.setState({...state});
});
Expand All @@ -188,15 +192,18 @@ export class Report extends React.Component<ReportProps, ReportState> {
}
}

componentWillReceiveProps(nextProps: ReportProps) {
if (nextProps.postReports) {
componentDidUpdate(prevProps, prevState) {
if (prevProps.postReports === false && this.props.postReports === true) {
this.setState(
{
reportsLoaded: false,
reportsPosted: false,
},
() => this.checkReportStatus()
);
this.checkReportStatus();
}
if (prevState.reportsLoaded === true && this.state.reportsLoaded === false) {
this.checkReportStatus();
}
}

Expand Down