-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathItem.vue
151 lines (139 loc) · 4.09 KB
/
Item.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<template>
<div class="p-1 m-0 col-sm-6 col-md-4">
<b-card no-body class="item-card" :class="{queued: !data, deprecated: isDeprecated, description: hasDescription}" v-b-visible.400="load">
<b-card-img-lazy v-if="hasImage" class="thumbnail" offset="200" v-bind="thumbnail" />
<b-card-body>
<b-card-title>
<StacLink :data="[data, item]" class="stretched-link" />
</b-card-title>
<b-card-text v-if="fileFormats.length > 0 || hasDescription || isDeprecated" class="intro">
<b-badge v-if="isDeprecated" variant="warning" class="mr-1 mt-1 deprecated">{{ $t('deprecated') }}</b-badge>
<b-badge v-for="format in fileFormats" :key="format" variant="secondary" class="mr-1 mt-1 fileformat">{{ format | formatMediaType }}</b-badge>
<template v-if="hasDescription">{{ data.properties.description | summarize }}</template>
</b-card-text>
<Keywords v-if="showKeywordsInItemCards && keywords.length > 0" :keywords="keywords" variant="primary" center />
<b-card-text>
<small class="text-muted">
<template v-if="extent">{{ extent | formatTemporalExtent }}</template>
<template v-else-if="data && data.properties.datetime">{{ data.properties.datetime | formatTimestamp }}</template>
<template v-else>{{ $t('items.noTime') }}</template>
</small>
</b-card-text>
</b-card-body>
</b-card>
</div>
</template>
<script>
import { mapState, mapGetters } from 'vuex';
import ThumbnailCardMixin from './ThumbnailCardMixin';
import StacLink from './StacLink.vue';
import STAC from '../models/stac';
import { formatTemporalExtent, formatTimestamp, formatMediaType } from '@radiantearth/stac-fields/formatters';
import Registry from '@radiantearth/stac-fields/registry';
import Utils from '../utils';
Registry.addDependency('content-type', require('content-type'));
export default {
name: 'Item',
components: {
StacLink,
Keywords: () => import('./Keywords.vue')
},
filters: {
summarize: text => Utils.summarizeMd(text, 150),
formatMediaType: value => formatMediaType(value, null, {shorten: true}),
formatTemporalExtent,
formatTimestamp
},
mixins: [
ThumbnailCardMixin
],
props: {
item: {
type: Object,
required: true
}
},
computed: {
...mapState(['showKeywordsInItemCards']),
...mapGetters(['getStac']),
data() {
return this.getStac(this.item);
},
extent() {
if (this.data && (this.data.properties.start_datetime || this.data.properties.end_datetime)) {
return [this.data.properties.start_datetime, this.data.properties.end_datetime];
}
return null;
},
fileFormats() {
if (this.data) {
return this.data.getFileFormats();
}
return [];
},
keywords() {
if (this.data) {
return this.data.getMetadata('keywords') || [];
}
return [];
},
isDeprecated() {
return this.data instanceof STAC && Boolean(this.data.properties.deprecated);
},
hasDescription() {
return this.data instanceof STAC && Utils.hasText(this.data.properties.description);
}
},
methods: {
load(visible) {
if (this.item instanceof STAC) {
return;
}
this.$store.commit(visible ? 'queue' : 'unqueue', this.item.href);
}
}
};
</script>
<style lang="scss">
#stac-browser {
.item-card {
text-align: center;
&.deprecated {
opacity: 0.7;
&:hover {
opacity: 1;
}
}
&.queued {
min-height: 200px;
}
.intro {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
overflow-wrap: anywhere;
margin-bottom: 0.5rem;
}
&.description {
.intro {
text-align: left;
margin-bottom: 0.5rem;
}
}
.badge.deprecated {
text-transform: uppercase;
}
.card-img {
width: auto;
height: auto;
max-width: 100%;
max-height: 200px;
}
.card-body {
text-align: center;
position: relative;
}
}
}
</style>