embark-area-51/cmd/dashboard/dashboard.js

46 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-03-29 17:50:05 +00:00
let async = require('async');
let windowSize = require('window-size');
2017-03-29 17:50:05 +00:00
let Monitor = require('./monitor.js');
2017-03-30 11:12:39 +00:00
class Dashboard {
constructor(options) {
this.logger = options.logger;
2017-12-17 23:34:41 +00:00
this.events = options.events;
2017-03-30 11:12:39 +00:00
this.plugins = options.plugins;
this.version = options.version;
this.env = options.env;
this.events.on('firstDeploymentDone', this.checkWindowSize.bind(this));
this.events.on('outputDone', this.checkWindowSize.bind(this));
}
checkWindowSize() {
let size = windowSize.get();
if (size.height < 40 || size.width < 118) {
this.logger.warn(__("tip: you can resize the terminal or disable the dashboard with") + " embark run --nodashboard".bold.underline);
}
2017-03-30 11:12:39 +00:00
}
start(done) {
2018-08-31 08:24:45 +00:00
let monitor;
2017-03-30 11:12:39 +00:00
2018-08-31 08:24:45 +00:00
monitor = new Monitor({env: this.env, events: this.events});
this.logger.logFunction = monitor.logEntry;
2017-03-30 11:12:39 +00:00
2018-08-31 08:24:45 +00:00
this.events.on('contractsState', monitor.setContracts);
this.events.on('status', monitor.setStatus.bind(monitor));
this.events.on('servicesState', monitor.availableServices.bind(monitor));
2018-07-23 12:30:58 +00:00
2018-08-31 08:24:45 +00:00
this.events.setCommandHandler("console:command", monitor.executeCmd.bind(monitor));
2018-02-27 22:50:43 +00:00
2018-08-31 08:24:45 +00:00
this.logger.info('========================'.bold.green);
this.logger.info((__('Welcome to Embark') + ' ' + this.version).yellow.bold);
this.logger.info('========================'.bold.green);
2017-03-30 11:12:39 +00:00
2018-08-31 08:24:45 +00:00
done();
2017-03-30 11:12:39 +00:00
}
}
module.exports = Dashboard;