GUAC-1126: Query root group and permissions directly within user page service. Return promises instead of pages.

This commit is contained in:
Michael Jumper
2015-04-06 14:32:55 -07:00
parent cff71345d1
commit 9c7e98c97e
3 changed files with 100 additions and 94 deletions

View File

@@ -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;
});
}]);