From c0e6660ac928d8fc054176919ce82837dff2455e Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 22 Jan 2019 16:50:42 -0500 Subject: [PATCH] Switch loading of the manifest contents to be lazy We don't need the manifest returned by the tags API except for manifest lists, so just load it lazily --- endpoints/api/tag.py | 5 ---- .../directives/repo-view/repo-panel-tags.html | 8 +++++- .../directives/repo-view/repo-panel-tags.js | 27 +++++++++++++++++-- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/endpoints/api/tag.py b/endpoints/api/tag.py index bdc631254..280853fdf 100644 --- a/endpoints/api/tag.py +++ b/endpoints/api/tag.py @@ -39,11 +39,6 @@ def _tag_dict(tag): tag_info['manifest_digest'] = tag.manifest_digest if tag.manifest: - try: - tag_info['manifest'] = json.loads(tag.manifest.internal_manifest_bytes.as_unicode()) - except (TypeError, ValueError): - pass - tag_info['is_manifest_list'] = tag.manifest.is_manifest_list if 'size' not in tag_info: diff --git a/static/directives/repo-view/repo-panel-tags.html b/static/directives/repo-view/repo-panel-tags.html index e8332b4cc..c805e73d4 100644 --- a/static/directives/repo-view/repo-panel-tags.html +++ b/static/directives/repo-view/repo-panel-tags.html @@ -261,8 +261,14 @@ + + +
+ + + + ng-if="expandedView && tag.is_manifest_list && tag.manifest_list"> diff --git a/static/js/directives/repo-view/repo-panel-tags.js b/static/js/directives/repo-view/repo-panel-tags.js index 9fbe7c2ba..8dfd40184 100644 --- a/static/js/directives/repo-view/repo-panel-tags.js +++ b/static/js/directives/repo-view/repo-panel-tags.js @@ -436,14 +436,37 @@ angular.module('quay').directive('repoPanelTags', function () { delete $scope.labelCache[manifest_digest]; }; + $scope.loadManifestList = function(tag) { + if (tag.manifest_list_loading) { + return; + } + + tag.manifest_list_loading = true; + + var params = { + 'repository': $scope.repository.namespace + '/' + $scope.repository.name, + 'manifestref': tag.manifest_digest + }; + + ApiService.getRepoManifest(null, params).then(function(resp) { + tag.manifest_list = JSON.parse(resp['manifest_data']); + tag.manifest_list_loading = false; + }, ApiService.errorDisplay('Could not load manifest list contents')) + }; + $scope.manifestsOf = function(tag) { - if (!tag.is_manifest_list || !tag.manifest) { + if (!tag.is_manifest_list) { + return []; + } + + if (!tag.manifest_list) { + $scope.loadManifestList(tag); return []; } if (!tag._mapped_manifests) { // Calculate once and cache to avoid angular digest cycles. - tag._mapped_manifests = tag.manifest.manifests.map(function(manifest) { + tag._mapped_manifests = tag.manifest_list.manifests.map(function(manifest) { return { 'raw': manifest, 'os': manifest.platform.os,