2014-11-18 14:39:26 -04:00
|
|
|
_ = require('lodash')
|
|
|
|
cliff = require('cliff')
|
2014-11-18 08:41:13 -04:00
|
|
|
server = require('../server/server')
|
2014-11-19 08:51:42 -04:00
|
|
|
device = require('../device/device')
|
2014-11-18 10:11:43 -04:00
|
|
|
applicationModel = require('../models/application')
|
2014-11-18 12:37:01 -04:00
|
|
|
authHooks = require('../hooks/auth')
|
2014-11-18 08:41:13 -04:00
|
|
|
|
2014-11-18 12:37:01 -04:00
|
|
|
exports.list = authHooks.failIfNotLoggedIn ->
|
2014-11-18 10:11:43 -04:00
|
|
|
applicationModel.getAll().then (applications) ->
|
2014-11-18 14:39:26 -04:00
|
|
|
|
|
|
|
applications = _.map applications, (application) ->
|
|
|
|
return {
|
|
|
|
ID: application.id
|
|
|
|
Name: application.app_name
|
2014-11-19 08:51:42 -04:00
|
|
|
'Device Type': device.getDisplayName(application.device_type)
|
2014-11-18 14:39:26 -04: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)
|
2014-11-19 09:23:40 -04:00
|
|
|
|
|
|
|
exports.info = authHooks.failIfNotLoggedIn (id) ->
|
|
|
|
applicationModel.get(id).then (application) ->
|
|
|
|
|
|
|
|
console.log("ID: #{application.id}")
|
|
|
|
console.log("Name: #{application.app_name}")
|
|
|
|
console.log("Device Type: #{device.getDisplayName(application.device_type)}")
|
|
|
|
console.log("Git Repository: #{application.git_repository}")
|
|
|
|
console.log("Commit: #{application.commit}")
|
|
|
|
|
|
|
|
.catch (error) ->
|
|
|
|
throw error
|