mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-12 15:16:37 +00:00
move dashboard api into dashboard module
This commit is contained in:
parent
119ef6f8e5
commit
46fd27842a
@ -28,6 +28,36 @@ class Dashboard {
|
|||||||
let console, monitor;
|
let console, monitor;
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
|
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));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function startConsole(callback) {
|
function startConsole(callback) {
|
||||||
console = new Console({
|
console = new Console({
|
||||||
|
@ -38,30 +38,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));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get('/embark', function (req, res) {
|
app.get('/embark', function (req, res) {
|
||||||
res.send('Welcome to Embark')
|
res.send('Welcome to Embark')
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
pragma solidity ^0.4.17;
|
pragma solidity ^0.4.17;
|
||||||
contract AnotherStorage {
|
contract AnotherStorage {
|
||||||
|
|
||||||
address public simpleStorageAddress;
|
address public simpleStorageAddress;
|
||||||
address simpleStorageAddress2;
|
address simpleStorageAddress2;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user