diff --git a/guacamole/src/main/webapp/app/client/templates/client.html b/guacamole/src/main/webapp/app/client/templates/client.html
index 7f99adf47..16d2b23ed 100644
--- a/guacamole/src/main/webapp/app/client/templates/client.html
+++ b/guacamole/src/main/webapp/app/client/templates/client.html
@@ -59,7 +59,7 @@
diff --git a/guacamole/src/main/webapp/app/home/templates/home.html b/guacamole/src/main/webapp/app/home/templates/home.html
index 4bbfa6f05..be41ada77 100644
--- a/guacamole/src/main/webapp/app/home/templates/home.html
+++ b/guacamole/src/main/webapp/app/home/templates/home.html
@@ -27,7 +27,7 @@
diff --git a/guacamole/src/main/webapp/app/manage/templates/manageConnection.html b/guacamole/src/main/webapp/app/manage/templates/manageConnection.html
index 7cdfabe8e..6f0505959 100644
--- a/guacamole/src/main/webapp/app/manage/templates/manageConnection.html
+++ b/guacamole/src/main/webapp/app/manage/templates/manageConnection.html
@@ -25,7 +25,7 @@ THE SOFTWARE.
diff --git a/guacamole/src/main/webapp/app/manage/templates/manageConnectionGroup.html b/guacamole/src/main/webapp/app/manage/templates/manageConnectionGroup.html
index 7986c735d..f1fb395df 100644
--- a/guacamole/src/main/webapp/app/manage/templates/manageConnectionGroup.html
+++ b/guacamole/src/main/webapp/app/manage/templates/manageConnectionGroup.html
@@ -25,7 +25,7 @@ THE SOFTWARE.
diff --git a/guacamole/src/main/webapp/app/manage/templates/manageConnections.html b/guacamole/src/main/webapp/app/manage/templates/manageConnections.html
index e314e299a..84773c8e7 100644
--- a/guacamole/src/main/webapp/app/manage/templates/manageConnections.html
+++ b/guacamole/src/main/webapp/app/manage/templates/manageConnections.html
@@ -24,7 +24,7 @@ THE SOFTWARE.
diff --git a/guacamole/src/main/webapp/app/manage/templates/manageSessions.html b/guacamole/src/main/webapp/app/manage/templates/manageSessions.html
index 5b50f5f64..2b39290e1 100644
--- a/guacamole/src/main/webapp/app/manage/templates/manageSessions.html
+++ b/guacamole/src/main/webapp/app/manage/templates/manageSessions.html
@@ -24,7 +24,7 @@ THE SOFTWARE.
diff --git a/guacamole/src/main/webapp/app/manage/templates/manageUser.html b/guacamole/src/main/webapp/app/manage/templates/manageUser.html
index 65c34eb06..188656253 100644
--- a/guacamole/src/main/webapp/app/manage/templates/manageUser.html
+++ b/guacamole/src/main/webapp/app/manage/templates/manageUser.html
@@ -25,7 +25,7 @@ THE SOFTWARE.
diff --git a/guacamole/src/main/webapp/app/manage/templates/manageUsers.html b/guacamole/src/main/webapp/app/manage/templates/manageUsers.html
index e61cc3564..e1231a262 100644
--- a/guacamole/src/main/webapp/app/manage/templates/manageUsers.html
+++ b/guacamole/src/main/webapp/app/manage/templates/manageUsers.html
@@ -24,7 +24,7 @@ THE SOFTWARE.
diff --git a/guacamole/src/main/webapp/app/navigation/directives/guacUserMenu.js b/guacamole/src/main/webapp/app/navigation/directives/guacUserMenu.js
index f48d30344..847c0d097 100644
--- a/guacamole/src/main/webapp/app/navigation/directives/guacUserMenu.js
+++ b/guacamole/src/main/webapp/app/navigation/directives/guacUserMenu.js
@@ -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.
*/
diff --git a/guacamole/src/main/webapp/app/navigation/navigationModule.js b/guacamole/src/main/webapp/app/navigation/navigationModule.js
index 089255940..06039e118 100644
--- a/guacamole/src/main/webapp/app/navigation/navigationModule.js
+++ b/guacamole/src/main/webapp/app/navigation/navigationModule.js
@@ -23,4 +23,4 @@
/**
* Module for generating and implementing user navigation options.
*/
-angular.module('navigation', ['notification']);
+angular.module('navigation', ['notification', 'rest']);