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.
26 import {aaiActionTypes} from './MainScreenWrapperConstants.js';
32 } from 'app/networking/NetworkConstants.js';
35 } from 'utils/GlobalConstants.js';
36 import {fetchRequestObj} from 'app/networking/NetworkCalls.js';
39 getSetGlobalMessageEvent,
40 getClearGlobalMessageEvent
41 } from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js';
43 function createWindowSizeChangeEvent() {
45 type: aaiActionTypes.AAI_WINDOW_RESIZE
49 function createShowMenuEvent(show) {
51 type: aaiActionTypes.AAI_SHOW_MENU,
58 export function windowResize() {
60 dispatch(createWindowSizeChangeEvent());
64 export function showMainMenu(show) {
66 dispatch(createShowMenuEvent(show));
70 function createViewDataFoundEvent(viewData, paramName, curViewData) {
73 obj['data']['paramName'] = paramName;
74 obj['data']['viewData'] = viewData;
75 obj['data']['curViewData'] = curViewData;
76 obj['type'] = aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_RESPONSE_RECEIVED;
81 function extensibleViewData(dataFetchRequest, paramName, curViewData) {
83 return dataFetchRequest().then(
85 return response.json();
89 dispatch(createViewDataFoundEvent(responseJson, paramName, curViewData));
92 dispatch(getSetGlobalMessageEvent(ERROR_RETRIEVING_DATA, MESSAGE_LEVEL_DANGER));
93 dispatch(createViewDataFoundEvent({}, paramName, curViewData));
94 //To-do: If need to send a flag later on to the view, add a function to have the flag
99 export function extensibleViewNetworkCallback(urlApi, postBody, paramName, curViewData) {
101 let dataFetchRequest =
102 () => fetchRequestObj(BASE_URL + urlApi, POST,
103 POST_HEADER, postBody);
107 dispatch(extensibleViewData(dataFetchRequest, paramName, curViewData));
111 export function extensibleViewMessageCallback(msgText, msgSeverity) {
112 if (msgText.length > 0) {
115 getSetGlobalMessageEvent(msgText, msgSeverity));
119 dispatch(getClearGlobalMessageEvent());
124 export function clearExtensibleViewData() {
126 type: aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_CLEAR_DATA,
131 export function setSecondaryTitle(title) {
133 type: aaiActionTypes.SET_SECONDARY_TITLE,