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=========================================================
24 ERROR_RETRIEVING_DATA,
27 } from 'app/networking/NetworkConstants.js';
30 INVENTORY_GEO_VISUALIZATION_SEARCH_URL,
31 GEO_VISUALIZATION_QUERY_STRING_PARAMETERS,
32 INVENTORY_COUNT_BY_TYPE_SEARCH_URL,
33 INVENTORY_COUNT_BY_DATE_SEARCH_URL,
35 } from 'app/inventory/InventoryConstants.js';
37 import {MESSAGE_LEVEL_DANGER} from 'utils/GlobalConstants.js';
39 function getSuccessfulTopographicVisualizationQueryEvent(responseJson) {
41 type: InventoryActionTypes.TOPOGRAPHIC_QUERY_SUCCESS,
43 plotPoints: responseJson.plotPoints
48 function getFailedTopographicVisualizationQueryEvent() {
50 type: InventoryActionTypes.TOPOGRAPHIC_QUERY_FAILED,
52 message: ERROR_RETRIEVING_DATA,
53 severity: MESSAGE_LEVEL_DANGER
58 function getSuccessfulCountByTypeQueryEvent(responseJson) {
60 type: InventoryActionTypes.COUNT_BY_ENTITY_SUCCESS,
62 countByType: responseJson.result
67 function getFailedCountByTypeQueryEvent() {
69 type: InventoryActionTypes.COUNT_BY_ENTITY_FAILED,
71 message: ERROR_RETRIEVING_DATA,
72 severity: MESSAGE_LEVEL_DANGER
77 function getSuccessfulCountsByDateQueryEvent(responseJson) {
79 type: InventoryActionTypes.COUNT_BY_DATE_SUCCESS,
81 countByDate: responseJson.result
86 function getFailedCountByDateQueryEvent() {
88 type: InventoryActionTypes.COUNT_BY_DATE_FAILED,
90 message: ERROR_RETRIEVING_DATA,
91 severity: MESSAGE_LEVEL_DANGER
96 function getDynamicTopographicQueryURL(entityType) {
97 return INVENTORY_GEO_VISUALIZATION_SEARCH_URL.replace(BACKEND_IP_ADDRESS,
99 GEO_VISUALIZATION_QUERY_STRING_PARAMETERS +
103 function getCountByTypeQueryURL() {
104 return INVENTORY_COUNT_BY_TYPE_SEARCH_URL.replace(BACKEND_IP_ADDRESS,
108 function getCountByDateQueryURL() {
109 return INVENTORY_COUNT_BY_DATE_SEARCH_URL.replace(BACKEND_IP_ADDRESS,
113 export function onLoadTotalCountByDate() {
114 return dispatch => fetch(getCountByDateQueryURL(), {
115 credentials: SAME_ORIGIN,
119 (response) => response.json()
121 (responseJson) => dispatch(
122 getSuccessfulCountsByDateQueryEvent(responseJson))
124 () => dispatch(getFailedCountByDateQueryEvent())
129 export function onCountByTypeLoad() {
130 return dispatch => fetch(getCountByTypeQueryURL(), {
131 credentials: SAME_ORIGIN,
135 (response) => response.json()
137 (responseJson) => dispatch(
138 getSuccessfulCountByTypeQueryEvent(responseJson))
140 () => dispatch(getFailedCountByTypeQueryEvent())
145 export function onTopographicMapMounted(requestObject) {
146 return dispatch => fetch(getDynamicTopographicQueryURL(requestObject.entityType), {
147 credentials: SAME_ORIGIN,
151 (response) => response.json()
153 (responseJson) => dispatch(
154 getSuccessfulTopographicVisualizationQueryEvent(responseJson))
157 dispatch(getFailedTopographicVisualizationQueryEvent());