diff --git a/ts/webui/src/App.tsx b/ts/webui/src/App.tsx index 97e9333ca..3d331ad9d 100644 --- a/ts/webui/src/App.tsx +++ b/ts/webui/src/App.tsx @@ -13,7 +13,12 @@ const echarts = require('echarts/lib/echarts'); echarts.registerTheme('nni_theme', { color: '#3c8dbc' }); - +export const NavContext = React.createContext({ + // eslint-disable-next-line @typescript-eslint/no-empty-function + changeInterval: (_val: number) => {}, + // eslint-disable-next-line @typescript-eslint/no-empty-function + refreshPage: (): void => {} +}); export const AppContext = React.createContext({ interval: 10, // sendons columnList: COLUMN, @@ -135,7 +140,14 @@ class App extends React.Component<{}, AppState> {
- + + +
diff --git a/ts/webui/src/components/experiment/trialdetail/TrialsDetail.tsx b/ts/webui/src/components/experiment/trialdetail/TrialsDetail.tsx index 49597e60d..98479e64f 100644 --- a/ts/webui/src/components/experiment/trialdetail/TrialsDetail.tsx +++ b/ts/webui/src/components/experiment/trialdetail/TrialsDetail.tsx @@ -1,4 +1,4 @@ -import React, { useState, useContext } from 'react'; +import React, { useContext } from 'react'; import { Stack, Pivot, PivotItem } from '@fluentui/react'; import { EXPERIMENT, TRIALS } from '@static/datamodel'; import { AppContext } from '@/App'; @@ -23,24 +23,14 @@ import '@style/common/trialStatus.css'; const TrialsDetail = (): any => { const { changeExpandRowIDs } = useContext(AppContext); - const [whichChart, setChart] = useState('Default metric' as string); - const handleWhichTabs = (item: any): void => { - setChart(item.props.headerText); - }; const source = TRIALS.toArray(); const paraSource = TRIALS.succeededTrials(); const succeededTrialIds = TRIALS.succeededTrials().map(trial => trial.id); return (
- - {/* doesn't work*/} - + + { /> - {/* */} - + - {/* */} - + - {/* */} - - {/* *why this graph has small footprint? */} + + {/* why this graph has small footprint? */} diff --git a/ts/webui/src/components/nav/Nav.tsx b/ts/webui/src/components/nav/Nav.tsx index c2c3daa41..7eb44a860 100644 --- a/ts/webui/src/components/nav/Nav.tsx +++ b/ts/webui/src/components/nav/Nav.tsx @@ -1,6 +1,6 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useContext } from 'react'; import axios from 'axios'; -import { Stack, StackItem, CommandBarButton, IContextualMenuProps, IStackTokens } from '@fluentui/react'; +import { Stack, StackItem, CommandBarButton, DefaultButton, IContextualMenuProps, IStackTokens } from '@fluentui/react'; import WebRouters from './WebsiteRouter'; import TooltipHostForIcon from './TooltipHostForIcon'; import LinksIcon from '@components/nav/LinksIcon'; @@ -10,9 +10,10 @@ import { EXPERIMENT } from '@static/datamodel'; import { getPrefix } from '@static/function'; import { SlideNavBtns } from './slideNav/SlideNavBtns'; import { timeIcon, disableUpdates, requency, closeTimer } from '@components/fluent/Icon'; +import { ErrorMessage } from '@components/nav/ErrorMessage'; +import { NavContext } from '@/App'; import '@style/nav/nav.scss'; import '@style/icon.scss'; -import { ErrorMessage } from '@components/nav/ErrorMessage'; const pageURLtoken: IStackTokens = { padding: '20px 10px', @@ -23,19 +24,16 @@ const navMaintoken: IStackTokens = { childrenGap: 16 }; -interface NavProps { - changeInterval: (value: number) => void; -} - -const NavCon = (props: NavProps): any => { - const { changeInterval } = props; +const NavCon = (): any => { const [version, setVersion] = useState('999' as string); + const { changeInterval, refreshPage } = useContext(NavContext); const [currentPage, setcurrentPage] = useState( window.location.pathname === '/oview' || window.location.pathname === '/' ? 'Overview' : ('Trials detail' as 'Overview' | 'Trials detail') ); const [visibleExperimentPanel, setVisibleExperimentPanel] = useState(false); + const [refreshBtnDisabled, setRefreshBtnDisabled] = useState(false); const [refreshText, setRefreshText] = useState('Auto refresh' as string); const [refreshFrequency, setRefreshFrequency] = useState(10 as number | string); @@ -157,6 +155,20 @@ const NavCon = (props: NavProps): any => {
|
|
+ {/* click to refresh page */} + { + setRefreshBtnDisabled(true); + refreshPage(); + setTimeout(() => { + setRefreshBtnDisabled(false); + }, 2000); + }} + allowDisabledFocus + disabled={refreshBtnDisabled} + /> +
|