Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

[webui] Maintain selected status when the page switched #1710

Merged
merged 1 commit into from
Nov 11, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/webui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface AppState {
columnList: Array<string>;
experimentUpdateBroadcast: number;
trialsUpdateBroadcast: number;
metricGraphMode: 'max' | 'min'; // tuner's optimize_mode filed
}

class App extends React.Component<{}, AppState> {
Expand All @@ -22,6 +23,7 @@ class App extends React.Component<{}, AppState> {
columnList: COLUMN,
experimentUpdateBroadcast: 0,
trialsUpdateBroadcast: 0,
metricGraphMode: 'max'
};
}

Expand All @@ -30,6 +32,7 @@ class App extends React.Component<{}, AppState> {
this.setState(state => ({ experimentUpdateBroadcast: state.experimentUpdateBroadcast + 1 }));
this.setState(state => ({ trialsUpdateBroadcast: state.trialsUpdateBroadcast + 1 }));
this.timerId = window.setTimeout(this.refresh, this.state.interval * 1000);
this.setState({ metricGraphMode: (EXPERIMENT.optimizeMode === 'minimize' ? 'min' : 'max') });
}

changeInterval = (interval: number) => {
Expand All @@ -46,8 +49,12 @@ class App extends React.Component<{}, AppState> {
this.setState({ columnList: columnList });
}

changeMetricGraphMode = (val: 'max' | 'min') => {
this.setState({ metricGraphMode: val });
}

render() {
const { interval, columnList, experimentUpdateBroadcast, trialsUpdateBroadcast } = this.state;
const { interval, columnList, experimentUpdateBroadcast, trialsUpdateBroadcast, metricGraphMode } = this.state;
if (experimentUpdateBroadcast === 0 || trialsUpdateBroadcast === 0) {
return null; // TODO: render a loading page
}
Expand All @@ -59,6 +66,7 @@ class App extends React.Component<{}, AppState> {
columnList, changeColumn: this.changeColumn,
experimentUpdateBroadcast,
trialsUpdateBroadcast,
metricGraphMode, changeMetricGraphMode: this.changeMetricGraphMode
})
);
return (
Expand Down
18 changes: 10 additions & 8 deletions src/webui/src/components/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,42 @@ require('../static/style/overviewTitle.scss');
interface OverviewProps {
experimentUpdateBroadcast: number;
trialsUpdateBroadcast: number;
metricGraphMode: 'max' | 'min';
changeMetricGraphMode: (val: 'max' | 'min') => void;
}

interface OverviewState {
trialConcurrency: number;
metricGraphMode: 'max' | 'min';
}

class Overview extends React.Component<OverviewProps, OverviewState> {
constructor(props: OverviewProps) {
super(props);
this.state = {
trialConcurrency: EXPERIMENT.trialConcurrency,
metricGraphMode: (EXPERIMENT.optimizeMode === 'minimize' ? 'min' : 'max'),
trialConcurrency: EXPERIMENT.trialConcurrency
};
}

clickMaxTop = (event: React.SyntheticEvent<EventTarget>) => {
event.stopPropagation();
// #999 panel active bgcolor; #b3b3b3 as usual
this.setState({ metricGraphMode: 'max' });
const { changeMetricGraphMode } = this.props;
changeMetricGraphMode('max');
}

clickMinTop = (event: React.SyntheticEvent<EventTarget>) => {
event.stopPropagation();
this.setState({ metricGraphMode: 'min' });
const { changeMetricGraphMode } = this.props;
changeMetricGraphMode('min');
}

changeConcurrency = (val: number) => {
this.setState({ trialConcurrency: val });
}

render() {
const { trialConcurrency, metricGraphMode } = this.state;
const { experimentUpdateBroadcast } = this.props;
const { trialConcurrency } = this.state;
const { experimentUpdateBroadcast, metricGraphMode } = this.props;

const searchSpace = this.convertSearchSpace();

Expand Down Expand Up @@ -160,7 +162,7 @@ class Overview extends React.Component<OverviewProps, OverviewState> {

private findBestTrials(): Trial[] {
let bestTrials = TRIALS.sort();
if (this.state.metricGraphMode === 'max') {
if (this.props.metricGraphMode === 'max') {
bestTrials.reverse().splice(10);
} else {
bestTrials.splice(10);
Expand Down