GUACAMOLE-292: Explicitly pull standard attributes when rendering user menu; do not rely on schema.

This commit is contained in:
Michael Jumper
2017-03-06 16:19:08 -08:00
parent ee6edb9c82
commit 06fb054ae2
3 changed files with 59 additions and 14 deletions

View File

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

View File

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

View File

@@ -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 -->