diff options
author | Aijana Schumann <aijana.schumann@highstreet-technologies.com> | 2020-03-16 09:15:00 +0100 |
---|---|---|
committer | Aijana S <aijana.schumann@highstreet-technologies.com> | 2020-03-18 15:19:40 +0000 |
commit | 284da45ec47cb85c6547eb3ae06acaf0578be894 (patch) | |
tree | 8d96cadcd21a0bb3ebfbd5fede6ece86a8d9569e /sdnr/wt/odlux/apps/performanceHistoryApp/src/pluginPerformance.tsx | |
parent | ce78a6683ab8648ed90e944cd23ed7c01205fce6 (diff) |
Bugfixes for PerformanceApp
Fix filter in table not always showing
Fix suspectInterval filter not linked between chart and table
Fix data not loaded problem
Issue-ID: SDNC-1118
Signed-off-by: Aijana Schumann <aijana.schumann@highstreet-technologies.com>
Change-Id: I7d1b71f094dfdd7cd16ed6f7fb5c597a7b209b69
Diffstat (limited to 'sdnr/wt/odlux/apps/performanceHistoryApp/src/pluginPerformance.tsx')
-rw-r--r-- | sdnr/wt/odlux/apps/performanceHistoryApp/src/pluginPerformance.tsx | 71 |
1 files changed, 53 insertions, 18 deletions
diff --git a/sdnr/wt/odlux/apps/performanceHistoryApp/src/pluginPerformance.tsx b/sdnr/wt/odlux/apps/performanceHistoryApp/src/pluginPerformance.tsx index df3ffd90a..a8aaca22f 100644 --- a/sdnr/wt/odlux/apps/performanceHistoryApp/src/pluginPerformance.tsx +++ b/sdnr/wt/odlux/apps/performanceHistoryApp/src/pluginPerformance.tsx @@ -30,6 +30,9 @@ import { ApplicationStore } from '../../../framework/src/store/applicationStore' import connect, { Connect, IDispatcher } from '../../../framework/src/flux/connect'; import { IApplicationStoreState } from "../../../framework/src/store/applicationStore"; import { updateMountIdActionCreator } from "./actions/deviceListActions"; +import { ResetAllSubViewsAction } from "./actions/toggleActions"; +import { ResetLtpsAction } from "./actions/ltpAction"; +import { ReloadAction } from "./actions/reloadAction"; let api: { readonly applicationStore: ApplicationStore | null; @@ -40,31 +43,63 @@ const mapProps = (state: IApplicationStoreState) => ({ }); const mapDisp = (dispatcher: IDispatcher) => ({ - updateMountId: (mountId: string) => dispatcher.dispatch(updateMountIdActionCreator(mountId)) + updateMountId: (mountId: string) => dispatcher.dispatch(updateMountIdActionCreator(mountId)), + resetLtps: () => dispatcher.dispatch(new ResetLtpsAction()), + resetSubViews: () => dispatcher.dispatch(new ResetAllSubViewsAction()), + setScheduleReload: (show: boolean) => dispatcher.dispatch(new ReloadAction(show)) }); let currentMountId: string | null = null; let lastUrl: string = "/performanceHistory"; -const PerformanceHistoryApplicationRouteAdapter = connect(mapProps, mapDisp)((props: RouteComponentProps<{ mountId?: string}> & Connect<typeof mapProps, typeof mapDisp>) => { +const PerformanceHistoryApplicationRouteAdapter = connect(mapProps, mapDisp)((props: RouteComponentProps<{ mountId?: string }> & Connect<typeof mapProps, typeof mapDisp>) => { let mountId: string = ""; - if (props.location.pathname !== lastUrl) { - // ensure the asynchronus update will only be called once per path + + // called when component finshed mounting + React.useEffect(() => { + + lastUrl = props.location.pathname; + mountId = getMountId(lastUrl); + + if (currentMountId !== mountId) { // new element is loaded + currentMountId = mountId; + schedueleReload(currentMountId); + } else + if (currentMountId !== "") { // same element is loaded again + schedueleReload(currentMountId); + } + }, []); + + // called when component gets updated + React.useEffect(() => { + lastUrl = props.location.pathname; + mountId = getMountId(lastUrl); + + if (currentMountId !== mountId) { + currentMountId = mountId; + schedueleReload(currentMountId); + } + + }); + + const getMountId = (lastUrl: string) => { let index = lastUrl.lastIndexOf("performanceHistory/"); - if(index >= 0) { - mountId = lastUrl.substr(index+19); + if (index >= 0) { + mountId = lastUrl.substr(index + 19); } else { mountId = ""; } - window.setTimeout(async () => { - // check if the mountId has changed - if (currentMountId !== mountId) { - currentMountId = mountId; - await props.updateMountId(currentMountId); - } - }); + return mountId; + } + + const schedueleReload = (currentMountId: string) => { + props.updateMountId(currentMountId); + props.resetLtps(); + props.resetSubViews(); + props.setScheduleReload(true); } + return ( <PerformanceHistoryApplication /> ); @@ -73,11 +108,11 @@ const PerformanceHistoryApplicationRouteAdapter = connect(mapProps, mapDisp)((pr const PerformanceHistoryRouterApp = withRouter((props: RouteComponentProps) => { props.history.action = "POP"; return ( - <Switch> - <Route path={`${props.match.path}/:mountId`} component={PerformanceHistoryApplicationRouteAdapter} /> - <Route path={`${props.match.path}`} component={PerformanceHistoryApplicationRouteAdapter} /> - <Redirect to={`${props.match.path}`} /> - </Switch> + <Switch> + <Route path={`${props.match.path}/:mountId`} component={PerformanceHistoryApplicationRouteAdapter} /> + <Route path={`${props.match.path}`} component={PerformanceHistoryApplicationRouteAdapter} /> + <Redirect to={`${props.match.path}`} /> + </Switch> ) }); |