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?
|
||||
|
||||
log.out ui.widgets.table.horizontal applications, (application) ->
|
||||
application.device_type = resin.models.device.getDisplayName(application.device_type)
|
||||
application['Online Devices'] = _.where(application.device, is_online: 1).length
|
||||
application['All Devices'] = application.device?.length or 0
|
||||
application.device_type = application.device_display_name
|
||||
application.all_devices = application.devices_length
|
||||
return application
|
||||
, [ 'ID', 'Name', 'Device Type', 'Online Devices', 'All Devices' ]
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
_ = require('lodash-contrib')
|
||||
pine = require('./_pine')
|
||||
deviceModel = require('./device')
|
||||
errors = require('../_errors/errors')
|
||||
server = require('../_server/server')
|
||||
settings = require('../settings')
|
||||
@ -25,6 +26,14 @@ exports.getAll = (callback) ->
|
||||
if _.isEmpty(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)
|
||||
|
||||
.catch (error) ->
|
||||
|
Loading…
Reference in New Issue
Block a user