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.
28 VNF_FILTER_AGGREGATION_URL,
34 VNF_FILTER_EMPTY_RESULT
35 } from 'app/vnfSearch/VnfSearchConstants.js';
40 } from 'app/networking/NetworkConstants.js';
42 getSetGlobalMessageEvent,
43 getClearGlobalMessageEvent
44 } from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js';
45 import {MESSAGE_LEVEL_WARNING} from 'utils/GlobalConstants.js';
47 let fetch = require('node-fetch');
48 fetch.Promise = require('es6-promise').Promise;
50 const itemKeyWord = 'key';
51 const countKeyWord = 'doc_count';
53 function getInvalidQueryEvent() {
55 type: vnfActionTypes.VNF_NETWORK_ERROR,
56 data: {errorMsg: ERROR_RETRIEVING_DATA}
60 function processProvData(provDataList) {
62 let newProvStatusChartData = CHART_PROV_STATUS.emptyData;
63 for (let provData of provDataList) {
66 'x': provData[itemKeyWord],
67 'y': provData[countKeyWord]
72 if (dataPoints.length > 0) {
73 newProvStatusChartData = {
78 return newProvStatusChartData;
81 function processOrchData(orchDataList) {
83 let newOrchStatusChartData = CHART_ORCH_STATUS.emptyData;
84 for (let orchData of orchDataList) {
87 'x': orchData[itemKeyWord],
88 'y': orchData[countKeyWord]
93 if (dataPoints.length > 0) {
94 newOrchStatusChartData = {
99 return newOrchStatusChartData;
102 function processNfTypeData(nfDataList) {
104 let newNfTypeChartData = CHART_NF_TYPE.emptyData;
105 for (let nfData of nfDataList) {
108 'x': nfData[itemKeyWord],
109 'y': nfData[countKeyWord]
114 if (dataPoints.length > 0) {
115 newNfTypeChartData = {
120 return newNfTypeChartData;
123 function processNfRoleData(nfDataList) {
125 let newNfRoleChartData = CHART_NF_ROLE.emptyData;
126 for (let nfData of nfDataList) {
129 'x': nfData[itemKeyWord],
130 'y': nfData[countKeyWord]
135 if (dataPoints.length > 0) {
136 newNfRoleChartData = {
141 return newNfRoleChartData;
144 function getVnfFilterAggregationQueryString(filterValueMap) {
147 for (let filter in filterValueMap) {
148 if (filterValueMap[filter] !== '') {
152 'filterValue': filterValueMap[filter]
165 'filters': filterList
169 function getVnfVisualizationsResultsEvent(results) {
170 let count = TOTAL_VNF_COUNT.emptyData;
171 let provData = CHART_PROV_STATUS.emptyData;
172 let orchData = CHART_ORCH_STATUS.emptyData;
173 let netFuncTypeData = CHART_NF_TYPE.emptyData;
174 let netFuncRoleData = CHART_NF_ROLE.emptyData;
177 count = results.total;
180 if (results['aggregations'] && results['aggregations']['prov-status']) {
181 provData = processProvData(results['aggregations']['prov-status']);
184 if (results['aggregations'] &&
185 results['aggregations']['orchestration-status']) {
186 orchData = processOrchData(results['aggregations']['orchestration-status']);
189 if (results['aggregations'] &&
190 results['aggregations']['nf-type']) {
191 netFuncTypeData = processNfTypeData(results['aggregations']['nf-type']);
194 if (results['aggregations'] &&
195 results['aggregations']['nf-role']) {
196 netFuncRoleData = processNfRoleData(results['aggregations']['nf-role']);
200 type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED,
203 provStatusData: provData,
204 orchStatusData: orchData,
205 nfTypeData: netFuncTypeData,
206 nfRoleData: netFuncRoleData
211 export function processVnfVisualizationsOnFilterChange(filterValueMap) {
213 return fetch(VNF_FILTER_AGGREGATION_URL, {
215 headers: POST_HEADER,
216 body: JSON.stringify(getVnfFilterAggregationQueryString(filterValueMap))
218 (response) => response.json()
221 if(responseJson.total === 0) {
222 dispatch(getSetGlobalMessageEvent(VNF_FILTER_EMPTY_RESULT, MESSAGE_LEVEL_WARNING));
224 dispatch(getClearGlobalMessageEvent());
226 dispatch(getVnfVisualizationsResultsEvent(responseJson));
230 dispatch(getInvalidQueryEvent());
236 export function processVnfFilterPanelCollapse(isOpen) {
237 let vnfVisualizationPanelClass = 'collapsible-panel-main-panel';
240 vnfVisualizationPanelClass += ' vertical-filter-panel-is-open';
244 type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED,
246 vnfVisualizationPanelClass: vnfVisualizationPanelClass
251 export function setNotificationText(msgText, msgSeverity) {
252 if (msgText.length > 0) {
255 getSetGlobalMessageEvent(msgText, msgSeverity));
259 dispatch(getClearGlobalMessageEvent());
264 export function clearVnfSearchData() {
266 type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED,
269 provStatusData: CHART_PROV_STATUS.emptyData,
270 orchStatusData: CHART_ORCH_STATUS.emptyData,
271 nfTypeData: CHART_NF_TYPE.emptyData,
272 nfRoleData: CHART_NF_ROLE.emptyData