Move table to widget module

This commit is contained in:
Juan Cruz Viotti 2014-11-26 13:20:56 -04:00
parent bc11b305b2
commit ce8b11004c
9 changed files with 10 additions and 10 deletions

View File

@ -1,6 +1,5 @@
_ = require('lodash')
async = require('async')
table = require('../table/table')
resin = require('../resin')
widgets = require('../widgets/widgets')
patterns = require('../patterns/patterns')
@ -34,7 +33,7 @@ exports.create = authHooks.failIfNotLoggedIn (name, program) ->
exports.list = authHooks.failIfNotLoggedIn ->
resin.models.application.getAll().then (applications) ->
resin.log.out table.horizontal applications, (application) ->
resin.log.out widgets.table.horizontal applications, (application) ->
application.device_type = resin.device.getDisplayName(application.device_type)
application['Online Devices'] = _.where(application.device, is_online: 1).length
application['All Devices'] = application.device?.length or 0
@ -48,7 +47,7 @@ exports.list = authHooks.failIfNotLoggedIn ->
exports.info = authHooks.failIfNotLoggedIn (id) ->
resin.models.application.get(id).then (application) ->
resin.log.out table.vertical application, (application) ->
resin.log.out widgets.table.vertical application, (application) ->
application.device_type = resin.device.getDisplayName(application.device_type)
delete application.device
return application

View File

@ -1,4 +1,3 @@
table = require('../table/table')
resin = require('../resin')
widgets = require('../widgets/widgets')
patterns = require('../patterns/patterns')
@ -8,7 +7,7 @@ config = require('../config')
exports.list = authHooks.failIfNotLoggedIn (applicationId) ->
resin.models.device.getAll(applicationId).then (devices) ->
resin.log.out table.horizontal devices, (device) ->
resin.log.out widgets.table.horizontal devices, (device) ->
device.application = device.application[0].app_name
device.device_type = resin.device.getDisplayName(device.device_type)
delete device.note

View File

@ -1,5 +1,5 @@
_ = require('lodash')
table = require('../table/table')
widgets = require('../widgets/widgets')
patterns = require('../patterns/patterns')
resin = require('../resin')
authHooks = require('../hooks/auth')
@ -20,7 +20,7 @@ exports.list = authHooks.failIfNotLoggedIn (program) ->
if not program.parent.verbose?
environmentVariables = _.reject(environmentVariables, isSystemVariable)
resin.log.out(table.horizontal(environmentVariables))
resin.log.out(widgets.table.horizontal(environmentVariables))
.catch(resin.errors.handle)
exports.remove = authHooks.failIfNotLoggedIn (id, program) ->

View File

@ -2,14 +2,14 @@ _ = require('lodash')
resin = require('../resin')
authHooks = require('../hooks/auth')
patterns = require('../patterns/patterns')
table = require('../table/table')
widgets = require('../widgets/widgets')
helpers = require('../helpers/helpers')
config = require('../config')
exports.list = authHooks.failIfNotLoggedIn ->
resin.server.get config.urls.keys, (error, response, keys) ->
resin.errors.handle(error) if error?
resin.log.out table.horizontal keys, (key) ->
resin.log.out widgets.table.horizontal keys, (key) ->
delete key.public_key
return key
, [ 'ID', 'Title' ]
@ -27,7 +27,7 @@ exports.info = authHooks.failIfNotLoggedIn (id) ->
resin.errors.handle(new resin.errors.NotFound("key #{id}"))
key.public_key = '\n' + helpers.formatLongString(key.public_key, config.sshKeyWidth)
resin.log.out(table.vertical(key, _.identity, [ 'ID', 'Title', 'Public Key' ]))
resin.log.out(widgets.table.vertical(key, _.identity, [ 'ID', 'Title', 'Public Key' ]))
exports.remove = authHooks.failIfNotLoggedIn (id, program) ->
patterns.remove 'key', program.parent.yes, (callback) ->

View File

@ -1,6 +1,8 @@
_ = require('lodash')
inquirer = require('inquirer')
exports.table = require('./table/table')
exports.login = (callback) ->
inquirer.prompt([
{