2015-02-20 23:15:48 +00:00
|
|
|
(function() {
|
|
|
|
/**
|
|
|
|
* Repository view page.
|
|
|
|
*/
|
2016-10-14 18:23:43 +00:00
|
|
|
angular.module('quayPages').config(['pages', function(pages) {
|
|
|
|
pages.create('repo-view', 'repo-view.html', RepoViewCtrl, {
|
|
|
|
'newLayout': true,
|
|
|
|
'title': '{{ namespace }}/{{ name }}',
|
|
|
|
'description': 'Repository {{ namespace }}/{{ name }}'
|
|
|
|
});
|
|
|
|
}]);
|
2015-02-20 23:15:48 +00:00
|
|
|
|
2016-09-20 21:10:09 +00:00
|
|
|
function RepoViewCtrl($scope, $routeParams, $location, $timeout, ApiService, UserService, AngularPollChannel, ImageLoaderService, CookieService) {
|
2015-03-10 05:03:39 +00:00
|
|
|
$scope.namespace = $routeParams.namespace;
|
|
|
|
$scope.name = $routeParams.name;
|
|
|
|
|
2015-11-03 23:15:23 +00:00
|
|
|
var imageLoader = ImageLoaderService.getLoader($scope.namespace, $scope.name);
|
2015-05-06 22:16:03 +00:00
|
|
|
|
|
|
|
// Tab-enabled counters.
|
2015-11-12 20:42:45 +00:00
|
|
|
$scope.infoShown = 0;
|
2015-06-24 21:07:38 +00:00
|
|
|
$scope.tagsShown = 0;
|
2015-03-10 05:03:39 +00:00
|
|
|
$scope.logsShown = 0;
|
2015-05-06 22:16:03 +00:00
|
|
|
$scope.buildsShown = 0;
|
|
|
|
$scope.settingsShown = 0;
|
2017-03-03 18:25:06 +00:00
|
|
|
$scope.historyShown = 0;
|
2015-05-06 22:16:03 +00:00
|
|
|
|
2015-03-12 19:22:47 +00:00
|
|
|
$scope.viewScope = {
|
|
|
|
'selectedTags': [],
|
|
|
|
'repository': null,
|
2015-11-03 23:15:23 +00:00
|
|
|
'imageLoader': imageLoader,
|
2017-03-03 18:25:06 +00:00
|
|
|
'builds': null,
|
|
|
|
'historyFilter': ''
|
2015-03-12 19:22:47 +00:00
|
|
|
};
|
2015-03-10 05:03:39 +00:00
|
|
|
|
2015-03-11 00:22:46 +00:00
|
|
|
var buildPollChannel = null;
|
|
|
|
|
2015-03-10 05:03:39 +00:00
|
|
|
// Make sure we track the current user.
|
|
|
|
UserService.updateUserIn($scope);
|
|
|
|
|
2015-03-12 19:22:47 +00:00
|
|
|
// Watch the repository to filter any tags removed.
|
|
|
|
$scope.$watch('viewScope.repository', function(repository) {
|
|
|
|
if (!repository) { return; }
|
|
|
|
$scope.viewScope.selectedTags = filterTags($scope.viewScope.selectedTags);
|
|
|
|
});
|
|
|
|
|
|
|
|
var filterTags = function(tags) {
|
|
|
|
return (tags || []).filter(function(tag) {
|
|
|
|
return !!$scope.viewScope.repository.tags[tag];
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2015-03-10 05:03:39 +00:00
|
|
|
var loadRepository = function() {
|
2015-05-07 19:51:49 +00:00
|
|
|
// Mark the images to be reloaded.
|
|
|
|
$scope.viewScope.images = null;
|
|
|
|
|
2015-03-10 05:03:39 +00:00
|
|
|
var params = {
|
2016-06-03 19:00:01 +00:00
|
|
|
'repository': $scope.namespace + '/' + $scope.name,
|
|
|
|
'includeStats': true
|
2015-03-10 05:03:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.repositoryResource = ApiService.getRepoAsResource(params).get(function(repo) {
|
2015-04-07 22:33:43 +00:00
|
|
|
$scope.repository = repo;
|
2015-03-12 19:22:47 +00:00
|
|
|
$scope.viewScope.repository = repo;
|
2016-09-20 21:10:09 +00:00
|
|
|
$scope.publicRepoExperiment = CookieService.get('quay.public-repo-exp') == 'true';
|
2015-03-11 00:22:46 +00:00
|
|
|
|
2016-09-20 19:52:06 +00:00
|
|
|
// Flag for new repo page experiment
|
2016-09-20 21:10:09 +00:00
|
|
|
$scope.newRepoExperiment = $scope.repository.is_public && $scope.user.username != $scope.repository.namespace && $scope.publicRepoExperiment;
|
2016-09-20 19:52:06 +00:00
|
|
|
|
2015-03-23 20:10:33 +00:00
|
|
|
// Load the remainder of the data async, so we don't block the initial view from
|
|
|
|
// showing.
|
|
|
|
$timeout(function() {
|
|
|
|
$scope.setTags($routeParams.tag);
|
|
|
|
|
|
|
|
// Track builds.
|
2015-05-06 22:16:03 +00:00
|
|
|
buildPollChannel = AngularPollChannel.create($scope, loadRepositoryBuilds, 30000 /* 30s */);
|
2015-05-07 22:26:11 +00:00
|
|
|
buildPollChannel.start();
|
2015-03-23 20:10:33 +00:00
|
|
|
}, 10);
|
2015-03-10 05:03:39 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2015-03-11 00:22:46 +00:00
|
|
|
var loadRepositoryBuilds = function(callback) {
|
|
|
|
var params = {
|
2015-03-18 16:14:30 +00:00
|
|
|
'repository': $scope.namespace + '/' + $scope.name,
|
|
|
|
'limit': 3
|
2015-03-11 00:22:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var errorHandler = function() {
|
|
|
|
callback(false);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.repositoryBuildsResource = ApiService.getRepoBuildsAsResource(params, /* background */true).get(function(resp) {
|
2015-04-22 17:33:20 +00:00
|
|
|
// Note: We could just set the builds here, but that causes a full digest cycle. Therefore,
|
|
|
|
// to be more efficient, we do some work here to determine if anything has changed since
|
|
|
|
// the last build load in the common case.
|
|
|
|
if ($scope.viewScope.builds && resp.builds.length == $scope.viewScope.builds.length) {
|
|
|
|
var hasNewInformation = false;
|
|
|
|
for (var i = 0; i < resp.builds.length; ++i) {
|
|
|
|
var current = $scope.viewScope.builds[i];
|
|
|
|
var updated = resp.builds[i];
|
|
|
|
if (current.phase != updated.phase || current.id != updated.id) {
|
|
|
|
hasNewInformation = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasNewInformation) {
|
|
|
|
callback(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-12 19:22:47 +00:00
|
|
|
$scope.viewScope.builds = resp.builds;
|
2015-03-11 00:27:19 +00:00
|
|
|
callback(true);
|
2015-03-11 00:22:46 +00:00
|
|
|
}, errorHandler);
|
|
|
|
};
|
|
|
|
|
2015-03-23 20:10:33 +00:00
|
|
|
// Load the repository.
|
2015-03-10 05:03:39 +00:00
|
|
|
loadRepository();
|
|
|
|
|
2015-03-12 19:22:47 +00:00
|
|
|
$scope.setTags = function(tagNames) {
|
|
|
|
if (!tagNames) {
|
|
|
|
$scope.viewScope.selectedTags = [];
|
|
|
|
return;
|
|
|
|
}
|
2015-03-11 00:22:46 +00:00
|
|
|
|
2015-03-12 19:22:47 +00:00
|
|
|
$scope.viewScope.selectedTags = $.unique(tagNames.split(','));
|
2015-03-10 05:03:39 +00:00
|
|
|
};
|
|
|
|
|
2015-11-12 20:42:45 +00:00
|
|
|
$scope.showInfo = function() {
|
|
|
|
$scope.infoShown++;
|
|
|
|
};
|
|
|
|
|
2015-05-06 22:16:03 +00:00
|
|
|
$scope.showBuilds = function() {
|
|
|
|
$scope.buildsShown++;
|
|
|
|
};
|
|
|
|
|
2017-03-03 18:25:06 +00:00
|
|
|
$scope.showHistory = function() {
|
|
|
|
$scope.historyShown++;
|
|
|
|
};
|
|
|
|
|
2015-05-06 22:16:03 +00:00
|
|
|
$scope.showSettings = function() {
|
|
|
|
$scope.settingsShown++;
|
|
|
|
};
|
|
|
|
|
2015-03-10 05:03:39 +00:00
|
|
|
$scope.showLogs = function() {
|
|
|
|
$scope.logsShown++;
|
|
|
|
};
|
2015-03-12 19:22:47 +00:00
|
|
|
|
2015-06-24 21:07:38 +00:00
|
|
|
$scope.showTags = function() {
|
|
|
|
$timeout(function() {
|
|
|
|
$scope.tagsShown = 1;
|
|
|
|
}, 10);
|
|
|
|
};
|
|
|
|
|
2015-05-07 19:51:49 +00:00
|
|
|
$scope.getImages = function(callback) {
|
|
|
|
loadImages(callback);
|
|
|
|
};
|
2015-03-10 05:03:39 +00:00
|
|
|
}
|
2016-10-10 22:48:45 +00:00
|
|
|
})();
|