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 VNF_FILTER_AGGREGATION_URL,
32 VNF_FILTER_EMPTY_RESULT
33 } from 'app/vnfSearch/VnfSearchConstants.js';
38 } from 'app/networking/NetworkConstants.js';
40 getSetGlobalMessageEvent,
41 getClearGlobalMessageEvent
42 } from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js';
43 import {MESSAGE_LEVEL_WARNING} from 'utils/GlobalConstants.js';
45 let fetch = require('node-fetch');
46 fetch.Promise = require('es6-promise').Promise;
48 const itemKeyWord = 'key';
49 const countKeyWord = 'doc_count';
51 function getInvalidQueryEvent() {
53 type: vnfActionTypes.VNF_NETWORK_ERROR,
54 data: {errorMsg: ERROR_RETRIEVING_DATA}
58 function processProvData(provDataList) {
60 let newProvStatusChartData = CHART_PROV_STATUS.emptyData;
61 for (let provData of provDataList) {
64 'x': provData[itemKeyWord],
65 'y': provData[countKeyWord]
70 if (dataPoints.length > 0) {
71 newProvStatusChartData = {
76 return newProvStatusChartData;
79 function processOrchData(orchDataList) {
81 let newOrchStatusChartData = CHART_ORCH_STATUS.emptyData;
82 for (let orchData of orchDataList) {
85 'x': orchData[itemKeyWord],
86 'y': orchData[countKeyWord]
91 if (dataPoints.length > 0) {
92 newOrchStatusChartData = {
97 return newOrchStatusChartData;
100 function processNfTypeData(nfDataList) {
102 let newNfTypeChartData = CHART_NF_TYPE.emptyData;
103 for (let nfData of nfDataList) {
106 'x': nfData[itemKeyWord],
107 'y': nfData[countKeyWord]
112 if (dataPoints.length > 0) {
113 newNfTypeChartData = {
118 return newNfTypeChartData;
121 function processNfRoleData(nfDataList) {
123 let newNfRoleChartData = CHART_NF_ROLE.emptyData;
124 for (let nfData of nfDataList) {
127 'x': nfData[itemKeyWord],
128 'y': nfData[countKeyWord]
133 if (dataPoints.length > 0) {
134 newNfRoleChartData = {
139 return newNfRoleChartData;
142 function getVnfFilterAggregationQueryString(filterValueMap) {
145 for (let filter in filterValueMap) {
146 if (filterValueMap[filter] !== '') {
150 'filterValue': filterValueMap[filter]
163 'filters': filterList
167 function getVnfVisualizationsResultsEvent(results) {
168 let count = TOTAL_VNF_COUNT.emptyData;
169 let provData = CHART_PROV_STATUS.emptyData;
170 let orchData = CHART_ORCH_STATUS.emptyData;
171 let netFuncTypeData = CHART_NF_TYPE.emptyData;
172 let netFuncRoleData = CHART_NF_ROLE.emptyData;
175 count = results.total;
178 if (results['aggregations'] && results['aggregations']['prov-status']) {
179 provData = processProvData(results['aggregations']['prov-status']);
182 if (results['aggregations'] &&
183 results['aggregations']['orchestration-status']) {
184 orchData = processOrchData(results['aggregations']['orchestration-status']);
187 if (results['aggregations'] &&
188 results['aggregations']['nf-type']) {
189 netFuncTypeData = processNfTypeData(results['aggregations']['nf-type']);
192 if (results['aggregations'] &&
193 results['aggregations']['nf-role']) {
194 netFuncRoleData = processNfRoleData(results['aggregations']['nf-role']);
198 type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED,
201 provStatusData: provData,
202 orchStatusData: orchData,
203 nfTypeData: netFuncTypeData,
204 nfRoleData: netFuncRoleData
209 export function processVnfVisualizationsOnFilterChange(filterValueMap) {
211 return fetch(VNF_FILTER_AGGREGATION_URL, {
213 headers: POST_HEADER,
214 body: JSON.stringify(getVnfFilterAggregationQueryString(filterValueMap))
216 (response) => response.json()
219 if(responseJson.total === 0) {
220 dispatch(getSetGlobalMessageEvent(VNF_FILTER_EMPTY_RESULT, MESSAGE_LEVEL_WARNING));
222 dispatch(getClearGlobalMessageEvent());
224 dispatch(getVnfVisualizationsResultsEvent(responseJson));
228 dispatch(getInvalidQueryEvent());
234 export function processVnfFilterPanelCollapse(isOpen) {
235 let vnfVisualizationPanelClass = 'collapsible-panel-main-panel';
238 vnfVisualizationPanelClass += ' vertical-filter-panel-is-open';
242 type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED,
244 vnfVisualizationPanelClass: vnfVisualizationPanelClass
249 export function setNotificationText(msgText, msgSeverity) {
250 if (msgText.length > 0) {
253 getSetGlobalMessageEvent(msgText, msgSeverity));
257 dispatch(getClearGlobalMessageEvent());
262 export function clearVnfSearchData() {
264 type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED,
267 provStatusData: CHART_PROV_STATUS.emptyData,
268 orchStatusData: CHART_ORCH_STATUS.emptyData,
269 nfTypeData: CHART_NF_TYPE.emptyData,
270 nfRoleData: CHART_NF_ROLE.emptyData