mirror of https://github.com/embarklabs/embark.git
move dashboard api into dashboard module
This commit is contained in:
parent
8b261cbc04
commit
26d7e42218
|
@ -27,6 +27,35 @@ class Dashboard {
|
||||||
|
|
||||||
monitor = new Monitor({env: this.env, events: this.events});
|
monitor = new Monitor({env: this.env, events: this.events});
|
||||||
this.logger.logFunction = monitor.logEntry;
|
this.logger.logFunction = monitor.logEntry;
|
||||||
|
let plugin = this.plugins.createPlugin('dashboard', {});
|
||||||
|
plugin.registerAPICall(
|
||||||
|
'ws',
|
||||||
|
'/embark/dashboard',
|
||||||
|
(ws, req) => {
|
||||||
|
let dashboardState = { contractsState: [], environment: "", status: "", availableServices: [] };
|
||||||
|
|
||||||
|
// TODO: doesn't feel quite right, should be refactored into a shared
|
||||||
|
// dashboard state
|
||||||
|
self.events.request('setDashboardState');
|
||||||
|
|
||||||
|
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(JSON.stringify(dashboardState));
|
||||||
|
});
|
||||||
|
self.events.on('status', (status) => {
|
||||||
|
dashboardState.status = status;
|
||||||
|
ws.send(JSON.stringify(dashboardState));
|
||||||
|
});
|
||||||
|
self.events.on('servicesState', (servicesState) => {
|
||||||
|
dashboardState.availableServices = servicesState;
|
||||||
|
ws.send(JSON.stringify(dashboardState));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
this.events.on('contractsState', monitor.setContracts);
|
this.events.on('contractsState', monitor.setContracts);
|
||||||
this.events.on('status', monitor.setStatus.bind(monitor));
|
this.events.on('status', monitor.setStatus.bind(monitor));
|
||||||
|
|
|
@ -73,30 +73,10 @@ class Server {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.ws('/embark/dashboard', function(ws, req) {
|
let apiCalls = self.plugins.getPluginsProperty("apiCalls", "apiCalls");
|
||||||
let dashboardState = { contractsState: [], environment: "", status: "", availableServices: [] };
|
for (let apiCall of apiCalls) {
|
||||||
|
app[apiCall.method].apply(app, [apiCall.endpoint, apiCall.cb]);
|
||||||
// TODO: doesn't feel quite right, should be refactored into a shared
|
}
|
||||||
// dashboard state
|
|
||||||
self.events.request('setDashboardState');
|
|
||||||
|
|
||||||
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(JSON.stringify(dashboardState));
|
|
||||||
});
|
|
||||||
self.events.on('status', (status) => {
|
|
||||||
dashboardState.status = status;
|
|
||||||
ws.send(JSON.stringify(dashboardState));
|
|
||||||
});
|
|
||||||
self.events.on('servicesState', (servicesState) => {
|
|
||||||
dashboardState.availableServices = servicesState;
|
|
||||||
ws.send(JSON.stringify(dashboardState));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
this.app.ws('/', function(ws, _req) {
|
this.app.ws('/', function(ws, _req) {
|
||||||
self.events.on('outputDone', () => {
|
self.events.on('outputDone', () => {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
pragma solidity ^0.4.24;
|
pragma solidity ^0.4.24;
|
||||||
contract AnotherStorage {
|
contract AnotherStorage {
|
||||||
|
|
||||||
address public simpleStorageAddress;
|
address public simpleStorageAddress;
|
||||||
address simpleStorageAddress2;
|
address simpleStorageAddress2;
|
||||||
address ens;
|
address ens;
|
||||||
|
|
Loading…
Reference in New Issue