2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 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=========================================================
26 } from 'app/networking/NetworkConstants.js';
29 } from 'utils/GlobalConstants.js';
30 import {fetchRequestObj} from 'app/networking/NetworkCalls.js';
33 getSetGlobalMessageEvent,
34 getClearGlobalMessageEvent
35 } from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js';
36 import {aaiActionTypes} from 'app/MainScreenWrapperConstants.js';
38 function createWindowSizeChangeEvent() {
40 type: aaiActionTypes.AAI_WINDOW_RESIZE
44 function createShowMenuEvent(show) {
46 type: aaiActionTypes.AAI_SHOW_MENU,
53 export function windowResize() {
55 dispatch(createWindowSizeChangeEvent());
59 export function showMainMenu(show) {
61 dispatch(createShowMenuEvent(show));
65 function createOverlayDataFoundEvent(overlayData, paramName, curData, responseEventKey) {
67 type: responseEventKey,
70 overlayData: overlayData,
76 function overlayViewData(dataFetchRequest, paramName, curData, responseEventKey) {
78 dataFetchRequest().then(
80 return response.json();
84 dispatch(createOverlayDataFoundEvent(responseJson, paramName, curData, responseEventKey));
87 dispatch(getSetGlobalMessageEvent(ERROR_RETRIEVING_DATA, MESSAGE_LEVEL_DANGER));
88 dispatch(createOverlayDataFoundEvent({}, paramName, curData, responseEventKey));
93 export function overlayNetworkCallback(urlApi, postBody, paramName, curData, responseEventKey) {
94 let dataFetchRequest =
95 () => fetchRequestObj(BASE_URL + urlApi, POST,
96 POST_HEADER, JSON.stringify(postBody));
100 dispatch(overlayViewData(dataFetchRequest, paramName, curData, responseEventKey));
104 function createViewDataFoundEvent(viewData, paramName, curViewData) {
107 obj['data']['paramName'] = paramName;
108 obj['data']['viewData'] = viewData;
109 obj['data']['curViewData'] = curViewData;
110 obj['type'] = aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_RESPONSE_RECEIVED;
115 function extensibleViewData(dataFetchRequest, paramName, curViewData) {
117 return dataFetchRequest().then(
119 return response.json();
123 dispatch(createViewDataFoundEvent(responseJson, paramName, curViewData));
126 dispatch(getSetGlobalMessageEvent(ERROR_RETRIEVING_DATA, MESSAGE_LEVEL_DANGER));
127 dispatch(createViewDataFoundEvent({}, paramName, curViewData));
128 //To-do: If need to send a flag later on to the view, add a function to have the flag
133 export function extensibleViewNetworkCallback(urlApi, postBody, paramName, curViewData) {
135 let dataFetchRequest =
136 () => fetchRequestObj(BASE_URL + urlApi, POST,
137 POST_HEADER, postBody);
140 dispatch(extensibleViewData(dataFetchRequest, paramName, curViewData));
144 export function extensibleViewMessageCallback(msgText, msgSeverity) {
145 if (msgText.length > 0) {
148 getSetGlobalMessageEvent(msgText, msgSeverity));
152 dispatch(getClearGlobalMessageEvent());
157 export function clearExtensibleViewData() {
159 type: aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_CLEAR_DATA,
164 export function setSecondaryTitle(title) {
166 type: aaiActionTypes.SET_SECONDARY_TITLE,