GUACAMOLE-292: Explicitly pull standard attributes when rendering user menu; do not rely on schema.
Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/06fb054a Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/06fb054a Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/06fb054a Branch: refs/heads/master Commit: 06fb054ae24c991d7a664e01e53f577a79701938 Parents: ee6edb9 Author: Michael Jumper <[email protected]> Authored: Mon Mar 6 16:19:08 2017 -0800 Committer: Michael Jumper <[email protected]> Committed: Sat May 27 11:28:13 2017 -0700 ---------------------------------------------------------------------- .../app/navigation/directives/guacUserMenu.js | 56 +++++++++++++++++--- .../webapp/app/navigation/styles/user-menu.css | 9 ++-- .../app/navigation/templates/guacUserMenu.html | 8 +-- 3 files changed, 59 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/06fb054a/guacamole/src/main/webapp/app/navigation/directives/guacUserMenu.js ---------------------------------------------------------------------- diff --git a/guacamole/src/main/webapp/app/navigation/directives/guacUserMenu.js b/guacamole/src/main/webapp/app/navigation/directives/guacUserMenu.js index 0905011..9534dd4 100644 --- a/guacamole/src/main/webapp/app/navigation/directives/guacUserMenu.js +++ b/guacamole/src/main/webapp/app/navigation/directives/guacUserMenu.js @@ -43,11 +43,13 @@ angular.module('navigation').directive('guacUserMenu', [function guacUserMenu() controller: ['$scope', '$injector', function guacUserMenuController($scope, $injector) { + // Required types + var User = $injector.get('User'); + // Get required services var $location = $injector.get('$location'); var $route = $injector.get('$route'); var authenticationService = $injector.get('authenticationService'); - var schemaService = $injector.get('schemaService'); var userService = $injector.get('userService'); var userPageService = $injector.get('userPageService'); @@ -57,17 +59,57 @@ angular.module('navigation').directive('guacUserMenu', [function guacUserMenu() * @type String */ $scope.username = authenticationService.getCurrentUsername(); - - // Pull user attribute schema - schemaService.getUserAttributes(authenticationService.getDataSource()) - .success(function attributesReceived(attributes) { - $scope.attributes = attributes; - }); + + /** + * The user's full name. If not yet available, or if not defined, + * this will be null. + * + * @type String + */ + $scope.fullName = null; + + /** + * A URL pointing to relevant user information such as the user's + * email address. If not yet available, or if no such URL can be + * determined, this will be null. + * + * @type String + */ + $scope.userURL = null; + + /** + * The organization, company, group, etc. that the user belongs to. + * If not yet available, or if not defined, this will be null. + * + * @type String + */ + $scope.organization = null; + + /** + * The role that the user has at the organization, company, group, + * etc. they belong to. If not yet available, or if not defined, + * this will be null. + * + * @type String + */ + $scope.role = null; // Pull user data userService.getUser(authenticationService.getDataSource(), $scope.username) .success(function userRetrieved(user) { + + // Store retrieved user object $scope.user = user; + + // Pull basic profile information + $scope.fullName = user.attributes[User.Attributes.FULL_NAME]; + $scope.organization = user.attributes[User.Attributes.ORGANIZATION]; + $scope.role = user.attributes[User.Attributes.ORGANIZATIONAL_ROLE]; + + // Link to email address if available + var email = user.attributes[User.Attributes.EMAIL_ADDRESS]; + $scope.userURL = email ? 'mailto:' + email : null; + }); /** http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/06fb054a/guacamole/src/main/webapp/app/navigation/styles/user-menu.css ---------------------------------------------------------------------- diff --git a/guacamole/src/main/webapp/app/navigation/styles/user-menu.css b/guacamole/src/main/webapp/app/navigation/styles/user-menu.css index a1ba797..d7759ac 100644 --- a/guacamole/src/main/webapp/app/navigation/styles/user-menu.css +++ b/guacamole/src/main/webapp/app/navigation/styles/user-menu.css @@ -90,7 +90,10 @@ width: 2in; } -.user-menu .menu-dropdown .menu-contents .profile span.field-header, -.user-menu .menu-dropdown .menu-contents .profile h3 { - display: none; +.user-menu .menu-dropdown .menu-contents .profile .full-name { + font-weight: bold; } +.user-menu .menu-dropdown .menu-contents .profile .organization, +.user-menu .menu-dropdown .menu-contents .profile .organizational-role { + font-size: 0.8em; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/06fb054a/guacamole/src/main/webapp/app/navigation/templates/guacUserMenu.html ---------------------------------------------------------------------- diff --git a/guacamole/src/main/webapp/app/navigation/templates/guacUserMenu.html b/guacamole/src/main/webapp/app/navigation/templates/guacUserMenu.html index 5640b3c..9869cd6 100644 --- a/guacamole/src/main/webapp/app/navigation/templates/guacUserMenu.html +++ b/guacamole/src/main/webapp/app/navigation/templates/guacUserMenu.html @@ -2,10 +2,10 @@ <guac-menu menu-title="username"> <!-- User profile view --> - <div class="profile"> - <guac-form namespace="'USER_ATTRIBUTES'" content="attributes" - model="user.attributes" values-only="true" - read-only="true"></guac-form> + <div class="profile" ng-show="fullName"> + <div class="full-name"><a ng-href="{{userURL}}">{{ fullName }}</a></div> + <div class="organizational-role" ng-show="role">{{ role }}</div> + <div class="organization" ng-show="organization">{{ organization }}</div> </div> <!-- Local actions -->
