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