balena-cli/lib/actions/device.coffee

26 lines
920 B
CoffeeScript
Raw Normal View History

2014-11-26 12:07:10 -04:00
resin = require('../resin')
2014-11-19 13:38:15 -04:00
2014-11-27 10:06:11 -04:00
exports.list = (applicationId) ->
2014-11-26 14:02:59 -04:00
resin.models.device.getAll applicationId, (error, devices) ->
resin.errors.handle(error) if error?
2014-11-19 13:38:15 -04:00
2014-11-26 13:26:01 -04:00
resin.log.out resin.ui.widgets.table.horizontal devices, (device) ->
2014-11-19 13:38:15 -04:00
device.application = device.application[0].app_name
2014-11-26 13:12:39 -04:00
device.device_type = resin.device.getDisplayName(device.device_type)
2014-11-19 13:38:15 -04:00
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' ]
2014-11-19 13:38:15 -04:00
exports.remove = (id) ->
confirmArgument = resin.cli.getArgument('yes')
resin.ui.patterns.remove 'device', confirmArgument, (callback) ->
2014-11-26 14:02:59 -04:00
resin.models.device.remove(id, callback)
2014-11-26 12:38:02 -04:00
, resin.errors.handle
2014-11-21 14:21:47 -04:00
2014-11-27 10:06:11 -04:00
exports.identify = (uuid) ->
2014-11-26 14:02:59 -04:00
resin.models.device.identify uuid, (error) ->
resin.errors.handle(error) if error?