mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-23 23:42:24 +00:00
Move application field manipulations to the model
This commit is contained in:
parent
45a4f8eda0
commit
c311738dd1
@ -34,9 +34,8 @@ exports.list = permissions.user ->
|
|||||||
errors.handle(error) if error?
|
errors.handle(error) if error?
|
||||||
|
|
||||||
log.out ui.widgets.table.horizontal applications, (application) ->
|
log.out ui.widgets.table.horizontal applications, (application) ->
|
||||||
application.device_type = resin.models.device.getDisplayName(application.device_type)
|
application.device_type = application.device_display_name
|
||||||
application['Online Devices'] = _.where(application.device, is_online: 1).length
|
application.all_devices = application.devices_length
|
||||||
application['All Devices'] = application.device?.length or 0
|
|
||||||
return application
|
return application
|
||||||
, [ 'ID', 'Name', 'Device Type', 'Online Devices', 'All Devices' ]
|
, [ 'ID', 'Name', 'Device Type', 'Online Devices', 'All Devices' ]
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
_ = require('lodash-contrib')
|
_ = require('lodash-contrib')
|
||||||
pine = require('./_pine')
|
pine = require('./_pine')
|
||||||
|
deviceModel = require('./device')
|
||||||
errors = require('../_errors/errors')
|
errors = require('../_errors/errors')
|
||||||
server = require('../_server/server')
|
server = require('../_server/server')
|
||||||
settings = require('../settings')
|
settings = require('../settings')
|
||||||
@ -25,6 +26,14 @@ exports.getAll = (callback) ->
|
|||||||
if _.isEmpty(applications)
|
if _.isEmpty(applications)
|
||||||
return callback(new errors.NotAny('applications'))
|
return callback(new errors.NotAny('applications'))
|
||||||
|
|
||||||
|
# TODO: It might be worth to do all these handy
|
||||||
|
# manipulations server side directly.
|
||||||
|
applications = _.map applications, (application) ->
|
||||||
|
application.device_display_name = deviceModel.getDisplayName(application.device_type)
|
||||||
|
application.online_devices = _.where(application.device, is_online: 1).length
|
||||||
|
application.devices_length = application.device?.length or 0
|
||||||
|
return application
|
||||||
|
|
||||||
return callback(null, applications)
|
return callback(null, applications)
|
||||||
|
|
||||||
.catch (error) ->
|
.catch (error) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user