mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-31 16:36:24 +00:00
Move UI outside resin module
This commit is contained in:
parent
e7495fa72d
commit
4b74ec7fc4
@ -2,6 +2,7 @@ _ = require('lodash')
|
||||
async = require('async')
|
||||
resin = require('../resin')
|
||||
cli = require('../cli/cli')
|
||||
ui = require('../ui')
|
||||
|
||||
exports.create = (name) ->
|
||||
async.waterfall [
|
||||
@ -13,7 +14,7 @@ exports.create = (name) ->
|
||||
return callback(null, deviceType)
|
||||
else
|
||||
deviceTypes = resin.device.getSupportedDevices()
|
||||
resin.ui.widgets.select('Select a type', deviceTypes, callback)
|
||||
ui.widgets.select('Select a type', deviceTypes, callback)
|
||||
|
||||
(type, callback) ->
|
||||
|
||||
@ -29,7 +30,7 @@ exports.list = ->
|
||||
resin.models.application.getAll (error, applications) ->
|
||||
resin.errors.handle(error) if error?
|
||||
|
||||
resin.log.out resin.ui.widgets.table.horizontal applications, (application) ->
|
||||
resin.log.out 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
|
||||
@ -42,7 +43,7 @@ exports.info = (id) ->
|
||||
resin.models.application.get id, (error, application) ->
|
||||
resin.errors.handle(error) if error?
|
||||
|
||||
resin.log.out resin.ui.widgets.table.vertical application, (application) ->
|
||||
resin.log.out ui.widgets.table.vertical application, (application) ->
|
||||
application.device_type = resin.device.getDisplayName(application.device_type)
|
||||
delete application.device
|
||||
return application
|
||||
@ -55,6 +56,6 @@ exports.restart = (id) ->
|
||||
|
||||
exports.remove = (id) ->
|
||||
confirmArgument = cli.getArgument('yes')
|
||||
resin.ui.patterns.remove 'application', confirmArgument, (callback) ->
|
||||
ui.patterns.remove 'application', confirmArgument, (callback) ->
|
||||
resin.models.application.remove(id, callback)
|
||||
, resin.errors.handle
|
||||
|
@ -2,6 +2,7 @@ url = require('url')
|
||||
open = require('open')
|
||||
async = require('async')
|
||||
resin = require('../resin')
|
||||
ui = require('../ui')
|
||||
|
||||
exports.login = (credentials) ->
|
||||
async.waterfall [
|
||||
@ -10,7 +11,7 @@ exports.login = (credentials) ->
|
||||
if credentials?
|
||||
return resin.auth.parseCredentials(credentials, callback)
|
||||
else
|
||||
return resin.ui.widgets.login(callback)
|
||||
return ui.widgets.login(callback)
|
||||
|
||||
(credentials, callback) ->
|
||||
resin.auth.login(credentials, callback)
|
||||
|
@ -1,11 +1,12 @@
|
||||
resin = require('../resin')
|
||||
cli = require('../cli/cli')
|
||||
ui = require('../ui')
|
||||
|
||||
exports.list = (applicationId) ->
|
||||
resin.models.device.getAllByApplication applicationId, (error, devices) ->
|
||||
resin.errors.handle(error) if error?
|
||||
|
||||
resin.log.out resin.ui.widgets.table.horizontal devices, (device) ->
|
||||
resin.log.out 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
|
||||
@ -19,7 +20,7 @@ exports.info = (deviceId) ->
|
||||
resin.models.device.get deviceId, (error, device) ->
|
||||
resin.errors.handle(error) if error?
|
||||
|
||||
resin.log.out resin.ui.widgets.table.vertical device, (device) ->
|
||||
resin.log.out ui.widgets.table.vertical device, (device) ->
|
||||
device.device_type = resin.device.getDisplayName(device.device_type)
|
||||
device.application = device.application[0].app_name
|
||||
return device
|
||||
@ -41,7 +42,7 @@ exports.info = (deviceId) ->
|
||||
|
||||
exports.remove = (id) ->
|
||||
confirmArgument = cli.getArgument('yes')
|
||||
resin.ui.patterns.remove 'device', confirmArgument, (callback) ->
|
||||
ui.patterns.remove 'device', confirmArgument, (callback) ->
|
||||
resin.models.device.remove(id, callback)
|
||||
, resin.errors.handle
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
_ = require('lodash')
|
||||
resin = require('../resin')
|
||||
cli = require('../cli/cli')
|
||||
ui = require('../ui')
|
||||
|
||||
SYSTEM_VAR_REGEX = /^RESIN_/
|
||||
|
||||
@ -19,10 +20,10 @@ exports.list = ->
|
||||
if not cli.getArgument('verbose')?
|
||||
environmentVariables = _.reject(environmentVariables, isSystemVariable)
|
||||
|
||||
resin.log.out(resin.ui.widgets.table.horizontal(environmentVariables))
|
||||
resin.log.out(ui.widgets.table.horizontal(environmentVariables))
|
||||
|
||||
exports.remove = (id) ->
|
||||
confirmArgument = cli.getArgument('yes')
|
||||
resin.ui.patterns.remove 'environment variable', confirmArgument, (callback) ->
|
||||
ui.patterns.remove 'environment variable', confirmArgument, (callback) ->
|
||||
resin.models.environmentVariables.remove(id, callback)
|
||||
, resin.errors.handle
|
||||
|
@ -2,11 +2,12 @@ _ = require('lodash')
|
||||
resin = require('../resin')
|
||||
helpers = require('../helpers/helpers')
|
||||
cli = require('../cli/cli')
|
||||
ui = require('../ui')
|
||||
|
||||
exports.list = ->
|
||||
resin.server.get resin.settings.get('urls.keys'), (error, response, keys) ->
|
||||
resin.errors.handle(error) if error?
|
||||
resin.log.out resin.ui.widgets.table.horizontal keys, (key) ->
|
||||
resin.log.out ui.widgets.table.horizontal keys, (key) ->
|
||||
delete key.public_key
|
||||
return key
|
||||
, [ 'ID', 'Title' ]
|
||||
@ -24,11 +25,11 @@ exports.info = (id) ->
|
||||
resin.errors.handle(new resin.errors.NotFound("key #{id}"))
|
||||
|
||||
key.public_key = '\n' + helpers.formatLongString(key.public_key, resin.settings.get('sshKeyWidth'))
|
||||
resin.log.out(resin.ui.widgets.table.vertical(key, _.identity, [ 'ID', 'Title', 'Public Key' ]))
|
||||
resin.log.out(ui.widgets.table.vertical(key, _.identity, [ 'ID', 'Title', 'Public Key' ]))
|
||||
|
||||
exports.remove = (id) ->
|
||||
confirmArgument = cli.getArgument('yes')
|
||||
resin.ui.patterns.remove 'key', confirmArgument, (callback) ->
|
||||
ui.patterns.remove 'key', confirmArgument, (callback) ->
|
||||
url = _.template(resin.settings.get('urls.sshKey'), { id })
|
||||
resin.server.delete(url, callback)
|
||||
, resin.errors.handle
|
||||
|
@ -6,6 +6,7 @@ url = require('url')
|
||||
resin = require('../resin')
|
||||
connection = require('../connection/connection')
|
||||
cli = require('../cli/cli')
|
||||
ui = require('../ui')
|
||||
|
||||
exports.download = (id) ->
|
||||
params =
|
||||
@ -36,7 +37,7 @@ exports.download = (id) ->
|
||||
return callback(null, downloadUrl)
|
||||
|
||||
(downloadUrl, callback) ->
|
||||
resin.ui.patterns.downloadFile(downloadUrl, outputFile, callback)
|
||||
ui.patterns.downloadFile(downloadUrl, outputFile, callback)
|
||||
|
||||
], (error) ->
|
||||
resin.errors.handle(error) if error?
|
||||
|
@ -7,6 +7,5 @@ module.exports =
|
||||
data: require('./data/data')
|
||||
auth: require('./auth/auth')
|
||||
device: require('./device/device')
|
||||
ui: require('./ui')
|
||||
os: require('./os/os')
|
||||
settings: require('./settings')
|
||||
|
@ -1,7 +1,7 @@
|
||||
async = require('async')
|
||||
fs = require('fs')
|
||||
widgets = require('../widgets/widgets')
|
||||
server = require('../../server/server')
|
||||
resin = require('../../resin')
|
||||
ProgressBar = require('progress')
|
||||
|
||||
exports.remove = (name, confirmAttribute, deleteFunction, outerCallback) ->
|
||||
@ -23,7 +23,7 @@ exports.downloadFile = (url, dest, callback) ->
|
||||
bar = null
|
||||
received = 0
|
||||
|
||||
server.request
|
||||
resin.server.request
|
||||
method: 'GET'
|
||||
url: url
|
||||
pipe: fs.createWriteStream(dest)
|
Loading…
x
Reference in New Issue
Block a user