diff options
Diffstat (limited to 'sdnr/wt/odlux/apps/faultApp')
4 files changed, 76 insertions, 36 deletions
diff --git a/sdnr/wt/odlux/apps/faultApp/src/actions/partialUpdatesAction.ts b/sdnr/wt/odlux/apps/faultApp/src/actions/partialUpdatesAction.ts new file mode 100644 index 000000000..198976796 --- /dev/null +++ b/sdnr/wt/odlux/apps/faultApp/src/actions/partialUpdatesAction.ts @@ -0,0 +1,25 @@ +/** + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt odlux + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + */ + +import { Action } from "../../../../framework/src/flux/action"; + +export class SetPartialUpdatesAction extends Action { + constructor(public isActive: boolean) { + super(); + } +}
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/faultApp/src/handlers/faultAppRootHandler.ts b/sdnr/wt/odlux/apps/faultApp/src/handlers/faultAppRootHandler.ts index a5cf928fc..e03d2b560 100644 --- a/sdnr/wt/odlux/apps/faultApp/src/handlers/faultAppRootHandler.ts +++ b/sdnr/wt/odlux/apps/faultApp/src/handlers/faultAppRootHandler.ts @@ -26,26 +26,31 @@ import { IActionHandler } from '../../../../framework/src/flux/action'; import { IFaultNotifications, faultNotificationsHandler } from './notificationsHandler'; import { ICurrentProblemsState, currentProblemsActionHandler } from './currentProblemsHandler'; import { IAlarmLogEntriesState, alarmLogEntriesActionHandler } from './alarmLogEntriesHandler'; -import { SetPanelAction, RememberCurrentPanelAction } from '../actions/panelChangeActions'; +import { SetPanelAction } from '../actions/panelChangeActions'; import { IFaultStatus, faultStatusHandler } from './faultStatusHandler'; import { stuckAlarmHandler } from './clearStuckAlarmsHandler'; import { PanelId } from 'models/panelId'; +import { SetPartialUpdatesAction } from '../actions/partialUpdatesAction'; export interface IFaultAppStoreState { currentProblems: ICurrentProblemsState; faultNotifications: IFaultNotifications; alarmLogEntries: IAlarmLogEntriesState; - currentOpenPanel: ICurrentOpenPanelState; + currentOpenPanel: PanelId | null; faultStatus: IFaultStatus; + listenForPartialUpdates: boolean; } -type ICurrentOpenPanelState = { openPanel: string | null, savedPanel: PanelId | null }; -const panelInitState = { openPanel: null, savedPanel: null }; -const currentOpenPanelHandler: IActionHandler<ICurrentOpenPanelState> = (state = panelInitState, action) => { +const currentOpenPanelHandler: IActionHandler<PanelId | null> = (state = null, action) => { if (action instanceof SetPanelAction) { - state = { ...state, openPanel: action.panelId }; - } else if (action instanceof RememberCurrentPanelAction) { - state = { ...state, savedPanel: action.panelId }; + state = action.panelId; + } + return state; +} + +const arePartialUpdatesActiveHandler: IActionHandler<boolean> = (state = false, action) => { + if (action instanceof SetPartialUpdatesAction) { + state = action.isActive; } return state; } @@ -62,7 +67,8 @@ const actionHandlers = { alarmLogEntries: alarmLogEntriesActionHandler, currentOpenPanel: currentOpenPanelHandler, faultStatus: faultStatusHandler, - stuckAlarms: stuckAlarmHandler + stuckAlarms: stuckAlarmHandler, + listenForPartialUpdates: arePartialUpdatesActiveHandler }; export const faultAppRootHandler = combineActionHandler<IFaultAppStoreState>(actionHandlers); diff --git a/sdnr/wt/odlux/apps/faultApp/src/pluginFault.tsx b/sdnr/wt/odlux/apps/faultApp/src/pluginFault.tsx index 666667e40..2056976d9 100644 --- a/sdnr/wt/odlux/apps/faultApp/src/pluginFault.tsx +++ b/sdnr/wt/odlux/apps/faultApp/src/pluginFault.tsx @@ -62,8 +62,12 @@ const FaultApplicationRouteAdapter = connect(mapProps, mapDisp)((props: RouteCom if (currentMountId) { props.setCurrentPanel("CurrentProblem"); props.currentProblemsActions.onFilterChanged("nodeId", currentMountId); - props.currentProblemsProperties.showFilter; // || (props.currentProblemsActions.onToggleFilter()); - props.currentProblemsActions.onRefresh(); + if (!props.currentProblemsProperties.showFilter) { + props.currentProblemsActions.onToggleFilter(false); + props.currentProblemsActions.onRefresh(); + } + else + props.currentProblemsActions.onRefresh(); } }); } @@ -95,11 +99,13 @@ export function register() { if (fault && store) { store.dispatch(new AddFaultNotificationAction(fault)); - //reload fault data if tab is open - if (store.state.fault.currentOpenPanel.openPanel === "AlarmLog") { - store.dispatch(alarmLogEntriesReloadAction); - } else if (store.state.fault.currentOpenPanel.openPanel === "CurrentProblem") { - store.dispatch(currentProblemsReloadAction); + // reload fault data if the view is displayed + if (store.state.fault.listenForPartialUpdates) { + if (store.state.fault.currentOpenPanel === "AlarmLog") { + store.dispatch(alarmLogEntriesReloadAction); + } else if (store.state.fault.currentOpenPanel === "CurrentProblem") { + store.dispatch(currentProblemsReloadAction); + } } } })); diff --git a/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx b/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx index ed395d2e4..10721549c 100644 --- a/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx +++ b/sdnr/wt/odlux/apps/faultApp/src/views/faultApplication.tsx @@ -33,14 +33,14 @@ import { PanelId } from '../models/panelId'; import { createCurrentProblemsProperties, createCurrentProblemsActions, currentProblemsReloadAction } from '../handlers/currentProblemsHandler'; import { createAlarmLogEntriesProperties, createAlarmLogEntriesActions, alarmLogEntriesReloadAction } from '../handlers/alarmLogEntriesHandler'; -import { setPanelAction, RememberCurrentPanelAction } from '../actions/panelChangeActions'; +import { setPanelAction } from '../actions/panelChangeActions'; import { Tooltip, IconButton, AppBar, Tabs, Tab } from '@material-ui/core'; import RefreshIcon from '@material-ui/icons/Refresh'; import ClearStuckAlarmsDialog, { ClearStuckAlarmsDialogMode } from '../components/clearStuckAlarmsDialog'; +import { SetPartialUpdatesAction } from '../actions/partialUpdatesAction'; const mapProps = (state: IApplicationStoreState) => ({ - panelId: state.fault.currentOpenPanel.openPanel, - savedPanel: state.fault.currentOpenPanel.savedPanel, + panelId: state.fault.currentOpenPanel, currentProblemsProperties: createCurrentProblemsProperties(state), faultNotifications: state.fault.faultNotifications, alarmLogEntriesProperties: createAlarmLogEntriesProperties(state) @@ -54,7 +54,7 @@ const mapDisp = (dispatcher: IDispatcher) => ({ switchActivePanel: (panelId: PanelId) => { dispatcher.dispatch(setPanelAction(panelId)); }, - rememberCurrentPanel: (panelId: PanelId) => dispatcher.dispatch(new RememberCurrentPanelAction(panelId)) + setPartialUpdates: (active: boolean) => dispatcher.dispatch(new SetPartialUpdatesAction(active)) }); type FaultApplicationComponentProps = RouteComponentProps & Connect<typeof mapProps, typeof mapDisp>; @@ -68,6 +68,8 @@ type FaultApplicationState = { const FaultTable = MaterialTable as MaterialTableCtorType<Fault>; const FaultAlarmNotificationTable = MaterialTable as MaterialTableCtorType<FaultAlarmNotification>; +let currentProblemsInitalSorted = false; +let alarmLogInitialSorted = false; class FaultApplicationComponent extends React.Component<FaultApplicationComponentProps, FaultApplicationState>{ @@ -97,10 +99,20 @@ class FaultApplicationComponent extends React.Component<FaultApplicationComponen this.props.switchActivePanel(nextActivePanel); switch (nextActivePanel) { case 'CurrentProblem': - this.props.reloadCurrentProblems(); + if (!currentProblemsInitalSorted) { + currentProblemsInitalSorted = true; + this.props.currentProblemsActions.onHandleExplicitRequestSort("timestamp", "desc"); + } else { + this.props.reloadCurrentProblems(); + } break; case 'AlarmLog': - this.props.reloadAlarmLogEntries(); + if (!alarmLogInitialSorted) { + alarmLogInitialSorted = true; + this.props.alarmLogEntriesActions.onHandleExplicitRequestSort("timestamp", "desc"); + } else { + this.props.reloadAlarmLogEntries(); + } break; case 'AlarmNotifications': case null: @@ -177,25 +189,16 @@ class FaultApplicationComponent extends React.Component<FaultApplicationComponen }; componentWillUnmount() { - if (this.props.panelId) { - this.props.rememberCurrentPanel(this.props.panelId as PanelId); - this.props.switchActivePanel(null); - } + this.props.setPartialUpdates(false); } public componentDidMount() { - - if (this.props.panelId === null && this.props.savedPanel === null) { //set default tab if none is set + if (this.props.panelId === null) { //set default tab if none is set this.onToggleTabs("CurrentProblem"); - } else // load saved tab if possible - if (this.props.panelId === null && this.props.savedPanel !== null) { - this.onToggleTabs(this.props.savedPanel); - this.props.rememberCurrentPanel(null); - } - - this.props.alarmLogEntriesActions.onToggleFilter(); - this.props.currentProblemsActions.onToggleFilter(); + } + this.props.setPartialUpdates(true); } + private renderIcon = (props: { rowData: Fault | FaultAlarmNotification }) => { return ( <FontAwesomeIcon icon={faExclamationTriangle} /> |