Commit 5b24f046 authored by Lijiao's avatar Lijiao Committed by QuanluZhang
Browse files

Fix the issue#211: WebUI does not support search for a specific Trial (#355)

* Fix the issue#211: WebUI does not support search for a specific Trial

* delete unuseful code

* Update

* default 20
parent 9380e68c
import * as React from 'react';
import axios from 'axios';
import { message } from 'antd';
import { MANAGER_IP } from '../static/const';
import '../static/style/tensor.scss';
interface TensorState {
urlTensor: string;
idTensor: string;
}
message.config({
top: 250,
duration: 2,
});
class Tensor extends React.Component<{}, TensorState> {
public _isMounted = false;
constructor(props: {}) {
super(props);
this.state = {
urlTensor: '',
idTensor: ''
};
}
geturl(): void {
Object.keys(this.props).forEach(item => {
if (item === 'location') {
let tensorId = this.props[item].state;
if (tensorId !== undefined && this._isMounted) {
this.setState({ idTensor: tensorId }, () => {
axios(`${MANAGER_IP}/tensorboard`, {
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
params: {
job_ids: tensorId
}
}).then(res => {
if (res.status === 200) {
setTimeout(
() => {
const url = new URL(res.data.endPoint);
if (url.hostname === 'localhost') {
url.hostname = window.location.hostname;
}
this.setState(
{ urlTensor: url.href },
() => message.success('Successful send'));
},
1000);
} else {
message.error('fail to link to tensorboard');
}
});
});
} else {
message.warning('Please link to Trial Status page to select a trial!');
}
}
});
}
componentDidMount() {
this._isMounted = true;
this.geturl();
}
componentWillUnmount() {
this._isMounted = false;
}
render() {
const { urlTensor } = this.state;
return (
<div className="tensor">
<div className="title">TensorBoard</div>
<div className="tenhttpage">
<iframe
frameBorder="no"
src={urlTensor}
sandbox="allow-scripts allow-same-origin"
/>
</div>
</div>
);
}
}
export default Tensor;
\ No newline at end of file
import * as React from 'react'; import * as React from 'react';
import axios from 'axios'; import axios from 'axios';
import { MANAGER_IP } from '../static/const'; import { MANAGER_IP } from '../static/const';
import { Row, Tabs } from 'antd'; import { Row, Col, Button, Tabs, Input } from 'antd';
const Search = Input.Search;
import { TableObj, Parameters, AccurPoint } from '../static/interface'; import { TableObj, Parameters, AccurPoint } from '../static/interface';
import Accuracy from './overview/Accuracy'; import Accuracy from './overview/Accuracy';
import Duration from './trial-detail/Duration'; import Duration from './trial-detail/Duration';
...@@ -22,6 +23,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> { ...@@ -22,6 +23,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
public _isMounted = false; public _isMounted = false;
public interAccuracy = 0; public interAccuracy = 0;
public interTableList = 1; public interTableList = 1;
constructor(props: {}) { constructor(props: {}) {
super(props); super(props);
...@@ -30,7 +32,6 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> { ...@@ -30,7 +32,6 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
accNodata: '', accNodata: '',
tableListSource: [] tableListSource: []
}; };
} }
// trial accuracy graph // trial accuracy graph
drawPointGraph = () => { drawPointGraph = () => {
...@@ -202,11 +203,38 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> { ...@@ -202,11 +203,38 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
} }
} }
// search a specific trial by trial No.
searchTrialNo = (value: string) => {
window.clearInterval(this.interTableList);
const { tableListSource } = this.state;
const searchResultList: Array<TableObj> = [];
Object.keys(tableListSource).map(key => {
const item = tableListSource[key];
if (item.sequenceId.toString() === value) {
searchResultList.push(item);
}
});
this.setState(() => ({
tableListSource: searchResultList
}));
}
// reset btn click: rerender table
resetRenderTable = () => {
const searchInput = document.getElementById('searchTrial') as HTMLInputElement;
if (searchInput !== null) {
searchInput.value = '';
}
this.drawTableList();
this.interTableList = window.setInterval(this.drawTableList, 10000);
}
componentDidMount() { componentDidMount() {
this._isMounted = true; this._isMounted = true;
this.drawPointGraph();
this.drawTableList(); this.drawTableList();
this.drawPointGraph();
this.interAccuracy = window.setInterval(this.drawPointGraph, 10000); this.interAccuracy = window.setInterval(this.drawPointGraph, 10000);
this.interTableList = window.setInterval(this.drawTableList, 10000); this.interTableList = window.setInterval(this.drawTableList, 10000);
} }
...@@ -253,6 +281,26 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> { ...@@ -253,6 +281,26 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
</Tabs> </Tabs>
</div> </div>
{/* trial table list */} {/* trial table list */}
<Row className="allList">
<Col span={12}>
<Title1 text="All Trials" icon="6.png" />
</Col>
<Col span={12} className="btns">
<Search
placeholder="input search Trial No."
onSearch={value => this.searchTrialNo(value)}
style={{ width: 200 }}
id="searchTrial"
/>
<Button
type="primary"
className="tableButton resetBtn"
onClick={this.resetRenderTable}
>
Reset
</Button>
</Col>
</Row>
<TableList <TableList
tableSource={tableListSource} tableSource={tableListSource}
updateList={this.drawTableList} updateList={this.drawTableList}
......
...@@ -429,7 +429,7 @@ class Para extends React.Component<{}, ParaState> { ...@@ -429,7 +429,7 @@ class Para extends React.Component<{}, ParaState> {
</Select> </Select>
<Button <Button
type="primary" type="primary"
className="changeBtu" className="changeBtu tableButton"
onClick={this.swapBtn} onClick={this.swapBtn}
> >
Confirm Confirm
......
import * as React from 'react'; import * as React from 'react';
import axios from 'axios'; import axios from 'axios';
import JSONTree from 'react-json-tree'; import JSONTree from 'react-json-tree';
import { browserHistory } from 'react-router';
import ReactEcharts from 'echarts-for-react'; import ReactEcharts from 'echarts-for-react';
import { Row, Table, Button, Popconfirm, Modal, message } from 'antd'; import { Row, Table, Button, Popconfirm, Modal, message } from 'antd';
import { MANAGER_IP, trialJobStatus } from '../../static/const'; import { MANAGER_IP, trialJobStatus } from '../../static/const';
import { convertDuration } from '../../static/function'; import { convertDuration } from '../../static/function';
import { TableObj, TrialJob } from '../../static/interface'; import { TableObj, TrialJob } from '../../static/interface';
import Title1 from '../overview/Title1';
require('../../static/style/tableStatus.css'); require('../../static/style/tableStatus.css');
require('../../static/style/logPath.scss'); require('../../static/style/logPath.scss');
require('../../static/style/search.scss');
require('../../static/style/table.scss'); require('../../static/style/table.scss');
require('../../static/style/button.scss'); require('../../static/style/button.scss');
const echarts = require('echarts/lib/echarts'); const echarts = require('echarts/lib/echarts');
...@@ -136,17 +135,6 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -136,17 +135,6 @@ class TableList extends React.Component<TableListProps, TableListState> {
}); });
} }
// get tensorflow address
getTensorpage = (id: string) => {
let path = {
pathname: '/tensor',
state: id
};
browserHistory.push(path);
}
componentDidMount() { componentDidMount() {
this._isMounted = true; this._isMounted = true;
} }
...@@ -156,6 +144,7 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -156,6 +144,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
} }
render() { render() {
const { tableSource } = this.props; const { tableSource } = this.props;
const { intermediateOption, modalVisible } = this.state; const { intermediateOption, modalVisible } = this.state;
let bgColor = ''; let bgColor = '';
...@@ -172,7 +161,7 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -172,7 +161,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
key: 'sequenceId', key: 'sequenceId',
width: 120, width: 120,
className: 'tableHead', className: 'tableHead',
sorter: (a: TableObj, b: TableObj) => (a.sequenceId as number) - (b.sequenceId as number) sorter: (a: TableObj, b: TableObj) => (a.sequenceId as number) - (b.sequenceId as number),
}, { }, {
title: 'Id', title: 'Id',
dataIndex: 'id', dataIndex: 'id',
...@@ -286,18 +275,18 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -286,18 +275,18 @@ class TableList extends React.Component<TableListProps, TableListState> {
); );
}, },
}, { }, {
title: 'Tensor', title: 'Intermediate Result',
dataIndex: 'tensor', dataIndex: 'intermediate',
key: 'tensor', key: 'intermediate',
width: '16%', width: '16%',
render: (text: string, record: TableObj) => { render: (text: string, record: TableObj) => {
return ( return (
<Button <Button
type="primary" type="primary"
className="tableButton" className="tableButton"
onClick={this.getTensorpage.bind(this, record.id)} onClick={this.showIntermediateModal.bind(this, record.id)}
> >
TensorBoard Intermediate
</Button> </Button>
); );
}, },
...@@ -347,27 +336,19 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -347,27 +336,19 @@ class TableList extends React.Component<TableListProps, TableListState> {
<span className="logContent">{logPathRow}</span> <span className="logContent">{logPathRow}</span>
</div> </div>
} }
<Button
type="primary"
className="tableButton"
onClick={this.showIntermediateModal.bind(this, record.id)}
>
Intermediate Result
</Button>
</pre> </pre>
); );
}; };
return ( return (
<Row className="tableList"> <Row className="tableList">
<Row><Title1 text="All Trials" icon="6.png" /></Row>
<div id="tableList"> <div id="tableList">
<Table <Table
columns={columns} columns={columns}
expandedRowRender={openRow} expandedRowRender={openRow}
dataSource={tableSource} dataSource={tableSource}
className="commonTableStyle" className="commonTableStyle"
pagination={{ pageSize: 10 }} pagination={{ pageSize: 20 }}
/> />
<Modal <Modal
title="Intermediate Result" title="Intermediate Result"
......
...@@ -4,11 +4,9 @@ import * as ReactDOM from 'react-dom'; ...@@ -4,11 +4,9 @@ import * as ReactDOM from 'react-dom';
import App from './App'; import App from './App';
import { Router, Route, browserHistory, IndexRedirect } from 'react-router'; import { Router, Route, browserHistory, IndexRedirect } from 'react-router';
import registerServiceWorker from './registerServiceWorker'; import registerServiceWorker from './registerServiceWorker';
import Tensor from './components/Tensor';
import Control from './components/Control'; import Control from './components/Control';
import Overview from './components/Overview'; import Overview from './components/Overview';
import TrialsDetail from './components/TrialsDetail'; import TrialsDetail from './components/TrialsDetail';
// import TrialsDetail from './components/TrialsDetail';
import './index.css'; import './index.css';
ReactDOM.render( ReactDOM.render(
...@@ -17,7 +15,6 @@ ReactDOM.render( ...@@ -17,7 +15,6 @@ ReactDOM.render(
<IndexRedirect to="/oview" /> <IndexRedirect to="/oview" />
<Route path="/oview" component={Overview} /> <Route path="/oview" component={Overview} />
<Route path="/detail" component={TrialsDetail} /> <Route path="/detail" component={TrialsDetail} />
<Route path="/tensor" component={Tensor} />
<Route path="/control" component={Control} /> <Route path="/control" component={Control} />
</Route> </Route>
</Router>, </Router>,
......
Button.changeBtu, Button.changeBtu:hover, Button.changeBtu:focus{ $btnBgcolor: #3c8dbc;
background-color: #3c8dbc;
border-color: #3c8dbc;
line-height: 30px;
}
Button.tableButton{ Button.tableButton{
background: #3c8dbc; background: $btnBgcolor;
border-color: #3c8dbc; border-color: $btnBgcolor;
height: 26px; height: 26px;
line-height: 26px; font-size: 14px;
margin-top: 2px; margin-top: 2px;
border-radius: 0;
} }
/* kill btn style: delete its own hover style */ /* kill btn style: delete its own hover style */
/* after button click the color not change */ /* after button click the color not change */
Button.tableButton:hover, Button.tableButton:focus{ Button.tableButton:hover, Button.tableButton:focus{
background-color: #3c8dbc; background-color: $btnBgcolor;
border-color: #3c8dbc; border-color: $btnBgcolor;
} }
\ No newline at end of file
Button.changeBtu{
height: 32px;
}
.ant-input, .ant-select-selection{
border-radius: 0 !important;
}
.allList{
background-color: #b3b3b3;
padding-right: 14px;
.btns{
height: 32px;
text-align: right;
.ant-input-search{
height: 32px;
}
}
Button.resetBtn{
height: 32px;
font-size: 15px;
position: relative;
top: 1px;
}
}
/* iframe include tensorborad page */
.tensor{
width: 98%;
height: 800px;
margin: 25px auto;
}
.tensor .title{
color: #333;
font-size: 16px;
}
.tensor iframe{
width: 100%;
height: 840px;
border: none;
margin-top: 10px;
}
\ No newline at end of file
...@@ -25,11 +25,6 @@ ...@@ -25,11 +25,6 @@
.panelTitle{ .panelTitle{
margin-right: 14px; margin-right: 14px;
border-right: 2px solid #e8e8e8; border-right: 2px solid #e8e8e8;
span{
font-size: 18px;
font-family: 'Segoe';
}
} }
} }
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
"static-before-instance", "static-before-instance",
"variables-before-functions" "variables-before-functions"
], ],
"no-any": false, "no-any": true,
"no-arg": true, "no-arg": true,
"no-bitwise": true, "no-bitwise": true,
"no-console": [ "no-console": [
......
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