mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-03-11 23:14:09 +00:00
Implement devices command
This commit is contained in:
parent
e0032c090f
commit
55fa8435bb
20
lib/actions/device.coffee
Normal file
20
lib/actions/device.coffee
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
_ = require('lodash')
|
||||||
|
deviceModel = require('../models/device')
|
||||||
|
getDeviceDisplayName = require('../device/device').getDisplayName
|
||||||
|
table = require('../table/table')
|
||||||
|
authHooks = require('../hooks/auth')
|
||||||
|
|
||||||
|
exports.list = authHooks.failIfNotLoggedIn (applicationId) ->
|
||||||
|
deviceModel.getAll(applicationId).then (devices) ->
|
||||||
|
|
||||||
|
console.log table.horizontal devices, (device) ->
|
||||||
|
device.application = device.application[0].app_name
|
||||||
|
device.device_type = getDeviceDisplayName(device.device_type)
|
||||||
|
delete device.note
|
||||||
|
delete device.supervisor_version
|
||||||
|
delete device.uuid
|
||||||
|
delete device.download_progress
|
||||||
|
return device
|
||||||
|
|
||||||
|
.catch (error) ->
|
||||||
|
throw error
|
@ -38,6 +38,15 @@ program
|
|||||||
.description('Show an application')
|
.description('Show an application')
|
||||||
.action(app.info)
|
.action(app.info)
|
||||||
|
|
||||||
|
# ---------- Device Module ----------
|
||||||
|
|
||||||
|
device = require('./actions/device')
|
||||||
|
|
||||||
|
program
|
||||||
|
.command('devices <id>')
|
||||||
|
.description('Show devices for an application')
|
||||||
|
.action(device.list)
|
||||||
|
|
||||||
# ---------- Preferences Module ----------
|
# ---------- Preferences Module ----------
|
||||||
|
|
||||||
preferences = require('./actions/preferences')
|
preferences = require('./actions/preferences')
|
||||||
|
10
lib/models/device.coffee
Normal file
10
lib/models/device.coffee
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
canvas = require('./_canvas')
|
||||||
|
|
||||||
|
exports.getAll = (applicationId) ->
|
||||||
|
return canvas.get
|
||||||
|
resource: 'device'
|
||||||
|
options:
|
||||||
|
filter:
|
||||||
|
application: applicationId
|
||||||
|
expand: 'application'
|
||||||
|
orderby: 'name asc'
|
Loading…
x
Reference in New Issue
Block a user