mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-1126: Query root group and permissions directly within user menu.
This commit is contained in:
@@ -59,7 +59,7 @@
|
||||
<!-- Stationary header -->
|
||||
<div class="header">
|
||||
<h2>{{client.name}}</h2>
|
||||
<guac-user-menu permissions="permissions" root-group="rootConnectionGroup"></guac-user-menu>
|
||||
<guac-user-menu></guac-user-menu>
|
||||
</div>
|
||||
|
||||
<!-- Scrollable body -->
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<!-- The recent connections for this user -->
|
||||
<div class="header">
|
||||
<h2>{{'HOME.SECTION_HEADER_RECENT_CONNECTIONS' | translate}}</h2>
|
||||
<guac-user-menu permissions="permissions" root-group="rootConnectionGroup"></guac-user-menu>
|
||||
<guac-user-menu></guac-user-menu>
|
||||
</div>
|
||||
<div class="recent-connections">
|
||||
<guac-recent-connections root-group="rootConnectionGroup"></guac-recent-connections>
|
||||
|
@@ -25,7 +25,7 @@ THE SOFTWARE.
|
||||
<!-- Main property editor -->
|
||||
<div class="header">
|
||||
<h2>{{'MANAGE_CONNECTION.SECTION_HEADER_EDIT_CONNECTION' | translate}}</h2>
|
||||
<guac-user-menu permissions="permissions"></guac-user-menu>
|
||||
<guac-user-menu></guac-user-menu>
|
||||
</div>
|
||||
<div class="section">
|
||||
<table class="properties">
|
||||
|
@@ -25,7 +25,7 @@ THE SOFTWARE.
|
||||
<!-- Main property editor -->
|
||||
<div class="header">
|
||||
<h2>{{'MANAGE_CONNECTION_GROUP.SECTION_HEADER_EDIT_CONNECTION_GROUP' | translate}}</h2>
|
||||
<guac-user-menu permissions="permissions"></guac-user-menu>
|
||||
<guac-user-menu></guac-user-menu>
|
||||
</div>
|
||||
<div class="section">
|
||||
<table class="properties">
|
||||
|
@@ -24,7 +24,7 @@ THE SOFTWARE.
|
||||
|
||||
<div class="header">
|
||||
<h2>{{'MANAGE_CONNECTION.SECTION_HEADER_CONNECTIONS' | translate}}</h2>
|
||||
<guac-user-menu permissions="permissions"></guac-user-menu>
|
||||
<guac-user-menu></guac-user-menu>
|
||||
</div>
|
||||
|
||||
<!-- Connection management -->
|
||||
|
@@ -24,7 +24,7 @@ THE SOFTWARE.
|
||||
|
||||
<div class="header">
|
||||
<h2>{{'MANAGE_SESSION.SECTION_HEADER_SESSIONS' | translate}}</h2>
|
||||
<guac-user-menu permissions="permissions"></guac-user-menu>
|
||||
<guac-user-menu></guac-user-menu>
|
||||
</div>
|
||||
|
||||
<!-- User Session management -->
|
||||
|
@@ -25,7 +25,7 @@ THE SOFTWARE.
|
||||
<!-- Main property editor -->
|
||||
<div class="header">
|
||||
<h2>{{'MANAGE_USER.SECTION_HEADER_EDIT_USER' | translate}}</h2>
|
||||
<guac-user-menu permissions="permissions"></guac-user-menu>
|
||||
<guac-user-menu></guac-user-menu>
|
||||
</div>
|
||||
<div class="section">
|
||||
<table class="properties">
|
||||
|
@@ -24,7 +24,7 @@ THE SOFTWARE.
|
||||
|
||||
<div class="header">
|
||||
<h2>{{'MANAGE_USER.SECTION_HEADER_USERS' | translate}}</h2>
|
||||
<guac-user-menu permissions="permissions"></guac-user-menu>
|
||||
<guac-user-menu></guac-user-menu>
|
||||
</div>
|
||||
|
||||
<!-- User management -->
|
||||
|
@@ -30,22 +30,6 @@ angular.module('navigation').directive('guacUserMenu', [function guacUserMenu()
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
scope: {
|
||||
|
||||
/**
|
||||
* The permissions associated with the user for whom this menu is
|
||||
* being displayed.
|
||||
*
|
||||
* @type PermissionSet
|
||||
*/
|
||||
permissions : '=',
|
||||
|
||||
/**
|
||||
* The root of the connection group tree.
|
||||
*
|
||||
* @type ConnectionGroup
|
||||
*/
|
||||
rootGroup : '='
|
||||
|
||||
},
|
||||
|
||||
templateUrl: 'app/navigation/templates/guacUserMenu.html',
|
||||
@@ -56,12 +40,14 @@ angular.module('navigation').directive('guacUserMenu', [function guacUserMenu()
|
||||
var PermissionSet = $injector.get('PermissionSet');
|
||||
|
||||
// Get required services
|
||||
var $document = $injector.get('$document');
|
||||
var $location = $injector.get('$location');
|
||||
var authenticationService = $injector.get('authenticationService');
|
||||
var guacNotification = $injector.get('guacNotification');
|
||||
var userService = $injector.get('userService');
|
||||
var userPageService = $injector.get('userPageService');
|
||||
var $document = $injector.get('$document');
|
||||
var $location = $injector.get('$location');
|
||||
var authenticationService = $injector.get('authenticationService');
|
||||
var connectionGroupService = $injector.get("connectionGroupService");
|
||||
var guacNotification = $injector.get('guacNotification');
|
||||
var permissionService = $injector.get("permissionService");
|
||||
var userService = $injector.get('userService');
|
||||
var userPageService = $injector.get('userPageService');
|
||||
|
||||
/**
|
||||
* An action to be provided along with the object sent to
|
||||
@@ -89,6 +75,22 @@ angular.module('navigation').directive('guacUserMenu', [function guacUserMenu()
|
||||
*/
|
||||
var document = $document[0];
|
||||
|
||||
/**
|
||||
* The root connection group, or null if the connection group hierarchy has
|
||||
* not yet been loaded.
|
||||
*
|
||||
* @type ConnectionGroup
|
||||
*/
|
||||
var rootConnectionGroup = null;
|
||||
|
||||
/**
|
||||
* All permissions associated with the current user, or null if the user's
|
||||
* permissions have not yet been loaded.
|
||||
*
|
||||
* @type PermissionSet
|
||||
*/
|
||||
var permissions = null;
|
||||
|
||||
/**
|
||||
* Whether the current user has sufficient permissions to change
|
||||
* his/her own password. If permissions have not yet been loaded,
|
||||
@@ -149,33 +151,43 @@ angular.module('navigation').directive('guacUserMenu', [function guacUserMenu()
|
||||
*/
|
||||
var updateMenuItems = function updateMenuItems() {
|
||||
|
||||
// Menu items are unknown until permissions and rootGroup are both available
|
||||
if (!$scope.permissions || !$scope.rootGroup) {
|
||||
// Menu items are unknown until permissions and rootConnectionGroup are both available
|
||||
if (!permissions || !rootConnectionGroup) {
|
||||
$scope.canChangePassword = null;
|
||||
$scope.pages = [];
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve the main pages from the user page service
|
||||
$scope.pages = userPageService.getMainPages($scope.rootGroup, $scope.permissions);
|
||||
$scope.pages = userPageService.getMainPages(rootConnectionGroup, permissions);
|
||||
|
||||
// Check whether the current user can change their own password
|
||||
$scope.canChangePassword = PermissionSet.hasUserPermission(
|
||||
$scope.permissions, PermissionSet.ObjectPermissionType.UPDATE,
|
||||
permissions, PermissionSet.ObjectPermissionType.UPDATE,
|
||||
authenticationService.getCurrentUserID()
|
||||
);
|
||||
};
|
||||
|
||||
// Update available menu options when permissions are changed
|
||||
$scope.$watch('permissions', function permissionsChanged() {
|
||||
// Retrieve root group and all descendants
|
||||
connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER)
|
||||
.success(function rootConnectionGroupRetrieved(retrievedRootConnectionGroup) {
|
||||
|
||||
rootConnectionGroup = retrievedRootConnectionGroup;
|
||||
|
||||
// Navigate to home page, if not already there
|
||||
var homePage = userPageService.getHomePage(rootConnectionGroup);
|
||||
$location.url(homePage.url);
|
||||
|
||||
updateMenuItems();
|
||||
});
|
||||
|
||||
// Update available menu options when root group is changed
|
||||
$scope.$watch('rootGroup', function rootGroupChanged() {
|
||||
// Retrieve current permissions
|
||||
permissionService.getPermissions(authenticationService.getCurrentUserID())
|
||||
.success(function permissionsRetrieved(retrievedPermissions) {
|
||||
permissions = retrievedPermissions;
|
||||
updateMenuItems();
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Toggles visibility of the user menu.
|
||||
*/
|
||||
|
@@ -23,4 +23,4 @@
|
||||
/**
|
||||
* Module for generating and implementing user navigation options.
|
||||
*/
|
||||
angular.module('navigation', ['notification']);
|
||||
angular.module('navigation', ['notification', 'rest']);
|
||||
|
Reference in New Issue
Block a user