aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/apps/faultApp/src/handlers/currentProblemsHandler.ts
blob: 67eb10d32b3c3f060c93639e40004029087182a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { createExternal,IExternalTableState } from '../../../../framework/src/components/material-table/utilities';
import { createSearchDataHandler } from '../../../../framework/src/utilities/elasticSearch';

import { FaultResult, Fault } from '../models/fault';

export interface ICurrentProblemsState extends IExternalTableState<Fault> { }

// create eleactic search material data fetch handler
const currentProblemsSearchHandler = createSearchDataHandler<FaultResult, Fault>(
    'sdnevents/faultcurrent',
    null,
    (hit) => ({ _id: hit._id, ...hit._source.faultCurrent }),
    (name) => `faultCurrent.${name}`
  );

export const {
  actionHandler: currentProblemsActionHandler,
  createActions: createCurrentProblemsActions,
  createProperties: createCurrentProblemsProperties,
  reloadAction: currentProblemsReloadAction,

  // set value action, to change a value
} = createExternal<Fault>(currentProblemsSearchHandler, appState => appState.fault.currentProblems);