add dashboard endpoint
This commit is contained in:
parent
8bf344e4a0
commit
be68625c01
|
@ -71,10 +71,26 @@ class Server {
|
|||
self.events.on("log", function(logLevel, logMsg) {
|
||||
ws.send(JSON.stringify({msg: logMsg, msg_clear: logMsg.stripColors, logLevel: logLevel}), () => {});
|
||||
});
|
||||
ws.on('message', function(msg) {
|
||||
console.dir("got message");
|
||||
console.dir(msg);
|
||||
ws.send(msg, () => {});
|
||||
});
|
||||
|
||||
app.ws('/dashboard', function(ws, req) {
|
||||
let dashboardState = { contractsState: [], environment: "", status: "", availableServices: [] };
|
||||
|
||||
self.events.on('contractsState', (contracts) => {
|
||||
dashboardState.contractsState = [];
|
||||
|
||||
contracts.forEach(function (row) {
|
||||
dashboardState.contractsState.push({contractName: row[0], address: row[1], status: row[2]});
|
||||
});
|
||||
ws.send(dashboardState);
|
||||
});
|
||||
self.events.on('status', (status) => {
|
||||
dashboardState.status = status;
|
||||
ws.send(dashboardState);
|
||||
});
|
||||
self.events.on('servicesState', (servicesState) => {
|
||||
dashboardState.availableServices = servicesState;
|
||||
ws.send(dashboardState);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue