CoreID/app/controllers/dash/Groups.controller.js
2020-05-03 20:16:54 -05:00

36 lines
951 B
JavaScript

const { Controller } = require('libflitter')
class GroupsController extends Controller {
static get services() {
return [...super.services, 'cobalt', 'models']
}
async get_listing(req, res, next) {
const Group = this.models.get('ldap:Group')
const groups = await Group.find()
const formatted = groups.map(x => {
return {
name: x.name,
count: x.user_ids.length,
}
})
return this.cobalt.listing(req, res, {
title: 'LDAP Groups', // TODO generalize this for SAML/OAuth2
columns: [
{
name: 'Group Name',
field: 'name',
},
{
name: '# Users',
field: 'count',
},
],
data: formatted,
})
}
}
module.exports = exports = GroupsController