3 * ============LICENSE_START========================================================================
4 * ONAP : ccsdk feature sdnr wt odlux
5 * =================================================================================================
6 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
7 * =================================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software distributed under the License
14 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
15 * or implied. See the License for the specific language governing permissions and limitations under
17 * ============LICENSE_END==========================================================================
21 * Create an update action that can distinguish whether one or the other view is currently active and update it.
22 * This action is then used for each update in the other actions and when notifications arrive.
23 * create an update action that can distinguish whether one or the other view is currently active and update it.
24 * This action is then used for each update in the other actions and when notifications arrive.
27 import { Action } from '../../../../framework/src/flux/action';
28 import { Dispatch } from '../../../../framework/src/flux/store';
29 import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore';
31 import { connectionStatusLogReloadAction } from '../handlers/connectionStatusLogHandler';
32 import { networkElementsReloadAction } from '../handlers/networkElementsHandler';
33 import { guiCutThrough } from '../models/guiCutTrough';
34 import { PanelId } from '../models/panelId';
35 import { connectService } from '../services/connectService';
38 export class SetPanelAction extends Action {
39 constructor(public panelId: PanelId) {
44 export class AddWebUriList extends Action {
45 constructor(public searchedElements: guiCutThrough[], public notSearchedElements: string[], public unsupportedElements: string[], public newlySearchedElements?: string[]) {
50 export class RemoveWebUri extends Action {
51 constructor(public element: string) {
56 export const removeWebUriAction = (nodeId: string) => {
57 return new RemoveWebUri(nodeId);
60 export class SetWeburiSearchBusy extends Action {
61 constructor(public isbusy: boolean) {
67 export const findWebUrisForGuiCutThroughAsyncAction = (networkElementIds: string[]) => async (dispatcher: Dispatch, getState: () => IApplicationStoreState) => {
69 // keep method from executing simultanously; state not used because change of iu isn't needed
75 const { connect: { guiCutThrough: guiCutThrough2, networkElements } } = getState();
77 let notConnectedElements: string[] = [];
78 let elementsToSearch: string[] = [];
79 let prevFoundElements: string[] = [];
80 let unsupportedElements: string[] = [];
82 networkElementIds.forEach(id => {
83 const item = networkElements.rows.find((ne) => ne.id === id);
85 if (item.status === 'Connected') {
87 // if (item.coreModelCapability !== "Unsupported") {
88 // element is connected and is added to search list, if it doesn't exist already
89 const exists = guiCutThrough2.searchedElements.filter(element => element.id === id).length > 0;
91 elementsToSearch.push(id);
93 //element was found previously, but wasn't connected
94 if (guiCutThrough2.notSearchedElements.length > 0 && guiCutThrough2.notSearchedElements.includes(id)) {
95 prevFoundElements.push(id);
99 // // element does not support core model and must not be searched for a weburi
100 // const id = item.id as string;
101 // const exists = guiCutThrough.unsupportedElements.filter(element => element === id).length > 0;
103 // unsupportedElements.push(id);
105 // //element was found previously, but wasn't connected
106 // if (guiCutThrough.notSearchedElements.length > 0 && guiCutThrough.notSearchedElements.includes(id)) {
107 // prevFoundElements.push(id);
112 // element isn't connected and cannot be searched for a weburi
113 if (!guiCutThrough2.notSearchedElements.includes(id)) {
114 notConnectedElements.push(item.id as string);
121 if (elementsToSearch.length > 0 || notConnectedElements.length > 0 || unsupportedElements.length > 0) {
122 const result = await connectService.getAllWebUriExtensionsForNetworkElementListAsync(elementsToSearch);
123 dispatcher(new AddWebUriList(result, notConnectedElements, unsupportedElements, prevFoundElements));
129 export const setPanelAction = (panelId: PanelId) => {
130 return new SetPanelAction(panelId);
133 export const updateCurrentViewAsyncAction = () => (dispatch: Dispatch, getState: () => IApplicationStoreState) => {
134 const { connect: { currentOpenPanel } } = getState();
135 if (currentOpenPanel === 'NetworkElements') {
136 return dispatch(networkElementsReloadAction);
138 return dispatch(connectionStatusLogReloadAction);