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 createSelectedNodeDetails(nodeDetails) {
90 var selectedNodeDetail;
91 for(let i = 0; i < nodeDetails.nodes.length; i++) {
92 if(nodeDetails.nodes[i].nodeMeta.className === 'selectedSearchedNodeClass') {
93 selectedNodeDetail = nodeDetails.nodes[i];
98 type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED,
99 data: selectedNodeDetail
103 function noNodeDetailsFoundEvent(errorText) {
105 type: tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS,
106 data: {errorMsg: errorText}
110 function getInvalidSelectedNodeSearchEvent(errorText) {
112 type: tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR,
113 data: {value: errorText, errorMsg: ERROR_RETRIEVING_DATA}
117 export function clearVIData() {
119 type: tierSupportActionTypes.TIER_SUPPORT_CLEAR_DATA
123 function setBusyFeedback(){
125 type: tierSupportActionTypes.TIER_SUPPORT_ACTIVATE_BUSY_FEEDBACK
129 function disableBusyFeedback(){
131 type: tierSupportActionTypes.TIER_SUPPORT_DISABLE_BUSY_FEEDBACK
135 export function fetchSelectedNodeElement(fetchRequestCallback) {
137 return fetchRequestCallback().then(
139 if (response.status === STATUS_CODE_204_NO_CONTENT || response.status >= STATUS_CODE_3XX_REDIRECTION) {
140 return Promise.reject(new Error(response.status));
143 return response.json();
148 if (responseJson.nodes.length > 0) {
149 dispatch(createNodeDetailsFoundEvent(responseJson));
150 dispatch(createSelectedNodeDetails(responseJson));
152 dispatch(noNodeDetailsFoundEvent(NO_RESULTS_FOUND));
157 dispatch(disableBusyFeedback());
161 dispatch(disableBusyFeedback());
162 if (errorCode.message >= STATUS_CODE_5XX_SERVER_ERROR) {
163 dispatch(getInvalidSelectedNodeSearchEvent(ERROR_RETRIEVING_DATA));
165 // TODO - assuming 204 status, but should include additional
166 // statuses in the future with proper messaging in order to return
168 dispatch(noNodeDetailsFoundEvent(NO_RESULTS_FOUND));
175 export function querySelectedNodeElement(
176 searchHashId, selectedNodeFetchRequest) {
181 if (selectedNodeFetchRequest === undefined) {
182 let postBody = JSON.stringify(payload);
183 selectedNodeFetchRequest =
184 () => networkCall.fetchRequestObj(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST,
185 POST_HEADER, postBody);
189 dispatch(setBusyFeedback());
190 dispatch(fetchSelectedNodeElement(selectedNodeFetchRequest));
194 export function setNotificationText(msgText, msgSeverity) {
195 if (msgText.length > 0) {
198 getSetGlobalMessageEvent(msgText, msgSeverity));
202 dispatch(getClearGlobalMessageEvent());