GUACAMOLE-5: Implement management interface for sharing profile permissions.

This commit is contained in:
Michael Jumper
2016-08-04 18:21:32 -07:00
parent 8a8ae8496c
commit e3db19d633
5 changed files with 86 additions and 1 deletions

View File

@@ -165,7 +165,8 @@ div.section {
}
.connection .icon,
.connection-group .icon {
.connection-group .icon,
.sharing-profile .icon {
display: inline-block;
width: 24px;
height: 24px;
@@ -199,6 +200,10 @@ div.section {
background-image: url('images/protocol-icons/guac-monitor.png');
}
.sharing-profile .icon {
background-image: url('images/share.png');
}
/*
* Groups
*/

View File

@@ -633,6 +633,10 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
{
label: "MANAGE_USER.FIELD_HEADER_CREATE_NEW_CONNECTION_GROUPS",
value: PermissionSet.SystemPermissionType.CREATE_CONNECTION_GROUP
},
{
label: "MANAGE_USER.FIELD_HEADER_CREATE_NEW_SHARING_PROFILES",
value: PermissionSet.SystemPermissionType.CREATE_SHARING_PROFILE
}
];
@@ -861,6 +865,45 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
};
/**
* Updates the permissionsAdded and permissionsRemoved permission sets to
* reflect the addition of the given sharing profile permission.
*
* @param {String} identifier
* The identifier of the sharing profile to add READ permission for.
*/
var addSharingProfilePermission = function addSharingProfilePermission(identifier) {
// If permission was previously removed, simply un-remove it
if (PermissionSet.hasSharingProfilePermission(permissionsRemoved, PermissionSet.ObjectPermissionType.READ, identifier))
PermissionSet.removeSharingProfilePermission(permissionsRemoved, PermissionSet.ObjectPermissionType.READ, identifier);
// Otherwise, explicitly add the permission
else
PermissionSet.addSharingProfilePermission(permissionsAdded, PermissionSet.ObjectPermissionType.READ, identifier);
};
/**
* Updates the permissionsAdded and permissionsRemoved permission sets to
* reflect the removal of the given sharing profile permission.
*
* @param {String} identifier
* The identifier of the sharing profile to remove READ permission for.
*/
var removeSharingProfilePermission = function removeSharingProfilePermission(identifier) {
// If permission was previously added, simply un-add it
if (PermissionSet.hasSharingProfilePermission(permissionsAdded, PermissionSet.ObjectPermissionType.READ, identifier))
PermissionSet.removeSharingProfilePermission(permissionsAdded, PermissionSet.ObjectPermissionType.READ, identifier);
// Otherwise, explicitly remove the permission
else
PermissionSet.addSharingProfilePermission(permissionsRemoved, PermissionSet.ObjectPermissionType.READ, identifier);
};
// Expose permission query and modification functions to group list template
$scope.groupListContext = {
@@ -918,6 +961,28 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
else
removeConnectionGroupPermission(identifier);
},
/**
* Notifies the controller that a change has been made to the given
* sharing profile permission for the user being edited. This only
* applies to READ permissions.
*
* @param {String} identifier
* The identifier of the sharing profile affected by the changed
* permission.
*/
sharingProfilePermissionChanged : function sharingProfilePermissionChanged(identifier) {
// Determine current permission setting
var value = $scope.permissionFlags.sharingProfilePermissions.READ[identifier];
// Add/remove permission depending on flag state
if (value)
addSharingProfilePermission(identifier);
else
removeSharingProfilePermission(identifier);
}
};

View File

@@ -79,6 +79,7 @@
context="groupListContext"
connection-groups="filteredRootGroups"
connection-template="'app/manage/templates/connectionPermission.html'"
sharing-profile-template="'app/manage/templates/sharingProfilePermission.html'"
connection-group-template="'app/manage/templates/connectionGroupPermission.html'"
page-size="20"/>
</div>

View File

@@ -0,0 +1,13 @@
<div class="choice">
<!-- Sharing profile icon -->
<div class="icon type"></div>
<!-- Permission checkbox -->
<input type="checkbox" ng-model="context.getPermissionFlags().sharingProfilePermissions.READ[item.identifier]"
ng-change="context.sharingProfilePermissionChanged(item.identifier)"/>
<!-- Sharing profile name -->
<span class="name">{{item.name}}</span>
</div>

View File

@@ -256,6 +256,7 @@
"FIELD_HEADER_CREATE_NEW_USERS" : "Create new users:",
"FIELD_HEADER_CREATE_NEW_CONNECTIONS" : "Create new connections:",
"FIELD_HEADER_CREATE_NEW_CONNECTION_GROUPS" : "Create new connection groups:",
"FIELD_HEADER_CREATE_NEW_SHARING_PROFILES" : "Create new sharing profiles:",
"FIELD_HEADER_PASSWORD" : "@:APP.FIELD_HEADER_PASSWORD",
"FIELD_HEADER_PASSWORD_AGAIN" : "@:APP.FIELD_HEADER_PASSWORD_AGAIN",
"FIELD_HEADER_USERNAME" : "Username:",