diff options
author | Herbert Eiselt <herbert.eiselt@highstreet-technologies.com> | 2019-06-07 17:40:50 +0200 |
---|---|---|
committer | Herbert Eiselt <herbert.eiselt@highstreet-technologies.com> | 2019-06-07 17:41:24 +0200 |
commit | d93e6a996e60fb6abce9a870cef6b2d57bfa70fd (patch) | |
tree | 97595acb7fa809e742beb6cd5eeaaeab5f956ba9 /sdnr/wt/odlux/apps/faultApp/src/services | |
parent | 1445dabe9bc28629077033e2f189ad05dc61b884 (diff) |
SDNR Add missing status bar to ODLUX Framework
Modify framework and adapt all apps
Issue-ID: SDNC-789
Signed-off-by: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
Change-Id: I1ea0a3df6c3f6db08f2bd7a21eb3b4cbf230a08a
Signed-off-by: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/odlux/apps/faultApp/src/services')
-rw-r--r-- | sdnr/wt/odlux/apps/faultApp/src/services/faultStatusService.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sdnr/wt/odlux/apps/faultApp/src/services/faultStatusService.ts b/sdnr/wt/odlux/apps/faultApp/src/services/faultStatusService.ts new file mode 100644 index 000000000..ad0d394ce --- /dev/null +++ b/sdnr/wt/odlux/apps/faultApp/src/services/faultStatusService.ts @@ -0,0 +1,22 @@ +import { requestRest } from "../../../../framework/src/services/restService"; +import { Result } from "../../../../framework/src/models/elasticSearch"; + +export const getFaultStateFromDatabase = async (): Promise < { [key: string]: number } | null > => { + const path = 'database/sdnevents/faultcurrent/_search'; + const query = { + "size": 0, + "aggregations": { + "severity": { + "terms": { + "field": "faultCurrent.severity" + } + } + } + }; + + const result = await requestRest<Result<{ severity: { buckets: { key: string, doc_count: number }[] } }>>(path, { method: "POST", body: JSON.stringify(query) }); + return result && result.aggregations && result.aggregations["severity"].buckets.reduce<{ [key: string]: number }>((acc, cur) => { + acc[cur.key] = cur.doc_count; + return acc; + }, {}) || null; +}
\ No newline at end of file |