1 // update action erstellen, die unterscheiden kann, ob die eine oder die andere Ansicht gerade aktive ist und diese katualisiert.
2 // Diese action wird dann bei jeder aktualisierung in den anderen Actions und bei eintreffen von notifikationen verwendet.
5 * ============LICENSE_START========================================================================
6 * ONAP : ccsdk feature sdnr wt odlux
7 * =================================================================================================
8 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
9 * =================================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
11 * in compliance with the License. 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 distributed under the License
16 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
17 * or implied. See the License for the specific language governing permissions and limitations under
19 * ============LICENSE_END==========================================================================
22 import { Action } from '../../../../framework/src/flux/action';
23 import { Dispatch } from '../../../../framework/src/flux/store';
24 import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore';
26 import { networkElementsReloadAction } from '../handlers/networkElementsHandler';
27 import { connectionStatusLogReloadAction } from '../handlers/connectionStatusLogHandler';
29 import { PanelId } from '../models/panelId';
30 import { guiCutThrough } from '../models/guiCutTrough';
31 import { connectService} from '../services/connectService';
34 export class SetPanelAction extends Action {
35 constructor(public panelId: PanelId) {
40 export class AddWebUriList extends Action {
41 constructor(public searchedElements: guiCutThrough[], public notSearchedElements: string[], public unsupportedElements: string[], public newlySearchedElements?: string[]) {
46 export class RemoveWebUri extends Action {
47 constructor(public element: string) {
52 export const removeWebUriAction = (nodeId: string) => {
53 return new RemoveWebUri(nodeId);
56 export class SetWeburiSearchBusy extends Action {
57 constructor(public isbusy: boolean) {
63 export const findWebUrisForGuiCutThroughAsyncAction = (networkElementIds: string[]) => async (dispatcher: Dispatch, getState: () => IApplicationStoreState) => {
65 // keep method from executing simultanously; state not used because change of iu isn't needed
68 const { connect: { guiCutThrough, networkElements } } = getState();
70 let notConnectedElements: string[] = [];
71 let elementsToSearch: string[] = [];
72 let prevFoundElements: string[] = [];
73 let unsupportedElements: string[] = [];
75 networkElementIds.forEach(id => {
76 const item = networkElements.rows.find((ne) => ne.id === id);
78 if (item.status === "Connected") {
80 // if (item.coreModelCapability !== "Unsupported") {
81 // element is connected and is added to search list, if it doesn't exist already
82 const exists = guiCutThrough.searchedElements.filter(element => element.id === id).length > 0;
84 elementsToSearch.push(id);
86 //element was found previously, but wasn't connected
87 if (guiCutThrough.notSearchedElements.length > 0 && guiCutThrough.notSearchedElements.includes(id)) {
88 prevFoundElements.push(id);
92 // // element does not support core model and must not be searched for a weburi
93 // const id = item.id as string;
94 // const exists = guiCutThrough.unsupportedElements.filter(element => element === id).length > 0;
96 // unsupportedElements.push(id);
98 // //element was found previously, but wasn't connected
99 // if (guiCutThrough.notSearchedElements.length > 0 && guiCutThrough.notSearchedElements.includes(id)) {
100 // prevFoundElements.push(id);
106 // element isn't connected and cannot be searched for a weburi
107 if (!guiCutThrough.notSearchedElements.includes(id)) {
108 notConnectedElements.push(item.id as string);
115 if (elementsToSearch.length > 0 || notConnectedElements.length > 0 || unsupportedElements.length > 0) {
116 const result = await connectService.getAllWebUriExtensionsForNetworkElementListAsync(elementsToSearch);
117 dispatcher(new AddWebUriList(result, notConnectedElements, unsupportedElements, prevFoundElements));
122 export const setPanelAction = (panelId: PanelId) => {
123 return new SetPanelAction(panelId);
126 export const updateCurrentViewAsyncAction = () => (dispatch: Dispatch, getState: () => IApplicationStoreState) => {
127 const { connect: { currentOpenPanel } } = getState();
128 if (currentOpenPanel === "NetworkElements") {
129 return dispatch(networkElementsReloadAction);
132 return dispatch(connectionStatusLogReloadAction);