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.
29 ERROR_RETRIEVING_DATA,
32 } from 'app/networking/NetworkConstants.js';
35 INVENTORY_GEO_VISUALIZATION_SEARCH_URL,
36 GEO_VISUALIZATION_QUERY_STRING_PARAMETERS,
37 INVENTORY_COUNT_BY_TYPE_SEARCH_URL,
38 INVENTORY_COUNT_BY_DATE_SEARCH_URL,
40 } from 'app/inventory/InventoryConstants.js';
42 import {MESSAGE_LEVEL_DANGER} from 'utils/GlobalConstants.js';
44 function getSuccessfulTopographicVisualizationQueryEvent(responseJson) {
46 type: InventoryActionTypes.TOPOGRAPHIC_QUERY_SUCCESS,
48 plotPoints: responseJson.plotPoints
53 function getFailedTopographicVisualizationQueryEvent() {
55 type: InventoryActionTypes.TOPOGRAPHIC_QUERY_FAILED,
57 message: ERROR_RETRIEVING_DATA,
58 severity: MESSAGE_LEVEL_DANGER
63 function getSuccessfulCountByTypeQueryEvent(responseJson) {
65 type: InventoryActionTypes.COUNT_BY_ENTITY_SUCCESS,
67 countByType: responseJson.result
72 function getFailedCountByTypeQueryEvent() {
74 type: InventoryActionTypes.COUNT_BY_ENTITY_FAILED,
76 message: ERROR_RETRIEVING_DATA,
77 severity: MESSAGE_LEVEL_DANGER
82 function getSuccessfulCountsByDateQueryEvent(responseJson) {
84 type: InventoryActionTypes.COUNT_BY_DATE_SUCCESS,
86 countByDate: responseJson.result
91 function getFailedCountByDateQueryEvent() {
93 type: InventoryActionTypes.COUNT_BY_DATE_FAILED,
95 message: ERROR_RETRIEVING_DATA,
96 severity: MESSAGE_LEVEL_DANGER
101 function getDynamicTopographicQueryURL(entityType) {
102 return INVENTORY_GEO_VISUALIZATION_SEARCH_URL.replace(BACKEND_IP_ADDRESS,
103 BACKEND_IP_ADDRESS) +
104 GEO_VISUALIZATION_QUERY_STRING_PARAMETERS +
108 function getCountByTypeQueryURL() {
109 return INVENTORY_COUNT_BY_TYPE_SEARCH_URL.replace(BACKEND_IP_ADDRESS,
113 function getCountByDateQueryURL() {
114 return INVENTORY_COUNT_BY_DATE_SEARCH_URL.replace(BACKEND_IP_ADDRESS,
118 export function onLoadTotalCountByDate() {
119 return function (dispatch) {
120 fetch(getCountByDateQueryURL(), {
121 credentials: SAME_ORIGIN,
125 (response) => response.json()
127 (responseJson) => dispatch(
128 getSuccessfulCountsByDateQueryEvent(responseJson))
130 () => dispatch(getFailedCountByDateQueryEvent())
135 export function onCountByTypeLoad() {
136 return function (dispatch) {
137 fetch(getCountByTypeQueryURL(), {
138 credentials: SAME_ORIGIN,
142 (response) => response.json()
144 (responseJson) => dispatch(
145 getSuccessfulCountByTypeQueryEvent(responseJson))
147 () => dispatch(getFailedCountByTypeQueryEvent())
152 export function onTopographicMapMounted(requestObject) {
153 return function (dispatch) {
154 fetch(getDynamicTopographicQueryURL(requestObject.entityType), {
155 credentials: SAME_ORIGIN,
159 (response) => response.json()
161 (responseJson) => dispatch(
162 getSuccessfulTopographicVisualizationQueryEvent(responseJson))
165 dispatch(getFailedTopographicVisualizationQueryEvent());