3da8814787
This allows users to choose grid view or table view in all repo lists Fixes #732
38 lines
No EOL
1.1 KiB
JavaScript
38 lines
No EOL
1.1 KiB
JavaScript
/**
|
|
* 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;
|
|
}); |