Unverified Commit 54496c29 authored by Lijiaoa's avatar Lijiaoa Committed by GitHub
Browse files

[WebUI] fix issue#2530: duration and intermediate results pictures don't update (#2531)

parent 89fa23cb
...@@ -151,13 +151,15 @@ class Customize extends React.Component<CustomizeProps, CustomizeState> { ...@@ -151,13 +151,15 @@ class Customize extends React.Component<CustomizeProps, CustomizeState> {
} }
} }
componentWillReceiveProps(nextProps: CustomizeProps): void { componentDidUpdate(prevProps: CustomizeProps): void {
const { copyTrialId } = nextProps; if (this.props.copyTrialId !== prevProps.copyTrialId) {
const { copyTrialId } = this.props;
if (copyTrialId !== undefined && TRIALS.getTrial(copyTrialId) !== undefined) { if (copyTrialId !== undefined && TRIALS.getTrial(copyTrialId) !== undefined) {
const originCopyTrialPara = TRIALS.getTrial(copyTrialId).description.parameters; const originCopyTrialPara = TRIALS.getTrial(copyTrialId).description.parameters;
this.setState(() => ({ copyTrialParameter: originCopyTrialPara })); this.setState(() => ({ copyTrialParameter: originCopyTrialPara }));
} }
} }
}
render(): React.ReactNode { render(): React.ReactNode {
const { closeCustomizeModal, visible } = this.props; const { closeCustomizeModal, visible } = this.props;
......
...@@ -39,7 +39,7 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState> ...@@ -39,7 +39,7 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState>
super(props); super(props);
this.state = { this.state = {
tablePageSize: 20, tablePageSize: 20,
whichGraph: '1', whichGraph: 'Default metric',
searchType: 'Id', searchType: 'Id',
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-function-return-type // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-function-return-type
searchFilter: trial => true searchFilter: trial => true
...@@ -81,8 +81,8 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState> ...@@ -81,8 +81,8 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState>
} }
} }
handleWhichTabs = (activeKey: string): void => { handleWhichTabs = (item: any): void => {
this.setState({ whichGraph: activeKey }); this.setState({whichGraph: item.props.headerText});
} }
updateSearchFilterType = (event: React.FormEvent<HTMLDivElement>, item: IDropdownOption | undefined): void => { updateSearchFilterType = (event: React.FormEvent<HTMLDivElement>, item: IDropdownOption | undefined): void => {
...@@ -109,19 +109,19 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState> ...@@ -109,19 +109,19 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState>
return ( return (
<div> <div>
<div className="trial" id="tabsty"> <div className="trial" id="tabsty">
<Pivot defaultSelectedKey={"0"} className="detial-title"> <Pivot defaultSelectedKey={"0"} className="detial-title" onLinkClick={this.handleWhichTabs} selectedKey={whichGraph}>
{/* <PivotItem tab={this.titleOfacc} key="1"> doesn't work*/} {/* <PivotItem tab={this.titleOfacc} key="1"> doesn't work*/}
<PivotItem headerText="Default metric" itemIcon="HomeGroup" key="1"> <PivotItem headerText="Default metric" itemIcon="HomeGroup" key="Default metric">
<Stack className="graph"> <Stack className="graph">
<DefaultPoint <DefaultPoint
trialIds={trialIds} trialIds={trialIds}
visible={whichGraph === '1'} visible={whichGraph === 'Default metric'}
trialsUpdateBroadcast={this.props.trialsUpdateBroadcast} trialsUpdateBroadcast={this.props.trialsUpdateBroadcast}
/> />
</Stack> </Stack>
</PivotItem> </PivotItem>
{/* <PivotItem tab={this.titleOfhyper} key="2"> */} {/* <PivotItem tab={this.titleOfhyper} key="2"> */}
<PivotItem headerText="Hyper-parameter" itemIcon="Equalizer" key="2"> <PivotItem headerText="Hyper-parameter" itemIcon="Equalizer" key="Hyper-parameter">
<Stack className="graph"> <Stack className="graph">
<Para <Para
dataSource={source} dataSource={source}
...@@ -131,11 +131,11 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState> ...@@ -131,11 +131,11 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState>
</Stack> </Stack>
</PivotItem> </PivotItem>
{/* <PivotItem tab={this.titleOfDuration} key="3"> */} {/* <PivotItem tab={this.titleOfDuration} key="3"> */}
<PivotItem headerText="Duration" itemIcon="BarChartHorizontal" key="3"> <PivotItem headerText="Duration" itemIcon="BarChartHorizontal" key="Duration">
<Duration source={source} whichGraph={whichGraph} /> <Duration source={source} whichGraph={whichGraph} />
</PivotItem> </PivotItem>
{/* <PivotItem tab={this.titleOfIntermediate} key="4"> */} {/* <PivotItem tab={this.titleOfIntermediate} key="4"> */}
<PivotItem headerText="Intermediate result" itemIcon="StackedLineChart" key="4"> <PivotItem headerText="Intermediate result" itemIcon="StackedLineChart" key="Intermediate result">
{/* *why this graph has small footprint? */} {/* *why this graph has small footprint? */}
<Intermediate source={source} whichGraph={whichGraph} /> <Intermediate source={source} whichGraph={whichGraph} />
</PivotItem> </PivotItem>
......
...@@ -126,10 +126,12 @@ class SuccessTable extends React.Component<SuccessTableProps, SuccessTableState> ...@@ -126,10 +126,12 @@ class SuccessTable extends React.Component<SuccessTableProps, SuccessTableState>
} }
]; ];
componentWillReceiveProps(nextProps: SuccessTableProps): void { componentDidUpdate(prevProps: SuccessTableProps): void {
const { trialIds } = nextProps; if(this.props.trialIds !== prevProps.trialIds){
const { trialIds } = this.props;
this.setState(() => ({ source: TRIALS.table(trialIds) })); this.setState(() => ({ source: TRIALS.table(trialIds) }));
} }
}
render(): React.ReactNode { render(): React.ReactNode {
const { columns, source } = this.state; const { columns, source } = this.state;
......
...@@ -167,36 +167,13 @@ class Duration extends React.Component<DurationProps, DurationState> { ...@@ -167,36 +167,13 @@ class Duration extends React.Component<DurationProps, DurationState> {
this.drawDurationGraph(source); this.drawDurationGraph(source);
} }
componentWillReceiveProps(nextProps: DurationProps): void { componentDidUpdate(prevProps: DurationProps): void {
const { whichGraph, source } = nextProps; // add this if to prevent endless loop
if (whichGraph === '3') { if (this.props.source !== prevProps.source) {
this.drawDurationGraph(source); if (this.props.whichGraph === 'Duration') {
} this.drawDurationGraph(this.props.source);
}
shouldComponentUpdate(nextProps: DurationProps): boolean {
const { whichGraph, source } = nextProps;
if (whichGraph === '3') {
const beforeSource = this.props.source;
if (whichGraph !== this.props.whichGraph) {
return true;
}
if (source.length !== beforeSource.length) {
return true;
}
if (beforeSource[beforeSource.length - 1] !== undefined) {
if (source[source.length - 1].duration !== beforeSource[beforeSource.length - 1].duration) {
return true;
}
if (source[source.length - 1].status !== beforeSource[beforeSource.length - 1].status) {
return true;
}
} }
} }
return false;
} }
render(): React.ReactNode { render(): React.ReactNode {
......
...@@ -212,11 +212,12 @@ class Intermediate extends React.Component<IntermediateProps, IntermediateState> ...@@ -212,11 +212,12 @@ class Intermediate extends React.Component<IntermediateProps, IntermediateState>
this.drawIntermediate(source); this.drawIntermediate(source);
} }
componentWillReceiveProps(nextProps: IntermediateProps, nextState: IntermediateState): void { componentDidUpdate(prevProps: IntermediateProps, prevState: any): void {
const { isFilter, filterSource } = nextState; if (this.props.source !== prevProps.source || this.state.isFilter !== prevState.isFilter) {
const { whichGraph, source } = nextProps; const { isFilter, filterSource } = this.state;
const { whichGraph, source } = this.props;
if (whichGraph === '4') { if (whichGraph === 'Intermediate result') {
if (isFilter === true) { if (isFilter === true) {
const pointVal = this.pointInput !== null ? this.pointInput.value : ''; const pointVal = this.pointInput !== null ? this.pointInput.value : '';
const minVal = this.minValInput !== null ? this.minValInput.value : ''; const minVal = this.minValInput !== null ? this.minValInput.value : '';
...@@ -230,6 +231,7 @@ class Intermediate extends React.Component<IntermediateProps, IntermediateState> ...@@ -230,6 +231,7 @@ class Intermediate extends React.Component<IntermediateProps, IntermediateState>
} }
} }
} }
}
render(): React.ReactNode { render(): React.ReactNode {
const { interSource, isLoadconfirmBtn, isFilter } = this.state; const { interSource, isLoadconfirmBtn, isFilter } = this.state;
......
...@@ -591,12 +591,14 @@ class Para extends React.Component<ParaProps, ParaState> { ...@@ -591,12 +591,14 @@ class Para extends React.Component<ParaProps, ParaState> {
this.reInit(); this.reInit();
} }
componentWillReceiveProps(nextProps: ParaProps): void { componentDidUpdate(prevProps: ParaProps): void {
const { dataSource, expSearchSpace, whichGraph } = nextProps; if(this.props.dataSource !== prevProps.dataSource) {
if (whichGraph === '2') { const { dataSource, expSearchSpace, whichGraph } = this.props;
if (whichGraph === 'Hyper-parameter') {
this.hyperParaPic(dataSource, expSearchSpace); this.hyperParaPic(dataSource, expSearchSpace);
} }
} }
}
render(): React.ReactNode { render(): React.ReactNode {
const { option, paraNodata, dimName, isLoadConfirm, selectedItem, swapyAxis } = this.state; const { option, paraNodata, dimName, isLoadConfirm, selectedItem, swapyAxis } = this.state;
......
...@@ -569,15 +569,17 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -569,15 +569,17 @@ class TableList extends React.Component<TableListProps, TableListState> {
window.addEventListener('resize', this.onWindowResize); window.addEventListener('resize', this.onWindowResize);
} }
UNSAFE_componentWillReceiveProps(nextProps: TableListProps): void { componentDidUpdate(prevProps: TableListProps): void {
const { columnList, tableSource } = nextProps; if (this.props.columnList !== prevProps.columnList || this.props.tableSource !== prevProps.tableSource) {
const { columnList, tableSource } = this.props;
this.setState({ this.setState({
tableSourceForSort: tableSource, tableSourceForSort: tableSource,
tableColumns: this.initTableColumnList(columnList), tableColumns: this.initTableColumnList(columnList),
allColumnList: this.getAllColumnKeys() allColumnList: this.getAllColumnKeys()
}); });
} }
}
render(): React.ReactNode { render(): React.ReactNode {
const { intermediateKey, modalIntermediateWidth, modalIntermediateHeight, const { intermediateKey, modalIntermediateWidth, modalIntermediateHeight,
tableColumns, allColumnList, isShowColumn, modalVisible, tableColumns, allColumnList, isShowColumn, modalVisible,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment