SDN-R odlux configuration
[ccsdk/features.git] / sdnr / wt / odlux / apps / connectApp / src / handlers / connectionStatusLogHandler.tsx
1 import { createExternal,IExternalTableState } from '../../../../framework/src/components/material-table/utilities';
2 import { createSearchDataHandler } from '../../../../framework/src/utilities/elasticSearch';
3
4 import { ConnectionStatusLogType } from '../models/connectionStatusLog';
5 export interface IConnectionStatusLogState extends IExternalTableState<ConnectionStatusLogType> { }
6
7 // create eleactic search material data fetch handler
8 const connectionStatusLogSearchHandler = createSearchDataHandler<{ event: ConnectionStatusLogType }, ConnectionStatusLogType>('sdnevents_v1/eventlog', null,
9   (event) => ({
10     _id: event._id,
11     timeStamp: event._source.event.timeStamp,
12     objectId: event._source.event.objectId,
13     type: event._source.event.type,
14     elementStatus: event._source.event.type === 'ObjectCreationNotificationXml'
15       ? 'mounted'
16       : event._source.event.type === 'ObjectDeletionNotificationXml'
17         ? 'unmounted'
18         : event._source.event.type === 'AttributeValueChangedNotificationXml'
19           ? event._source.event.newValue
20           : 'unknown',
21     newValue: ''
22
23   }),
24   (name) => `event.${ name }`);
25
26 export const {
27   actionHandler: connectionStatusLogActionHandler,
28   createActions: createConnectionStatusLogActions,
29   createProperties: createConnectionStatusLogProperties,
30   reloadAction: connectionStatusLogReloadAction,
31
32   // set value action, to change a value
33 } = createExternal<ConnectionStatusLogType>(connectionStatusLogSearchHandler, appState => appState.connect.connectionStatusLog);
34