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'); visuals = require('resin-cli-visuals');
events = require('resin-cli-events'); events = require('resin-cli-events');
return resin.models.device.get(params.uuid).then(function(device) { return resin.models.device.get(params.uuid).then(function(device) {
if (device.last_seen == null) { return resin.models.device.getStatus(device).then(function(status) {
device.last_seen = 'Not seen'; 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']));
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', {
return events.send('device.open', { device: device.uuid
device: device.uuid });
}); });
}).nodeify(done); }).nodeify(done);
} }

View File

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

View File

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