2024-02-13 23:54:45 +00:00
|
|
|
const m = require('mithril')
|
|
|
|
const client = require('./api/client')
|
|
|
|
|
|
|
|
const Status = {
|
|
|
|
oninit: function(vnode) {
|
|
|
|
client.registerComponent(this)
|
|
|
|
},
|
|
|
|
|
|
|
|
onremove: function(vnode) {
|
|
|
|
client.unregisterComponent(this)
|
|
|
|
},
|
|
|
|
|
2024-02-20 04:57:49 +00:00
|
|
|
startClicked() {
|
|
|
|
client.emit('encoder.start')
|
2024-02-13 23:54:45 +00:00
|
|
|
},
|
|
|
|
|
2024-02-20 04:57:49 +00:00
|
|
|
stopClicked() {
|
|
|
|
client.emit('encoder.stop')
|
2024-02-13 23:54:45 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
view: function(vnode) {
|
2024-02-20 04:57:49 +00:00
|
|
|
let display = client.status.serial_display || { first: '', second: ''}
|
2024-02-13 23:54:45 +00:00
|
|
|
return [
|
2024-02-20 04:57:49 +00:00
|
|
|
m('pre.status', client.isConnected
|
|
|
|
? display.first.padEnd(20) + '\n' + display.second
|
|
|
|
: ' \n '
|
|
|
|
),
|
|
|
|
m('.status.row', [
|
|
|
|
m('button.button', {
|
|
|
|
hidden: client.status.encoder_running || client.status.encoder_starting,
|
|
|
|
onclick: this.startClicked.bind(this),
|
|
|
|
}, 'Start'),
|
|
|
|
m('button.button', {
|
|
|
|
hidden: !client.status.encoder_running && !client.status.encoder_starting,
|
|
|
|
onclick: this.stopClicked.bind(this),
|
|
|
|
}, 'Stop'),
|
|
|
|
]),
|
2024-02-13 23:54:45 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Status
|