Add sdnr wt odlux
[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
14 export interface IFaultAppStoreState {
15   currentProblems: ICurrentProblemsState;
16   faultNotifications: IFaultNotifications;
17   alarmLogEntries: IAlarmLogEntriesState;
18   currentOpenPanel: string|null;
19 }
20
21 const currentOpenPanelHandler: IActionHandler<string | null> = (state = null, action) => {
22   if (action instanceof SetPanelAction) {
23     state = action.panelId;
24   }
25   return state;
26 }
27
28 declare module '../../../../framework/src/store/applicationStore' {
29   interface IApplicationStoreState {
30     faultApp: IFaultAppStoreState;
31   }
32 }
33
34 const actionHandlers = {
35   currentProblems: currentProblemsActionHandler,
36   faultNotifications: faultNotificationsHandler,
37   alarmLogEntries: alarmLogEntriesActionHandler,
38   currentOpenPanel: currentOpenPanelHandler
39 };
40
41 export const faultAppRootHandler = combineActionHandler<IFaultAppStoreState>(actionHandlers);
42 export default faultAppRootHandler;