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.
25 VNF_FILTER_AGGREGATION_URL,
31 VNF_FILTER_EMPTY_RESULT
32 } from 'app/vnfSearch/VnfSearchConstants.js';
37 } from 'app/networking/NetworkConstants.js';
39 getSetGlobalMessageEvent,
40 getClearGlobalMessageEvent
41 } from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js';
42 import {MESSAGE_LEVEL_WARNING} from 'utils/GlobalConstants.js';
44 let fetch = require('node-fetch');
45 fetch.Promise = require('es6-promise').Promise;
47 const itemKeyWord = 'key';
48 const countKeyWord = 'doc_count';
50 function getInvalidQueryEvent() {
52 type: vnfActionTypes.VNF_NETWORK_ERROR,
53 data: {errorMsg: ERROR_RETRIEVING_DATA}
57 function processProvData(provDataList) {
59 let newProvStatusChartData = CHART_PROV_STATUS.emptyData;
60 for (let provData of provDataList) {
63 'x': provData[itemKeyWord],
64 'y': provData[countKeyWord]
69 if (dataPoints.length > 0) {
70 newProvStatusChartData = {
75 return newProvStatusChartData;
78 function processOrchData(orchDataList) {
80 let newOrchStatusChartData = CHART_ORCH_STATUS.emptyData;
81 for (let orchData of orchDataList) {
84 'x': orchData[itemKeyWord],
85 'y': orchData[countKeyWord]
90 if (dataPoints.length > 0) {
91 newOrchStatusChartData = {
96 return newOrchStatusChartData;
99 function processNfTypeData(nfDataList) {
101 let newNfTypeChartData = CHART_NF_TYPE.emptyData;
102 for (let nfData of nfDataList) {
105 'x': nfData[itemKeyWord],
106 'y': nfData[countKeyWord]
111 if (dataPoints.length > 0) {
112 newNfTypeChartData = {
117 return newNfTypeChartData;
120 function processNfRoleData(nfDataList) {
122 let newNfRoleChartData = CHART_NF_ROLE.emptyData;
123 for (let nfData of nfDataList) {
126 'x': nfData[itemKeyWord],
127 'y': nfData[countKeyWord]
132 if (dataPoints.length > 0) {
133 newNfRoleChartData = {
138 return newNfRoleChartData;
141 function getVnfFilterAggregationQueryString(filterValueMap) {
144 for (let filter in filterValueMap) {
145 if (filterValueMap[filter] !== '') {
149 'filterValue': filterValueMap[filter]
162 'filters': filterList
166 function getVnfVisualizationsResultsEvent(results) {
167 let count = TOTAL_VNF_COUNT.emptyData;
168 let provData = CHART_PROV_STATUS.emptyData;
169 let orchData = CHART_ORCH_STATUS.emptyData;
170 let netFuncTypeData = CHART_NF_TYPE.emptyData;
171 let netFuncRoleData = CHART_NF_ROLE.emptyData;
174 count = results.total;
177 if (results['aggregations'] && results['aggregations']['prov-status']) {
178 provData = processProvData(results['aggregations']['prov-status']);
181 if (results['aggregations'] &&
182 results['aggregations']['orchestration-status']) {
183 orchData = processOrchData(results['aggregations']['orchestration-status']);
186 if (results['aggregations'] &&
187 results['aggregations']['nf-type']) {
188 netFuncTypeData = processNfTypeData(results['aggregations']['nf-type']);
191 if (results['aggregations'] &&
192 results['aggregations']['nf-role']) {
193 netFuncRoleData = processNfRoleData(results['aggregations']['nf-role']);
197 type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED,
200 provStatusData: provData,
201 orchStatusData: orchData,
202 nfTypeData: netFuncTypeData,
203 nfRoleData: netFuncRoleData
208 export function processVnfVisualizationsOnFilterChange(filterValueMap) {
210 return fetch(VNF_FILTER_AGGREGATION_URL, {
212 headers: POST_HEADER,
213 body: JSON.stringify(getVnfFilterAggregationQueryString(filterValueMap))
215 (response) => response.json()
218 if(responseJson.total === 0) {
219 dispatch(getSetGlobalMessageEvent(VNF_FILTER_EMPTY_RESULT, MESSAGE_LEVEL_WARNING));
221 dispatch(getClearGlobalMessageEvent());
223 dispatch(getVnfVisualizationsResultsEvent(responseJson));
227 dispatch(getInvalidQueryEvent());
233 export function processVnfFilterPanelCollapse(isOpen) {
234 let vnfVisualizationPanelClass = 'collapsible-panel-main-panel';
237 vnfVisualizationPanelClass += ' vertical-filter-panel-is-open';
241 type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED,
243 vnfVisualizationPanelClass: vnfVisualizationPanelClass
248 export function setNotificationText(msgText, msgSeverity) {
249 if (msgText.length > 0) {
252 getSetGlobalMessageEvent(msgText, msgSeverity));
256 dispatch(getClearGlobalMessageEvent());
261 export function clearVnfSearchData() {
263 type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED,
266 provStatusData: CHART_PROV_STATUS.emptyData,
267 orchStatusData: CHART_ORCH_STATUS.emptyData,
268 nfTypeData: CHART_NF_TYPE.emptyData,
269 nfRoleData: CHART_NF_ROLE.emptyData