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