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.
24 import {tierSupportActionTypes,
25 TS_BACKEND_SEARCH_SELECTED_NODE_URL} from 'app/tierSupport/TierSupportConstants.js';
29 ERROR_RETRIEVING_DATA,
31 } from 'app/networking/NetworkConstants.js';
32 import networkCall from 'app/networking/NetworkCalls.js';
34 getSetGlobalMessageEvent,
35 getClearGlobalMessageEvent
36 } from 'app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js';
38 STATUS_CODE_204_NO_CONTENT,
39 STATUS_CODE_3XX_REDIRECTION,
40 STATUS_CODE_5XX_SERVER_ERROR
41 } from 'utils/GlobalConstants.js';
43 function createOnNodeDetailsChangeEvent(newDetails) {
45 type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED,
50 function createSplitPaneResizeEvent(initialLoad) {
52 type: tierSupportActionTypes.SPLIT_PANE_RESIZE,
57 function createOnNodeMenuSelectEvent(selectedMenu) {
59 type: tierSupportActionTypes.TS_GRAPH_NODE_MENU_SELECTED,
64 export function onNodeDetailsChange(newDetails) {
66 dispatch(createOnNodeDetailsChangeEvent(newDetails));
70 export function splitPaneResize(initialLoad) {
72 dispatch(createSplitPaneResizeEvent(initialLoad));
76 export function onNodeMenuChange(selectedMenu) {
78 dispatch(createOnNodeMenuSelectEvent(selectedMenu));
82 function createNodeDetailsFoundEvent(nodeDetails) {
84 type: tierSupportActionTypes.TS_NODE_SEARCH_RESULTS,
89 function noNodeDetailsFoundEvent(errorText) {
91 type: tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS,
92 data: {errorMsg: errorText}
96 function getInvalidSelectedNodeSearchEvent(errorText) {
98 type: tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR,
99 data: {value: errorText, errorMsg: ERROR_RETRIEVING_DATA}
103 export function clearVIData() {
105 type: tierSupportActionTypes.TIER_SUPPORT_CLEAR_DATA
109 export function fetchSelectedNodeElement(fetchRequestCallback) {
111 return fetchRequestCallback().then(
113 if (response.status === STATUS_CODE_204_NO_CONTENT || response.status >= STATUS_CODE_3XX_REDIRECTION) {
114 return Promise.reject(new Error(response.status));
117 return response.json();
122 if (responseJson.nodes.length > 0) {
123 dispatch(createNodeDetailsFoundEvent(responseJson));
125 dispatch(noNodeDetailsFoundEvent(NO_RESULTS_FOUND));
130 if (errorCode.message >= STATUS_CODE_5XX_SERVER_ERROR) {
131 dispatch(getInvalidSelectedNodeSearchEvent(ERROR_RETRIEVING_DATA));
133 // TODO - assuming 204 status, but should include additional
134 // statuses in the future with proper messaging in order to return
136 dispatch(noNodeDetailsFoundEvent(NO_RESULTS_FOUND));
143 export function querySelectedNodeElement(
144 searchHashId, selectedNodeFetchRequest) {
149 if (selectedNodeFetchRequest === undefined) {
150 let postBody = JSON.stringify(payload);
151 selectedNodeFetchRequest =
152 () => networkCall.fetchRequestObj(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST,
153 POST_HEADER, postBody);
157 dispatch(fetchSelectedNodeElement(selectedNodeFetchRequest));
161 export function setNotificationText(msgText, msgSeverity) {
162 if (msgText.length > 0) {
165 getSetGlobalMessageEvent(msgText, msgSeverity));
169 dispatch(getClearGlobalMessageEvent());