resin = require('../resin') ui = require('../ui') permissions = require('../permissions/permissions') exports.list = permissions.user (params) -> resin.models.device.getAllByApplication params.id, (error, devices) -> resin.errors.handle(error) if error? resin.log.out ui.widgets.table.horizontal devices, (device) -> device.application = device.application[0].app_name device.device_type = resin.device.getDisplayName(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' ] exports.info = permissions.user (params) -> resin.models.device.get params.id, (error, device) -> resin.errors.handle(error) if error? resin.log.out 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 = permissions.user (params, options) -> ui.patterns.remove 'device', options.yes, (callback) -> resin.models.device.remove(params.id, callback) , resin.errors.handle exports.identify = permissions.user (params) -> resin.models.device.identify params.uuid, (error) -> resin.errors.handle(error) if error?