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]
|
[machines, notifier.checkPings(machines), dbm.machineEvents(), config]
|
||||||
))
|
))
|
||||||
.then(([machines, pings, events, config]) => {
|
.then(([machines, pings, events, config]) => {
|
||||||
const getPingStatus = (ping) => {
|
const getStatus = (ping, stuck) => {
|
||||||
if (!ping) return fullyFunctionalStatus
|
if (stuck && stuck.age) return stuckStatus
|
||||||
|
|
||||||
if (ping.age) return unresponsiveStatus
|
if (ping && ping.age) return unresponsiveStatus
|
||||||
|
|
||||||
return fullyFunctionalStatus
|
return fullyFunctionalStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
const getStuckStatus = (stuck) => {
|
|
||||||
if (!stuck || !stuck.age) return undefined
|
|
||||||
|
|
||||||
return stuckStatus
|
|
||||||
}
|
|
||||||
|
|
||||||
const addName = r => {
|
const addName = r => {
|
||||||
const cashOutConfig = configManager.getCashOut(r.deviceId, config)
|
const cashOutConfig = configManager.getCashOut(r.deviceId, config)
|
||||||
|
|
||||||
const cashOut = !!cashOutConfig.active
|
const cashOut = !!cashOutConfig.active
|
||||||
|
|
||||||
const ping = getPingStatus(_.first(pings[r.deviceId]))
|
|
||||||
const stuck = getStuckStatus(_.first(notifier.checkStuckScreen(events, r.name)))
|
|
||||||
|
|
||||||
const statuses = [ping]
|
const statuses = [
|
||||||
|
getStatus(
|
||||||
if (stuck) statuses.push(stuck)
|
_.first(pings[r.deviceId]),
|
||||||
|
_.first(notifier.checkStuckScreen(events, r.name))
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
return _.assign(r, {cashOut, statuses})
|
return _.assign(r, {cashOut, statuses})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue