Implement device info command

This commit is contained in:
Juan Cruz Viotti 2014-12-05 11:32:14 -04:00
parent 199635b311
commit 4d0ecbdc4c
2 changed files with 40 additions and 0 deletions

View File

@ -14,6 +14,30 @@ exports.list = (applicationId) ->
return device return device
, [ 'ID', 'Name', 'Device Type', 'Is Online', 'IP Address', 'Application', 'Status', 'Last Seen' ] , [ 'ID', 'Name', 'Device Type', 'Is Online', 'IP Address', 'Application', 'Status', 'Last Seen' ]
exports.info = (deviceId) ->
resin.models.device.get deviceId, (error, device) ->
resin.errors.handle(error) if error?
resin.log.out resin.ui.widgets.table.vertical device, (device) ->
device.device_type = resin.device.getDisplayName(device.device_type)
device.application = device.application[0].app_name
return device
, [
'ID'
'Name'
'Device Type'
'Is Online'
'IP Address'
'Application'
'Status'
'Last Seen'
'UUID'
'Commit'
'Supervisor Version'
'Is Web Accessible'
'Note'
]
exports.remove = (id) -> exports.remove = (id) ->
confirmArgument = resin.cli.getArgument('yes') confirmArgument = resin.cli.getArgument('yes')
resin.ui.patterns.remove 'device', confirmArgument, (callback) -> resin.ui.patterns.remove 'device', confirmArgument, (callback) ->

View File

@ -36,6 +36,22 @@ exports.getAllByApplication = (applicationId, callback) ->
.catch (error) -> .catch (error) ->
return callback(error) return callback(error)
exports.get = (deviceId, callback) ->
return canvas.get
resource: 'device'
id: deviceId
options:
expand: 'application'
.then (device) ->
if not device?
return callback(new errors.NotFound("device #{id}"))
return callback(null, device)
.catch (error) ->
return callback(error)
exports.remove = (id, callback) -> exports.remove = (id, callback) ->
return canvas.delete return canvas.delete
resource: 'device' resource: 'device'