1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

query statistics endpoint of VILLASnode in addition to status endpoint

- commented parts to be uncommented as soon as fix in VILLASnode is deployable
This commit is contained in:
Sonja Happ 2021-02-26 15:55:30 +01:00
parent 7ae9679b5f
commit 460cd2c4af
3 changed files with 48 additions and 8 deletions

View file

@ -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);

View file

@ -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){

View file

@ -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
});