diff --git a/src/components/Catalog.vue b/src/components/Catalog.vue index 21f9f540f..ab57cdf0e 100644 --- a/src/components/Catalog.vue +++ b/src/components/Catalog.vue @@ -49,6 +49,37 @@
+ + + + + + + x.rel === "data"); + if (externalCollections === undefined) { + return []; + } + + try { + const rsp = await fetchUri(externalCollections.href); + if (!rsp.ok) { + console.warn(await rsp.text()); + return []; + } + + const data = await rsp.json(); + if (!data || !Array.isArray(data.collections)) { + console.warn(await rsp.text()); + return []; + } + + return data.collections + .map(collection => { + // strip /collection from the target path + let p = this.path.replace(/^\/collection/, ""); + if (!p.endsWith("/")) { + p += "/"; + } + + // Try to get the location of the collection + let href = externalCollections.href + '/collections/' + collection.id; + if (Array.isArray(collection.links)) { + let selfLink = collection.links.find(l => l.rel == 'self'); + if (selfLink && selfLink.href) { + href = selfLink.href; + } + } + + const resolved = this.resolve(href, this.url); + const slug = this.slugify(resolved); + const to = [p, slug].join(""); + + return Object.assign(collection, { + path: href, + to, + title: collection.title || collection.id || href, + url: resolved + }); + }); + } catch (err) { + console.warn(err); + + return []; + } + } + }, externalItems: { default: [], lazy: true, async get() { const externalItemsLink = this.links.find(x => x.rel === "items"); - if (externalItemsLink == null) { + if (externalItemsLink === undefined) { return []; } try { - const rsp = await fetch( + const rsp = await fetchUri( `${externalItemsLink.href}?page=${this.currentItemPage}` ); @@ -337,8 +440,11 @@ export default { catalog() { return this.entity; }, + collectionCount() { + return this.collections.length; + }, childCount() { - return this.links.filter(x => x.rel === "child").length; + return this.children.length; }, children() { return this.links @@ -351,7 +457,8 @@ export default { p += "/"; } - const slug = this.slugify(this.resolve(child.href, this.url)); + const resolved = this.resolve(child.href, this.url); + const slug = this.slugify(resolved); const to = [p, slug].join(""); return { @@ -359,7 +466,7 @@ export default { to, // child.id is a workaround for https://earthengine-stac.storage.googleapis.com/catalog/catalog.json title: child.title || child.id || child.href, - url: this.resolve(child.href, this.url) + url: resolved }; }); }, @@ -606,6 +713,7 @@ export default { }, visibleTabs() { return [ + this.collectionCount > 0 && "collections", this.childCount > 0 && "catalogs", (this.hasExternalItems || this.itemCount > 0) && "items", this.bands.length > 0 && "bands", diff --git a/src/components/MetadataSidebar.vue b/src/components/MetadataSidebar.vue index 966f897ad..dd55feb87 100644 --- a/src/components/MetadataSidebar.vue +++ b/src/components/MetadataSidebar.vue @@ -47,7 +47,7 @@ -