2020-09-08 07:53:42 +00:00
|
|
|
const m = require('mithril')
|
|
|
|
const socket = require('../socket')
|
|
|
|
const Module = require('../module')
|
2022-03-29 10:25:25 +00:00
|
|
|
const util = require('../util')
|
2020-09-08 07:53:42 +00:00
|
|
|
|
|
|
|
const Status = Module({
|
|
|
|
init: function() {
|
|
|
|
},
|
|
|
|
|
|
|
|
remove: function() {
|
|
|
|
},
|
|
|
|
|
|
|
|
restartClicked: function() {
|
|
|
|
socket.emit('core.restart', {})
|
|
|
|
},
|
|
|
|
|
2022-03-29 10:25:25 +00:00
|
|
|
startSoftware: function(name) {
|
|
|
|
socket.emit('core.start', {
|
2020-09-09 15:42:55 +00:00
|
|
|
name: name,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2020-09-08 07:53:42 +00:00
|
|
|
view: function() {
|
2022-03-29 10:25:25 +00:00
|
|
|
let name = this.core.name
|
|
|
|
if (this.core.title) {
|
|
|
|
name += ' - ' + this.core.title
|
|
|
|
}
|
2020-09-08 07:53:42 +00:00
|
|
|
return m('div#status', [
|
2022-03-29 10:25:25 +00:00
|
|
|
m('h1.header', name),
|
2020-09-08 07:53:42 +00:00
|
|
|
m('div.split', [
|
2022-03-29 10:25:25 +00:00
|
|
|
this.core.apps.map((app) => {
|
|
|
|
let box = []
|
|
|
|
let appStatus = this.core.status[app.name] || {}
|
|
|
|
|
|
|
|
box.push(m('h4', [
|
|
|
|
app.name + ' (',
|
|
|
|
m('span', { class: appStatus.running ? 'running' : 'notrunning' }, appStatus.running ? 'Running ' + appStatus.running : 'Not running'),
|
|
|
|
')'
|
|
|
|
]))
|
|
|
|
box.push(m('p', app.config.port
|
|
|
|
? `Port: ${app.config.port}`
|
|
|
|
: ''))
|
|
|
|
box.push(m('p', util.getRepoMessage(app)))
|
|
|
|
|
|
|
|
box.push(m('p', 'Running version: ' + util.getVersionSummary(appStatus.active, appStatus)))
|
|
|
|
box.push(m('p', 'Latest installed: ' + util.getVersionSummary(appStatus.latestInstalled)))
|
|
|
|
|
|
|
|
if (!this.core.status[app.name].running) {
|
|
|
|
box.push(m('button', {
|
|
|
|
onclick: () => this.startSoftware(app.name),
|
|
|
|
}, 'Start'))
|
|
|
|
} else if (app.config.scAllowStop) {
|
|
|
|
box.push(m('button.fatal', {
|
|
|
|
onclick: () => this.startSoftware(app.name),
|
|
|
|
}, 'Restart'))
|
|
|
|
}
|
|
|
|
|
|
|
|
return m('div.item', box)
|
2020-09-08 07:53:42 +00:00
|
|
|
}),
|
|
|
|
]),
|
2022-03-29 10:25:25 +00:00
|
|
|
m('button.fatal', {
|
|
|
|
hidden: !this.core.allowRestart,
|
2020-09-08 07:53:42 +00:00
|
|
|
onclick: () => this.restartClicked(),
|
2022-03-29 10:25:25 +00:00
|
|
|
}, 'Restart ' + this.core.name)
|
2020-09-08 07:53:42 +00:00
|
|
|
])
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
module.exports = Status
|