2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt odlux
4 * =================================================================================================
5 * Copyright (C) 2020 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 { Action } from '../../../../framework/src/flux/action';
20 import { requestRest } from '../../../../framework/src/services/restService';
23 import { site, Device } from "../model/site";
24 import { link } from '../model/link';
25 import { HistoryEntry } from "../model/historyEntry";
26 import { IApplicationStoreState } from '../../../../framework/src/store/applicationStore';
27 import { Dispatch } from '../../../../framework/src/flux/store';
29 export class SelectSiteAction extends Action {
30 constructor(public site: site){
35 export class SelectLinkAction extends Action {
36 constructor(public link: link){
41 export class ClearDetailsAction extends Action{
47 export class AddToHistoryAction extends Action {
48 constructor(public entry: HistoryEntry){
53 export class ClearHistoryAction extends Action {
59 export class IsBusyCheckingDeviceListAction extends Action{
60 constructor(public isBusy: boolean){
65 export class FinishedLoadingDeviceListAction extends Action{
66 constructor(public devices: Device[]){
71 export class ClearLoadedDevicesAction extends Action{
79 export const UpdateDetailsView = (nodeId: string) =>(dispatcher: Dispatch, getState: () => IApplicationStoreState) =>{
80 const {network:{details:{checkedDevices}}} = getState();
81 if(checkedDevices!==null){
82 const index = checkedDevices.findIndex(item=>item.name===nodeId)
84 requestRest<any>("/rests/operational/network-topology:network-topology/topology/topology-netconf/node/"+nodeId, { method: "GET" })
87 checkedDevices[index].status = result.node[0]["netconf-node-topology:connection-status"];
90 checkedDevices[index].status = "Not connected";
92 dispatcher(new FinishedLoadingDeviceListAction(checkedDevices));
99 export const CheckDeviceList = (list: Device[]) => async (dispatcher: Dispatch, getState: () => IApplicationStoreState) =>{
102 dispatcher(new IsBusyCheckingDeviceListAction(true));
104 const promises = list.map((device)=>{
105 if(device.simulatorId){
106 return requestRest<any>("/rests/operational/network-topology:network-topology/topology/topology-netconf/node/"+device.simulatorId, { method: "GET" })
109 return requestRest<any>("/rests/operational/network-topology:network-topology/topology/topology-netconf/node/"+device.name, { method: "GET" })
115 Promise.all(promises).then((result)=>{
119 result.forEach((res: any, index)=>{
120 if(res !==null && res.node!==null){
122 list[index].status = res.node[0]["netconf-node-topology:connection-status"];
124 list[index].status = "Not connected";
128 dispatcher(new FinishedLoadingDeviceListAction(list));
129 dispatcher(new IsBusyCheckingDeviceListAction(false));
135 dispatcher(new IsBusyCheckingDeviceListAction(false));