2016-04-10 08:37:05 +00:00
|
|
|
const m = require('mithril')
|
2018-06-26 18:35:12 +00:00
|
|
|
const createModule = require('./common/module')
|
|
|
|
const socket = require('../socket')
|
2016-04-10 08:37:05 +00:00
|
|
|
|
2016-04-14 04:01:51 +00:00
|
|
|
const Menu = createModule({
|
|
|
|
init: function() {
|
|
|
|
this.monitor('list', 'graphic.all', [])
|
2018-06-26 18:35:12 +00:00
|
|
|
this.monitor('settings', 'settings.all', {})
|
|
|
|
this.monitor('schedule', 'schedule.total', { total: 0 })
|
|
|
|
this.monitor('status', 'casparcg.status', {
|
|
|
|
connected: false,
|
|
|
|
playing: false,
|
|
|
|
})
|
|
|
|
this.newHost = ''
|
|
|
|
this.enableEdit = false
|
|
|
|
},
|
|
|
|
|
|
|
|
setHost(value) {
|
|
|
|
this.newHost = value
|
|
|
|
this.enableEdit = true
|
|
|
|
},
|
|
|
|
|
|
|
|
saveNewHost() {
|
|
|
|
socket.emit('settings.update', {
|
|
|
|
name: 'casparcg',
|
|
|
|
value: this.newHost,
|
|
|
|
})
|
|
|
|
|
|
|
|
this.newHost = ''
|
|
|
|
this.enableEdit = false
|
|
|
|
},
|
|
|
|
}, function() {
|
|
|
|
return [
|
|
|
|
m('a', {
|
|
|
|
href: '/',
|
|
|
|
oncreate: m.route.link,
|
|
|
|
class: m.route.get() === '/' && 'active' || '',
|
|
|
|
}, `Schedule (${this.schedule.total})` ),
|
|
|
|
m('h4.header.header--space', 'Graphics'),
|
|
|
|
this.list.map((item) =>
|
|
|
|
m('a', {
|
|
|
|
href: `/graphic/${item.id}`,
|
|
|
|
oncreate: m.route.link,
|
|
|
|
class: m.route.get() === `/graphic/${item.id}` && 'active' || '',
|
|
|
|
}, item.name)
|
|
|
|
),
|
|
|
|
m('h5.header.header--space', 'Other'),
|
|
|
|
m('a', {
|
|
|
|
href: '/add',
|
|
|
|
oncreate: m.route.link,
|
|
|
|
class: m.route.get() === '/add' && 'active' || '',
|
|
|
|
}, 'Add graphic' ),
|
|
|
|
m('h5.header.header--space', 'CasparCG Status'),
|
|
|
|
m('input[type=text]', {
|
|
|
|
placeholder: 'Host IP',
|
|
|
|
value: this.newHost || this.settings.casparcg || '',
|
|
|
|
oninput: control => this.setHost(control.target.value),
|
|
|
|
}),
|
|
|
|
this.enableEdit && m('button', {
|
|
|
|
onclick: () => this.saveNewHost(),
|
|
|
|
}, 'Connect'),
|
|
|
|
m('div.status', {
|
|
|
|
class: this.status.connected && 'green',
|
|
|
|
}, 'connected'),
|
|
|
|
m('div.status', {
|
|
|
|
class: this.status.playing && 'green',
|
|
|
|
}, 'playing'),
|
|
|
|
]
|
2016-04-14 04:01:51 +00:00
|
|
|
})
|
2016-04-10 08:37:05 +00:00
|
|
|
module.exports = Menu
|