From 460cd2c4af7760ca2543a0c5e44e8ae1795f55dd Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Fri, 26 Feb 2021 15:55:30 +0100 Subject: [PATCH] query statistics endpoint of VILLASnode in addition to status endpoint - commented parts to be uncommented as soon as fix in VILLASnode is deployable --- src/ic/ic-store.js | 28 +++++++++++++++++++++++++++- src/ic/ics-data-manager.js | 26 ++++++++++++++++++++------ src/ic/ics.js | 2 +- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/ic/ic-store.js b/src/ic/ic-store.js index 36abb91..b852b94 100644 --- a/src/ic/ic-store.js +++ b/src/ic/ic-store.js @@ -117,7 +117,12 @@ class InfrastructureComponentStore extends ArrayStore { if(!tempIC.managedexternally){ tempIC.state = action.data.state; tempIC.uptime = action.data.time_now - action.data.time_started; - tempIC.statusupdateraw = action.data; + if (tempIC.statusupdateraw === null || tempIC.statusupdateraw === undefined){ + tempIC.statusupdateraw = {}; + tempIC.statusupdateraw["status"] = action.data; + } else { + tempIC.statusupdateraw["status"] = action.data; + } AppDispatcher.dispatch({ type: 'ics/start-edit', data: tempIC, @@ -130,6 +135,27 @@ class InfrastructureComponentStore extends ArrayStore { console.log("status error:", action.error); return super.reduce(state, action); + case 'ics/nodestats-received': + let tempIC2 = action.ic; + if(!tempIC2.managedexternally){ + if (tempIC2.statusupdateraw === null || tempIC2.statusupdateraw === undefined){ + tempIC2.statusupdateraw = {}; + tempIC2.statusupdateraw["statistics"] = action.data; + } else { + tempIC2.statusupdateraw["statistics"] = action.data; + } + AppDispatcher.dispatch({ + type: 'ics/start-edit', + data: tempIC2, + token: action.token, + }); + } + return super.reduce(state, action); + + case 'ics/nodestats-error': + console.log("nodestats error:", action.error); + return super.reduce(state, action); + case 'ics/restart': ICsDataManager.restart(action.url, action.token); return super.reduce(state, action); diff --git a/src/ic/ics-data-manager.js b/src/ic/ics-data-manager.js index a2382fc..74b4080 100644 --- a/src/ic/ics-data-manager.js +++ b/src/ic/ics-data-manager.js @@ -97,17 +97,12 @@ class IcsDataManager extends RestDataManager { error }); }); - - } - - - } } getStatus(url,token,ic){ - RestAPI.get(url, null).then(response => { + RestAPI.get(url + "/status", null).then(response => { AppDispatcher.dispatch({ type: 'ics/status-received', data: response, @@ -120,6 +115,25 @@ class IcsDataManager extends RestDataManager { error: error }) }) + + // get name of websocket + /*let ws_api = ic.websocketurl.split("/") + let ws_name = ws_api[ws_api.length-1] // websocket name is the last element in the websocket url + + RestAPI.get(url + "/node/" + ws_name + "/stats", null).then(response => { + AppDispatcher.dispatch({ + type: 'ics/nodestats-received', + data: response, + token: token, + ic: ic + }); + }).catch(error => { + AppDispatcher.dispatch({ + type: 'ics/nodestats-error', + error: error + }) + })*/ + } restart(url,token){ diff --git a/src/ic/ics.js b/src/ic/ics.js index bb97ef1..6152c17 100644 --- a/src/ic/ics.js +++ b/src/ic/ics.js @@ -137,7 +137,7 @@ class InfrastructureComponents extends Component { && ic.apiurl !== '' && ic.apiurl !== undefined && ic.apiurl !== null && !ic.managedexternally) { AppDispatcher.dispatch({ type: 'ics/get-status', - url: ic.apiurl + "/status", + url: ic.apiurl, token: this.state.sessionToken, ic: ic });