Skip to content

Commit 1a2387d

Browse files
Merge pull request #12 from opendata-swiss/distribution_list
Show distributions as DownloadList
2 parents ef37a30 + 8cadbca commit 1a2387d

File tree

9 files changed

+177
-26
lines changed

9 files changed

+177
-26
lines changed

opendata.swiss/ui/app/components/OdsCard.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,9 @@ const classes = computed(() => {
5555
</div>
5656
</div>
5757
</template>
58+
59+
<style lang="scss" scoped>
60+
.card {
61+
height: fit-content;
62+
}
63+
</style>

opendata.swiss/ui/app/components/dataset-detail/OdsDatasetMetaInfo.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
2+
<span class="dataset-label">{{ t('message.dataset_detail.dataset') }}</span>
3+
24
<p class="meta-info">
3-
<span class="meta-info__item">{{ t('message.dataset_detail.dataset') }}</span>
45
<span
56
v-if="props.dataset.getCreated"
67
class="meta-info__item"
@@ -74,4 +75,18 @@ function toggleRaw() {
7475
flex-direction: row;
7576
align-items: center;
7677
}
78+
.dataset-label {
79+
position: relative;
80+
background-color: #e6f0fa;
81+
color: #1976d2;
82+
padding: 2px 10px;
83+
border-radius: 6px;
84+
font-weight: 600;
85+
letter-spacing: 0.03em;
86+
display: inline-block;
87+
margin-right: 10px;
88+
vertical-align: middle;
89+
border: 1px solid #b3d4fc;
90+
}
91+
7792
</style>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<template>
2+
<OdsDistributionListItem v-for="item in items" :key="item.id" :item="item" :dataset-id="props.dataset.getId" />
3+
</template>
4+
5+
<script setup lang="ts">
6+
7+
import { computed } from 'vue'
8+
9+
import { useI18n } from 'vue-i18n'
10+
11+
import type { Dataset } from '~/model/dataset';
12+
import OdsDistributionListItem, { type DistributionListItem } from './OdsDistributionListItem.vue';
13+
import type { PropertyTableEntryBase, PropertyTableEntryNode } from '@piveau/sdk-vue';
14+
15+
const { locale } = useI18n()
16+
17+
18+
const props = defineProps({
19+
dataset: {
20+
type: Object as PropType<Dataset>,
21+
required: true
22+
}
23+
})
24+
25+
const items = computed<DistributionListItem[]>(() => {
26+
const distributions = props.dataset.getDistributions
27+
return (distributions || []).map(d => {
28+
const propertyTable = d.getPropertyTable ?? []
29+
const byteSize = findByteSize(propertyTable)
30+
return {
31+
id: d.id ?? '',
32+
title: d.title ?? '',
33+
description: d.description ?? '',
34+
format: d.format ?? '',
35+
modified: d.modified ?? '',
36+
created: d.created ?? '',
37+
issued: d.issued ?? '',
38+
accessUrls: d.accessUrls || [],
39+
downloadUrls: d.downloadUrls || [],
40+
languages: d.languages || [],
41+
byteSize
42+
}}).sort((a, b) => a.title.localeCompare(b.title, locale.value))
43+
})
44+
45+
function findByteSize(table: PropertyTableEntryNode[] | undefined): string {
46+
const byteSizeNode = table?.find(entry => entry.id === 'byteSize')
47+
if(!byteSizeNode) {
48+
return ''
49+
}
50+
const valueEntry = byteSizeNode.data?.find((entry: PropertyTableEntryBase) => entry.id === 'byteSize_value')
51+
if(!valueEntry) {
52+
return ''
53+
}
54+
return valueEntry.data as string
55+
}
56+
57+
</script>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<template>
2+
<div class="download-item">
3+
<!-- spacer if no download URLs -->
4+
<SvgIcon v-if="!props.item.downloadUrls.length" title="No download available. This is probably an api. Check details" icon="Download" size="xl" class="download-item__icon disabled" />
5+
6+
<a v-for="downloadUrl in props.item.downloadUrls" :key="downloadUrl" :href="downloadUrl" target="_blank" rel="noopener" :title="'Download ' + props.item.title" class="download-item__link">
7+
<SvgIcon icon="Download" size="xl" class="download-item__icon" />
8+
</a>
9+
10+
<NuxtLink :to="`${props.datasetId}/distribution/${props.item.id}`" class="no-underline" style="flex-grow: 1;">
11+
<h3 class="download-item__title">{{ props.item.title }}</h3>
12+
<p class="download-item__description" />
13+
14+
<p class="meta-info download-item__meta-info">
15+
<span v-if="item.format" class="meta-info__item">{{ item.format }}</span>
16+
<span v-if="item.issued" class="meta-info__item">{{ item.modified ? item.modified : item.issued }}</span>
17+
<span v-if="item.byteSize" class="meta-info__item">{{ item.byteSize }} Bytes</span>
18+
</p>
19+
<div style="display: flex; justify-content: flex-end; align-items: center; height: 100%; margin-top: -10px; margin-top:-40px;">
20+
<OdsButton icon="ArrowRight" variant="bare" size="sm" class="download-item__button" icon-right :to="`${props.datasetId}/distribution/${props.item.id}`" >
21+
<span>{{ t('message.dataset_detail.details') }}</span>
22+
</OdsButton>
23+
</div>
24+
25+
</NuxtLink>
26+
27+
28+
</div>
29+
</template>
30+
31+
<script setup lang="ts">
32+
import SvgIcon from '../SvgIcon.vue';
33+
import OdsButton from '../OdsButton.vue';
34+
import { useI18n } from 'vue-i18n';
35+
36+
const { t } = useI18n();
37+
38+
const props = defineProps({
39+
item: {
40+
type: Object as PropType<DistributionListItem>,
41+
required: true
42+
},
43+
datasetId: {
44+
type: String,
45+
required: true
46+
}
47+
})
48+
49+
export interface DistributionListItem {
50+
id: string,
51+
title: string,
52+
description: string,
53+
format: string,
54+
modified: string,
55+
created: string,
56+
issued: string,
57+
accessUrls: string[],
58+
downloadUrls: string[],
59+
languages: string[],
60+
byteSize: string
61+
}
62+
63+
</script>
64+
65+
66+
<style scoped lang="scss">
67+
.disabled {
68+
fill: lightgray;
69+
stroke: lightgray;
70+
color: lightgray;
71+
}
72+
.no-underline {
73+
text-decoration: none;
74+
}
75+
76+
</style>

opendata.swiss/ui/i18n/locales/de.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"accrual_periodicity": "Aktualisierungsfrequenz",
4444
"show_catalog_entry": "Katalogeintrag anzeigen",
4545
"hide_catalog_entry": "Katalogeintrag ausblenden",
46-
"distribution": "Verteilung",
46+
"distribution": "Distribution",
47+
"distributions": "Distributionen",
4748
"additional_information": "Zusätzliche Informationen",
4849
"published_on": "Publiziert",
4950
"created_on": "Erstellt",
@@ -52,7 +53,8 @@
5253
"download": "Download",
5354
"go_to_resource": "Gehe zur Ressource",
5455
"show_raw": "Datum anzeigen",
55-
"show_relative": "Relative Zeit anzeigen"
56+
"show_relative": "Relative Zeit anzeigen",
57+
"details": "Details"
5658
},
5759
"showcase": {
5860
"type": {
@@ -124,4 +126,4 @@
124126
}
125127
}
126128
}
127-
}
129+
}

opendata.swiss/ui/i18n/locales/en.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"show_catalog_entry": "Show catalog entry",
4545
"hide_catalog_entry": "Hide catalog entry",
4646
"distribution": "Distribution",
47+
"distributions": "Distributions",
4748
"additional_information": "Additional information",
4849
"published_on": "Published",
4950
"created_on": "Created",
@@ -52,7 +53,8 @@
5253
"download": "Download",
5354
"go_to_resource": "Go to resource",
5455
"show_raw": "Show raw date",
55-
"show_relative": "Show relative time"
56+
"show_relative": "Show relative time",
57+
"details": "Details"
5658
},
5759
"showcase": {
5860
"type": {
@@ -124,4 +126,4 @@
124126
}
125127
}
126128
}
127-
}
129+
}

opendata.swiss/ui/i18n/locales/fr.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"show_catalog_entry": "Afficher l’entrée du catalogue",
4545
"hide_catalog_entry": "Masquer l’entrée du catalogue",
4646
"distribution": "Distribution",
47+
"distributions": "Distributions",
4748
"additional_information": "Informations supplémentaires",
4849
"published_on": "Publié",
4950
"created_on": "Créé",
@@ -52,7 +53,8 @@
5253
"download": "Télécharger",
5354
"go_to_resource": "Aller à la ressource",
5455
"show_raw": "Afficher la date brute",
55-
"show_relative": "Afficher le temps relatif"
56+
"show_relative": "Afficher le temps relatif",
57+
"details": "Détails"
5658
},
5759
"showcase": {
5860
"type": {
@@ -124,4 +126,4 @@
124126
}
125127
}
126128
}
127-
}
129+
}

opendata.swiss/ui/i18n/locales/it.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"show_catalog_entry": "Mostra la voce di catalogo",
4545
"hide_catalog_entry": "Nascondi la voce di catalogo",
4646
"distribution": "Distribuzione",
47+
"distributions": "Distribuzioni",
4748
"additional_information": "Informazioni aggiuntive",
4849
"published_on": "Pubblicato",
4950
"created_on": "Creato",
@@ -52,7 +53,8 @@
5253
"download": "Scarica",
5354
"go_to_resource": "Vai alla risorsa",
5455
"show_raw": "Mostra data grezza",
55-
"show_relative": "Mostra tempo relativo"
56+
"show_relative": "Mostra tempo relativo",
57+
"details": "Dettagli"
5658
},
5759
"showcase": {
5860
"type": {
@@ -124,4 +126,4 @@
124126
}
125127
}
126128
}
127-
}
129+
}

opendata.swiss/ui/pages/datasets/[datasetId]/index.vue

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,10 @@ import OdsBreadcrumbs from "../../../app/components/OdsBreadcrumbs.vue";
88
import OdsDetailTermsOfUse from '../../../app/components/dataset-detail/OdsDetailTermsOfUse.vue'
99
import OdsDetailsTable from '../../../app/components/dataset-detail/OdsDetailsTable.vue'
1010
import OdsTagList from '../../../app/components/dataset-detail/OdsTagList.vue'
11-
import OdsDownloadsList from '../../../app/components/dataset-detail/OdsDownloadsList.vue'
1211
import OdsDatasetMetaInfo from '../../../app/components/dataset-detail/OdsDatasetMetaInfo.vue'
13-
import OdsDatasetCatalogPanel from '../../../app/components/dataset-detail/OdsDatasetCatalogPanel.vue'
12+
import OdsDistributionList from '../../../app/components/dataset-detail/OdsDistributionList.vue'
1413
import { useI18n } from 'vue-i18n';
15-
const md = `
16-
::alert
17-
Hello MDC
18-
::
19-
`
14+
2015
const { locale, t } = useI18n();
2116
const route = useRoute()
2217
const router = useRouter()
@@ -88,17 +83,15 @@ const breadcrumbs = computed(() => {
8883
<section class="section">
8984
<div class="container container--grid gap--responsive">
9085
<div class="container__main vertical-spacing">
91-
9286
<div class="container__mobile">
93-
<div class="box">
94-
<h2 class="h5">Download</h2>
95-
<OdsDownloadsList :dataset="resultEnhanced" />
96-
</div>
9787
<div class="box">
9888
<h2 class="h5">{{ t(`message.header.navigation.terms_of_use`) }}</h2>
9989
<OdsDetailTermsOfUse v-for="value in resultEnhanced?.getLicenses" :key="value" :name="value" />
10090
</div>
10191
</div>
92+
<h2 class="h2">{{ t('message.dataset_detail.distributions') }}</h2>
93+
<OdsDistributionList :dataset="resultEnhanced" />
94+
10295
<h2 class="h2">{{ t('message.dataset_detail.additional_information') }}</h2>
10396
<OdsDetailsTable :root-node="node"/>
10497
<div>
@@ -110,10 +103,6 @@ const breadcrumbs = computed(() => {
110103
</div>
111104
<div class="hidden container__aside md:block">
112105
<div id="aside-content" class="sticky sticky--top">
113-
<div class="box">
114-
<h2 class="h5">{{ t('message.dataset_detail.go_to_resource') }}</h2>
115-
<OdsDownloadsList :dataset="resultEnhanced"/>
116-
</div>
117106
<div class="box">
118107
<h2 class="h5">{{ t(`message.header.navigation.terms_of_use`) }}</h2>
119108
<OdsDetailTermsOfUse v-for="value in resultEnhanced?.getLicenses" :key="value" :name="value" />

0 commit comments

Comments
 (0)