Merge pull request #1109 from coreos-inc/commonlistgrid
Create a common repo-list-view control and use it everywhere
This commit is contained in:
commit
4dfeb907c3
13 changed files with 115 additions and 77 deletions
|
@ -13,7 +13,8 @@ angular.module('quay').directive('repoListGrid', function () {
|
|||
starred: '=starred',
|
||||
namespace: '=namespace',
|
||||
starToggled: '&starToggled',
|
||||
hideTitle: '=hideTitle'
|
||||
hideTitle: '=hideTitle',
|
||||
hideNamespaces: '=hideNamespaces'
|
||||
},
|
||||
controller: function($scope, $element, UserService) {
|
||||
$scope.isOrganization = function(namespace) {
|
||||
|
|
|
@ -10,7 +10,8 @@ angular.module('quay').directive('repoListTable', function () {
|
|||
restrict: 'C',
|
||||
scope: {
|
||||
'repositoriesResources': '=repositoriesResources',
|
||||
'namespaces': '=namespaces'
|
||||
'namespaces': '=namespaces',
|
||||
'starToggled': '&starToggled'
|
||||
},
|
||||
controller: function($scope, $element, $filter) {
|
||||
var orderBy = $filter('orderBy');
|
||||
|
@ -59,7 +60,7 @@ angular.module('quay').directive('repoListTable', function () {
|
|||
$scope.getAvatarData = function(namespace) {
|
||||
var found = {};
|
||||
$scope.namespaces.forEach(function(current) {
|
||||
if (current.name == namespace) {
|
||||
if (current.name == namespace || current.username == namespace) {
|
||||
found = current.avatar;
|
||||
}
|
||||
});
|
||||
|
|
38
static/js/directives/ui/repo-list-view.js
Normal file
38
static/js/directives/ui/repo-list-view.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* An element that displays a list (grid or table) of repositories.
|
||||
*/
|
||||
angular.module('quay').directive('repoListView', function () {
|
||||
var directiveDefinitionObject = {
|
||||
priority: 0,
|
||||
templateUrl: '/static/directives/repo-list-view.html',
|
||||
replace: false,
|
||||
transclude: true,
|
||||
restrict: 'C',
|
||||
scope: {
|
||||
namespaces: '=namespaces',
|
||||
starredRepositories: '=starredRepositories',
|
||||
starToggled: '&starToggled',
|
||||
},
|
||||
controller: function($scope, $element, CookieService) {
|
||||
$scope.resources = [];
|
||||
$scope.showAsList = CookieService.get('quay.repoview') == 'list';
|
||||
|
||||
$scope.$watch('namespaces', function(namespaces) {
|
||||
if (!namespaces) { return; }
|
||||
|
||||
$scope.resources = [];
|
||||
namespaces.forEach(function(namespace) {
|
||||
if (namespace && namespace.repositories) {
|
||||
$scope.resources.push(namespace.repositories);
|
||||
}
|
||||
});
|
||||
}, true);
|
||||
|
||||
$scope.setShowAsList = function(value) {
|
||||
$scope.showAsList = value;
|
||||
CookieService.putPermanent('quay.repoview', value ? 'list' : 'grid');
|
||||
};
|
||||
}
|
||||
};
|
||||
return directiveDefinitionObject;
|
||||
});
|
Reference in a new issue