Skip to content

Commit 076cc33

Browse files
committed
Show metadata information in App Mode
1 parent 9eaa99b commit 076cc33

File tree

2 files changed

+83
-3
lines changed

2 files changed

+83
-3
lines changed

src/components/Viewer.vue

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<template #dynamic="{ tab }">
66
<LogViewer v-if="logViewerIcons.includes(tab.icon)" :data="tab.data" @mounted="onMounted" @options="onOptionsChanged" />
77
<component v-else-if="tab.data.component" :is="tab.data.component" v-on="tab.data.events" v-bind="tab.data.props" @mounted="onMounted" @options="onOptionsChanged" /> <!-- for file formats -->
8+
<MetadataViewer v-if="tab.icon === 'fa-info'" :data="tab.data" @mounted="onMounted" @options="onOptionsChanged" /> <!-- for STAC metadata -->
89
<MapViewer v-else-if="tab.icon === 'fa-map'" :data="tab.data" :removableLayers="isCollectionPreview(tab.data)" @mounted="onMounted" @options="onOptionsChanged" /> <!-- for services -->
910
<div class="unsupported" v-else>
1011
Sorry, the viewer doesn't support showing this type of data.
@@ -35,7 +36,8 @@ export default {
3536
TableViewer: () => import('./viewer/TableViewer.vue'),
3637
ImageViewer: () => import('./viewer/ImageViewer.vue'),
3738
LogViewer: () => import('./viewer/LogViewer.vue'),
38-
MapViewer: () => import('./viewer/MapViewer.vue')
39+
MapViewer: () => import('./viewer/MapViewer.vue'),
40+
MetadataViewer: () => import('./viewer/MetadataViewer.vue')
3941
},
4042
mounted() {
4143
this.listen('viewSyncResult', this.showSyncResults);
@@ -84,7 +86,7 @@ export default {
8486
this.showWebService(service);
8587
}
8688
else {
87-
this.showJobResults(this.appMode.data, null, this.appMode.title);
89+
this.showJobResults(this.appMode.data, null, this.appMode.title, true);
8890
if (typeof this.appMode.expires === 'string') {
8991
const expires = Formatters.formatTimestamp(this.appMode.expires);
9092
Utils.info(this, `The shared data is available until ${expires}`);
@@ -181,7 +183,7 @@ export default {
181183
}
182184
});
183185
},
184-
showJobResults(stac, job = null, title = null) {
186+
showJobResults(stac, job = null, title = null, showMetadata = false) {
185187
if (title === null) {
186188
if (stac.title) {
187189
title = stac.title;
@@ -205,6 +207,9 @@ export default {
205207
else if (files.length > 5 && !Utils.confirmOpenAll(files)) {
206208
return;
207209
}
210+
if (showMetadata) {
211+
this.showMetadataViewer(stac, id, title);
212+
}
208213
this.showViewer(files, title, file => `${id}-${file.getUrl()}`, true)
209214
.catch(error => Utils.exception(this, error));
210215
},
@@ -232,6 +237,20 @@ export default {
232237
onClose
233238
);
234239
},
240+
showMetadataViewer(resource, id = null, title = null) {
241+
if (!title) {
242+
title = Utils.getResourceTitle(resource, true);
243+
}
244+
if (!id) {
245+
id = this.nextTabId;
246+
this.tabIdCounter++;
247+
}
248+
this.$refs.tabs.addTab(
249+
title, "fa-info", resource, id, true, true,
250+
tab => this.onShow(tab),
251+
tab => this.onHide(tab)
252+
);
253+
},
235254
addToMapChooser({asset, context}) {
236255
const openMapTabs = this.$refs.tabs.tabs.filter(tab => tab.icon === 'fa-map');
237256
const maps = [
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<template>
2+
<div class="metadataViewer">
3+
<Collection v-if="isCollection" :data="data">
4+
<template #spatial-extents="p">
5+
<MapExtentViewer class="jobMap" :footprint="p.extents"></MapExtentViewer>
6+
</template>
7+
</Collection>
8+
<Item v-else-if="isItem" :data="data">
9+
<template #location="p">
10+
<MapExtentViewer class="jobMap" :footprint="p.geometry || p.bbox"></MapExtentViewer>
11+
</template>
12+
</Item>
13+
<ul class="list">
14+
<StacAsset v-for="(asset, id) in data.assets" :key="id" :asset="asset" :id="id" :context="data" />
15+
</ul>
16+
</div>
17+
</template>
18+
19+
<script>
20+
let tabId = 0;
21+
22+
export default {
23+
name: 'MetadataViewer',
24+
props: {
25+
data: {
26+
type: Object,
27+
required: true
28+
}
29+
},
30+
components: {
31+
Collection: () => import('@openeo/vue-components/components/Collection.vue'),
32+
Item: () => import('@openeo/vue-components/components/Item.vue'),
33+
MapExtentViewer: () => import('../maps/MapExtentViewer.vue'),
34+
StacAsset: () => import('@openeo/vue-components/components/internal/StacAsset.vue'),
35+
},
36+
computed: {
37+
isCollection() {
38+
return this.data.type === 'Collection';
39+
},
40+
isItem() {
41+
return this.data.type === 'Feature';
42+
}
43+
},
44+
data() {
45+
return {
46+
tabsId: "metadata_viewer_" + tabId++,
47+
};
48+
},
49+
mounted() {
50+
this.$emit('mounted', this);
51+
}
52+
};
53+
</script>
54+
55+
<style lang="scss" scoped>
56+
.metadataViewer {
57+
width: 98%;
58+
height: 98%;
59+
padding: 1%;
60+
}
61+
</style>

0 commit comments

Comments
 (0)