mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-05-04 18:12:56 +00:00
Improve backwards-compatible response of GET /v1/device
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
parent
3fd52bb0c7
commit
e43c9052dd
@ -148,16 +148,23 @@ class DeviceStateRouter
|
|||||||
.then (state) ->
|
.then (state) ->
|
||||||
stateToSend = _.pick(state.local, [
|
stateToSend = _.pick(state.local, [
|
||||||
'api_port'
|
'api_port'
|
||||||
'commit'
|
|
||||||
'ip_address'
|
'ip_address'
|
||||||
'status'
|
|
||||||
'download_progress'
|
|
||||||
'os_version'
|
'os_version'
|
||||||
'supervisor_version'
|
'supervisor_version'
|
||||||
'update_pending'
|
'update_pending'
|
||||||
'update_failed'
|
'update_failed'
|
||||||
'update_downloaded'
|
'update_downloaded'
|
||||||
])
|
])
|
||||||
|
if state.local.is_on__commit?
|
||||||
|
stateToSend.commit = state.local.is_on__commit
|
||||||
|
# Will produce nonsensical results for multicontainer apps...
|
||||||
|
service = _.toPairs(_.toPairs(state.local.apps)[0]?[1]?.services)[0]?[1]
|
||||||
|
if service?
|
||||||
|
stateToSend.status = service.status
|
||||||
|
# For backwards compatibility, we adapt Running to the old "Idle"
|
||||||
|
if stateToSend.status == 'Running'
|
||||||
|
stateToSend.status = 'Idle'
|
||||||
|
stateToSend.download_progress = service.download_progress
|
||||||
res.json(stateToSend)
|
res.json(stateToSend)
|
||||||
.catch (err) ->
|
.catch (err) ->
|
||||||
res.status(500).json({ Data: '', Error: err?.message or err or 'Unknown error' })
|
res.status(500).json({ Data: '', Error: err?.message or err or 'Unknown error' })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user