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 ERROR_RETRIEVING_DATA,
29 } from 'app/networking/NetworkConstants.js';
32 INVENTORY_GEO_VISUALIZATION_SEARCH_URL,
33 GEO_VISUALIZATION_QUERY_STRING_PARAMETERS,
34 INVENTORY_COUNT_BY_TYPE_SEARCH_URL,
35 INVENTORY_COUNT_BY_DATE_SEARCH_URL,
37 } from 'app/inventory/InventoryConstants.js';
39 import {MESSAGE_LEVEL_DANGER} from 'utils/GlobalConstants.js';
41 function getSuccessfulTopographicVisualizationQueryEvent(responseJson) {
43 type: InventoryActionTypes.TOPOGRAPHIC_QUERY_SUCCESS,
45 plotPoints: responseJson.plotPoints
50 function getFailedTopographicVisualizationQueryEvent() {
52 type: InventoryActionTypes.TOPOGRAPHIC_QUERY_FAILED,
54 message: ERROR_RETRIEVING_DATA,
55 severity: MESSAGE_LEVEL_DANGER
60 function getSuccessfulCountByTypeQueryEvent(responseJson) {
62 type: InventoryActionTypes.COUNT_BY_ENTITY_SUCCESS,
64 countByType: responseJson.result
69 function getFailedCountByTypeQueryEvent() {
71 type: InventoryActionTypes.COUNT_BY_ENTITY_FAILED,
73 message: ERROR_RETRIEVING_DATA,
74 severity: MESSAGE_LEVEL_DANGER
79 function getSuccessfulCountsByDateQueryEvent(responseJson) {
81 type: InventoryActionTypes.COUNT_BY_DATE_SUCCESS,
83 countByDate: responseJson.result
88 function getFailedCountByDateQueryEvent() {
90 type: InventoryActionTypes.COUNT_BY_DATE_FAILED,
92 message: ERROR_RETRIEVING_DATA,
93 severity: MESSAGE_LEVEL_DANGER
98 function getDynamicTopographicQueryURL(entityType) {
99 return INVENTORY_GEO_VISUALIZATION_SEARCH_URL.replace(BACKEND_IP_ADDRESS,
100 BACKEND_IP_ADDRESS) +
101 GEO_VISUALIZATION_QUERY_STRING_PARAMETERS +
105 function getCountByTypeQueryURL() {
106 return INVENTORY_COUNT_BY_TYPE_SEARCH_URL.replace(BACKEND_IP_ADDRESS,
110 function getCountByDateQueryURL() {
111 return INVENTORY_COUNT_BY_DATE_SEARCH_URL.replace(BACKEND_IP_ADDRESS,
115 export function onLoadTotalCountByDate() {
116 return function (dispatch) {
117 fetch(getCountByDateQueryURL(), {
118 credentials: SAME_ORIGIN,
122 (response) => response.json()
124 (responseJson) => dispatch(
125 getSuccessfulCountsByDateQueryEvent(responseJson))
127 () => dispatch(getFailedCountByDateQueryEvent())
132 export function onCountByTypeLoad() {
133 return function (dispatch) {
134 fetch(getCountByTypeQueryURL(), {
135 credentials: SAME_ORIGIN,
139 (response) => response.json()
141 (responseJson) => dispatch(
142 getSuccessfulCountByTypeQueryEvent(responseJson))
144 () => dispatch(getFailedCountByTypeQueryEvent())
149 export function onTopographicMapMounted(requestObject) {
150 return function (dispatch) {
151 fetch(getDynamicTopographicQueryURL(requestObject.entityType), {
152 credentials: SAME_ORIGIN,
156 (response) => response.json()
158 (responseJson) => dispatch(
159 getSuccessfulTopographicVisualizationQueryEvent(responseJson))
162 dispatch(getFailedTopographicVisualizationQueryEvent());