Skip to content

Commit 95d734c

Browse files
author
Hofstetter Benjamin
committed
Merge branch 'dataset-detail-markdown' of https://github.com/opendata-swiss/metadata.swiss into dataset-detail-markdown
2 parents 9b0286a + b637e0a commit 95d734c

File tree

9 files changed

+176
-20
lines changed

9 files changed

+176
-20
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"
@@ -73,4 +74,18 @@ function toggleRaw() {
7374
flex-direction: row;
7475
align-items: center;
7576
}
77+
.dataset-label {
78+
position: relative;
79+
background-color: #e6f0fa;
80+
color: #1976d2;
81+
padding: 2px 10px;
82+
border-radius: 6px;
83+
font-weight: 600;
84+
letter-spacing: 0.03em;
85+
display: inline-block;
86+
margin-right: 10px;
87+
vertical-align: middle;
88+
border: 1px solid #b3d4fc;
89+
}
90+
7691
</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: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ 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'
12+
import OdsDistributionList from '../../../app/components/dataset-detail/OdsDistributionList.vue'
1313
import { useI18n } from 'vue-i18n';
1414
1515
const { locale, t } = useI18n();
@@ -82,17 +82,15 @@ const breadcrumbs = computed(() => {
8282
<section class="section">
8383
<div class="container container--grid gap--responsive">
8484
<div class="container__main vertical-spacing">
85-
8685
<div class="container__mobile">
87-
<div class="box">
88-
<h2 class="h5">Download</h2>
89-
<OdsDownloadsList :dataset="resultEnhanced" />
90-
</div>
9186
<div class="box">
9287
<h2 class="h5">{{ t(`message.header.navigation.terms_of_use`) }}</h2>
9388
<OdsDetailTermsOfUse v-for="value in resultEnhanced?.getLicenses" :key="value" :name="value" />
9489
</div>
9590
</div>
91+
<h2 class="h2">{{ t('message.dataset_detail.distributions') }}</h2>
92+
<OdsDistributionList :dataset="resultEnhanced" />
93+
9694
<h2 class="h2">{{ t('message.dataset_detail.additional_information') }}</h2>
9795
<OdsDetailsTable :root-node="node"/>
9896
<div>
@@ -104,10 +102,6 @@ const breadcrumbs = computed(() => {
104102
</div>
105103
<div class="hidden container__aside md:block">
106104
<div id="aside-content" class="sticky sticky--top">
107-
<div class="box">
108-
<h2 class="h5">{{ t('message.dataset_detail.go_to_resource') }}</h2>
109-
<OdsDownloadsList :dataset="resultEnhanced"/>
110-
</div>
111105
<div class="box">
112106
<h2 class="h5">{{ t(`message.header.navigation.terms_of_use`) }}</h2>
113107
<OdsDetailTermsOfUse v-for="value in resultEnhanced?.getLicenses" :key="value" :name="value" />

0 commit comments

Comments
 (0)