Make images loaded lazily on the repo tags page, as they will not be needed in the read-only (common) case.
This commit is contained in:
parent
8eb9c376cd
commit
23fafa6b4a
7 changed files with 107 additions and 38 deletions
|
@ -13,6 +13,8 @@ angular.module('quay').directive('repoPanelTags', function () {
|
|||
'selectedTags': '=selectedTags',
|
||||
'imagesResource': '=imagesResource',
|
||||
'images': '=images',
|
||||
|
||||
'getImages': '&getImages'
|
||||
},
|
||||
controller: function($scope, $element, $filter, $location, ApiService, UIService) {
|
||||
var orderBy = $filter('orderBy');
|
||||
|
|
|
@ -14,10 +14,17 @@ angular.module('quay').directive('tagOperationsDialog', function () {
|
|||
'images': '=images',
|
||||
'actionHandler': '=actionHandler',
|
||||
|
||||
'getImages': '&getImages',
|
||||
'tagChanged': '&tagChanged'
|
||||
},
|
||||
controller: function($scope, $element, $timeout, ApiService) {
|
||||
$scope.addingTag = false;
|
||||
$scope.imagesInternal = [];
|
||||
|
||||
$scope.$watch('images', function(images) {
|
||||
if (!images) { return; }
|
||||
$scope.imagesInternal = images;
|
||||
});
|
||||
|
||||
var markChanged = function(added, removed) {
|
||||
// Reload the repository and the images.
|
||||
|
@ -142,39 +149,70 @@ angular.module('quay').directive('tagOperationsDialog', function () {
|
|||
}, errorHandler);
|
||||
};
|
||||
|
||||
var lazyLoadImages = function(callback) {
|
||||
if ($scope.imagesInternal.length) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
var isLoading = true;
|
||||
$timeout(function() {
|
||||
if (isLoading) {
|
||||
$('#loadingImagesModal').modal({});
|
||||
}
|
||||
}, 500);
|
||||
|
||||
var cb = function(images) {
|
||||
isLoading = false;
|
||||
$('#loadingImagesModal').modal('hide');
|
||||
$scope.imagesInternal = images;
|
||||
callback();
|
||||
};
|
||||
|
||||
$scope.getImages({'callback': cb});
|
||||
};
|
||||
|
||||
$scope.actionHandler = {
|
||||
'askDeleteTag': function(tag) {
|
||||
$scope.deleteTagInfo = {
|
||||
'tag': tag
|
||||
};
|
||||
lazyLoadImages(function() {
|
||||
$scope.deleteTagInfo = {
|
||||
'tag': tag
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
'askDeleteMultipleTags': function(tags) {
|
||||
$scope.deleteMultipleTagsInfo = {
|
||||
'tags': tags
|
||||
};
|
||||
lazyLoadImages(function() {
|
||||
$scope.deleteMultipleTagsInfo = {
|
||||
'tags': tags
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
'askAddTag': function(image) {
|
||||
$scope.tagToCreate = '';
|
||||
$scope.toTagImage = image;
|
||||
$scope.addingTag = false;
|
||||
$scope.addTagForm.$setPristine();
|
||||
$element.find('#createOrMoveTagModal').modal('show');
|
||||
lazyLoadImages(function() {
|
||||
$scope.tagToCreate = '';
|
||||
$scope.toTagImage = image;
|
||||
$scope.addingTag = false;
|
||||
$scope.addTagForm.$setPristine();
|
||||
$element.find('#createOrMoveTagModal').modal('show');
|
||||
});
|
||||
},
|
||||
|
||||
'askRevertTag': function(tag, image_id) {
|
||||
if (tag.image_id == image_id) {
|
||||
bootbox.alert('This is the current image for the tag');
|
||||
return;
|
||||
}
|
||||
lazyLoadImages(function() {
|
||||
if (tag.image_id == image_id) {
|
||||
bootbox.alert('This is the current image for the tag');
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.revertTagInfo = {
|
||||
'tag': tag,
|
||||
'image_id': image_id
|
||||
};
|
||||
$scope.revertTagInfo = {
|
||||
'tag': tag,
|
||||
'image_id': image_id
|
||||
};
|
||||
|
||||
$element.find('#revertTagModal').modal('show');
|
||||
$element.find('#revertTagModal').modal('show');
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Reference in a new issue