2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt odlux
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
19 import { IActionHandler } from '../../../../framework/src/flux/action';
20 import { combineActionHandler } from '../../../../framework/src/flux/middleware';
22 import { AddWebUriList, RemoveWebUri, SetPanelAction } from '../actions/commonNetworkElementsActions';
23 import { guiCutThrough } from '../models/guiCutTrough';
24 import { PanelId } from '../models/panelId';
25 import { connectionStatusLogActionHandler, IConnectionStatusLogState } from './connectionStatusLogHandler';
26 import { IInfoNetworkElementFeaturesState, IInfoNetworkElementsState, infoNetworkElementFeaturesActionHandler, infoNetworkElementsActionHandler } from './infoNetworkElementHandler';
27 import { INetworkElementsState, networkElementsActionHandler } from './networkElementsHandler';
28 import { availableTlsKeysActionHandler, IAvailableTlsKeysState } from './tlsKeyHandler';
30 export interface IConnectAppStoreState {
31 networkElements: INetworkElementsState;
32 connectionStatusLog: IConnectionStatusLogState;
33 currentOpenPanel: PanelId;
34 elementInfo: IInfoNetworkElementsState;
35 elementFeatureInfo: IInfoNetworkElementFeaturesState;
36 guiCutThrough: guiCutThroughState;
37 availableTlsKeys: IAvailableTlsKeysState;
40 const currentOpenPanelHandler: IActionHandler<PanelId> = (state = null, action) => {
41 if (action instanceof SetPanelAction) {
42 state = action.panelId;
47 interface guiCutThroughState {
48 searchedElements: guiCutThrough[];
49 notSearchedElements: string[];
50 unsupportedElements: string[];
53 const guiCutThroughHandler: IActionHandler<guiCutThroughState> = (state = { searchedElements: [], notSearchedElements: [], unsupportedElements: [] }, action) => {
54 if (action instanceof AddWebUriList) {
55 let notSearchedElements: string[];
56 let searchedElements: guiCutThrough[];
57 let unsupportedElements: string[];
59 notSearchedElements = state.notSearchedElements.concat(action.notSearchedElements);
60 unsupportedElements = state.unsupportedElements.concat(action.unsupportedElements);
62 //remove elements, which were just searched
63 if (action.newlySearchedElements) {
64 action.newlySearchedElements.forEach(item => {
65 notSearchedElements = notSearchedElements.filter(id => id !== item);
69 searchedElements = state.searchedElements.concat(action.searchedElements);
71 state = { searchedElements: searchedElements, notSearchedElements: notSearchedElements, unsupportedElements: unsupportedElements };
73 } else if (action instanceof RemoveWebUri) {
74 const nodeId = action.element;
75 const webUris = state.searchedElements.filter(item => item.id !== nodeId);
76 const knownElements = state.notSearchedElements.filter(item => item !== nodeId);
77 const unsupportedElement = state.unsupportedElements.filter(item => item != nodeId);
78 state = { notSearchedElements: knownElements, searchedElements: webUris, unsupportedElements: unsupportedElement };
83 declare module '../../../../framework/src/store/applicationStore' {
84 interface IApplicationStoreState {
85 connect: IConnectAppStoreState;
89 const actionHandlers = {
90 networkElements: networkElementsActionHandler,
91 connectionStatusLog: connectionStatusLogActionHandler,
92 currentOpenPanel: currentOpenPanelHandler,
93 elementInfo: infoNetworkElementsActionHandler,
94 elementFeatureInfo: infoNetworkElementFeaturesActionHandler,
95 guiCutThrough: guiCutThroughHandler,
96 availableTlsKeys: availableTlsKeysActionHandler,
99 export const connectAppRootHandler = combineActionHandler<IConnectAppStoreState>(actionHandlers);
100 export default connectAppRootHandler;