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:
Joseph Schorr 2015-05-07 15:51:49 -04:00
parent 8eb9c376cd
commit 23fafa6b4a
7 changed files with 107 additions and 38 deletions

View file

@ -64,6 +64,9 @@
};
var loadRepository = function() {
// Mark the images to be reloaded.
$scope.viewScope.images = null;
var params = {
'repository': $scope.namespace + '/' + $scope.name
};
@ -77,11 +80,6 @@
$timeout(function() {
$scope.setTags($routeParams.tag);
// Load the images.
if ($scope.imagesRequired) {
loadImages();
}
// Track builds.
if (!$scope.repository.is_building) {
$scope.viewScope.builds = [];
@ -93,13 +91,14 @@
});
};
var loadImages = function() {
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);
});
};
@ -166,16 +165,18 @@
$scope.requireImages = function() {
// Lazily load the repo's images if this is the first call to a tab
// that needs the images.
if (!$scope.imagesRequired) {
if ($scope.viewScope.images == null) {
loadImages();
}
$scope.imagesRequired = true;
};
$scope.handleChangesState = function(value) {
$scope.viewScope.changesVisible = value;
};
$scope.getImages = function(callback) {
loadImages(callback);
};
}
function OldRepoViewCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiService, $routeParams, $rootScope, $location, $timeout, Config, UtilService) {