Show shorter uuids when listing devices

This commit is contained in:
Juan Cruz Viotti 2016-01-21 10:26:13 -04:00
parent fb1ef0df63
commit ebefd816b6
2 changed files with 11 additions and 1 deletions

View File

@ -28,8 +28,9 @@ limitations under the License.
permission: 'user', permission: 'user',
primary: true, primary: true,
action: function(params, options, done) { action: function(params, options, done) {
var Promise, resin, visuals; var Promise, _, resin, visuals;
Promise = require('bluebird'); Promise = require('bluebird');
_ = require('lodash');
resin = require('resin-sdk'); resin = require('resin-sdk');
visuals = require('resin-cli-visuals'); visuals = require('resin-cli-visuals');
return Promise["try"](function() { return Promise["try"](function() {
@ -38,6 +39,10 @@ limitations under the License.
} }
return resin.models.device.getAll(); return resin.models.device.getAll();
}).tap(function(devices) { }).tap(function(devices) {
devices = _.map(devices, function(device) {
device.uuid = device.uuid.slice(0, 7);
return device;
});
return console.log(visuals.table.horizontal(devices, ['id', 'uuid', 'name', 'device_type', 'application_name', 'status'])); return console.log(visuals.table.horizontal(devices, ['id', 'uuid', 'name', 'device_type', 'application_name', 'status']));
}).nodeify(done); }).nodeify(done);
} }

View File

@ -36,6 +36,7 @@ exports.list =
primary: true primary: true
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird') Promise = require('bluebird')
_ = require('lodash')
resin = require('resin-sdk') resin = require('resin-sdk')
visuals = require('resin-cli-visuals') visuals = require('resin-cli-visuals')
@ -45,6 +46,10 @@ exports.list =
return resin.models.device.getAll() return resin.models.device.getAll()
.tap (devices) -> .tap (devices) ->
devices = _.map devices, (device) ->
device.uuid = device.uuid.slice(0, 7)
return device
console.log visuals.table.horizontal devices, [ console.log visuals.table.horizontal devices, [
'id' 'id'
'uuid' 'uuid'