mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-30 02:28:51 +00:00
Move device to resin module
This commit is contained in:
parent
ff07764b39
commit
bc11b305b2
@ -1,6 +1,5 @@
|
|||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
async = require('async')
|
async = require('async')
|
||||||
device = require('../device/device')
|
|
||||||
table = require('../table/table')
|
table = require('../table/table')
|
||||||
resin = require('../resin')
|
resin = require('../resin')
|
||||||
widgets = require('../widgets/widgets')
|
widgets = require('../widgets/widgets')
|
||||||
@ -17,14 +16,14 @@ exports.create = authHooks.failIfNotLoggedIn (name, program) ->
|
|||||||
if deviceType?
|
if deviceType?
|
||||||
return callback(null, deviceType)
|
return callback(null, deviceType)
|
||||||
else
|
else
|
||||||
deviceTypes = device.getSupportedDevices()
|
deviceTypes = resin.device.getSupportedDevices()
|
||||||
widgets.select('Select a type', deviceTypes, callback)
|
widgets.select('Select a type', deviceTypes, callback)
|
||||||
|
|
||||||
(type, callback) ->
|
(type, callback) ->
|
||||||
|
|
||||||
# TODO: Currently returns 'unknown'.
|
# TODO: Currently returns 'unknown'.
|
||||||
# Maybe we should break or handle better?
|
# Maybe we should break or handle better?
|
||||||
slugifiedType = device.getDeviceSlug(type)
|
slugifiedType = resin.device.getDeviceSlug(type)
|
||||||
|
|
||||||
resin.models.application.create(name, slugifiedType).then ->
|
resin.models.application.create(name, slugifiedType).then ->
|
||||||
return callback()
|
return callback()
|
||||||
@ -36,7 +35,7 @@ exports.list = authHooks.failIfNotLoggedIn ->
|
|||||||
resin.models.application.getAll().then (applications) ->
|
resin.models.application.getAll().then (applications) ->
|
||||||
|
|
||||||
resin.log.out table.horizontal applications, (application) ->
|
resin.log.out table.horizontal applications, (application) ->
|
||||||
application.device_type = 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
|
||||||
delete application.git_repository
|
delete application.git_repository
|
||||||
@ -50,7 +49,7 @@ exports.info = authHooks.failIfNotLoggedIn (id) ->
|
|||||||
resin.models.application.get(id).then (application) ->
|
resin.models.application.get(id).then (application) ->
|
||||||
|
|
||||||
resin.log.out table.vertical application, (application) ->
|
resin.log.out table.vertical application, (application) ->
|
||||||
application.device_type = device.getDisplayName(application.device_type)
|
application.device_type = resin.device.getDisplayName(application.device_type)
|
||||||
delete application.device
|
delete application.device
|
||||||
return application
|
return application
|
||||||
, [ 'ID', 'Name', 'Device Type', 'Git Repository', 'Commit' ]
|
, [ 'ID', 'Name', 'Device Type', 'Git Repository', 'Commit' ]
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
getDeviceDisplayName = require('../device/device').getDisplayName
|
|
||||||
table = require('../table/table')
|
table = require('../table/table')
|
||||||
resin = require('../resin')
|
resin = require('../resin')
|
||||||
widgets = require('../widgets/widgets')
|
widgets = require('../widgets/widgets')
|
||||||
@ -11,7 +10,7 @@ exports.list = authHooks.failIfNotLoggedIn (applicationId) ->
|
|||||||
|
|
||||||
resin.log.out table.horizontal devices, (device) ->
|
resin.log.out table.horizontal devices, (device) ->
|
||||||
device.application = device.application[0].app_name
|
device.application = device.application[0].app_name
|
||||||
device.device_type = getDeviceDisplayName(device.device_type)
|
device.device_type = resin.device.getDisplayName(device.device_type)
|
||||||
delete device.note
|
delete device.note
|
||||||
delete device.supervisor_version
|
delete device.supervisor_version
|
||||||
delete device.uuid
|
delete device.uuid
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
|
|
||||||
|
# TODO: This should be fetch from the server
|
||||||
DEVICES = require('./device-data.json')
|
DEVICES = require('./device-data.json')
|
||||||
|
|
||||||
exports.getDisplayName = (device) ->
|
exports.getDisplayName = (device) ->
|
@ -6,3 +6,4 @@ module.exports =
|
|||||||
token: require('./token/token')
|
token: require('./token/token')
|
||||||
data: require('./data/data')
|
data: require('./data/data')
|
||||||
auth: require('./auth/auth')
|
auth: require('./auth/auth')
|
||||||
|
device: require('./device/device')
|
||||||
|
Loading…
Reference in New Issue
Block a user