Show parsed device status in device command

This commit is contained in:
Juan Cruz Viotti 2016-01-26 12:16:55 -04:00
parent dd382158dd
commit 35bba04b16
3 changed files with 26 additions and 27 deletions

View File

@ -60,12 +60,12 @@ limitations under the License.
visuals = require('resin-cli-visuals');
events = require('resin-cli-events');
return resin.models.device.get(params.uuid).then(function(device) {
if (device.last_seen == null) {
device.last_seen = 'Not seen';
}
console.log(visuals.table.vertical(device, ["$" + device.name + "$", 'id', 'device_type', 'is_online', 'ip_address', 'application_name', 'status', 'last_seen', 'uuid', 'commit', 'supervisor_version', 'is_web_accessible', 'note']));
return events.send('device.open', {
device: device.uuid
return resin.models.device.getStatus(device).then(function(status) {
device.status = status;
console.log(visuals.table.vertical(device, ["$" + device.name + "$", 'id', 'device_type', 'status', 'is_online', 'ip_address', 'application_name', 'last_seen', 'uuid', 'commit', 'supervisor_version', 'is_web_accessible', 'note']));
return events.send('device.open', {
device: device.uuid
});
});
}).nodeify(done);
}

View File

@ -79,27 +79,26 @@ exports.info =
resin.models.device.get(params.uuid).then (device) ->
# TODO: We should outsource this logic and probably
# other last_seen edge cases to either Resin CLI Visuals
# or have it parsed appropriately in the SDK.
device.last_seen ?= 'Not seen'
resin.models.device.getStatus(device).then (status) ->
device.status = status
console.log visuals.table.vertical device, [
"$#{device.name}$"
'id'
'device_type'
'is_online'
'ip_address'
'application_name'
'status'
'last_seen'
'uuid'
'commit'
'supervisor_version'
'is_web_accessible'
'note'
]
events.send('device.open', device: device.uuid)
console.log visuals.table.vertical device, [
"$#{device.name}$"
'id'
'device_type'
'status'
'is_online'
'ip_address'
'application_name'
'last_seen'
'uuid'
'commit'
'supervisor_version'
'is_web_accessible'
'note'
]
events.send('device.open', device: device.uuid)
.nodeify(done)
exports.register =

View File

@ -51,7 +51,7 @@
"resin-device-init": "^2.0.0",
"resin-image-manager": "^3.2.6",
"resin-pine": "^1.3.0",
"resin-sdk": "^5.0.1",
"resin-sdk": "^5.1.0",
"resin-settings-client": "^3.1.0",
"resin-vcs": "^2.0.0",
"rimraf": "^2.4.3",