church_streamer/app/page_status.js

43 lines
1,019 B
JavaScript
Raw Normal View History

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)
},
startClicked() {
client.emit('encoder.start')
2024-02-13 23:54:45 +00:00
},
stopClicked() {
client.emit('encoder.stop')
2024-02-13 23:54:45 +00:00
},
view: function(vnode) {
let display = client.status.serial_display || { first: '', second: ''}
2024-02-13 23:54:45 +00:00
return [
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