Added frond-end and needed get calls.
This commit is contained in:
26
endpoints/listgrouppermissions.js
Normal file
26
endpoints/listgrouppermissions.js
Normal file
@@ -0,0 +1,26 @@
|
||||
//Call for listing all groups with their permissions - needed for control panel
|
||||
//Groups without permissions also included
|
||||
//
|
||||
const handleListPerm = (req, res, db) => {
|
||||
|
||||
db.transaction ( trx => {
|
||||
trx.select('groups.groupname', 'permissions.objname', 'permissions.type')
|
||||
.from('groups')
|
||||
.leftJoin('permissions', function () {
|
||||
this.on('groups.groupname', 'ilike','permissions.owner')
|
||||
})
|
||||
.where('username', 'like', '')
|
||||
.orderBy('groupname', 'asc')
|
||||
.orderBy('objname', 'asc')
|
||||
.then ( data => {
|
||||
res.json(data);
|
||||
})
|
||||
.then(trx.commit)
|
||||
.catch(trx.rollback)
|
||||
.catch (err => res.status(400).json('Error accesing database.'))
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
handleListPerm
|
||||
}
|
||||
20
endpoints/listgroupusers.js
Normal file
20
endpoints/listgroupusers.js
Normal file
@@ -0,0 +1,20 @@
|
||||
//Call for listing all groups with their users - needed for control panel
|
||||
//
|
||||
const handleListGroup = (req, res, db) => {
|
||||
db.transaction (trx => {
|
||||
trx.select('*')
|
||||
.from('groups')
|
||||
.orderBy('groupname', 'asc')
|
||||
.orderBy('username', 'asc')
|
||||
.then( data => {
|
||||
res.json(data);
|
||||
})
|
||||
.then(trx.commit)
|
||||
.catch(trx.rollback)
|
||||
.catch (err => res.status(400).json('Error accesing database.'))
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
handleListGroup
|
||||
}
|
||||
29
endpoints/listuserpermissions.js
Normal file
29
endpoints/listuserpermissions.js
Normal file
@@ -0,0 +1,29 @@
|
||||
//Call for listing all users with their permissions - needed for control panel
|
||||
//Users without permissions also included
|
||||
//
|
||||
const handleListPerm = (req, res, db) => {
|
||||
|
||||
db.transaction ( trx => {
|
||||
trx.select('users.username', 'permissions.objname', 'permissions.type')
|
||||
.from('groups')
|
||||
.fullOuterJoin('permissions', function () {
|
||||
this.on('groups.groupname', '=', 'permissions.owner')
|
||||
})
|
||||
.rightJoin('users', function () {
|
||||
this.on('groups.username', 'ilike','users.username')
|
||||
.orOn('permissions.owner', 'ilike', 'users.username')
|
||||
})
|
||||
.orderBy('username', 'asc')
|
||||
.orderBy('objname', 'asc')
|
||||
.then ( data => {
|
||||
res.json(data);
|
||||
})
|
||||
.then(trx.commit)
|
||||
.catch(trx.rollback)
|
||||
.catch (err => res.status(400).json('Error accesing database.'))
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
handleListPerm
|
||||
}
|
||||
Reference in New Issue
Block a user