"deployment/git@developer.sourcefind.cn:OpenDAS/nni.git" did not exist on "45c6508eec59fbc40255d9703b6c606c76b1d842"
Commit 61fec446 authored by Lijiao's avatar Lijiao Committed by Yan Ni
Browse files

Enhancement: ability to adjust rendering interval (#1181)

* Add interval

* update

* change back react version

* change to alpha version
parent e12df2b1
...@@ -9,11 +9,12 @@ ...@@ -9,11 +9,12 @@
"copy-to-clipboard": "^3.0.8", "copy-to-clipboard": "^3.0.8",
"echarts": "^4.1.0", "echarts": "^4.1.0",
"echarts-for-react": "^2.0.14", "echarts-for-react": "^2.0.14",
"react": "^16.4.2", "react": "^16.7.0-alpha.2",
"react-dom": "^16.4.2", "react-dom": "^16.7.0-alpha.2",
"react-json-tree": "^0.11.0", "react-json-tree": "^0.11.0",
"react-monaco-editor": "^0.22.0", "react-monaco-editor": "^0.22.0",
"react-router": "3.2.1", "react-router": "3.2.1",
"react-responsive": "^7.0.0",
"react-scripts-ts-antd": "2.17.0" "react-scripts-ts-antd": "2.17.0"
}, },
"scripts": { "scripts": {
...@@ -28,7 +29,8 @@ ...@@ -28,7 +29,8 @@
"@types/react": "^16.4.17", "@types/react": "^16.4.17",
"@types/react-dom": "^16.0.7", "@types/react-dom": "^16.0.7",
"@types/react-json-tree": "^0.6.8", "@types/react-json-tree": "^0.6.8",
"@types/react-responsive": "^3.0.3",
"@types/react-router": "3.0.15", "@types/react-router": "3.0.15",
"typescript": "^3.0.1" "typescript": "^3.0.1"
} }
} }
\ No newline at end of file
...@@ -15,9 +15,7 @@ ...@@ -15,9 +15,7 @@
border-right: 1px solid #ccc; border-right: 1px solid #ccc;
z-index: 1000; z-index: 1000;
} }
.headerCon{
min-width: 1024px;
}
.contentBox{ .contentBox{
width: 100%; width: 100%;
} }
...@@ -29,5 +27,3 @@ ...@@ -29,5 +27,3 @@
margin-bottom: 30px; margin-bottom: 30px;
background: #fff; background: #fff;
} }
...@@ -3,20 +3,59 @@ import { Row, Col } from 'antd'; ...@@ -3,20 +3,59 @@ import { Row, Col } from 'antd';
import './App.css'; import './App.css';
import SlideBar from './components/SlideBar'; import SlideBar from './components/SlideBar';
class App extends React.Component<{}, {}> { interface AppState {
interval: number;
whichPageToFresh: string;
}
class App extends React.Component<{}, AppState> {
public _isMounted: boolean;
constructor(props: {}) {
super(props);
this.state = {
interval: 10, // sendons
whichPageToFresh: ''
};
}
changeInterval = (interval: number) => {
if (this._isMounted === true) {
this.setState(() => ({ interval: interval }));
}
}
changeFresh = (fresh: string) => {
// interval * 1000
if (this._isMounted === true) {
this.setState(() => ({ whichPageToFresh: fresh }));
}
}
componentDidMount() {
this._isMounted = true;
}
componentWillUnmount() {
this._isMounted = false;
}
render() { render() {
const { interval, whichPageToFresh } = this.state;
const reactPropsChildren = React.Children.map(this.props.children, child =>
// tslint:disable-next-line:no-any
React.cloneElement(child as React.ReactElement<any>, { interval, whichPageToFresh })
);
return ( return (
<Row className="nni" style={{minHeight: window.innerHeight}}> <Row className="nni" style={{ minHeight: window.innerHeight }}>
<Row className="header"> <Row className="header">
<Col span={1} /> <Col span={1} />
<Col className="headerCon" span={22}> <Col className="headerCon" span={22}>
<SlideBar /> <SlideBar changeInterval={this.changeInterval} changeFresh={this.changeFresh}/>
</Col> </Col>
<Col span={1} /> <Col span={1} />
</Row> </Row>
<Row className="contentBox"> <Row className="contentBox">
<Row className="content"> <Row className="content">
{this.props.children} {reactPropsChildren}
</Row> </Row>
</Row> </Row>
</Row> </Row>
......
...@@ -39,13 +39,18 @@ interface OverviewState { ...@@ -39,13 +39,18 @@ interface OverviewState {
isMultiPhase: boolean; isMultiPhase: boolean;
} }
class Overview extends React.Component<{}, OverviewState> { interface OverviewProps {
interval: number; // user select
whichPageToFresh: string;
}
class Overview extends React.Component<OverviewProps, OverviewState> {
public _isMounted = false; public _isMounted = false;
public intervalID = 0; public intervalID = 0;
public intervalProfile = 1; public intervalProfile = 1;
constructor(props: {}) { constructor(props: OverviewProps) {
super(props); super(props);
this.state = { this.state = {
searchSpace: {}, searchSpace: {},
...@@ -377,17 +382,19 @@ class Overview extends React.Component<{}, OverviewState> { ...@@ -377,17 +382,19 @@ class Overview extends React.Component<{}, OverviewState> {
data: accarr data: accarr
}] }]
}; };
this.setState({ accuracyData: accOption }, () => { if (this._isMounted) {
if (accarr.length === 0) { this.setState({ accuracyData: accOption }, () => {
this.setState({ if (accarr.length === 0) {
accNodata: 'No data' this.setState({
}); accNodata: 'No data'
} else { });
this.setState({ } else {
accNodata: '' this.setState({
}); accNodata: ''
} });
}); }
});
}
} }
clickMaxTop = (event: React.SyntheticEvent<EventTarget>) => { clickMaxTop = (event: React.SyntheticEvent<EventTarget>) => {
...@@ -405,23 +412,39 @@ class Overview extends React.Component<{}, OverviewState> { ...@@ -405,23 +412,39 @@ class Overview extends React.Component<{}, OverviewState> {
isOffInterval = () => { isOffInterval = () => {
const { status } = this.state; const { status } = this.state;
switch (status) { const { interval } = this.props;
case 'DONE': if (status === 'DONE' || status === 'ERROR' || status === 'STOPPED' ||
case 'ERROR': interval === 0
case 'STOPPED': ) {
window.clearInterval(this.intervalID); window.clearInterval(this.intervalID);
window.clearInterval(this.intervalProfile); window.clearInterval(this.intervalProfile);
break; return;
default: }
}
componentWillReceiveProps(nextProps: OverviewProps) {
const { interval, whichPageToFresh } = nextProps;
window.clearInterval(this.intervalID);
window.clearInterval(this.intervalProfile);
if (whichPageToFresh.includes('/oview')) {
this.showTrials();
this.showSessionPro();
}
if (interval !== 0) {
this.intervalID = window.setInterval(this.showTrials, interval * 1000);
this.intervalProfile = window.setInterval(this.showSessionPro, interval * 1000);
} }
} }
componentDidMount() { componentDidMount() {
this._isMounted = true; this._isMounted = true;
this.showSessionPro(); const { interval } = this.props;
this.showTrials(); this.showTrials();
this.intervalID = window.setInterval(this.showTrials, 10000); this.showSessionPro();
this.intervalProfile = window.setInterval(this.showSessionPro, 60000); if (interval !== 0) {
this.intervalID = window.setInterval(this.showTrials, interval * 1000);
this.intervalProfile = window.setInterval(this.showSessionPro, interval * 1000);
}
} }
componentWillUnmount() { componentWillUnmount() {
...@@ -447,7 +470,7 @@ class Overview extends React.Component<{}, OverviewState> { ...@@ -447,7 +470,7 @@ class Overview extends React.Component<{}, OverviewState> {
</Row> </Row>
<Row className="overMessage"> <Row className="overMessage">
{/* status graph */} {/* status graph */}
<Col span={9} className="prograph overviewBoder"> <Col span={9} className="prograph overviewBoder cc">
<Title1 text="Status" icon="5.png" /> <Title1 text="Status" icon="5.png" />
<Progressed <Progressed
trialNumber={trialNumber} trialNumber={trialNumber}
...@@ -459,13 +482,13 @@ class Overview extends React.Component<{}, OverviewState> { ...@@ -459,13 +482,13 @@ class Overview extends React.Component<{}, OverviewState> {
/> />
</Col> </Col>
{/* experiment parameters search space tuner assessor... */} {/* experiment parameters search space tuner assessor... */}
<Col span={7} className="overviewBoder"> <Col span={7} className="overviewBoder cc">
<Title1 text="Search space" icon="10.png" /> <Title1 text="Search space" icon="10.png" />
<Row className="experiment"> <Row className="experiment">
<SearchSpace searchSpace={searchSpace} /> <SearchSpace searchSpace={searchSpace} />
</Row> </Row>
</Col> </Col>
<Col span={8} className="overviewBoder"> <Col span={8} className="overviewBoder cc">
<Title1 text="Profile" icon="4.png" /> <Title1 text="Profile" icon="4.png" />
<Row className="experiment"> <Row className="experiment">
{/* the scroll bar all the trial profile in the searchSpace div*/} {/* the scroll bar all the trial profile in the searchSpace div*/}
......
This diff is collapsed.
...@@ -33,7 +33,12 @@ interface TrialDetailState { ...@@ -33,7 +33,12 @@ interface TrialDetailState {
intermediateCounts: number; intermediateCounts: number;
} }
class TrialsDetail extends React.Component<{}, TrialDetailState> { interface TrialsDetailProps {
interval: number;
whichPageToFresh: string;
}
class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState> {
public _isMounted = false; public _isMounted = false;
public interAccuracy = 0; public interAccuracy = 0;
...@@ -61,7 +66,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> { ...@@ -61,7 +66,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
</div> </div>
); );
constructor(props: {}) { constructor(props: TrialsDetailProps) {
super(props); super(props);
this.state = { this.state = {
...@@ -227,21 +232,24 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> { ...@@ -227,21 +232,24 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
// close timer // close timer
isOffIntervals = () => { isOffIntervals = () => {
axios(`${MANAGER_IP}/check-status`, { const { interval } = this.props;
method: 'GET' if (interval === 0) {
}) window.clearInterval(this.interTableList);
.then(res => { return;
if (res.status === 200 && this._isMounted) { } else {
switch (res.data.status) { axios(`${MANAGER_IP}/check-status`, {
case 'DONE': method: 'GET'
case 'ERROR': })
case 'STOPPED': .then(res => {
if (res.status === 200 && this._isMounted) {
const expStatus = res.data.status;
if (expStatus === 'DONE' || expStatus === 'ERROR' || expStatus === 'STOPPED') {
window.clearInterval(this.interTableList); window.clearInterval(this.interTableList);
break; return;
default: }
} }
} });
}); }
} }
handleEntriesSelect = (value: string) => { handleEntriesSelect = (value: string) => {
...@@ -304,11 +312,23 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> { ...@@ -304,11 +312,23 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
}); });
} }
componentWillReceiveProps(nextProps: TrialsDetailProps) {
const { interval, whichPageToFresh } = nextProps;
window.clearInterval(this.interTableList);
if (interval !== 0) {
this.interTableList = window.setInterval(this.getDetailSource, interval * 1000);
}
if (whichPageToFresh.includes('/detail')) {
this.getDetailSource();
}
}
componentDidMount() { componentDidMount() {
this._isMounted = true; this._isMounted = true;
const { interval } = this.props;
this.getDetailSource(); this.getDetailSource();
this.interTableList = window.setInterval(this.getDetailSource, 10000); this.interTableList = window.setInterval(this.getDetailSource, interval * 1000);
this.checkExperimentPlatform(); this.checkExperimentPlatform();
} }
...@@ -329,7 +349,6 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> { ...@@ -329,7 +349,6 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
<div> <div>
<div className="trial" id="tabsty"> <div className="trial" id="tabsty">
<Tabs type="card" onChange={this.handleWhichTabs}> <Tabs type="card" onChange={this.handleWhichTabs}>
{/* <TabPane tab={this.titleOfacc} key="1" destroyInactiveTabPane={true}> */}
<TabPane tab={this.titleOfacc} key="1"> <TabPane tab={this.titleOfacc} key="1">
<Row className="graph"> <Row className="graph">
<DefaultPoint <DefaultPoint
...@@ -350,7 +369,6 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> { ...@@ -350,7 +369,6 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
</TabPane> </TabPane>
<TabPane tab={this.titleOfDuration} key="3"> <TabPane tab={this.titleOfDuration} key="3">
<Duration source={source} whichGraph={whichGraph} /> <Duration source={source} whichGraph={whichGraph} />
{/* <Duration source={source} whichGraph={whichGraph} clickCounts={durationCounts} /> */}
</TabPane> </TabPane>
<TabPane tab={this.titleOfIntermediate} key="4"> <TabPane tab={this.titleOfIntermediate} key="4">
<Intermediate source={source} whichGraph={whichGraph} /> <Intermediate source={source} whichGraph={whichGraph} />
......
$barHeight: 56px; $barHeight: 56px;
/* drowdown and select default bgcolor */
$drowBgColor: #f2f2f2;
/* drowdown and select hover bgcolor */
$drowHoverBgColor: #e2e2e2;
.nav{ .nav{
list-style: none; list-style: none;
width: 94%; width: 95%;
height: $barHeight; height: $barHeight;
margin: 0 auto; margin: 0 auto;
position: relative;
.tab{ .tab{
font-family: 'Segoe'; font-family: 'Segoe';
line-height: $barHeight; line-height: $barHeight;
...@@ -14,7 +19,7 @@ $barHeight: 56px; ...@@ -14,7 +19,7 @@ $barHeight: 56px;
} }
} }
.firstTab{ .firstTab{
margin: 0 32px; margin: 0 20px;
} }
.logo{ .logo{
margin-top: 2px; margin-top: 2px;
...@@ -28,17 +33,26 @@ $barHeight: 56px; ...@@ -28,17 +33,26 @@ $barHeight: 56px;
} }
.feedback{ .feedback{
text-align: right; position: fixed;
right: 19%;
line-height: $barHeight; line-height: $barHeight;
font-size: 16px; font-size: 16px;
color: #fff; color: #fff;
.fresh{
span{
margin: 0 10px 0 3px;
}
}
.fresh:hover{
cursor: pointer;
}
a{ a{
color: #fff; color: #fff;
text-decoration: none; text-decoration: none;
margin-left: 10px; margin-left: 10px;
} }
img{ img{
width: 24px; width: 20px;
margin-right: 8px; margin-right: 8px;
} }
.version{ .version{
...@@ -51,4 +65,66 @@ $barHeight: 56px; ...@@ -51,4 +65,66 @@ $barHeight: 56px;
} }
.dropdown{ .dropdown{
margin-right: 10px; margin-right: 10px;
} /* make dropdown content box position in blue bar bottom */
\ No newline at end of file padding-bottom: 14px;
}
.interval{
position: fixed;
right: 7%;
top: 12px;
.ant-select-selection{
background-color: transparent;
border: none;
color: #fff;
outline: none;
font-size: 16px;
}
.ant-select-arrow{
color: #fff;
}
}
/* set select bgcolor */
.ant-select-dropdown-menu{
background-color: $drowBgColor;
}
.ant-select-dropdown-menu-item:hover{
background-color: $drowHoverBgColor;
}
.ant-select-dropdown-menu-item-active{
background-color: transparent;
}
/* set dropdown bgcolor */
.ant-dropdown{
.ant-dropdown-menu{
padding: 0;
background-color: $drowBgColor;
border-radius: 0;
.ant-dropdown-menu-item:hover{
background-color: $drowHoverBgColor;
}
}
}
/* nav style*/
.little{
width: 100%;
.menu{
.show{
display: block;
}
.hide{
display: none;
}
.more{
color: #fff;
font-size: 24px;
margin-top: 16px;
}
.more:hover{
cursor: pointer;
}
}
.logo{
text-align: center;
}
}
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