mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
use new API of VILLASnode to detect running simulators
This commit is contained in:
parent
2bb1611842
commit
fbe3576892
1 changed files with 14 additions and 8 deletions
|
@ -26,20 +26,26 @@ import AppDispatcher from '../app-dispatcher';
|
|||
function isRunning(simulator) {
|
||||
// get path to nodes.json and simulator name
|
||||
var path = simulator.endpoint.substring(0, simulator.endpoint.lastIndexOf('/'));
|
||||
path += '/nodes.json';
|
||||
|
||||
var name = simulator.endpoint.substring(simulator.endpoint.lastIndexOf('/') + 1);
|
||||
|
||||
var url = 'http://' + path + '/api/v1';
|
||||
var body = {
|
||||
action: 'nodes',
|
||||
id: '1234' /// @todo use random generated id
|
||||
};
|
||||
|
||||
// send request
|
||||
RestAPI.get('http://' + path).then(response => {
|
||||
RestAPI.post(url, body).then(response => {
|
||||
// check if simulator is running
|
||||
simulator.running = false;
|
||||
|
||||
response.forEach(sim => {
|
||||
if (sim.name === name) {
|
||||
simulator.running = true;
|
||||
}
|
||||
});
|
||||
if (response.id == body.id) {
|
||||
response.response.forEach(sim => {
|
||||
if (sim.name === name) {
|
||||
simulator.running = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'simulators/running',
|
||||
|
|
Loading…
Add table
Reference in a new issue