mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-10 07:01:21 +00:00
GUAC-1126: Query root group and permissions directly within user page service. Return promises instead of pages.
This commit is contained in:
@@ -30,10 +30,8 @@ angular.module('home').controller('homeController', ['$scope', '$injector',
|
||||
var ConnectionGroup = $injector.get("ConnectionGroup");
|
||||
|
||||
// Get required services
|
||||
var $location = $injector.get("$location");
|
||||
var authenticationService = $injector.get("authenticationService");
|
||||
var connectionGroupService = $injector.get("connectionGroupService");
|
||||
var permissionService = $injector.get("permissionService");
|
||||
var userPageService = $injector.get("userPageService");
|
||||
|
||||
/**
|
||||
@@ -44,14 +42,6 @@ angular.module('home').controller('homeController', ['$scope', '$injector',
|
||||
*/
|
||||
$scope.rootConnectionGroup = null;
|
||||
|
||||
/**
|
||||
* All permissions associated with the current user, or null if the user's
|
||||
* permissions have not yet been loaded.
|
||||
*
|
||||
* @type PermissionSet
|
||||
*/
|
||||
$scope.permissions = null;
|
||||
|
||||
/**
|
||||
* Returns whether critical data has completed being loaded.
|
||||
*
|
||||
@@ -61,27 +51,20 @@ angular.module('home').controller('homeController', ['$scope', '$injector',
|
||||
*/
|
||||
$scope.isLoaded = function isLoaded() {
|
||||
|
||||
return $scope.rootConnectionGroup !== null
|
||||
&& $scope.permissions !== null;
|
||||
return $scope.rootConnectionGroup !== null;
|
||||
|
||||
};
|
||||
|
||||
// Retrieve root group and all descendants
|
||||
connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER)
|
||||
.success(function rootGroupRetrieved(rootConnectionGroup) {
|
||||
|
||||
$scope.rootConnectionGroup = rootConnectionGroup;
|
||||
});
|
||||
|
||||
// Navigate to home page, if not already there
|
||||
var homePage = userPageService.getHomePage(rootConnectionGroup);
|
||||
// Navigate to home page, if not already there
|
||||
userPageService.getHomePage()
|
||||
.then(function homePageRetrieved(homePage) {
|
||||
$location.url(homePage.url);
|
||||
|
||||
});
|
||||
|
||||
// Retrieve current permissions
|
||||
permissionService.getPermissions(authenticationService.getCurrentUserID())
|
||||
.success(function permissionsRetrieved(permissions) {
|
||||
$scope.permissions = permissions;
|
||||
});
|
||||
|
||||
|
||||
}]);
|
||||
|
Reference in New Issue
Block a user