mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-20 22:23:07 +00:00
32 lines
1.1 KiB
CoffeeScript
32 lines
1.1 KiB
CoffeeScript
deviceModel = require('../models/device')
|
|
getDeviceDisplayName = require('../device/device').getDisplayName
|
|
log = require('../log/log')
|
|
table = require('../table/table')
|
|
widgets = require('../widgets/widgets')
|
|
patterns = require('../patterns/patterns')
|
|
authHooks = require('../hooks/auth')
|
|
|
|
exports.list = authHooks.failIfNotLoggedIn (applicationId) ->
|
|
deviceModel.getAll(applicationId).then (devices) ->
|
|
|
|
log.out 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
|
|
, [ 'ID', 'Name', 'Device Type', 'Is Online', 'IP Address', 'Application', 'Status', 'Last Seen' ]
|
|
|
|
.catch (error) ->
|
|
throw error
|
|
|
|
exports.remove = authHooks.failIfNotLoggedIn (id, program) ->
|
|
patterns.remove 'device', program.parent.yes, (callback) ->
|
|
deviceModel.remove(id).then ->
|
|
return callback()
|
|
.catch(callback)
|
|
, (error) ->
|
|
throw error if error?
|