Added event to obtain list of contracts and show them on the dashboard

This commit is contained in:
Richard Ramos 2018-04-19 11:45:54 -04:00 committed by Pascal Precht
parent 502d2c0dec
commit 56afed906a
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
2 changed files with 26 additions and 2 deletions

View File

@ -26,6 +26,22 @@ class Deploy {
cb(self.contractsManager.getContract(contractName));
});
self.events.setCommandHandler("contracts:all", (contractName, cb) => {
let contracts = self.contractsManager.listContracts();
let results = {};
for (let className in contracts) {
let contract = contracts[className];
results[className] = {
name: contract.className,
deploy: contract.deploy,
error: contract.error,
address: contract.deployedAddress
};
}
cb(results);
});
let plugin = this.plugins.createPlugin('deployment', {});
plugin.registerAPICall(
'get',
@ -34,6 +50,14 @@ class Deploy {
self.events.request('contracts:contract', req.params.contractName, res.send.bind(res));
}
);
plugin.registerAPICall(
'get',
'/embark/contracts',
(req, res) => {
self.events.request('contracts:all', null, res.send.bind(res));
}
);
}
initTracker(cb) {

View File

@ -75,7 +75,7 @@
<div class="header">
<div class="container">
<div class="d-flex">
<a class="navbar-brand" href="./index.html">
<a class="navbar-brand" href="/embark/index.html">
<img src="../assets/images/logo.png" class="navbar-brand-img" alt="Embark">
</a>
<div class="ml-auto d-flex order-lg-2">
@ -150,7 +150,7 @@
<div class="col">
<ul class="nav nav-tabs">
<li class="nav-item">
<a href="./index.html" class="nav-link"><i class="fe fe-home"></i> Home</a>
<a href="/embark/index.html" class="nav-link"><i class="fe fe-home"></i> Home</a>
</li>
<li class="nav-item">
<a href="javascript:void(0)" class="nav-link active"><i class="fe fe-box"></i> Contracts</a>