Feat: warn admin before restarting services

This commit is contained in:
Cesar 2020-12-15 14:58:11 +00:00 committed by Josh Harvey
parent a432d913be
commit 6994303069
6 changed files with 126 additions and 8 deletions

View file

@ -9,7 +9,7 @@ const dbm = require('./postgresql_interface')
const configManager = require('./new-config-manager')
const settingsLoader = require('./new-settings-loader')
module.exports = {getMachineName, getMachines, getMachineNames, setMachine}
module.exports = {getMachineName, getMachines, getMachine, getMachineNames, setMachine}
function getMachines () {
return db.any('select * from devices where display=TRUE order by created')
@ -88,6 +88,11 @@ function getMachineName (machineId) {
.then(it => it.name)
}
function getMachine (machineId) {
const sql = 'select * from devices where device_id=$1'
return db.oneOrNone(sql, [machineId]).then(res => _.mapKeys(_.camelCase)(res))
}
function renameMachine (rec) {
const sql = 'update devices set name=$1 where device_id=$2'
return db.none(sql, [rec.newName, rec.deviceId])