mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 17:13:21 +00:00 
			
		
		
		
	GUAC-975: Only display views once critical data is loaded.
This commit is contained in:
		| @@ -60,6 +60,59 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i | ||||
|      */ | ||||
|     var identifier = $routeParams.id; | ||||
|  | ||||
|     /** | ||||
|      * All known protocols. | ||||
|      * | ||||
|      * @type Object.<String, Protocol> | ||||
|      */ | ||||
|     $scope.protocols = null; | ||||
|  | ||||
|     /** | ||||
|      * The root connection group of the connection group hierarchy. | ||||
|      * | ||||
|      * @type ConnectionGroup | ||||
|      */ | ||||
|     $scope.rootGroup = null; | ||||
|  | ||||
|     /** | ||||
|      * The connection being modified. | ||||
|      *  | ||||
|      * @type Connection | ||||
|      */ | ||||
|     $scope.connection = null; | ||||
|  | ||||
|     /** | ||||
|      * The parameter name/value pairs associated with the connection being | ||||
|      * modified. | ||||
|      * | ||||
|      * @type Object.<String, String> | ||||
|      */ | ||||
|     $scope.parameters = null; | ||||
|  | ||||
|     /** | ||||
|      * The usage history of the connection being modified. | ||||
|      * | ||||
|      * @type HistoryEntryWrapper[] | ||||
|      */ | ||||
|     $scope.historyEntryWrappers = null; | ||||
|  | ||||
|     /** | ||||
|      * Returns whether critical data has completed being loaded. | ||||
|      * | ||||
|      * @returns {Boolean} | ||||
|      *     true if enough data has been loaded for the user interface to be | ||||
|      *     useful, false otherwise. | ||||
|      */ | ||||
|     $scope.isLoaded = function isLoaded() { | ||||
|  | ||||
|         return $scope.protocols            !== null | ||||
|             && $scope.rootGroup            !== null | ||||
|             && $scope.connection           !== null | ||||
|             && $scope.parameters           !== null | ||||
|             && $scope.historyEntryWrappers !== null; | ||||
|  | ||||
|     }; | ||||
|  | ||||
|     // Pull connection group hierarchy | ||||
|     connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER, PermissionSet.ObjectPermissionType.UPDATE) | ||||
|     .success(function connectionGroupReceived(rootGroup) { | ||||
|   | ||||
| @@ -55,6 +55,35 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope' | ||||
|      */ | ||||
|     var identifier = $routeParams.id; | ||||
|  | ||||
|     /** | ||||
|      * The root connection group of the connection group hierarchy. | ||||
|      * | ||||
|      * @type ConnectionGroup | ||||
|      */ | ||||
|     $scope.rootGroup = null; | ||||
|  | ||||
|     /** | ||||
|      * The connection group being modified. | ||||
|      *  | ||||
|      * @type ConnectionGroup | ||||
|      */ | ||||
|     $scope.connectionGroup = null; | ||||
|  | ||||
|     /** | ||||
|      * Returns whether critical data has completed being loaded. | ||||
|      * | ||||
|      * @returns {Boolean} | ||||
|      *     true if enough data has been loaded for the user interface to be | ||||
|      *     useful, false otherwise. | ||||
|      */ | ||||
|     $scope.isLoaded = function isLoaded() { | ||||
|  | ||||
|         return $scope.rootGroup       !== null | ||||
|             && $scope.connectionGroup !== null; | ||||
|  | ||||
|     }; | ||||
|  | ||||
|  | ||||
|     // Pull connection group hierarchy | ||||
|     connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER, PermissionSet.ObjectPermissionType.UPDATE) | ||||
|     .success(function connectionGroupReceived(rootGroup) { | ||||
|   | ||||
| @@ -32,7 +32,9 @@ angular.module('manage').controller('manageController', ['$scope', '$injector', | ||||
|     var User            = $injector.get('User'); | ||||
|  | ||||
|     // Required services | ||||
|     var authenticationService  = $injector.get('authenticationService'); | ||||
|     var connectionGroupService = $injector.get('connectionGroupService'); | ||||
|     var permissionService      = $injector.get('permissionService'); | ||||
|     var userService            = $injector.get('userService'); | ||||
|  | ||||
|     /** | ||||
| @@ -47,6 +49,46 @@ angular.module('manage').controller('manageController', ['$scope', '$injector', | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
|      * Whether the current user can manage users. If the current permissions | ||||
|      * have not yet been loaded, this will be null. | ||||
|      * | ||||
|      * @type Boolean | ||||
|      */ | ||||
|     $scope.canManageUsers = null; | ||||
|  | ||||
|     /** | ||||
|      * Whether the current user can manage connections. If the current | ||||
|      * permissions have not yet been loaded, this will be null. | ||||
|      * | ||||
|      * @type Boolean | ||||
|      */ | ||||
|     $scope.canManageConnections = null; | ||||
|  | ||||
|     /** | ||||
|      * Whether the current user can create new users. If the current | ||||
|      * permissions have not yet been loaded, this will be null. | ||||
|      * | ||||
|      * @type Boolean | ||||
|      */ | ||||
|     $scope.canCreateUsers = null; | ||||
|  | ||||
|     /** | ||||
|      * Whether the current user can create new connections. If the current | ||||
|      * permissions have not yet been loaded, this will be null. | ||||
|      * | ||||
|      * @type Boolean | ||||
|      */ | ||||
|     $scope.canCreateConnections = null; | ||||
|  | ||||
|     /** | ||||
|      * Whether the current user can create new connection groups. If the | ||||
|      * current permissions have not yet been loaded, this will be null. | ||||
|      * | ||||
|      * @type Boolean | ||||
|      */ | ||||
|     $scope.canCreateConnectionGroups = null; | ||||
|  | ||||
|     /** | ||||
|      * The name of the new user to create, if any, when user creation is | ||||
|      * requested via newUser(). | ||||
| @@ -54,6 +96,58 @@ angular.module('manage').controller('manageController', ['$scope', '$injector', | ||||
|      * @type String | ||||
|      */ | ||||
|     $scope.newUsername = ""; | ||||
|  | ||||
|     /** | ||||
|      * Returns whether critical data has completed being loaded. | ||||
|      * | ||||
|      * @returns {Boolean} | ||||
|      *     true if enough data has been loaded for the user interface to be | ||||
|      *     useful, false otherwise. | ||||
|      */ | ||||
|     $scope.isLoaded = function isLoaded() { | ||||
|  | ||||
|         return $scope.users                     !== null | ||||
|             && $scope.rootGroup                 !== null | ||||
|             && $scope.canManageUsers            !== null | ||||
|             && $scope.canManageConnections      !== null | ||||
|             && $scope.canCreateUsers            !== null | ||||
|             && $scope.canCreateConnections      !== null | ||||
|             && $scope.canCreateConnectionGroups !== null; | ||||
|  | ||||
|     }; | ||||
|  | ||||
|     // Retrieve current permissions | ||||
|     permissionService.getPermissions(authenticationService.getCurrentUserID()) | ||||
|     .success(function permissionsRetrieved(permissions) { | ||||
|  | ||||
|         // Determine whether the current user can create new users | ||||
|         $scope.canCreateUsers = | ||||
|                PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|             || PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.CREATE_USER); | ||||
|  | ||||
|         // Determine whether the current user can create new users | ||||
|         $scope.canCreateConnections = | ||||
|                PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|             || PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.CREATE_CONNECTION); | ||||
|  | ||||
|         // Determine whether the current user can create new users | ||||
|         $scope.canCreateConnectionGroups = | ||||
|                PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|             || PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.CREATE_CONNECTION_GROUP); | ||||
|  | ||||
|         // Determine whether the current user can manage other users | ||||
|         $scope.canManageUsers = | ||||
|                $scope.canCreateUsers | ||||
|             || PermissionSet.hasUserPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE); | ||||
|  | ||||
|         // Determine whether the current user can manage other connections | ||||
|         $scope.canManageConnections = | ||||
|                $scope.canCreateConnections | ||||
|             || $scope.canCreateConnectionGroups | ||||
|             || PermissionSet.hasConnectionPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE) | ||||
|             || PermissionSet.hasConnectionGroupPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE); | ||||
|      | ||||
|     }); | ||||
|      | ||||
|     // Retrieve all connections for which we have UPDATE permission | ||||
|     connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER, PermissionSet.ObjectPermissionType.UPDATE) | ||||
|   | ||||
| @@ -57,6 +57,42 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto | ||||
|      */ | ||||
|     var username = $routeParams.id; | ||||
|  | ||||
|     /** | ||||
|      * The user being modified. | ||||
|      * | ||||
|      * @type User | ||||
|      */ | ||||
|     $scope.user = null; | ||||
|  | ||||
|     /** | ||||
|      * All permissions associated with the user being modified. | ||||
|      *  | ||||
|      * @type PermissionFlagSet | ||||
|      */ | ||||
|     $scope.permissionFlags = null; | ||||
|  | ||||
|     /** | ||||
|      * The root connection group of the connection group hierarchy. | ||||
|      * | ||||
|      * @type ConnectionGroup | ||||
|      */ | ||||
|     $scope.rootGroup = null; | ||||
|  | ||||
|     /** | ||||
|      * Returns whether critical data has completed being loaded. | ||||
|      * | ||||
|      * @returns {Boolean} | ||||
|      *     true if enough data has been loaded for the user interface to be | ||||
|      *     useful, false otherwise. | ||||
|      */ | ||||
|     $scope.isLoaded = function isLoaded() { | ||||
|  | ||||
|         return $scope.user            !== null | ||||
|             && $scope.permissionFlags !== null | ||||
|             && $scope.rootGroup       !== null; | ||||
|  | ||||
|     }; | ||||
|  | ||||
|     // Pull user data | ||||
|     userService.getUser(username).success(function userReceived(user) { | ||||
|         $scope.user = user; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user