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
|
@ -87,33 +87,32 @@ angular.module('quay').directive('repoPanelChanges', function () {
|
|||
transclude: false,
|
||||
restrict: 'C',
|
||||
scope: {
|
||||
'repository': '=repository'
|
||||
'repository': '=repository',
|
||||
'selectedTags': '=selectedTags',
|
||||
'isEnabled': '=isEnabled'
|
||||
},
|
||||
controller: function($scope, $element, $location, $timeout, ApiService, UtilService, ImageMetadataService) {
|
||||
controller: function($scope, $element, $timeout, ApiService, UtilService, ImageMetadataService) {
|
||||
|
||||
var update = function() {
|
||||
if (!$scope.repository) { return; }
|
||||
|
||||
var tagString = $location.search()['tags'] || '';
|
||||
if (!tagString) {
|
||||
$scope.selectedTags = [];
|
||||
return;
|
||||
}
|
||||
if (!$scope.repository || !$scope.selectedTags) { return; }
|
||||
|
||||
$scope.currentImage = null;
|
||||
$scope.currentImage = null;
|
||||
$scope.selectedTags = tagString.split(',');
|
||||
$scope.currentTag = null;
|
||||
|
||||
if (!$scope.imageResource) {
|
||||
if (!$scope.imagesResource) {
|
||||
loadImages();
|
||||
} else {
|
||||
refreshTree();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$on('$routeUpdate', update);
|
||||
$scope.$watch('selectedTags', update)
|
||||
$scope.$watch('repository', update);
|
||||
|
||||
$scope.$watch('isEnabled', function(isEnabled) {
|
||||
if (isEnabled) {
|
||||
refreshTree();
|
||||
}
|
||||
});
|
||||
|
||||
var refreshTree = function() {
|
||||
if (!$scope.repository || !$scope.images) { return; }
|
||||
|
||||
|
@ -157,10 +156,6 @@ angular.module('quay').directive('repoPanelChanges', function () {
|
|||
$scope.images = resp.images;
|
||||
$scope.tracker = new RepositoryImageTracker($scope.repository, $scope.images);
|
||||
|
||||
$scope.selectedTags = $.grep($scope.selectedTags, function(tag) {
|
||||
return !!$scope.tracker.lookupTag(tag);
|
||||
});
|
||||
|
||||
if ($scope.selectedTags && $scope.selectedTags.length) {
|
||||
refreshTree();
|
||||
}
|
||||
|
@ -193,26 +188,16 @@ angular.module('quay').directive('repoPanelChanges', function () {
|
|||
$scope.tracker = new RepositoryImageTracker($scope.repository, $scope.images);
|
||||
|
||||
data.removed.map(function(tag) {
|
||||
$scope.selectedTags = $.grep($scope.selectedTags, function(cTag) {
|
||||
return cTag != tag;
|
||||
});
|
||||
|
||||
if ($scope.selectedTags.length) {
|
||||
$location.search('tags', $scope.selectedTags.join(','));
|
||||
} else {
|
||||
$location.search('tags', null);
|
||||
}
|
||||
|
||||
$scope.currentImage = null;
|
||||
$scope.currentTag = null;
|
||||
});
|
||||
|
||||
data.added.map(function(tag) {
|
||||
$scope.selectedTags.push(tag);
|
||||
$location.search('tags', $scope.selectedTags.join(','));
|
||||
|
||||
$scope.currentTag = tag;
|
||||
});
|
||||
|
||||
refreshTree();
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
Reference in a new issue