From c26d5a77ab2cc9843ae854d4c43c9dd2f23123a2 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 22 Dec 2014 22:51:43 -0800 Subject: [PATCH] GUAC-932: Display current system permissions in user edit interface. --- .../controllers/manageUserController.js | 48 +++++++++++++++++++ .../app/manage/templates/manageUser.html | 25 ++-------- 2 files changed, 51 insertions(+), 22 deletions(-) diff --git a/guacamole/src/main/webapp/app/manage/controllers/manageUserController.js b/guacamole/src/main/webapp/app/manage/controllers/manageUserController.js index b6ce22b43..25d38d3ef 100644 --- a/guacamole/src/main/webapp/app/manage/controllers/manageUserController.js +++ b/guacamole/src/main/webapp/app/manage/controllers/manageUserController.js @@ -72,6 +72,31 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto $scope.rootGroup = rootGroup; }); + /** + * Available system permission types, as translation string / internal + * value pairs. + * + * @type Object[] + */ + $scope.systemPermissionTypes = [ + { + label: "manage.edit.user.administerSystem", + value: PermissionSet.SystemPermissionType.ADMINISTER + }, + { + label: "manage.edit.user.createUser", + value: PermissionSet.SystemPermissionType.CREATE_USER + }, + { + label: "manage.edit.user.createConnection", + value: PermissionSet.SystemPermissionType.CREATE_CONNECTION + }, + { + label: "manage.edit.user.createConnectionGroup", + value: PermissionSet.SystemPermissionType.CREATE_CONNECTION_GROUP + } + ]; + // Expose permission query and modification functions to group list template $scope.groupListContext = { @@ -123,6 +148,29 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto }; + /** + * Determines whether the given system permission is granted for the + * user being edited. + * + * @param {String} type + * The type string of the system permission to check. + * + * @returns {Boolean} + * true if the user has the given system permission, false if the + * user lacks the given system permission, or the permissions have + * not yet been loaded. + */ + $scope.hasSystemPermission = function hasSystemPermission(type) { + + // Assume no permission if permissions not available yet + if (!$scope.permissions) + return false; + + // Return whether given permission is present + return PermissionSet.hasSystemPermission($scope.permissions, type); + + }; + /** * Cancels all pending edits, returning to the management page. */ diff --git a/guacamole/src/main/webapp/app/manage/templates/manageUser.html b/guacamole/src/main/webapp/app/manage/templates/manageUser.html index 01cffb88c..0b02695ca 100644 --- a/guacamole/src/main/webapp/app/manage/templates/manageUser.html +++ b/guacamole/src/main/webapp/app/manage/templates/manageUser.html @@ -51,28 +51,9 @@ THE SOFTWARE.

{{'manage.edit.user.permissions' | translate}}

- - - - - - - - - - - - - - - - - - - - - - + + +
{{'manage.edit.user.administerSystem' | translate}}
{{'manage.edit.user.createUser' | translate}}
{{'manage.edit.user.createConnection' | translate}}
{{'manage.edit.user.createConnectionGroup' | translate}}
{{systemPermissionType.label | translate}}