From 35bba04b16dd1ad337f11db1d48a2090dcd70cf5 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Tue, 26 Jan 2016 12:16:55 -0400 Subject: [PATCH] Show parsed device status in device command --- build/actions/device.js | 12 ++++++------ lib/actions/device.coffee | 39 +++++++++++++++++++-------------------- package.json | 2 +- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/build/actions/device.js b/build/actions/device.js index 0f55e20e..f3b7542f 100644 --- a/build/actions/device.js +++ b/build/actions/device.js @@ -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); } diff --git a/lib/actions/device.coffee b/lib/actions/device.coffee index 387b5abb..e67dba56 100644 --- a/lib/actions/device.coffee +++ b/lib/actions/device.coffee @@ -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 = diff --git a/package.json b/package.json index d17307d0..05471b52 100644 --- a/package.json +++ b/package.json @@ -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",