From 47fc603b864b52a70157515f29ec741dd9192f3a Mon Sep 17 00:00:00 2001 From: Herbert Eiselt Date: Fri, 7 Jun 2019 17:55:16 +0200 Subject: SDNR align ODLUX Add missing chart view to UX Performance app Issue-ID: SDNC-790 Signed-off-by: Herbert Eiselt Change-Id: I6f5af1e01d2246927b8d05f826f629c7dd5f59a5 Signed-off-by: Herbert Eiselt --- .../src/services/performanceHistoryService.ts | 46 +++++++++++ .../src/services/performanceHistoryService.tsx | 93 ---------------------- 2 files changed, 46 insertions(+), 93 deletions(-) create mode 100644 sdnr/wt/odlux/apps/performanceHistoryApp/src/services/performanceHistoryService.ts delete mode 100644 sdnr/wt/odlux/apps/performanceHistoryApp/src/services/performanceHistoryService.tsx (limited to 'sdnr/wt/odlux/apps/performanceHistoryApp/src/services') diff --git a/sdnr/wt/odlux/apps/performanceHistoryApp/src/services/performanceHistoryService.ts b/sdnr/wt/odlux/apps/performanceHistoryApp/src/services/performanceHistoryService.ts new file mode 100644 index 000000000..d0b8346cd --- /dev/null +++ b/sdnr/wt/odlux/apps/performanceHistoryApp/src/services/performanceHistoryService.ts @@ -0,0 +1,46 @@ +import { requestRest } from '../../../../framework/src/services/restService'; +import { Result } from '../../../../framework/src/models/elasticSearch'; + +import { DistinctLtp, LtpIds } from '../models/availableLtps'; + +/** + * Represents a web api accessor service for Network elements actions. + */ +class PerformanceService { + + /** + * Get distinct ltps based on the selected network element and time period from the historicalperformance15min database table. + */ + public async getDistinctLtpsFromDatabase(networkElement: string, selectedTimePeriod: string): Promise { + let path; + const query = { + "size": 0, + "query": { + "match": { + "node-name": networkElement + } + }, + "aggs": { + "uuid-interface": { + "terms": { + "field": "uuid-interface" + } + } + } + }; + + if (selectedTimePeriod === "15min") { + path = 'database/sdnperformance/historicalperformance15min/_search'; + } else { + path = 'database/sdnperformance/historicalperformance24h/_search'; + } + + const result = await requestRest>(path, { method: "POST", body: JSON.stringify(query) }); + return result && result.aggregations && result.aggregations["uuid-interface"].buckets.map(ne => ({ + key: ne.key + })) || null; + } +} + +export const PerformanceHistoryService = new PerformanceService(); +export default PerformanceHistoryService; diff --git a/sdnr/wt/odlux/apps/performanceHistoryApp/src/services/performanceHistoryService.tsx b/sdnr/wt/odlux/apps/performanceHistoryApp/src/services/performanceHistoryService.tsx deleted file mode 100644 index a1cdcffcc..000000000 --- a/sdnr/wt/odlux/apps/performanceHistoryApp/src/services/performanceHistoryService.tsx +++ /dev/null @@ -1,93 +0,0 @@ -import { requestRest } from '../../../../framework/src/services/restService'; -import { Result } from '../../../../framework/src/models/elasticSearch'; - -import { ConnectedNetworkElements } from '../models/connectedNetworkElements'; -import { DistinctLtp, Ltp } from '../models/availableLtps'; -import { Topology, TopologyNode } from '../models/topologyNetConf'; - -/** - * Represents a web api accessor service for Network elements actions. - */ -class PerformanceService { - - private static networkElementTopology = (mountPoint: TopologyNode) => { - const mountId = mountPoint["node-id"]; - return { - mountId: mountId, - } - } - - /** - * Get all connected network elements from restconf. - */ - public async getConnectedNetworkElementsList(): Promise { - const path = "restconf/operational/network-topology:network-topology/topology/topology-netconf"; - const topologyRequestPomise = requestRest<{ topology: Topology[] | null }>(path, { method: "GET" }, true); - const [netconfResponse] = await Promise.all([topologyRequestPomise]); - const topologyNetconf = netconfResponse && netconfResponse.topology && netconfResponse.topology.find(topology => topology["topology-id"] === "topology-netconf"); - let mountPoints = topologyNetconf && topologyNetconf.node && topologyNetconf.node.filter( - mountPoint => mountPoint["netconf-node-topology:connection-status"] == "connected").map(mountedElement => { - return PerformanceService.networkElementTopology(mountedElement); - }); - return mountPoints || []; - } - - /** - * Get distinct ltps based on the selected network element and time period from the historicalperformance15min database table. - */ - public async getDistinctLtpsFrom15minDatabase(networkElement: string): Promise { - const path = 'database/sdnperformance/historicalperformance15min/_search'; - const query = { - "size": 0, - "query": { - "match": { - "node-name": networkElement - } - }, - "aggs": { - "uuid-interface": { - "terms": { - "field": "uuid-interface" - } - } - } - }; - const result = await requestRest>(path, { method: "POST", body: JSON.stringify(query) }); - if(result && result.aggregations) { - } - return result && result.aggregations && result.aggregations["uuid-interface"].buckets.map(ne=>({ - key:ne.key - }))|| null; - } - - /** - * Get distinct ltps based on the selected network element and time period from the historicalperformance24h database table. - */ - public async getDistinctLtpsFrom24hoursDatabase(networkElement: string): Promise { - const path = 'database/sdnperformance/historicalperformance24h/_search'; - const query = { - "size": 0, - "query": { - "match": { - "node-name": networkElement - } - }, - "aggs": { - "uuid-interface": { - "terms": { - "field": "uuid-interface" - } - } - } - }; - const result = await requestRest>(path, { method: "POST", body: JSON.stringify(query) }); - if(result && result.aggregations) { - } - return result && result.aggregations && result.aggregations["uuid-interface"].buckets.map(ne=>({ - key:ne.key - }))|| null; - } -} - -export const PerformanceHistoryService = new PerformanceService(); -export default PerformanceHistoryService; -- cgit 1.2.3-korg