mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 09:03:21 +00:00 
			
		
		
		
	GUAC-1126: Move menu actions into own class. Make rendering of menu actions generic.
This commit is contained in:
		| @@ -73,15 +73,6 @@ angular.module('navigation').directive('guacUserMenu', [function guacUserMenu() | ||||
|              */ | ||||
|             var document = $document[0]; | ||||
|  | ||||
|             /** | ||||
|              * Whether the current user has sufficient permissions to change | ||||
|              * his/her own password. If permissions have not yet been loaded, | ||||
|              * this will be null. | ||||
|              * | ||||
|              * @type Boolean | ||||
|              */ | ||||
|             $scope.canChangePassword = null; | ||||
|  | ||||
|             /** | ||||
|              * Whether the password edit dialog should be shown. | ||||
|              * | ||||
| @@ -125,18 +116,6 @@ angular.module('navigation').directive('guacUserMenu', [function guacUserMenu() | ||||
|              */ | ||||
|             $scope.pages = null; | ||||
|  | ||||
|             // Retrieve current permissions | ||||
|             permissionService.getPermissions(authenticationService.getCurrentUserID()) | ||||
|             .success(function permissionsRetrieved(permissions) { | ||||
|  | ||||
|                 // Check whether the current user can change their own password | ||||
|                 $scope.canChangePassword = PermissionSet.hasUserPermission( | ||||
|                         permissions, PermissionSet.ObjectPermissionType.UPDATE,  | ||||
|                         authenticationService.getCurrentUserID() | ||||
|                 ); | ||||
|  | ||||
|             }); | ||||
|  | ||||
|             // Retrieve the main pages from the user page service | ||||
|             userPageService.getMainPages() | ||||
|             .then(function retrievedMainPages(pages) { | ||||
| @@ -258,6 +237,44 @@ angular.module('navigation').directive('guacUserMenu', [function guacUserMenu() | ||||
|                 }); | ||||
|             }; | ||||
|  | ||||
|             /** | ||||
|              * Action which logs out the current user, redirecting them to back | ||||
|              * to the login screen after logout completes. | ||||
|              */ | ||||
|             var LOGOUT_ACTION = { | ||||
|                 name      : 'USER_MENU.ACTION_LOGOUT', | ||||
|                 className : 'logout', | ||||
|                 callback  : $scope.logout | ||||
|             }; | ||||
|  | ||||
|             /** | ||||
|              * Action which shows the password update dialog. | ||||
|              */ | ||||
|             var CHANGE_PASSWORD_ACTION = { | ||||
|                 name      : 'USER_MENU.ACTION_CHANGE_PASSWORD', | ||||
|                 className : 'change-password', | ||||
|                 callback  : $scope.showPasswordUpdate | ||||
|             }; | ||||
|  | ||||
|             /** | ||||
|              * All available actions for the current user. | ||||
|              */ | ||||
|             $scope.actions = [ LOGOUT_ACTION ]; | ||||
|  | ||||
|             // Retrieve current permissions | ||||
|             permissionService.getPermissions(authenticationService.getCurrentUserID()) | ||||
|             .success(function permissionsRetrieved(permissions) { | ||||
|  | ||||
|                 // Add action for changing password if permission is granted | ||||
|                 if (PermissionSet.hasUserPermission(permissions, | ||||
|                         PermissionSet.ObjectPermissionType.UPDATE,  | ||||
|                         authenticationService.getCurrentUserID())) | ||||
|                     $scope.actions.unshift(CHANGE_PASSWORD_ACTION); | ||||
|                          | ||||
|  | ||||
|             }); | ||||
|  | ||||
|  | ||||
|             // Close menu when use clicks anywhere else | ||||
|             document.body.addEventListener('click', function clickOutsideMenu() { | ||||
|                 $scope.$apply(function closeMenu() { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user