fix: send a single state for the machine status
This commit is contained in:
parent
db014a3ed4
commit
79298d5dec
1 changed files with 9 additions and 15 deletions
|
|
@ -45,31 +45,25 @@ function getMachineNames (config) {
|
|||
[machines, notifier.checkPings(machines), dbm.machineEvents(), config]
|
||||
))
|
||||
.then(([machines, pings, events, config]) => {
|
||||
const getPingStatus = (ping) => {
|
||||
if (!ping) return fullyFunctionalStatus
|
||||
const getStatus = (ping, stuck) => {
|
||||
if (stuck && stuck.age) return stuckStatus
|
||||
|
||||
if (ping.age) return unresponsiveStatus
|
||||
if (ping && ping.age) return unresponsiveStatus
|
||||
|
||||
return fullyFunctionalStatus
|
||||
}
|
||||
|
||||
const getStuckStatus = (stuck) => {
|
||||
if (!stuck || !stuck.age) return undefined
|
||||
|
||||
return stuckStatus
|
||||
}
|
||||
|
||||
const addName = r => {
|
||||
const cashOutConfig = configManager.getCashOut(r.deviceId, config)
|
||||
|
||||
const cashOut = !!cashOutConfig.active
|
||||
|
||||
const ping = getPingStatus(_.first(pings[r.deviceId]))
|
||||
const stuck = getStuckStatus(_.first(notifier.checkStuckScreen(events, r.name)))
|
||||
|
||||
const statuses = [ping]
|
||||
|
||||
if (stuck) statuses.push(stuck)
|
||||
const statuses = [
|
||||
getStatus(
|
||||
_.first(pings[r.deviceId]),
|
||||
_.first(notifier.checkStuckScreen(events, r.name))
|
||||
)
|
||||
]
|
||||
|
||||
return _.assign(r, {cashOut, statuses})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue