Have tags selected be handled universally throughout the entire repository view page.
This commit is contained in:
parent
ea61a68bcb
commit
347bf31f2d
9 changed files with 154 additions and 85 deletions
|
@ -13,25 +13,56 @@
|
|||
}, ['old-layout']);
|
||||
}]);
|
||||
|
||||
function RepoViewCtrl($scope, $routeParams, ApiService, UserService, AngularPollChannel) {
|
||||
function RepoViewCtrl($scope, $routeParams, $location, ApiService, UserService, AngularPollChannel) {
|
||||
$scope.namespace = $routeParams.namespace;
|
||||
$scope.name = $routeParams.name;
|
||||
|
||||
$scope.logsShown = 0;
|
||||
$scope.viewScope = {
|
||||
'selectedTags': [],
|
||||
'repository': null,
|
||||
'builds': null,
|
||||
'changesVisible': false
|
||||
};
|
||||
|
||||
var buildPollChannel = null;
|
||||
|
||||
// Make sure we track the current user.
|
||||
UserService.updateUserIn($scope);
|
||||
|
||||
// Watch the selected tags and update the URL accordingly.
|
||||
$scope.$watch('viewScope.selectedTags', function(selectedTags) {
|
||||
if (!selectedTags || !$scope.viewScope.repository) { return; }
|
||||
|
||||
var tags = filterTags(selectedTags);
|
||||
if (!tags.length) {
|
||||
$location.search('tag', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$location.search('tag', tags.join(','));
|
||||
}, true);
|
||||
|
||||
// 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() {
|
||||
var params = {
|
||||
'repository': $scope.namespace + '/' + $scope.name
|
||||
};
|
||||
|
||||
$scope.repositoryResource = ApiService.getRepoAsResource(params).get(function(repo) {
|
||||
$scope.repository = repo;
|
||||
$scope.setTag($routeParams.tag);
|
||||
$scope.viewScope.repository = repo;
|
||||
$scope.setTags($routeParams.tag);
|
||||
|
||||
// Track builds.
|
||||
buildPollChannel = AngularPollChannel.create($scope, loadRepositoryBuilds, 5000 /* 5s */);
|
||||
|
@ -49,7 +80,7 @@
|
|||
};
|
||||
|
||||
$scope.repositoryBuildsResource = ApiService.getRepoBuildsAsResource(params, /* background */true).get(function(resp) {
|
||||
$scope.builds = resp.builds;
|
||||
$scope.viewScope.builds = resp.builds;
|
||||
callback(true);
|
||||
}, errorHandler);
|
||||
};
|
||||
|
@ -57,14 +88,22 @@
|
|||
// Load the repository.
|
||||
loadRepository();
|
||||
|
||||
$scope.setTags = function(tagNames) {
|
||||
if (!tagNames) {
|
||||
$scope.viewScope.selectedTags = [];
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.setTag = function(tagName) {
|
||||
window.console.log('set tag')
|
||||
$scope.viewScope.selectedTags = $.unique(tagNames.split(','));
|
||||
};
|
||||
|
||||
$scope.showLogs = function() {
|
||||
$scope.logsShown++;
|
||||
};
|
||||
|
||||
$scope.handleChangesState = function(value) {
|
||||
$scope.viewScope.changesVisible = value;
|
||||
};
|
||||
}
|
||||
|
||||
function OldRepoViewCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiService, $routeParams, $rootScope, $location, $timeout, Config, UtilService) {
|
||||
|
|
Reference in a new issue