mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-21 06:33:28 +00:00
Move widgets to resin/ui module
This commit is contained in:
parent
ce8b11004c
commit
67ade4bf12
@ -1,7 +1,6 @@
|
||||
_ = require('lodash')
|
||||
async = require('async')
|
||||
resin = require('../resin')
|
||||
widgets = require('../widgets/widgets')
|
||||
patterns = require('../patterns/patterns')
|
||||
authHooks = require('../hooks/auth')
|
||||
config = require('../config')
|
||||
@ -16,7 +15,7 @@ exports.create = authHooks.failIfNotLoggedIn (name, program) ->
|
||||
return callback(null, deviceType)
|
||||
else
|
||||
deviceTypes = resin.device.getSupportedDevices()
|
||||
widgets.select('Select a type', deviceTypes, callback)
|
||||
resin.ui.widgets.select('Select a type', deviceTypes, callback)
|
||||
|
||||
(type, callback) ->
|
||||
|
||||
@ -33,7 +32,7 @@ exports.create = authHooks.failIfNotLoggedIn (name, program) ->
|
||||
exports.list = authHooks.failIfNotLoggedIn ->
|
||||
resin.models.application.getAll().then (applications) ->
|
||||
|
||||
resin.log.out widgets.table.horizontal applications, (application) ->
|
||||
resin.log.out resin.ui.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
|
||||
@ -47,7 +46,7 @@ exports.list = authHooks.failIfNotLoggedIn ->
|
||||
exports.info = authHooks.failIfNotLoggedIn (id) ->
|
||||
resin.models.application.get(id).then (application) ->
|
||||
|
||||
resin.log.out widgets.table.vertical application, (application) ->
|
||||
resin.log.out resin.ui.widgets.table.vertical application, (application) ->
|
||||
application.device_type = resin.device.getDisplayName(application.device_type)
|
||||
delete application.device
|
||||
return application
|
||||
|
@ -2,7 +2,6 @@ open = require('open')
|
||||
async = require('async')
|
||||
resin = require('../resin')
|
||||
authHooks = require('../hooks/auth')
|
||||
widgets = require('../widgets/widgets')
|
||||
config = require('../config')
|
||||
|
||||
exports.login = (credentials) ->
|
||||
@ -12,7 +11,7 @@ exports.login = (credentials) ->
|
||||
if credentials?
|
||||
return resin.auth.parseCredentials(credentials, callback)
|
||||
else
|
||||
return widgets.login(callback)
|
||||
return resin.ui.widgets.login(callback)
|
||||
|
||||
(credentials, callback) ->
|
||||
resin.auth.login(credentials, callback)
|
||||
|
@ -1,5 +1,4 @@
|
||||
resin = require('../resin')
|
||||
widgets = require('../widgets/widgets')
|
||||
patterns = require('../patterns/patterns')
|
||||
authHooks = require('../hooks/auth')
|
||||
config = require('../config')
|
||||
@ -7,7 +6,7 @@ config = require('../config')
|
||||
exports.list = authHooks.failIfNotLoggedIn (applicationId) ->
|
||||
resin.models.device.getAll(applicationId).then (devices) ->
|
||||
|
||||
resin.log.out widgets.table.horizontal devices, (device) ->
|
||||
resin.log.out resin.ui.widgets.table.horizontal devices, (device) ->
|
||||
device.application = device.application[0].app_name
|
||||
device.device_type = resin.device.getDisplayName(device.device_type)
|
||||
delete device.note
|
||||
|
@ -1,5 +1,4 @@
|
||||
_ = require('lodash')
|
||||
widgets = require('../widgets/widgets')
|
||||
patterns = require('../patterns/patterns')
|
||||
resin = require('../resin')
|
||||
authHooks = require('../hooks/auth')
|
||||
@ -20,7 +19,7 @@ exports.list = authHooks.failIfNotLoggedIn (program) ->
|
||||
if not program.parent.verbose?
|
||||
environmentVariables = _.reject(environmentVariables, isSystemVariable)
|
||||
|
||||
resin.log.out(widgets.table.horizontal(environmentVariables))
|
||||
resin.log.out(resin.ui.widgets.table.horizontal(environmentVariables))
|
||||
.catch(resin.errors.handle)
|
||||
|
||||
exports.remove = authHooks.failIfNotLoggedIn (id, program) ->
|
||||
|
@ -2,14 +2,13 @@ _ = require('lodash')
|
||||
resin = require('../resin')
|
||||
authHooks = require('../hooks/auth')
|
||||
patterns = require('../patterns/patterns')
|
||||
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 widgets.table.horizontal keys, (key) ->
|
||||
resin.log.out resin.ui.widgets.table.horizontal keys, (key) ->
|
||||
delete key.public_key
|
||||
return key
|
||||
, [ 'ID', 'Title' ]
|
||||
@ -27,7 +26,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(widgets.table.vertical(key, _.identity, [ 'ID', 'Title', 'Public Key' ]))
|
||||
resin.log.out(resin.ui.widgets.table.vertical(key, _.identity, [ 'ID', 'Title', 'Public Key' ]))
|
||||
|
||||
exports.remove = authHooks.failIfNotLoggedIn (id, program) ->
|
||||
patterns.remove 'key', program.parent.yes, (callback) ->
|
||||
|
@ -1,5 +1,5 @@
|
||||
async = require('async')
|
||||
widgets = require('../widgets/widgets')
|
||||
resin = require('../resin')
|
||||
|
||||
exports.remove = (name, confirmAttribute, deleteFunction, outerCallback) ->
|
||||
async.waterfall([
|
||||
@ -8,7 +8,7 @@ exports.remove = (name, confirmAttribute, deleteFunction, outerCallback) ->
|
||||
if confirmAttribute
|
||||
return callback(null, true)
|
||||
|
||||
widgets.confirmRemoval(name, callback)
|
||||
resin.ui.widgets.confirmRemoval(name, callback)
|
||||
|
||||
(confirmed, callback) ->
|
||||
return callback() if not confirmed
|
||||
|
@ -7,3 +7,4 @@ module.exports =
|
||||
data: require('./data/data')
|
||||
auth: require('./auth/auth')
|
||||
device: require('./device/device')
|
||||
ui: require('./ui')
|
||||
|
2
lib/resin/ui/index.coffee
Normal file
2
lib/resin/ui/index.coffee
Normal file
@ -0,0 +1,2 @@
|
||||
module.exports =
|
||||
widgets: require('./widgets/widgets')
|
Loading…
Reference in New Issue
Block a user