SDNR Add missing status bar to ODLUX Framework
[ccsdk/features.git] / sdnr / wt / odlux / apps / faultApp / src / handlers / faultAppRootHandler.ts
1 // main state handler
2
3 import { combineActionHandler } from '../../../../framework/src/flux/middleware';
4
5 // ** do not remove **
6 import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore';
7 import { IActionHandler } from '../../../../framework/src/flux/action';
8
9 import { IFaultNotifications, faultNotificationsHandler } from './notificationsHandler';
10 import { ICurrentProblemsState, currentProblemsActionHandler } from './currentProblemsHandler';
11 import { IAlarmLogEntriesState, alarmLogEntriesActionHandler } from './alarmLogEntriesHandler';
12 import { SetPanelAction } from '../actions/panelChangeActions';
13 import { IFaultStatus, faultStatusHandler } from './faultStatusHandler';
14
15 export interface IFaultAppStoreState {
16   currentProblems: ICurrentProblemsState;
17   faultNotifications: IFaultNotifications;
18   alarmLogEntries: IAlarmLogEntriesState;
19   currentOpenPanel: string|null;
20   faultStatus: IFaultStatus;
21 }
22
23 const currentOpenPanelHandler: IActionHandler<string | null> = (state = null, action) => {
24   if (action instanceof SetPanelAction) {
25     state = action.panelId;
26   }
27   return state;
28 }
29
30 declare module '../../../../framework/src/store/applicationStore' {
31   interface IApplicationStoreState {
32     fault: IFaultAppStoreState;
33   }
34 }
35
36 const actionHandlers = {
37   currentProblems: currentProblemsActionHandler,
38   faultNotifications: faultNotificationsHandler,
39   alarmLogEntries: alarmLogEntriesActionHandler,
40   currentOpenPanel: currentOpenPanelHandler,
41   faultStatus: faultStatusHandler
42 };
43
44 export const faultAppRootHandler = combineActionHandler<IFaultAppStoreState>(actionHandlers);
45 export default faultAppRootHandler;