2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 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=========================================================
23 VNF_FILTER_AGGREGATION_URL,
29 VNF_FILTER_EMPTY_RESULT
30 } from 'app/vnfSearch/VnfSearchConstants.js';
35 } from 'app/networking/NetworkConstants.js';
37 getSetGlobalMessageEvent,
38 getClearGlobalMessageEvent
39 } from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js';
40 import {MESSAGE_LEVEL_WARNING} from 'utils/GlobalConstants.js';
42 const itemKeyWord = 'key';
43 const countKeyWord = 'doc_count';
45 function getInvalidQueryEvent() {
47 type: vnfActionTypes.VNF_NETWORK_ERROR,
48 data: {errorMsg: ERROR_RETRIEVING_DATA}
52 function processProvData(provDataList) {
54 let newProvStatusChartData = CHART_PROV_STATUS.emptyData;
55 for (let provData of provDataList) {
58 'x': provData[itemKeyWord],
59 'y': provData[countKeyWord]
64 if (dataPoints.length > 0) {
65 newProvStatusChartData = {
70 return newProvStatusChartData;
73 function processOrchData(orchDataList) {
75 let newOrchStatusChartData = CHART_ORCH_STATUS.emptyData;
76 for (let orchData of orchDataList) {
79 'x': orchData[itemKeyWord],
80 'y': orchData[countKeyWord]
85 if (dataPoints.length > 0) {
86 newOrchStatusChartData = {
91 return newOrchStatusChartData;
94 function processNfTypeData(nfDataList) {
96 let newNfTypeChartData = CHART_NF_TYPE.emptyData;
97 for (let nfData of nfDataList) {
100 'x': nfData[itemKeyWord],
101 'y': nfData[countKeyWord]
106 if (dataPoints.length > 0) {
107 newNfTypeChartData = {
112 return newNfTypeChartData;
115 function processNfRoleData(nfDataList) {
117 let newNfRoleChartData = CHART_NF_ROLE.emptyData;
118 for (let nfData of nfDataList) {
121 'x': nfData[itemKeyWord],
122 'y': nfData[countKeyWord]
127 if (dataPoints.length > 0) {
128 newNfRoleChartData = {
133 return newNfRoleChartData;
136 function getVnfFilterAggregationQueryString(filterValueMap) {
139 for (let filter in filterValueMap) {
140 if (filterValueMap[filter] !== '') {
144 'filterValue': filterValueMap[filter]
157 'filters': filterList
161 function getVnfVisualizationsResultsEvent(results) {
162 let count = TOTAL_VNF_COUNT.emptyData;
163 let provData = CHART_PROV_STATUS.emptyData;
164 let orchData = CHART_ORCH_STATUS.emptyData;
165 let netFuncTypeData = CHART_NF_TYPE.emptyData;
166 let netFuncRoleData = CHART_NF_ROLE.emptyData;
169 count = results.total;
172 if (results['aggregations'] && results['aggregations']['prov-status']) {
173 provData = processProvData(results['aggregations']['prov-status']);
176 if (results['aggregations'] &&
177 results['aggregations']['orchestration-status']) {
178 orchData = processOrchData(results['aggregations']['orchestration-status']);
181 if (results['aggregations'] &&
182 results['aggregations']['nf-type']) {
183 netFuncTypeData = processNfTypeData(results['aggregations']['nf-type']);
186 if (results['aggregations'] &&
187 results['aggregations']['nf-role']) {
188 netFuncRoleData = processNfRoleData(results['aggregations']['nf-role']);
192 type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED,
195 provStatusData: provData,
196 orchStatusData: orchData,
197 nfTypeData: netFuncTypeData,
198 nfRoleData: netFuncRoleData
203 function setBusyFeedback(){
205 type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK
209 function disableBusyFeedback(){
211 type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK
215 export function processVnfVisualizationsOnFilterChange(filterValueMap) {
217 dispatch(setBusyFeedback());
218 return fetch(VNF_FILTER_AGGREGATION_URL, {
220 headers: POST_HEADER,
221 body: JSON.stringify(getVnfFilterAggregationQueryString(filterValueMap))
223 (response) => response.json()
226 if(responseJson.total === 0) {
227 dispatch(getSetGlobalMessageEvent(VNF_FILTER_EMPTY_RESULT, MESSAGE_LEVEL_WARNING));
229 dispatch(getClearGlobalMessageEvent());
231 dispatch(getVnfVisualizationsResultsEvent(responseJson));
235 dispatch(disableBusyFeedback());
239 dispatch(disableBusyFeedback());
240 dispatch(getInvalidQueryEvent());
246 export function processVnfFilterPanelCollapse(isOpen) {
247 let vnfVisualizationPanelClass = 'collapsible-panel-main-panel';
250 vnfVisualizationPanelClass += ' vertical-filter-panel-is-open';
254 type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED,
256 vnfVisualizationPanelClass: vnfVisualizationPanelClass
261 export function setNotificationText(msgText, msgSeverity) {
262 if (msgText.length > 0) {
265 getSetGlobalMessageEvent(msgText, msgSeverity));
269 dispatch(getClearGlobalMessageEvent());
274 export function clearVnfSearchData() {
276 type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED,
279 provStatusData: CHART_PROV_STATUS.emptyData,
280 orchStatusData: CHART_ORCH_STATUS.emptyData,
281 nfTypeData: CHART_NF_TYPE.emptyData,
282 nfRoleData: CHART_NF_ROLE.emptyData