2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
26 } from 'app/vnfSearch/VnfSearchConstants.js';
29 getVnfProvStatusQueryString,
30 getVnfOrchStatusQueryString,
31 getVnfCountQueryString
32 } from 'app/networking/NetworkUtil.js';
37 } from 'app/networking/NetworkConstants.js';
39 getSetGlobalMessageEvent,
40 getClearGlobalMessageEvent
41 } from 'app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js';
43 let fetch = require('node-fetch');
44 fetch.Promise = require('es6-promise').Promise;
46 const itemKeyWord = 'key';
47 const countKeyWord = 'doc_count';
49 function getInvalidQueryEvent() {
51 type: vnfActionTypes.VNF_NETWORK_ERROR,
52 data: {errorMsg: ERROR_RETRIEVING_DATA}
55 /*it is a vertical bar chart then y and x are switched */
56 function getProvStatusEvent(responseJson) {
57 if (responseJson && responseJson.groupby_aggregation &&
58 responseJson.groupby_aggregation.buckets &&
59 responseJson.groupby_aggregation.buckets.length > 0) {
60 let groupByProvStatusBucket;
62 for (groupByProvStatusBucket of
63 responseJson.groupby_aggregation.buckets) {
65 'x': groupByProvStatusBucket[itemKeyWord].split('=', 1)[0],
66 'y': groupByProvStatusBucket[countKeyWord]
70 let newProvStatusChartData = [
76 let provStatusCountChartData = {
77 chartData: newProvStatusChartData
80 type: vnfActionTypes.COUNT_BY_PROV_STATUS_RECEIVED,
81 data: {provStatusCountChartData}
86 type: vnfActionTypes.ERROR_NO_DATA_FOR_PROV_STATUS_IN_SEARCH_RANGE_RECEIVED
91 function getOrchStatusEvent(responseJson) {
92 if (responseJson && responseJson.groupby_aggregation &&
93 responseJson.groupby_aggregation.buckets &&
94 responseJson.groupby_aggregation.buckets.length > 0) {
95 let groupByOrchStatusBucket;
97 for (groupByOrchStatusBucket of
98 responseJson.groupby_aggregation.buckets) {
100 'x': groupByOrchStatusBucket[itemKeyWord].split('=', 1)[0],
101 'y': groupByOrchStatusBucket[countKeyWord]
105 let newOrchStatusChartData = [
111 let orchStatusCountChartData = {
112 chartData: newOrchStatusChartData
115 type: vnfActionTypes.COUNT_BY_ORCH_STATUS_RECEIVED,
116 data: {orchStatusCountChartData}
121 type: vnfActionTypes.ERROR_NO_DATA_FOR_ORCH_STATUS_IN_SEARCH_RANGE_RECEIVED
126 function getTotalVnfEvent(responseJson) {
127 if (responseJson && responseJson.count && responseJson.count > 0) {
129 type: vnfActionTypes.TOTAL_VNF_COUNT_RECEIVED,
130 data: {count: responseJson.count}
135 type: vnfActionTypes.ERROR_NO_COUNT_RECEIVED
140 export function processProvStatusVisualizationOnSearchChange(requestObject) {
142 return fetch(VNF_RESULT_URL, {
144 headers: POST_HEADER,
145 body: JSON.stringify(getVnfProvStatusQueryString(requestObject))
147 (response) => response.json()
150 dispatch(getProvStatusEvent(responseJson));
154 dispatch(getInvalidQueryEvent());
160 export function processOrchStatusVisualizationOnSearchChange(requestObject) {
162 return fetch(VNF_RESULT_URL, {
164 headers: POST_HEADER,
165 body: JSON.stringify(getVnfOrchStatusQueryString(requestObject))
167 (response) => response.json()
170 dispatch(getOrchStatusEvent(responseJson));
174 dispatch(getInvalidQueryEvent());
180 export function processTotalVnfVisualizationOnSearchChange(requestObject) {
182 return fetch(VNF_RESULT_URL + '/count', {
184 headers: POST_HEADER,
185 body: JSON.stringify(
186 getVnfCountQueryString(requestObject))
188 (response) => response.json()
191 dispatch(getTotalVnfEvent(responseJson));
195 dispatch(getInvalidQueryEvent());
201 export function setNotificationText(msgText, msgSeverity) {
202 if (msgText.length > 0) {
205 getSetGlobalMessageEvent(msgText, msgSeverity));
209 dispatch(getClearGlobalMessageEvent());