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.
27 import {tierSupportActionTypes,
28 TS_BACKEND_SEARCH_SELECTED_NODE_URL} from 'app/tierSupport/TierSupportConstants.js';
32 ERROR_RETRIEVING_DATA,
34 } from 'app/networking/NetworkConstants.js';
35 import networkCall from 'app/networking/NetworkCalls.js';
37 getSetGlobalMessageEvent,
38 getClearGlobalMessageEvent
39 } from 'app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js';
41 STATUS_CODE_204_NO_CONTENT,
42 STATUS_CODE_3XX_REDIRECTION,
43 STATUS_CODE_5XX_SERVER_ERROR
44 } from 'utils/GlobalConstants.js';
46 function createOnNodeDetailsChangeEvent(newDetails) {
48 type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED,
53 function createSplitPaneResizeEvent(initialLoad) {
55 type: tierSupportActionTypes.SPLIT_PANE_RESIZE,
60 function createOnNodeMenuSelectEvent(selectedMenu) {
62 type: tierSupportActionTypes.TS_GRAPH_NODE_MENU_SELECTED,
67 export function onNodeDetailsChange(newDetails) {
69 dispatch(createOnNodeDetailsChangeEvent(newDetails));
73 export function splitPaneResize(initialLoad) {
75 dispatch(createSplitPaneResizeEvent(initialLoad));
79 export function onNodeMenuChange(selectedMenu) {
81 dispatch(createOnNodeMenuSelectEvent(selectedMenu));
85 function createNodeDetailsFoundEvent(nodeDetails) {
87 type: tierSupportActionTypes.TS_NODE_SEARCH_RESULTS,
92 function noNodeDetailsFoundEvent(errorText) {
94 type: tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS,
95 data: {errorMsg: errorText}
99 function getInvalidSelectedNodeSearchEvent(errorText) {
101 type: tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR,
102 data: {value: errorText, errorMsg: ERROR_RETRIEVING_DATA}
106 export function clearVIData() {
108 type: tierSupportActionTypes.TIER_SUPPORT_CLEAR_DATA
112 export function fetchSelectedNodeElement(fetchRequestCallback) {
114 return fetchRequestCallback().then(
116 if (response.status === STATUS_CODE_204_NO_CONTENT || response.status >= STATUS_CODE_3XX_REDIRECTION) {
117 return Promise.reject(new Error(response.status));
120 return response.json();
125 if (responseJson.nodes.length > 0) {
126 dispatch(createNodeDetailsFoundEvent(responseJson));
128 dispatch(noNodeDetailsFoundEvent(NO_RESULTS_FOUND));
133 if (errorCode.message >= STATUS_CODE_5XX_SERVER_ERROR) {
134 dispatch(getInvalidSelectedNodeSearchEvent(ERROR_RETRIEVING_DATA));
136 // TODO - assuming 204 status, but should include additional
137 // statuses in the future with proper messaging in order to return
139 dispatch(noNodeDetailsFoundEvent(NO_RESULTS_FOUND));
146 export function querySelectedNodeElement(
147 searchHashId, selectedNodeFetchRequest) {
152 if (selectedNodeFetchRequest === undefined) {
153 let postBody = JSON.stringify(payload);
154 selectedNodeFetchRequest =
155 () => networkCall.fetchRequestObj(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST,
156 POST_HEADER, postBody);
160 dispatch(fetchSelectedNodeElement(selectedNodeFetchRequest));
164 export function setNotificationText(msgText, msgSeverity) {
165 if (msgText.length > 0) {
168 getSetGlobalMessageEvent(msgText, msgSeverity));
172 dispatch(getClearGlobalMessageEvent());