balena-cli/lib/actions/app.coffee

22 lines
706 B
CoffeeScript
Raw Normal View History

2014-11-18 18:39:26 +00:00
_ = require('lodash')
cliff = require('cliff')
server = require('../server/server')
2014-11-19 12:51:42 +00:00
device = require('../device/device')
applicationModel = require('../models/application')
2014-11-18 16:37:01 +00:00
authHooks = require('../hooks/auth')
2014-11-18 16:37:01 +00:00
exports.list = authHooks.failIfNotLoggedIn ->
applicationModel.getAll().then (applications) ->
2014-11-18 18:39:26 +00:00
applications = _.map applications, (application) ->
return {
ID: application.id
Name: application.app_name
2014-11-19 12:51:42 +00:00
'Device Type': device.getDisplayName(application.device_type)
2014-11-18 18:39:26 +00:00
'Online Devices': _.where(application.device, is_online: 1).length
'All Devices': application.device?.length or 0
}
console.log cliff.stringifyObjectRows(applications, _.keys _.first applications)