Add ID-based pagination to logs using new decorators and an encrypted token
Fixes #599
This commit is contained in:
parent
af77b92bcf
commit
bd0a098282
8 changed files with 110 additions and 36 deletions
|
@ -23,7 +23,6 @@ angular.module('quay').directive('logsView', function () {
|
|||
$scope.kindsAllowed = null;
|
||||
$scope.chartVisible = true;
|
||||
$scope.chartLoading = true;
|
||||
$scope.currentPage = 1;
|
||||
|
||||
$scope.options = {};
|
||||
|
||||
|
@ -309,7 +308,7 @@ angular.module('quay').directive('logsView', function () {
|
|||
$scope.chartLoading = false;
|
||||
});
|
||||
|
||||
$scope.currentPage = 0;
|
||||
$scope.nextPageToken = null;
|
||||
$scope.hasAdditional = true;
|
||||
$scope.loading = false;
|
||||
$scope.logs = [];
|
||||
|
@ -317,11 +316,15 @@ angular.module('quay').directive('logsView', function () {
|
|||
};
|
||||
|
||||
$scope.nextPage = function() {
|
||||
if ($scope.loading) { return; }
|
||||
if ($scope.loading || !$scope.hasAdditional) { return; }
|
||||
|
||||
$scope.loading = true;
|
||||
|
||||
var logsUrl = getUrl('logs') + '&page=' + ($scope.currentPage + 1);
|
||||
var logsUrl = getUrl('logs');
|
||||
if ($scope.nextPageToken) {
|
||||
logsUrl = logsUrl + '&next_page=' + encodeURIComponent($scope.nextPageToken);
|
||||
}
|
||||
|
||||
var loadLogs = Restangular.one(logsUrl);
|
||||
loadLogs.customGET().then(function(resp) {
|
||||
resp.logs.forEach(function(log) {
|
||||
|
@ -329,8 +332,8 @@ angular.module('quay').directive('logsView', function () {
|
|||
});
|
||||
|
||||
$scope.loading = false;
|
||||
$scope.currentPage = resp.page;
|
||||
$scope.hasAdditional = resp.has_additional;
|
||||
$scope.nextPageToken = resp.next_page;
|
||||
$scope.hasAdditional = !!resp.next_page;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Reference in a new issue