Change the repo view page to minimize the number of API calls necessary until such time as the information is needed (lazy load everything). Also increase the build timer to 30s.

This commit is contained in:
Joseph Schorr 2015-05-06 18:16:03 -04:00
parent 03481261e8
commit c04cb4e988
9 changed files with 91 additions and 23 deletions

View file

@ -17,7 +17,13 @@
$scope.namespace = $routeParams.namespace;
$scope.name = $routeParams.name;
$scope.imagesRequired = false;
// Tab-enabled counters.
$scope.logsShown = 0;
$scope.buildsShown = 0;
$scope.settingsShown = 0;
$scope.viewScope = {
'selectedTags': [],
'repository': null,
@ -72,11 +78,17 @@
$scope.setTags($routeParams.tag);
// Load the images.
loadImages();
if ($scope.imagesRequired) {
loadImages();
}
// Track builds.
buildPollChannel = AngularPollChannel.create($scope, loadRepositoryBuilds, 15000 /* 15s */);
buildPollChannel.start();
if (!$scope.repository.is_building) {
$scope.viewScope.builds = [];
}
buildPollChannel = AngularPollChannel.create($scope, loadRepositoryBuilds, 30000 /* 30s */);
buildPollChannel.start(!$scope.repository.is_building);
}, 10);
});
};
@ -139,10 +151,28 @@
$scope.viewScope.selectedTags = $.unique(tagNames.split(','));
};
$scope.showBuilds = function() {
$scope.buildsShown++;
};
$scope.showSettings = function() {
$scope.settingsShown++;
};
$scope.showLogs = function() {
$scope.logsShown++;
};
$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) {
loadImages();
}
$scope.imagesRequired = true;
};
$scope.handleChangesState = function(value) {
$scope.viewScope.changesVisible = value;
};