2015-02-20 23:15:48 +00:00
|
|
|
(function() {
|
|
|
|
/**
|
|
|
|
* Repository listing page. Shows all repositories for all visibile namespaces.
|
|
|
|
*/
|
|
|
|
angular.module('quayPages').config(['pages', function(pages) {
|
2015-02-23 19:23:54 +00:00
|
|
|
pages.create('repo-list', 'repo-list.html', RepoListCtrl, {
|
|
|
|
'title': 'Repositories',
|
|
|
|
'description': 'View and manage Docker repositories'
|
|
|
|
});
|
2015-02-20 23:15:48 +00:00
|
|
|
}]);
|
|
|
|
|
|
|
|
function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
|
|
|
|
$scope.namespace = null;
|
|
|
|
$scope.page = 1;
|
|
|
|
$scope.publicPageCount = null;
|
|
|
|
|
|
|
|
// Monitor changes in the user.
|
|
|
|
UserService.updateUserIn($scope, function() {
|
|
|
|
loadMyRepos($scope.namespace);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Monitor changes in the namespace.
|
|
|
|
$scope.$watch('namespace', function(namespace) {
|
|
|
|
loadMyRepos(namespace);
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.movePublicPage = function(increment) {
|
|
|
|
if ($scope.publicPageCount == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.page += increment;
|
|
|
|
if ($scope.page < 1) {
|
|
|
|
$scope.page = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($scope.page > $scope.publicPageCount) {
|
|
|
|
$scope.page = $scope.publicPageCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
loadPublicRepos();
|
|
|
|
};
|
|
|
|
|
|
|
|
var loadMyRepos = function(namespace) {
|
|
|
|
if (!$scope.user || $scope.user.anonymous || !namespace) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var options = {'public': false, 'sort': true, 'namespace': namespace};
|
|
|
|
|
|
|
|
$scope.user_repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
|
|
|
return resp.repositories;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var loadPublicRepos = function() {
|
|
|
|
var options = {
|
|
|
|
'public': true,
|
|
|
|
'private': false,
|
|
|
|
'sort': true,
|
|
|
|
'limit': 10,
|
|
|
|
'page': $scope.page,
|
|
|
|
'count': $scope.page == 1
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.public_repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
|
|
|
if (resp.count) {
|
|
|
|
$scope.publicPageCount = Math.ceil(resp.count / 10);
|
|
|
|
}
|
|
|
|
return resp.repositories;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
loadPublicRepos();
|
|
|
|
}
|
|
|
|
})();
|