2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
29 } from 'app/vnfSearch/VnfSearchConstants.js';
32 getVnfProvStatusQueryString,
33 getVnfOrchStatusQueryString,
34 getVnfCountQueryString
35 } from 'app/networking/NetworkUtil.js';
40 } from 'app/networking/NetworkConstants.js';
42 getSetGlobalMessageEvent,
43 getClearGlobalMessageEvent
44 } from 'app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js';
46 let fetch = require('node-fetch');
47 fetch.Promise = require('es6-promise').Promise;
49 const itemKeyWord = 'key';
50 const countKeyWord = 'doc_count';
52 function getInvalidQueryEvent() {
54 type: vnfActionTypes.VNF_NETWORK_ERROR,
55 data: {errorMsg: ERROR_RETRIEVING_DATA}
58 /*it is a vertical bar chart then y and x are switched */
59 function getProvStatusEvent(responseJson) {
60 if (responseJson && responseJson.groupby_aggregation &&
61 responseJson.groupby_aggregation.buckets &&
62 responseJson.groupby_aggregation.buckets.length > 0) {
63 let groupByProvStatusBucket;
65 for (groupByProvStatusBucket of
66 responseJson.groupby_aggregation.buckets) {
68 'x': groupByProvStatusBucket[itemKeyWord].split('=', 1)[0],
69 'y': groupByProvStatusBucket[countKeyWord]
73 let newProvStatusChartData = [
79 let provStatusCountChartData = {
80 chartData: newProvStatusChartData
83 type: vnfActionTypes.COUNT_BY_PROV_STATUS_RECEIVED,
84 data: {provStatusCountChartData}
89 type: vnfActionTypes.ERROR_NO_DATA_FOR_PROV_STATUS_IN_SEARCH_RANGE_RECEIVED
94 function getOrchStatusEvent(responseJson) {
95 if (responseJson && responseJson.groupby_aggregation &&
96 responseJson.groupby_aggregation.buckets &&
97 responseJson.groupby_aggregation.buckets.length > 0) {
98 let groupByOrchStatusBucket;
100 for (groupByOrchStatusBucket of
101 responseJson.groupby_aggregation.buckets) {
103 'x': groupByOrchStatusBucket[itemKeyWord].split('=', 1)[0],
104 'y': groupByOrchStatusBucket[countKeyWord]
108 let newOrchStatusChartData = [
114 let orchStatusCountChartData = {
115 chartData: newOrchStatusChartData
118 type: vnfActionTypes.COUNT_BY_ORCH_STATUS_RECEIVED,
119 data: {orchStatusCountChartData}
124 type: vnfActionTypes.ERROR_NO_DATA_FOR_ORCH_STATUS_IN_SEARCH_RANGE_RECEIVED
129 function getTotalVnfEvent(responseJson) {
130 if (responseJson && responseJson.count && responseJson.count > 0) {
132 type: vnfActionTypes.TOTAL_VNF_COUNT_RECEIVED,
133 data: {count: responseJson.count}
138 type: vnfActionTypes.ERROR_NO_COUNT_RECEIVED
143 export function processProvStatusVisualizationOnSearchChange(requestObject) {
145 return fetch(VNF_RESULT_URL, {
147 headers: POST_HEADER,
148 body: JSON.stringify(getVnfProvStatusQueryString(requestObject))
150 (response) => response.json()
153 dispatch(getProvStatusEvent(responseJson));
157 dispatch(getInvalidQueryEvent());
163 export function processOrchStatusVisualizationOnSearchChange(requestObject) {
165 return fetch(VNF_RESULT_URL, {
167 headers: POST_HEADER,
168 body: JSON.stringify(getVnfOrchStatusQueryString(requestObject))
170 (response) => response.json()
173 dispatch(getOrchStatusEvent(responseJson));
177 dispatch(getInvalidQueryEvent());
183 export function processTotalVnfVisualizationOnSearchChange(requestObject) {
185 return fetch(VNF_RESULT_URL + '/count', {
187 headers: POST_HEADER,
188 body: JSON.stringify(
189 getVnfCountQueryString(requestObject))
191 (response) => response.json()
194 dispatch(getTotalVnfEvent(responseJson));
198 dispatch(getInvalidQueryEvent());
204 export function setNotificationText(msgText, msgSeverity) {
205 if (msgText.length > 0) {
208 getSetGlobalMessageEvent(msgText, msgSeverity));
212 dispatch(getClearGlobalMessageEvent());