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 function (dispatch) {
115 fetch(getCountByDateQueryURL(), {
116 credentials: SAME_ORIGIN,
120 (response) => response.json()
122 (responseJson) => dispatch(
123 getSuccessfulCountsByDateQueryEvent(responseJson))
125 () => dispatch(getFailedCountByDateQueryEvent())
130 export function onCountByTypeLoad() {
131 return function (dispatch) {
132 fetch(getCountByTypeQueryURL(), {
133 credentials: SAME_ORIGIN,
137 (response) => response.json()
139 (responseJson) => dispatch(
140 getSuccessfulCountByTypeQueryEvent(responseJson))
142 () => dispatch(getFailedCountByTypeQueryEvent())
147 export function onTopographicMapMounted(requestObject) {
148 return function (dispatch) {
149 fetch(getDynamicTopographicQueryURL(requestObject.entityType), {
150 credentials: SAME_ORIGIN,
154 (response) => response.json()
156 (responseJson) => dispatch(
157 getSuccessfulTopographicVisualizationQueryEvent(responseJson))
160 dispatch(getFailedTopographicVisualizationQueryEvent());