This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/directives/ui/repo-list-view.js

49 lines
1.5 KiB
JavaScript
Raw Normal View History

/**
* 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 = [];
2016-01-11 19:05:41 +00:00
$scope.loading = true;
$scope.showAsList = CookieService.get('quay.repoview') == 'list';
$scope.optionAllowed = true;
$scope.$watch('namespaces', function(namespaces) {
if (!namespaces) { return; }
2016-01-11 19:05:41 +00:00
$scope.loading = false;
$scope.resources = [];
namespaces.forEach(function(namespace) {
if (namespace && namespace.repositories) {
$scope.resources.push(namespace.repositories);
2016-01-11 19:05:41 +00:00
if (namespace.repositories.loading) {
$scope.loading = true;
}
}
});
$scope.optionAllowed = $scope.resources.length <= 250;
if (!$scope.optionAllowed) {
$scope.showAsList = true;
}
}, true);
$scope.setShowAsList = function(value) {
$scope.showAsList = value;
CookieService.putPermanent('quay.repoview', value ? 'list' : 'grid');
};
}
};
return directiveDefinitionObject;
});