4160b720f9
- Change the tag check bar to only select the current page (by default), but allow for selecting ALL tags - Limit the number of tags compared in the visualization view to 10 - Fix the multiselect dropdown to limit itself to 10 items selected - Remove saving the selected tags in the URL, as it is too slow and overloads the URLs in Chrome when there are 1000+ tags selected - Change the images API to not return locations: By skipping the extra join and looping, it made the /images API call 10x faster (in hand tests) Fixes #292 Fixes #293
168 lines
No EOL
4.7 KiB
JavaScript
168 lines
No EOL
4.7 KiB
JavaScript
(function() {
|
|
/**
|
|
* Repository view page.
|
|
*/
|
|
angular.module('quayPages').config(['pages', function(pages) {
|
|
pages.create('repo-view', 'repo-view.html', RepoViewCtrl, {
|
|
'newLayout': true,
|
|
'title': '{{ namespace }}/{{ name }}',
|
|
'description': 'Repository {{ namespace }}/{{ name }}'
|
|
})
|
|
}]);
|
|
|
|
function RepoViewCtrl($scope, $routeParams, $location, $timeout, ApiService, UserService, AngularPollChannel) {
|
|
$scope.namespace = $routeParams.namespace;
|
|
$scope.name = $routeParams.name;
|
|
|
|
$scope.imagesRequired = false;
|
|
|
|
// Tab-enabled counters.
|
|
$scope.tagsShown = 0;
|
|
$scope.logsShown = 0;
|
|
$scope.buildsShown = 0;
|
|
$scope.settingsShown = 0;
|
|
|
|
$scope.viewScope = {
|
|
'selectedTags': [],
|
|
'repository': null,
|
|
'images': null,
|
|
'imagesResource': null,
|
|
'builds': null,
|
|
'changesVisible': false
|
|
};
|
|
|
|
var buildPollChannel = null;
|
|
|
|
// Make sure we track the current user.
|
|
UserService.updateUserIn($scope);
|
|
|
|
// 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];
|
|
});
|
|
};
|
|
|
|
var loadRepository = function() {
|
|
// Mark the images to be reloaded.
|
|
$scope.viewScope.images = null;
|
|
|
|
var params = {
|
|
'repository': $scope.namespace + '/' + $scope.name
|
|
};
|
|
|
|
$scope.repositoryResource = ApiService.getRepoAsResource(params).get(function(repo) {
|
|
$scope.repository = repo;
|
|
$scope.viewScope.repository = repo;
|
|
|
|
// 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.
|
|
buildPollChannel = AngularPollChannel.create($scope, loadRepositoryBuilds, 30000 /* 30s */);
|
|
buildPollChannel.start();
|
|
}, 10);
|
|
});
|
|
};
|
|
|
|
var loadImages = function(opt_callback) {
|
|
var params = {
|
|
'repository': $scope.namespace + '/' + $scope.name
|
|
};
|
|
|
|
$scope.viewScope.imagesResource = ApiService.listRepositoryImagesAsResource(params).get(function(resp) {
|
|
$scope.viewScope.images = resp.images;
|
|
opt_callback && opt_callback(resp.images);
|
|
});
|
|
};
|
|
|
|
var loadRepositoryBuilds = function(callback) {
|
|
var params = {
|
|
'repository': $scope.namespace + '/' + $scope.name,
|
|
'limit': 3
|
|
};
|
|
|
|
var errorHandler = function() {
|
|
callback(false);
|
|
};
|
|
|
|
$scope.repositoryBuildsResource = ApiService.getRepoBuildsAsResource(params, /* background */true).get(function(resp) {
|
|
// 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;
|
|
}
|
|
}
|
|
|
|
$scope.viewScope.builds = resp.builds;
|
|
callback(true);
|
|
}, errorHandler);
|
|
};
|
|
|
|
// Load the repository.
|
|
loadRepository();
|
|
|
|
$scope.setTags = function(tagNames) {
|
|
if (!tagNames) {
|
|
$scope.viewScope.selectedTags = [];
|
|
return;
|
|
}
|
|
|
|
$scope.viewScope.selectedTags = $.unique(tagNames.split(','));
|
|
};
|
|
|
|
$scope.showBuilds = function() {
|
|
$scope.buildsShown++;
|
|
};
|
|
|
|
$scope.showSettings = function() {
|
|
$scope.settingsShown++;
|
|
};
|
|
|
|
$scope.showLogs = function() {
|
|
$scope.logsShown++;
|
|
};
|
|
|
|
$scope.showTags = function() {
|
|
$timeout(function() {
|
|
$scope.tagsShown = 1;
|
|
}, 10);
|
|
};
|
|
|
|
$scope.requireImages = function() {
|
|
// Lazily load the repo's images if this is the first call to a tab
|
|
// that needs the images.
|
|
if ($scope.viewScope.images == null) {
|
|
loadImages();
|
|
}
|
|
};
|
|
|
|
$scope.handleChangesState = function(value) {
|
|
$scope.viewScope.changesVisible = value;
|
|
};
|
|
|
|
$scope.getImages = function(callback) {
|
|
loadImages(callback);
|
|
};
|
|
}
|
|
})(); |