Merge pull request #2368 from coreos-inc/entity-search-avatar
Display avatars in entity search autocomplete
This commit is contained in:
commit
0214b1ba9f
4 changed files with 57 additions and 36 deletions
|
@ -55,4 +55,53 @@
|
||||||
|
|
||||||
.entity-search-element .menuitem .avatar {
|
.entity-search-element .menuitem .avatar {
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entity-mini-listing {
|
||||||
|
margin: 2px;
|
||||||
|
white-space: nowrap !important;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entity-mini-listing i {
|
||||||
|
margin-right: 8px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entity-mini-listing i.fa {
|
||||||
|
width: 20px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 16px;
|
||||||
|
color: #444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entity-mini-listing i.fa-exclamation-triangle {
|
||||||
|
position: absolute;
|
||||||
|
right: -14px;
|
||||||
|
top: 4px;
|
||||||
|
color: #c09853;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entity-mini-listing i.fa.ci-robot {
|
||||||
|
position: relative;
|
||||||
|
top: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entity-mini-listing i.fa .avatar-image {
|
||||||
|
position: absolute;
|
||||||
|
top: -2px;
|
||||||
|
left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entity-mini-listing .warning {
|
||||||
|
margin-top: 6px;
|
||||||
|
font-size: 10px;
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entity-mini-listing span.title {
|
||||||
|
color: #aaa;
|
||||||
|
font-size: 12px;
|
||||||
|
display: block;
|
||||||
}
|
}
|
|
@ -1135,35 +1135,6 @@ form input.ng-valid.ng-dirty,
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.entity-mini-listing {
|
|
||||||
margin: 2px;
|
|
||||||
white-space: nowrap !important;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.entity-mini-listing i {
|
|
||||||
margin-right: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.entity-mini-listing i.fa-exclamation-triangle {
|
|
||||||
position: absolute;
|
|
||||||
right: -14px;
|
|
||||||
top: 4px;
|
|
||||||
color: #c09853;
|
|
||||||
}
|
|
||||||
|
|
||||||
.entity-mini-listing .warning {
|
|
||||||
margin-top: 6px;
|
|
||||||
font-size: 10px;
|
|
||||||
padding: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.entity-mini-listing span.title {
|
|
||||||
color: #aaa;
|
|
||||||
font-size: 12px;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editable {
|
.editable {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ angular.module('quay').directive('entitySearch', function () {
|
||||||
// True if the menu should pull right.
|
// True if the menu should pull right.
|
||||||
'pullRight': '@pullRight'
|
'pullRight': '@pullRight'
|
||||||
},
|
},
|
||||||
controller: function($rootScope, $scope, $element, Restangular, UserService, ApiService, UtilService, Config) {
|
controller: function($rootScope, $scope, $element, Restangular, UserService, ApiService, UtilService, AvatarService, Config) {
|
||||||
$scope.lazyLoading = true;
|
$scope.lazyLoading = true;
|
||||||
|
|
||||||
$scope.teams = null;
|
$scope.teams = null;
|
||||||
|
@ -286,16 +286,16 @@ angular.module('quay').directive('entitySearch', function () {
|
||||||
},
|
},
|
||||||
'suggestion': function (datum) {
|
'suggestion': function (datum) {
|
||||||
template = '<div class="entity-mini-listing">';
|
template = '<div class="entity-mini-listing">';
|
||||||
if (datum.entity.kind == 'user' && !datum.entity.is_robot) {
|
if ((datum.entity.kind == 'user' && !datum.entity.is_robot) || (datum.entity.kind == 'org')) {
|
||||||
template += '<i class="fa fa-user fa-lg"></i>';
|
template += '<i class="fa fa-user fa-lg"><img class="avatar-image" src="' +
|
||||||
|
AvatarService.getAvatar(datum.entity.avatar.hash, 20, 'blank') +
|
||||||
|
'"></i>';
|
||||||
} else if (datum.entity.kind == 'external') {
|
} else if (datum.entity.kind == 'external') {
|
||||||
template += '<i class="fa fa-user fa-lg"></i>';
|
template += '<i class="fa fa-user fa-lg"></i>';
|
||||||
} else if (datum.entity.kind == 'user' && datum.entity.is_robot) {
|
} else if (datum.entity.kind == 'user' && datum.entity.is_robot) {
|
||||||
template += '<i class="fa ci-robot fa-lg"></i>';
|
template += '<i class="fa ci-robot fa-lg"></i>';
|
||||||
} else if (datum.entity.kind == 'team') {
|
} else if (datum.entity.kind == 'team') {
|
||||||
template += '<i class="fa fa-group fa-lg"></i>';
|
template += '<i class="fa fa-group fa-lg"></i>';
|
||||||
} else if (datum.entity.kind == 'org') {
|
|
||||||
template += '<i class="fa">' + AvatarService.getAvatar(datum.entity.avatar, 16) + '</i>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template += '<span class="name">' + datum.value + '</span>';
|
template += '<span class="name">' + datum.value + '</span>';
|
||||||
|
|
|
@ -6,7 +6,7 @@ angular.module('quay').factory('AvatarService', ['Config', '$sanitize', 'md5',
|
||||||
var avatarService = {};
|
var avatarService = {};
|
||||||
var cache = {};
|
var cache = {};
|
||||||
|
|
||||||
avatarService.getAvatar = function(hash, opt_size) {
|
avatarService.getAvatar = function(hash, opt_size, opt_notfound) {
|
||||||
var size = opt_size || 16;
|
var size = opt_size || 16;
|
||||||
switch (Config['AVATAR_KIND']) {
|
switch (Config['AVATAR_KIND']) {
|
||||||
case 'local':
|
case 'local':
|
||||||
|
@ -14,7 +14,8 @@ angular.module('quay').factory('AvatarService', ['Config', '$sanitize', 'md5',
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'gravatar':
|
case 'gravatar':
|
||||||
return '//www.gravatar.com/avatar/' + hash + '?d=404&size=' + size;
|
var notfound = opt_notfound || '404';
|
||||||
|
return '//www.gravatar.com/avatar/' + hash + '?d=' + notfound + '&size=' + size;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue