diff --git a/src/ic/ic-store.js b/src/ic/ic-store.js index bc9aa18..f3532e0 100644 --- a/src/ic/ic-store.js +++ b/src/ic/ic-store.js @@ -112,9 +112,18 @@ class InfrastructureComponentStore extends ArrayStore { ICsDataManager.getStatus(action.url, action.token, action.ic); return super.reduce(state, action); + case 'ics/get-config': + ICsDataManager.getConfig(action.url, action.token, action.ic); + return super.reduce(state, action); + + case 'ics/get-statistics': + ICsDataManager.getStatistics(action.url, action.token, action.ic); + return super.reduce(state, action); + + case 'ics/status-received': let tempIC = action.ic; - if(!tempIC.managedexternally){ + if (!tempIC.managedexternally) { tempIC.state = action.data.state; tempIC.uptime = action.data.time_now - action.data.time_started; tempIC.statusupdateraw = action.data @@ -130,9 +139,17 @@ class InfrastructureComponentStore extends ArrayStore { console.log("status error:", action.error); return super.reduce(state, action); + case 'ics/config-error': + console.log("config error:", action.error); + return super.reduce(state, action); + + case 'ics/statistics-error': + console.log("statistics error:", action.error); + return super.reduce(state, action); + case 'ics/nodestats-received': let tempIC2 = action.ic; - if(!tempIC2.managedexternally){ + if (!tempIC2.managedexternally) { if (tempIC2.statusupdateraw === null || tempIC2.statusupdateraw === undefined) { tempIC2.statusupdateraw = {}; } diff --git a/src/ic/ics-data-manager.js b/src/ic/ics-data-manager.js index 74b4080..43dc045 100644 --- a/src/ic/ics-data-manager.js +++ b/src/ic/ics-data-manager.js @@ -117,7 +117,8 @@ class IcsDataManager extends RestDataManager { }) // get name of websocket - /*let ws_api = ic.websocketurl.split("/") + /* + 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 => { @@ -136,6 +137,38 @@ class IcsDataManager extends RestDataManager { } + getConfig(url,token,ic){ + RestAPI.get(url + "node/" + ic.uuid, null).then(response => { + AppDispatcher.dispatch({ + type: 'ics/config-received', + data: response, + token: token, + ic: ic + }); + }).catch(error => { + AppDispatcher.dispatch({ + type: 'ics/config-error', + error: error + }) + }) + } + + getStatistics(url,token,ic){ + RestAPI.get(url + "/node/" +ic.uuid + "/stats", null).then(response => { + AppDispatcher.dispatch({ + type: 'ics/statistics-received', + data: response, + token: token, + ic: ic + }); + }).catch(error => { + AppDispatcher.dispatch({ + type: 'ics/statistics-error', + error: error + }) + }) + } + restart(url,token){ RestAPI.post(url, null).then(response => { AppDispatcher.dispatch({