Add caching for manifest labels

Helps reuse and makes UI faster when filtering
This commit is contained in:
Joseph Schorr 2017-03-08 16:28:23 -05:00
parent f17ef4adda
commit 94c41cc7e3
3 changed files with 9 additions and 1 deletions

View file

@ -244,7 +244,7 @@
<td class="checkbox-col"></td>
<td class="labels-col" colspan="{{5 + (Features.SECURITY_SCANNER ? 1 : 0)}}">
<div class="manifest-label-list" repository="repository"
manifest-digest="tag.manifest_digest"></div>
manifest-digest="tag.manifest_digest" cache="labelCache"></div>
</td>
<td class="hidden-xs hidden-sm image-track" ng-repeat="it in imageTracks"
ng-if="imageTracks.length <= maxTrackCount" bindonce>

View file

@ -36,6 +36,7 @@ angular.module('quay').directive('repoPanelTags', function () {
$scope.tagsPerPage = 25;
$scope.expandedView = false;
$scope.labelCache = {};
$scope.imageVulnerabilities = {};
$scope.defcon1 = {};

View file

@ -11,6 +11,7 @@ angular.module('quay').directive('manifestLabelList', function () {
scope: {
'repository': '=repository',
'manifestDigest': '=manifestDigest',
'cache': '=cache'
},
controller: function($scope, $element, ApiService) {
$scope.labels = null;
@ -24,6 +25,11 @@ angular.module('quay').directive('manifestLabelList', function () {
return;
}
if ($scope.cache[$scope.manifestDigest]) {
$scope.labels = $scope.cache[$scope.manifestDigest];
return;
}
$scope.labels = null;
$scope.loadError = false;
@ -34,6 +40,7 @@ angular.module('quay').directive('manifestLabelList', function () {
ApiService.listManifestLabels(null, params).then(function(resp) {
$scope.labels = resp['labels'];
$scope.cache[$scope.manifestDigest] = resp['labels'];
}, function() {
$scope.loadError = true;
});