feat: add _Booting up_ machine status
This commit is contained in:
parent
ff3c51623f
commit
9ad884be5d
1 changed files with 8 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ const logger = require('./logger')
|
||||||
const fullyFunctionalStatus = { label: 'Fully functional', type: 'success' }
|
const fullyFunctionalStatus = { label: 'Fully functional', type: 'success' }
|
||||||
const unresponsiveStatus = { label: 'Unresponsive', type: 'error' }
|
const unresponsiveStatus = { label: 'Unresponsive', type: 'error' }
|
||||||
const stuckStatus = { label: 'Stuck', type: 'error' }
|
const stuckStatus = { label: 'Stuck', type: 'error' }
|
||||||
|
const bootingUpStatus = { label: 'Booting up', type: 'warning' }
|
||||||
const OPERATOR_DATA_DIR = process.env.OPERATOR_DATA_DIR
|
const OPERATOR_DATA_DIR = process.env.OPERATOR_DATA_DIR
|
||||||
|
|
||||||
const MACHINE_WITH_CALCULATED_FIELD_SQL = `
|
const MACHINE_WITH_CALCULATED_FIELD_SQL = `
|
||||||
|
|
@ -104,6 +105,11 @@ function getConfig(defaultConfig) {
|
||||||
return defaultConfig ? Promise.resolve(defaultConfig) : loadLatestConfig()
|
return defaultConfig ? Promise.resolve(defaultConfig) : loadLatestConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isBootingState = state => ['booting', 'pendingIdle'].includes(state)
|
||||||
|
|
||||||
|
const isBooting = machineEvents =>
|
||||||
|
isBootingState(machineEvents[machineEvents.length - 1]?.note?.state)
|
||||||
|
|
||||||
const getMachineStatuses = (pings, events, machine) => {
|
const getMachineStatuses = (pings, events, machine) => {
|
||||||
const lastPing = pings[machine.deviceId][0]
|
const lastPing = pings[machine.deviceId][0]
|
||||||
if (lastPing?.age) return [unresponsiveStatus]
|
if (lastPing?.age) return [unresponsiveStatus]
|
||||||
|
|
@ -124,6 +130,8 @@ const getMachineStatuses = (pings, events, machine) => {
|
||||||
const stuckScreen = checkStuckScreen(machineEvents, machine)[0]
|
const stuckScreen = checkStuckScreen(machineEvents, machine)[0]
|
||||||
if (stuckScreen?.age) return [stuckStatus]
|
if (stuckScreen?.age) return [stuckStatus]
|
||||||
|
|
||||||
|
if (isBooting(machineEvents)) return [bootingUpStatus]
|
||||||
|
|
||||||
return [fullyFunctionalStatus]
|
return [fullyFunctionalStatus]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue