fix: CSS clean up due to some orphan styling
This commit is contained in:
parent
53431a9fd9
commit
735c46ed55
4 changed files with 34 additions and 167 deletions
|
|
@ -10,6 +10,10 @@ const settingsLoader = require('./new-settings-loader')
|
|||
const notifierUtils = require('./notifier/utils')
|
||||
const notifierQueries = require('./notifier/queries')
|
||||
|
||||
const fullyFunctionalStatus = { label: 'Fully functional', type: 'success' }
|
||||
const unresponsiveStatus = { label: 'Unresponsive', type: 'error' }
|
||||
const stuckStatus = { label: 'Stuck', type: 'error' }
|
||||
|
||||
function getMachines () {
|
||||
return db.any('SELECT * FROM devices WHERE display=TRUE ORDER BY created')
|
||||
.then(rr => rr.map(r => ({
|
||||
|
|
@ -34,40 +38,38 @@ function getConfig (defaultConfig) {
|
|||
return settingsLoader.loadLatest().config
|
||||
}
|
||||
|
||||
function getMachineNames (config) {
|
||||
const fullyFunctionalStatus = { label: 'Fully functional', type: 'success' }
|
||||
const unresponsiveStatus = { label: 'Unresponsive', type: 'error' }
|
||||
const stuckStatus = { label: 'Stuck', type: 'error' }
|
||||
const getStatus = (ping, stuck) => {
|
||||
if (ping && ping.age) return unresponsiveStatus
|
||||
|
||||
if (stuck && stuck.age) return stuckStatus
|
||||
|
||||
return fullyFunctionalStatus
|
||||
}
|
||||
|
||||
function addName (pings, events, config) {
|
||||
return machine => {
|
||||
const cashOutConfig = configManager.getCashOut(machine.deviceId, config)
|
||||
|
||||
const cashOut = !!cashOutConfig.active
|
||||
|
||||
const statuses = [
|
||||
getStatus(
|
||||
_.first(pings[machine.deviceId]),
|
||||
_.first(checkStuckScreen(events, machine.name))
|
||||
)
|
||||
]
|
||||
|
||||
return _.assign(machine, { cashOut, statuses })
|
||||
}
|
||||
}
|
||||
|
||||
function getMachineNames (config) {
|
||||
return Promise.all([getMachines(), getConfig(config)])
|
||||
.then(([machines, config]) => Promise.all(
|
||||
[machines, checkPings(machines), dbm.machineEvents(), config]
|
||||
))
|
||||
.then(([machines, pings, events, config]) => {
|
||||
const getStatus = (ping, stuck) => {
|
||||
if (ping && ping.age) return unresponsiveStatus
|
||||
|
||||
if (stuck && stuck.age) return stuckStatus
|
||||
|
||||
return fullyFunctionalStatus
|
||||
}
|
||||
|
||||
const addName = r => {
|
||||
const cashOutConfig = configManager.getCashOut(r.deviceId, config)
|
||||
|
||||
const cashOut = !!cashOutConfig.active
|
||||
|
||||
const statuses = [
|
||||
getStatus(
|
||||
_.first(pings[r.deviceId]),
|
||||
_.first(checkStuckScreen(events, r.name))
|
||||
)
|
||||
]
|
||||
|
||||
return _.assign(r, { cashOut, statuses })
|
||||
}
|
||||
|
||||
return _.map(addName, machines)
|
||||
return machines.map(addName(pings, events, config))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -88,10 +90,6 @@ function getMachineName (machineId) {
|
|||
}
|
||||
|
||||
function getMachine (machineId, config) {
|
||||
const fullyFunctionalStatus = { label: 'Fully functional', type: 'success' }
|
||||
const unresponsiveStatus = { label: 'Unresponsive', type: 'error' }
|
||||
const stuckStatus = { label: 'Stuck', type: 'error' }
|
||||
|
||||
const sql = 'SELECT * FROM devices WHERE device_id=$1'
|
||||
const queryMachine = db.oneOrNone(sql, [machineId]).then(r => ({
|
||||
deviceId: r.device_id,
|
||||
|
|
@ -109,31 +107,8 @@ function getMachine (machineId, config) {
|
|||
return Promise.all([queryMachine, dbm.machineEvents(), config])
|
||||
.then(([machine, events, config]) => {
|
||||
const pings = checkPings([machine])
|
||||
|
||||
const getStatus = (ping, stuck) => {
|
||||
if (ping && ping.age) return unresponsiveStatus
|
||||
|
||||
if (stuck && stuck.age) return stuckStatus
|
||||
|
||||
return fullyFunctionalStatus
|
||||
}
|
||||
|
||||
const addName = r => {
|
||||
const cashOutConfig = configManager.getCashOut(r.deviceId, config)
|
||||
|
||||
const cashOut = !!cashOutConfig.active
|
||||
|
||||
const statuses = [
|
||||
getStatus(
|
||||
_.first(pings[r.deviceId]),
|
||||
_.first(checkStuckScreen(events, r.name))
|
||||
)
|
||||
]
|
||||
|
||||
return _.assign(r, { cashOut, statuses })
|
||||
}
|
||||
|
||||
return addName(machine)
|
||||
return [machine].map(addName(pings, events, config))[0]
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue