From 88bc504d0d9bc18348df761fcf685399a3219517 Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Mon, 25 Jan 2021 12:44:26 +0100 Subject: [PATCH] perform VILLASnode status and graph query in refresh method for ICs --- src/ic/ic-store.js | 22 ---------------------- src/ic/ics.js | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/ic/ic-store.js b/src/ic/ic-store.js index 5a77642..21d84ea 100644 --- a/src/ic/ic-store.js +++ b/src/ic/ic-store.js @@ -30,28 +30,6 @@ class InfrastructureComponentStore extends ArrayStore { reduce(state, action) { switch(action.type) { case 'ics/loaded': - action.data.forEach(ic => { - if ((ic.type === "villas-node" || ic.type === "villas-relay") - && ic.apiurl !== '' && ic.apiurl !== undefined && ic.apiurl !== null) { - let splitWebsocketURL = ic.websocketurl.split("/"); - AppDispatcher.dispatch({ - type: 'ic-status/get-status', - url: ic.apiurl + "/status", - socketname: splitWebsocketURL[splitWebsocketURL.length - 1], - token: action.token, - icid: ic.id, - ic: ic - }); - - AppDispatcher.dispatch({ - type: 'ic-graph/get-graph', - url: ic.apiurl + "/graph.svg", - socketname: splitWebsocketURL[splitWebsocketURL.length - 1], - token: action.token, - icid: ic.id, - }); - } - }) return super.reduce(state, action); diff --git a/src/ic/ics.js b/src/ic/ics.js index 9868231..5c8c6fb 100644 --- a/src/ic/ics.js +++ b/src/ic/ics.js @@ -119,6 +119,30 @@ class InfrastructureComponents extends Component { token: this.state.sessionToken, }); + // get status and graph of VILLASnode and VILLASrelay ICs + this.state.ics.forEach(ic => { + if ((ic.type === "villas-node" || ic.type === "villas-relay") + && ic.apiurl !== '' && ic.apiurl !== undefined && ic.apiurl !== null) { + let splitWebsocketURL = ic.websocketurl.split("/"); + AppDispatcher.dispatch({ + type: 'ic-status/get-status', + url: ic.apiurl + "/status", + socketname: splitWebsocketURL[splitWebsocketURL.length - 1], + token: this.state.sessionToken, + icid: ic.id, + ic: ic + }); + + AppDispatcher.dispatch({ + type: 'ic-graph/get-graph', + url: ic.apiurl + "/graph.svg", + socketname: splitWebsocketURL[splitWebsocketURL.length - 1], + token: this.state.sessionToken, + icid: ic.id, + }); + } + }) + } }