@datagouv/components-next 1.0.2-dev.20 → 1.0.2-dev.200
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/assets/main.css +4 -0
- package/dist/{Control-DuZJdKV_.js → Control-B9WQxlpJ.js} +1 -1
- package/dist/{Datafair.client-Ds3VQrRi.js → Datafair.client-CFTmBFoY.js} +9 -9
- package/dist/{Event--kp8kMdJ.js → Event-iXDrp-fy.js} +31 -31
- package/dist/{Image-34hvypZI.js → Image-mNMBOofs.js} +9 -9
- package/dist/ImagePreview.client-BvDM3qjE.js +36 -0
- package/dist/JsonPreview.client-BP6gPRxf.js +40 -0
- package/dist/{Map-BjUnLyj8.js → Map-BfqKMw0S.js} +1739 -1599
- package/dist/{MapContainer.client-B2BijMx5.js → MapContainer.client-D9N3664r.js} +41 -42
- package/dist/{OSM-s40W6sQ2.js → OSM-CcrUhItr.js} +15 -23
- package/dist/{PdfPreview.client-DJBMzrlC.js → PdfPreview.client-C6A6ZiKl.js} +835 -856
- package/dist/Pmtiles.client-B_sDZoqu.js +26333 -0
- package/dist/PreviewWrapper.vue_vue_type_script_setup_true_lang-DGLXBys_.js +60 -0
- package/dist/{ScaleLine-KW-nXqp3.js → ScaleLine-VGQ7nkMS.js} +2 -2
- package/dist/{Tile-DbNFNPfU.js → Tile-CSpn0Ca8.js} +160 -163
- package/dist/{TileImage-BsXBxMtq.js → TileImage-CpbaEFwd.js} +143 -131
- package/dist/{View-BR92hTWP.js → View-BYBpt-AU.js} +483 -422
- package/dist/XmlPreview.client-DFQ1T-LN.js +34 -0
- package/dist/{common-PJfpC179.js → common-BoeTUnDZ.js} +52 -52
- package/dist/components-next.css +1 -52
- package/dist/components-next.js +196 -150
- package/dist/components.css +2 -2
- package/dist/{index-BFQX7Ccz.js → index-B_tPYi5Z.js} +34094 -27864
- package/dist/{leaflet-src-7m1mB8LI.js → leaflet-src-PeylHk0o.js} +162 -164
- package/dist/{main-vqhkVhVS.js → main-CVOZp_Nx.js} +41939 -73132
- package/dist/{proj-DsetBcW7.js → proj-DxGbobp7.js} +662 -626
- package/dist/{text-clamp.esm-B5kW_XMt.js → text-clamp.esm-DVseBqZZ.js} +4 -4
- package/dist/{tilecoord-Db24Px13.js → tilecoord-DvX7WWiA.js} +273 -264
- package/dist/{vue3-json-viewer-BXwup7nO.js → vue3-json-viewer-CJLQFzXZ.js} +10 -16
- package/dist/{vue3-xml-viewer.common-BcNJo35o.js → vue3-xml-viewer.common-CcF3Xd23.js} +1 -1
- package/package.json +47 -38
- package/src/chart.ts +5 -0
- package/src/components/ActivityList/ActivityList.vue +24 -14
- package/src/components/AppLink.vue +3 -0
- package/src/components/BannerAction.vue +6 -2
- package/src/components/Chart/ChartViewer.vue +320 -0
- package/src/components/Chart/ChartViewerWrapper.vue +182 -0
- package/src/components/CopyButton.vue +6 -2
- package/src/components/DataserviceCard.vue +24 -5
- package/src/components/DataserviceQuality.vue +82 -0
- package/src/components/DataserviceQualityInline.vue +31 -0
- package/src/components/DataserviceQualityTooltipContent.vue +79 -0
- package/src/components/DatasetCard.vue +24 -9
- package/src/components/DatasetInformation/DatasetTemporalitySection.vue +7 -4
- package/src/components/DatasetQuality.vue +11 -11
- package/src/components/DatasetQualityInline.vue +2 -2
- package/src/components/DatasetQualityTooltipContent.vue +1 -1
- package/src/components/DiscussionMessageCard.vue +14 -15
- package/src/components/Form/Listbox.vue +101 -0
- package/src/components/Form/SchemaSelect.vue +2 -0
- package/src/components/FormattedDate.vue +81 -0
- package/src/components/InfiniteLoader.vue +53 -0
- package/src/components/LoadingBlock.vue +4 -1
- package/src/components/ObjectCardHeader.vue +11 -4
- package/src/components/OpenApiViewer/ContentTypeSelect.vue +48 -0
- package/src/components/OpenApiViewer/EndpointRequest.vue +164 -0
- package/src/components/OpenApiViewer/EndpointResponses.vue +149 -0
- package/src/components/OpenApiViewer/OpenApiViewer.vue +308 -0
- package/src/components/OpenApiViewer/SchemaPanel.vue +53 -0
- package/src/components/OpenApiViewer/SchemaTree.vue +77 -0
- package/src/components/OpenApiViewer/openapi.ts +150 -0
- package/src/components/OrganizationNameWithCertificate.vue +3 -2
- package/src/components/Pagination.vue +25 -62
- package/src/components/PostCard.vue +13 -15
- package/src/components/RadioInput.vue +7 -2
- package/src/components/ResourceAccordion/DataStructure.vue +11 -33
- package/src/components/ResourceAccordion/Datafair.client.vue +1 -1
- package/src/components/ResourceAccordion/Downloads.vue +172 -0
- package/src/components/ResourceAccordion/ImagePreview.client.vue +48 -0
- package/src/components/ResourceAccordion/JsonPreview.client.vue +23 -104
- package/src/components/ResourceAccordion/MapContainer.client.vue +2 -11
- package/src/components/ResourceAccordion/Metadata.vue +4 -6
- package/src/components/ResourceAccordion/PdfPreview.client.vue +58 -97
- package/src/components/ResourceAccordion/PdfSkeleton.vue +44 -0
- package/src/components/ResourceAccordion/Pmtiles.client.vue +28 -13
- package/src/components/ResourceAccordion/Preview.vue +19 -15
- package/src/components/ResourceAccordion/PreviewWrapper.vue +89 -0
- package/src/components/ResourceAccordion/ResourceAccordion.vue +36 -117
- package/src/components/ResourceAccordion/XmlPreview.client.vue +16 -98
- package/src/components/ResourceExplorer/ResourceExplorer.vue +105 -210
- package/src/components/ResourceExplorer/ResourceExplorerHeader.vue +79 -0
- package/src/components/ResourceExplorer/ResourceExplorerSidebar.vue +104 -71
- package/src/components/ResourceExplorer/ResourceExplorerViewer.vue +143 -291
- package/src/components/ResourceExplorer/ResourceMainAction.vue +240 -0
- package/src/components/ResourceExplorer/ResourceSelector.vue +51 -0
- package/src/components/ResourceExplorer/ResourceViewerHeader.vue +122 -0
- package/src/components/ResourceExplorer/ResourceViewerSkeleton.vue +94 -0
- package/src/components/ResourceListItem.vue +168 -0
- package/src/components/ReuseCard.vue +28 -9
- package/src/components/ReuseDetails.vue +2 -2
- package/src/components/ReuseHorizontalCard.vue +2 -2
- package/src/components/SchemaCard.vue +10 -1
- package/src/components/Search/Filter/AccessTypeFilter.vue +2 -2
- package/src/components/Search/GlobalSearch.vue +229 -123
- package/src/components/Search/SearchInput.vue +5 -4
- package/src/components/Search/Sidemenu.vue +4 -3
- package/src/components/SmallChart.vue +11 -10
- package/src/components/StatBox.vue +13 -5
- package/src/components/TabularExplorer/TabularActiveFilters.vue +79 -0
- package/src/components/TabularExplorer/TabularCell.vue +50 -0
- package/src/components/TabularExplorer/TabularCellPopover.vue +170 -0
- package/src/components/TabularExplorer/TabularColumnsMenu.vue +112 -0
- package/src/components/TabularExplorer/TabularExplorer.vue +299 -0
- package/src/components/TabularExplorer/TabularFilterContent.vue +362 -0
- package/src/components/TabularExplorer/TabularFilterPopover.vue +106 -0
- package/src/components/TabularExplorer/TabularMobileFilterButton.vue +21 -0
- package/src/components/TabularExplorer/TabularMobileFilters.vue +150 -0
- package/src/components/TabularExplorer/TabularRowsInfo.vue +31 -0
- package/src/components/TabularExplorer/TabularSkeleton.vue +92 -0
- package/src/components/TabularExplorer/TabularTable.vue +481 -0
- package/src/components/TabularExplorer/TabularToolbar.vue +25 -0
- package/src/components/TabularExplorer/types.ts +84 -0
- package/src/components/TabularExplorer/useColumnMetadata.ts +98 -0
- package/src/components/TabularExplorer/useTabularContext.ts +82 -0
- package/src/components/TopicCard.vue +13 -14
- package/src/composables/useActiveDescendant.ts +5 -0
- package/src/composables/useDatasetResources.ts +164 -0
- package/src/composables/useHasTabularData.ts +15 -1
- package/src/composables/useMetrics.ts +1 -1
- package/src/composables/useResizable.ts +46 -0
- package/src/composables/useResourceCapabilities.ts +48 -40
- package/src/composables/useSearchFilter.ts +120 -0
- package/src/composables/useStableQueryParams.ts +38 -6
- package/src/composables/useTabularProfile.ts +70 -0
- package/src/composables/useTranslation.ts +24 -9
- package/src/config.ts +21 -3
- package/src/functions/activities.ts +3 -3
- package/src/functions/api.ts +20 -42
- package/src/functions/api.types.ts +1 -0
- package/src/functions/charts.ts +99 -0
- package/src/functions/datasets.ts +0 -17
- package/src/functions/dates.ts +6 -7
- package/src/functions/helpers.ts +15 -0
- package/src/functions/metrics.ts +63 -60
- package/src/functions/paginate.ts +46 -0
- package/src/functions/resourceCapabilities.ts +34 -0
- package/src/functions/resources.ts +136 -1
- package/src/functions/schemas.ts +27 -0
- package/src/functions/scroll.ts +20 -0
- package/src/functions/tabular.ts +214 -0
- package/src/functions/tabularApi.ts +96 -11
- package/src/main.ts +119 -14
- package/src/types/dataservices.ts +17 -0
- package/src/types/organizations.ts +10 -0
- package/src/types/pages.ts +0 -5
- package/src/types/posts.ts +2 -2
- package/src/types/reports.ts +5 -1
- package/src/types/resources.ts +0 -1
- package/src/types/reuses.ts +12 -1
- package/src/types/search.ts +63 -1
- package/src/types/site.ts +5 -3
- package/src/types/ui.ts +2 -0
- package/src/types/users.ts +2 -1
- package/src/types/visualizations.ts +93 -0
- package/assets/swagger-themes/newspaper.css +0 -1670
- package/dist/JsonPreview.client-CYxmz0yV.js +0 -72
- package/dist/Pmtiles.client-C_hvRDuy.js +0 -25185
- package/dist/Swagger.client-B4y0hXME.js +0 -4
- package/dist/XmlPreview.client-LETEfNBH.js +0 -64
- package/src/components/ResourceAccordion/Swagger.client.vue +0 -48
- package/src/functions/pagination.ts +0 -9
- /package/src/components/{DatasetQualityItem.vue → QualityItem.vue} +0 -0
- /package/src/components/{DatasetQualityItemWarning.vue → QualityItemWarning.vue} +0 -0
- /package/src/components/{DatasetQualityScore.vue → QualityScore.vue} +0 -0
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
</li>
|
|
20
20
|
<li>
|
|
21
21
|
<a
|
|
22
|
-
:href="getHref(
|
|
22
|
+
:href="getHref(currentPage - 1)"
|
|
23
23
|
class="fr-pagination__link fr-pagination__link--prev fr-pagination__link--lg-label"
|
|
24
24
|
data-testid="previous-page"
|
|
25
25
|
@click.prevent.stop="previousPage"
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
</li>
|
|
30
30
|
<li>
|
|
31
31
|
<a
|
|
32
|
-
:aria-current="
|
|
32
|
+
:aria-current="currentPage === 1 ? 'page' : undefined"
|
|
33
33
|
:href="getHref(1)"
|
|
34
34
|
class="fr-pagination__link"
|
|
35
|
-
:class="{ 'fr-hidden fr-unhidden-sm':
|
|
35
|
+
:class="{ 'fr-hidden fr-unhidden-sm': currentPage > 1 }"
|
|
36
36
|
:title="t('Page {nb}', { nb: 1 })"
|
|
37
37
|
:data-testid="1"
|
|
38
38
|
@click.prevent.stop="onClick(1)"
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
<a
|
|
48
48
|
v-if="index"
|
|
49
49
|
class="fr-pagination__link"
|
|
50
|
-
:class="{ 'fr-hidden fr-unhidden-lg': index <
|
|
51
|
-
:aria-current="
|
|
50
|
+
:class="{ 'fr-hidden fr-unhidden-lg': index < currentPage - 1 || index > currentPage + 1 }"
|
|
51
|
+
:aria-current="currentPage === index ? 'page' : undefined"
|
|
52
52
|
:href="getHref(index)"
|
|
53
53
|
:title="t('Page {nb}', { nb: index })"
|
|
54
54
|
:data-testid="index"
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
<li>
|
|
67
67
|
<a
|
|
68
68
|
class="fr-pagination__link"
|
|
69
|
-
:aria-current="
|
|
69
|
+
:aria-current="currentPage === pageCount ? 'page' : undefined"
|
|
70
70
|
:href="getHref(pageCount)"
|
|
71
71
|
:title="t('Page {nb}', { nb: pageCount })"
|
|
72
72
|
:data-testid="pageCount"
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
<li>
|
|
79
79
|
<a
|
|
80
80
|
class="fr-pagination__link fr-pagination__link--next fr-pagination__link--lg-label"
|
|
81
|
-
:href="getHref(
|
|
81
|
+
:href="getHref(currentPage + 1)"
|
|
82
82
|
data-testid="next-page"
|
|
83
83
|
@click.prevent.stop="nextPage"
|
|
84
84
|
>
|
|
@@ -101,7 +101,10 @@
|
|
|
101
101
|
|
|
102
102
|
<script setup lang="ts">
|
|
103
103
|
import { computed, useTemplateRef } from 'vue'
|
|
104
|
+
import { useRoute } from 'vue-router'
|
|
104
105
|
import { useTranslation } from '../composables/useTranslation'
|
|
106
|
+
import { clampPage, getVisiblePages } from '../functions/paginate'
|
|
107
|
+
import { scrollToBlockTop } from '../functions/scroll'
|
|
105
108
|
|
|
106
109
|
type Props = {
|
|
107
110
|
/**
|
|
@@ -112,10 +115,6 @@ type Props = {
|
|
|
112
115
|
* The page size.
|
|
113
116
|
*/
|
|
114
117
|
pageSize?: number
|
|
115
|
-
/**
|
|
116
|
-
* Customize the links used
|
|
117
|
-
*/
|
|
118
|
-
link?: (page: number) => string
|
|
119
118
|
/**
|
|
120
119
|
* The number of items in the collection. It's used to calculated the number of pages.
|
|
121
120
|
*/
|
|
@@ -131,77 +130,36 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
131
130
|
pageSize: 20,
|
|
132
131
|
})
|
|
133
132
|
|
|
134
|
-
const PAGES_AROUND = 3
|
|
135
|
-
|
|
136
|
-
function range(size: number, startAt = 1) {
|
|
137
|
-
return [...Array(size).keys()].map(i => i + startAt)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function getPages(pageCount: number) {
|
|
141
|
-
return range(pageCount)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function getPagesShown(pages: { length: number }, currentPage: number) {
|
|
145
|
-
return Math.min(
|
|
146
|
-
PAGES_AROUND * 2 + 1,
|
|
147
|
-
pages.length - 2,
|
|
148
|
-
PAGES_AROUND + currentPage - 1,
|
|
149
|
-
PAGES_AROUND + pages.length - currentPage,
|
|
150
|
-
)
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function getStartPage(currentPage: number) {
|
|
154
|
-
return Math.max(
|
|
155
|
-
currentPage - PAGES_AROUND, // we want to start 3 pages before the current one
|
|
156
|
-
2, // we don't want to start below page 2
|
|
157
|
-
)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function getVisiblePages(currentPage: number, pageCount: number) {
|
|
161
|
-
const pages = getPages(pageCount)
|
|
162
|
-
const start = getStartPage(currentPage)
|
|
163
|
-
if (pageCount <= 2) {
|
|
164
|
-
return []
|
|
165
|
-
}
|
|
166
|
-
const pagination: Array<number | null> = range(getPagesShown(pages, currentPage), start)
|
|
167
|
-
if (!pagination.includes(2)) {
|
|
168
|
-
pagination.unshift(null)
|
|
169
|
-
}
|
|
170
|
-
if (!pagination.includes(pageCount - 1)) {
|
|
171
|
-
pagination.push(null)
|
|
172
|
-
}
|
|
173
|
-
return pagination
|
|
174
|
-
}
|
|
175
|
-
|
|
176
133
|
const { t } = useTranslation()
|
|
134
|
+
const route = useRoute()
|
|
177
135
|
const pageCount = computed(() => Math.ceil(props.totalResults / props.pageSize))
|
|
178
|
-
|
|
136
|
+
// The `page` prop often comes straight from a query string, so it is normalised
|
|
137
|
+
// once here and every link below builds on an existing page.
|
|
138
|
+
const currentPage = computed(() => clampPage(props.page, pageCount.value))
|
|
139
|
+
const visiblePages = computed(() => getVisiblePages(currentPage.value, pageCount.value))
|
|
179
140
|
|
|
180
141
|
const nav = useTemplateRef('navRef')
|
|
181
142
|
function change(index: number) {
|
|
182
143
|
emit('change', index)
|
|
183
144
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
nav.value.parentElement.style.scrollMarginTop = '100px'
|
|
187
|
-
nav.value.parentElement.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
|
145
|
+
scrollToBlockTop(nav.value?.parentElement)
|
|
188
146
|
}
|
|
189
147
|
|
|
190
148
|
function onClick(index: number) {
|
|
191
|
-
if (index !==
|
|
149
|
+
if (index !== currentPage.value) {
|
|
192
150
|
change(index)
|
|
193
151
|
}
|
|
194
152
|
}
|
|
195
153
|
|
|
196
154
|
function nextPage() {
|
|
197
|
-
const index =
|
|
155
|
+
const index = currentPage.value + 1
|
|
198
156
|
if (index <= pageCount.value) {
|
|
199
157
|
change(index)
|
|
200
158
|
}
|
|
201
159
|
}
|
|
202
160
|
|
|
203
161
|
function previousPage() {
|
|
204
|
-
const index =
|
|
162
|
+
const index = currentPage.value - 1
|
|
205
163
|
if (index > 0) {
|
|
206
164
|
change(index)
|
|
207
165
|
}
|
|
@@ -211,6 +169,11 @@ function getHref(forPage: number) {
|
|
|
211
169
|
if (forPage < 1 || forPage > pageCount.value) {
|
|
212
170
|
return undefined
|
|
213
171
|
}
|
|
214
|
-
|
|
172
|
+
if (currentPage.value === forPage) {
|
|
173
|
+
return undefined
|
|
174
|
+
}
|
|
175
|
+
const search = new URLSearchParams(route.query as Record<string, string>)
|
|
176
|
+
search.set('page', forPage.toFixed(0))
|
|
177
|
+
return `${route.path}?${search.toString()}`
|
|
215
178
|
}
|
|
216
179
|
</script>
|
|
@@ -23,12 +23,20 @@
|
|
|
23
23
|
|
|
24
24
|
<ObjectCardShortDescription :text="post.headline || post.content" />
|
|
25
25
|
|
|
26
|
-
<
|
|
26
|
+
<TranslationT
|
|
27
27
|
v-if="post.published || post.created_at"
|
|
28
|
+
tag="div"
|
|
28
29
|
class="text-sm text-gray-medium mt-1"
|
|
30
|
+
keypath="Publié {date}"
|
|
29
31
|
>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
<template #date>
|
|
33
|
+
<FormattedDate
|
|
34
|
+
:date="post.published || post.created_at"
|
|
35
|
+
format="relative"
|
|
36
|
+
:options="{ dateStyle: 'long', timeStyle: 'short' }"
|
|
37
|
+
/>
|
|
38
|
+
</template>
|
|
39
|
+
</TranslationT>
|
|
32
40
|
|
|
33
41
|
<slot />
|
|
34
42
|
</ObjectCard>
|
|
@@ -37,26 +45,16 @@
|
|
|
37
45
|
<script setup lang="ts">
|
|
38
46
|
import { RiArticleLine } from '@remixicon/vue'
|
|
39
47
|
import type { RouteLocationRaw } from 'vue-router'
|
|
40
|
-
import { useFormatDate } from '../functions/dates'
|
|
41
|
-
import { useTranslation } from '../composables/useTranslation'
|
|
42
48
|
import type { Post } from '../types/posts'
|
|
43
49
|
import Placeholder from './Placeholder.vue'
|
|
44
50
|
import ObjectCard from './ObjectCard.vue'
|
|
45
51
|
import ObjectCardHeader from './ObjectCardHeader.vue'
|
|
46
52
|
import ObjectCardShortDescription from './ObjectCardShortDescription.vue'
|
|
53
|
+
import FormattedDate from './FormattedDate.vue'
|
|
54
|
+
import TranslationT from './TranslationT.vue'
|
|
47
55
|
|
|
48
56
|
defineProps<{
|
|
49
57
|
post: Post
|
|
50
58
|
postUrl?: RouteLocationRaw
|
|
51
59
|
}>()
|
|
52
|
-
|
|
53
|
-
const { t } = useTranslation()
|
|
54
|
-
const { formatRelativeIfRecentDate } = useFormatDate()
|
|
55
|
-
|
|
56
|
-
const formatDate = (dateString: string) => {
|
|
57
|
-
return formatRelativeIfRecentDate(dateString, {
|
|
58
|
-
dateStyle: 'long',
|
|
59
|
-
timeStyle: 'short',
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
60
|
</script>
|
|
@@ -13,9 +13,14 @@
|
|
|
13
13
|
>
|
|
14
14
|
<component
|
|
15
15
|
:is="icon"
|
|
16
|
-
v-if="icon"
|
|
16
|
+
v-if="icon && typeof icon !== 'string'"
|
|
17
17
|
class="w-4 h-4"
|
|
18
18
|
/>
|
|
19
|
+
<span
|
|
20
|
+
v-else-if="icon"
|
|
21
|
+
:class="icon"
|
|
22
|
+
aria-hidden="true"
|
|
23
|
+
/>
|
|
19
24
|
<span class="text-sm flex-1 min-w-0">
|
|
20
25
|
<slot />
|
|
21
26
|
</span>
|
|
@@ -40,7 +45,7 @@ type Props = {
|
|
|
40
45
|
value: string
|
|
41
46
|
count?: number
|
|
42
47
|
loading?: boolean
|
|
43
|
-
icon?: Component
|
|
48
|
+
icon?: Component | string
|
|
44
49
|
highlighted?: boolean
|
|
45
50
|
}
|
|
46
51
|
|
|
@@ -49,45 +49,23 @@
|
|
|
49
49
|
</template>
|
|
50
50
|
|
|
51
51
|
<script setup lang="ts">
|
|
52
|
-
import {
|
|
52
|
+
import { computed } from 'vue'
|
|
53
53
|
import type { Resource } from '../../types/resources'
|
|
54
|
-
import { useGetProfile } from '../../functions/tabularApi'
|
|
55
54
|
import { useTranslation } from '../../composables/useTranslation'
|
|
55
|
+
import { injectTabularProfile } from '../../composables/useTabularProfile'
|
|
56
56
|
import PreviewLoader from './PreviewLoader.vue'
|
|
57
57
|
|
|
58
58
|
const props = defineProps<{ resource: Resource }>()
|
|
59
|
-
const getProfile = useGetProfile()
|
|
60
59
|
const { t } = useTranslation()
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
61
|
+
// Profile is shared with sibling components (e.g. TabularExplorer) via
|
|
62
|
+
// `provideTabularProfile` in the parent. Falls back to a local fetch
|
|
63
|
+
// when no parent provides it (standalone usage).
|
|
64
|
+
const { data: profileData, status } = await injectTabularProfile(() => props.resource.id)
|
|
67
65
|
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
onMounted(async () => {
|
|
75
|
-
try {
|
|
76
|
-
const response = await getProfile(props.resource.id) // Assurez-vous que cette fonction retourne bien les données attendues
|
|
77
|
-
if ('profile' in response && response.profile) {
|
|
78
|
-
columns.value = Object.keys(response.profile.columns)
|
|
79
|
-
columnsInfo.value = response.profile.columns
|
|
80
|
-
hasColumnInfo.value = true
|
|
81
|
-
loading.value = false
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
hasError.value = true
|
|
85
|
-
loading.value = false
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
hasError.value = true
|
|
90
|
-
loading.value = false
|
|
91
|
-
}
|
|
92
|
-
})
|
|
66
|
+
const loading = computed(() => status.value === 'idle' || status.value === 'pending')
|
|
67
|
+
const hasError = computed(() => status.value === 'error')
|
|
68
|
+
const hasColumnInfo = computed(() => !!profileData.value?.profile?.columns)
|
|
69
|
+
const columns = computed(() => profileData.value?.profile ? Object.keys(profileData.value.profile.columns) : [])
|
|
70
|
+
const columnsInfo = computed(() => profileData.value?.profile?.columns ?? {})
|
|
93
71
|
</script>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
/>
|
|
11
11
|
</div>
|
|
12
12
|
<PreviewUnavailable v-else>
|
|
13
|
-
{{ t("L'aperçu de ce fichier n'a pas pu être chargé. Téléchargez-le
|
|
13
|
+
{{ t("L'aperçu de ce fichier n'a pas pu être chargé. Téléchargez-le pour le consulter.") }}
|
|
14
14
|
</PreviewUnavailable>
|
|
15
15
|
</div>
|
|
16
16
|
</template>
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<dl class="fr-pl-0">
|
|
3
|
+
<dt
|
|
4
|
+
v-if="resource.format === 'url'"
|
|
5
|
+
class="font-bold fr-text--sm fr-mb-0"
|
|
6
|
+
>
|
|
7
|
+
{{ t("URL d'origine") }}
|
|
8
|
+
</dt>
|
|
9
|
+
<dt
|
|
10
|
+
v-else
|
|
11
|
+
class="font-bold fr-text--sm fr-mb-0"
|
|
12
|
+
>
|
|
13
|
+
{{ t('Format original') }}
|
|
14
|
+
</dt>
|
|
15
|
+
<dd class="text-sm pl-0 mb-4 text-gray-medium h-8 flex flex-wrap items-center">
|
|
16
|
+
<span
|
|
17
|
+
v-if="resource.format === 'url'"
|
|
18
|
+
class="inline-flex items-center max-w-full"
|
|
19
|
+
>
|
|
20
|
+
<a
|
|
21
|
+
:href="resource.latest"
|
|
22
|
+
class="fr-link no-icon-after truncate"
|
|
23
|
+
rel="ugc nofollow noopener"
|
|
24
|
+
target="_blank"
|
|
25
|
+
@click="trackEvent('Jeux de données', 'Télécharger un fichier', 'Bouton : télécharger un fichier')"
|
|
26
|
+
>
|
|
27
|
+
{{ resource.url }}
|
|
28
|
+
</a>
|
|
29
|
+
<span class="fr-ml-1v fr-icon-external-link-line fr-icon--sm shrink-0" />
|
|
30
|
+
</span>
|
|
31
|
+
<span v-else>
|
|
32
|
+
<span class="text-datagouv fr-icon-download-line fr-icon--sm fr-mr-1v fr-mt-1v" />
|
|
33
|
+
<a
|
|
34
|
+
:href="resource.latest"
|
|
35
|
+
class="fr-link"
|
|
36
|
+
rel="ugc nofollow noopener"
|
|
37
|
+
@click="trackEvent('Jeux de données', 'Télécharger un fichier', `Bouton : format ${resource.format}`)"
|
|
38
|
+
>
|
|
39
|
+
<span>{{ t('Format {format}', { format: resource.format }) }}<span v-if="resourceFilesize"> - {{ filesize(resourceFilesize) }}</span></span>
|
|
40
|
+
</a>
|
|
41
|
+
</span>
|
|
42
|
+
<CopyButton
|
|
43
|
+
:label="t('Copier le lien')"
|
|
44
|
+
:copied-label="t('Lien copié !')"
|
|
45
|
+
:text="resource.latest"
|
|
46
|
+
class="relative"
|
|
47
|
+
/>
|
|
48
|
+
</dd>
|
|
49
|
+
<template v-if="generatedFormats.length">
|
|
50
|
+
<TranslationT
|
|
51
|
+
tag="dt"
|
|
52
|
+
class="font-bold fr-text--sm fr-mb-0"
|
|
53
|
+
keypath="Formats générés automatiquement par {platform} (dernière mise à jour {date})"
|
|
54
|
+
>
|
|
55
|
+
<template #platform>
|
|
56
|
+
{{ config.name }}
|
|
57
|
+
</template>
|
|
58
|
+
<template #date>
|
|
59
|
+
<FormattedDate
|
|
60
|
+
:date="conversionsFinishedAt"
|
|
61
|
+
format="relative"
|
|
62
|
+
/>
|
|
63
|
+
</template>
|
|
64
|
+
</TranslationT>
|
|
65
|
+
<dd
|
|
66
|
+
v-for="generatedFormat in generatedFormats"
|
|
67
|
+
:key="generatedFormat.format"
|
|
68
|
+
class="text-sm pl-0 mb-4 text-gray-medium h-8 flex flex-wrap items-center"
|
|
69
|
+
>
|
|
70
|
+
<span>
|
|
71
|
+
<span class="text-datagouv fr-icon-download-line fr-icon--sm fr-mr-1v fr-mt-1v" />
|
|
72
|
+
<a
|
|
73
|
+
:href="generatedFormat.url"
|
|
74
|
+
class="fr-link"
|
|
75
|
+
rel="ugc nofollow noopener"
|
|
76
|
+
@click="trackEvent('Jeux de données', 'Télécharger un fichier', `Bouton : format ${generatedFormat.format}`)"
|
|
77
|
+
>
|
|
78
|
+
<span>{{ t('Format {format}', { format: generatedFormat.format }) }}<span v-if="generatedFormat.size"> - {{ filesize(generatedFormat.size) }}</span></span>
|
|
79
|
+
</a>
|
|
80
|
+
</span>
|
|
81
|
+
<CopyButton
|
|
82
|
+
:label="t('Copier le lien')"
|
|
83
|
+
:copied-label="t('Lien copié !')"
|
|
84
|
+
:text="generatedFormat.url"
|
|
85
|
+
class="relative"
|
|
86
|
+
/>
|
|
87
|
+
</dd>
|
|
88
|
+
</template>
|
|
89
|
+
<template v-if="wfsFormats.length">
|
|
90
|
+
<dt class="font-bold fr-text--sm fr-mb-0">
|
|
91
|
+
<div class="flex gap-1 items-center">
|
|
92
|
+
{{ t('Formats exportés depuis le service WFS') }}
|
|
93
|
+
<span v-if="defaultWfsProjection"> ({{ t('projection {crs}', { crs: defaultWfsProjection }) }})</span>
|
|
94
|
+
<Tooltip>
|
|
95
|
+
<RiInformationLine
|
|
96
|
+
class="flex-none size-4"
|
|
97
|
+
:aria-label="t(`Le lien de téléchargement interroge directement le flux WFS distant. Le nombre de features téléchargées peut être limité.`)"
|
|
98
|
+
aria-hidden="true"
|
|
99
|
+
/>
|
|
100
|
+
<template #tooltip>
|
|
101
|
+
<p class="text-sm font-normal mb-0">
|
|
102
|
+
{{ t(`Le lien de téléchargement interroge directement le flux WFS distant.`) }}
|
|
103
|
+
</p>
|
|
104
|
+
<p class="text-sm font-normal mb-0">
|
|
105
|
+
{{ t(`Le nombre de features téléchargées peut être limité.`) }}
|
|
106
|
+
</p>
|
|
107
|
+
</template>
|
|
108
|
+
</Tooltip>
|
|
109
|
+
</div>
|
|
110
|
+
</dt>
|
|
111
|
+
<dd
|
|
112
|
+
v-for="wfsFormat in wfsFormats"
|
|
113
|
+
:key="wfsFormat.format"
|
|
114
|
+
class="text-sm pl-0 mb-4 text-gray-medium h-8 flex flex-wrap items-center"
|
|
115
|
+
>
|
|
116
|
+
<span>
|
|
117
|
+
<span class="text-datagouv fr-icon-download-line fr-icon--sm fr-mr-1v fr-mt-1v" />
|
|
118
|
+
<a
|
|
119
|
+
:href="wfsFormat.url"
|
|
120
|
+
class="fr-link"
|
|
121
|
+
rel="ugc nofollow noopener"
|
|
122
|
+
@click="trackEvent('Jeux de données', 'Télécharger un fichier', `Bouton : format ${wfsFormat.format}`)"
|
|
123
|
+
>
|
|
124
|
+
<span>{{ t('Format {format}', { format: wfsFormat.format }) }}</span>
|
|
125
|
+
</a>
|
|
126
|
+
</span>
|
|
127
|
+
<CopyButton
|
|
128
|
+
:label="t('Copier le lien')"
|
|
129
|
+
:copied-label="t('Lien copié !')"
|
|
130
|
+
:text="wfsFormat.url"
|
|
131
|
+
class="relative"
|
|
132
|
+
/>
|
|
133
|
+
</dd>
|
|
134
|
+
</template>
|
|
135
|
+
</dl>
|
|
136
|
+
</template>
|
|
137
|
+
|
|
138
|
+
<script setup lang="ts">
|
|
139
|
+
import { computed } from 'vue'
|
|
140
|
+
import { RiInformationLine } from '@remixicon/vue'
|
|
141
|
+
import CopyButton from '../CopyButton.vue'
|
|
142
|
+
import Tooltip from '../Tooltip.vue'
|
|
143
|
+
import { filesize } from '../../functions/helpers'
|
|
144
|
+
import { getResourceFilesize } from '../../functions/resources'
|
|
145
|
+
import { trackEvent } from '../../functions/matomo'
|
|
146
|
+
import { useComponentsConfig } from '../../config'
|
|
147
|
+
import FormattedDate from '../FormattedDate.vue'
|
|
148
|
+
import TranslationT from '../TranslationT.vue'
|
|
149
|
+
import { useTranslation } from '../../composables/useTranslation'
|
|
150
|
+
import { useResourceCapabilities } from '../../composables/useResourceCapabilities'
|
|
151
|
+
import type { Resource } from '../../types/resources'
|
|
152
|
+
import type { Dataset, DatasetV2 } from '../../types/datasets'
|
|
153
|
+
|
|
154
|
+
const props = defineProps<{
|
|
155
|
+
resource: Resource
|
|
156
|
+
dataset: Dataset | DatasetV2
|
|
157
|
+
}>()
|
|
158
|
+
|
|
159
|
+
const { t } = useTranslation()
|
|
160
|
+
const config = useComponentsConfig()
|
|
161
|
+
|
|
162
|
+
const { generatedFormats, wfsFormats, defaultWfsProjection } = useResourceCapabilities(
|
|
163
|
+
() => props.resource,
|
|
164
|
+
() => props.dataset,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
const resourceFilesize = computed(() => getResourceFilesize(props.resource))
|
|
168
|
+
|
|
169
|
+
const conversionsFinishedAt = computed(() =>
|
|
170
|
+
props.resource.extras['analysis:parsing:finished_at'] as string | undefined,
|
|
171
|
+
)
|
|
172
|
+
</script>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="text-xs">
|
|
3
|
+
<PreviewUnavailable v-if="!isSizeAllowed">
|
|
4
|
+
{{ fileSizeBytes
|
|
5
|
+
? t("Le fichier {fileType} est trop volumineux pour être prévisualisé. Téléchargez-le pour le consulter.", { fileType })
|
|
6
|
+
: t("La taille du fichier est inconnue, l'aperçu n'est pas disponible. Téléchargez-le pour le consulter.")
|
|
7
|
+
}}
|
|
8
|
+
</PreviewUnavailable>
|
|
9
|
+
<PreviewUnavailable v-else-if="hasError">
|
|
10
|
+
{{ t("L'aperçu de ce fichier n'a pas pu être chargé. Téléchargez-le pour le consulter.") }}
|
|
11
|
+
</PreviewUnavailable>
|
|
12
|
+
<img
|
|
13
|
+
v-else
|
|
14
|
+
:src="resource.url"
|
|
15
|
+
alt=""
|
|
16
|
+
class="block w-full h-auto max-w-[800px]"
|
|
17
|
+
@error="hasError = true"
|
|
18
|
+
>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup lang="ts">
|
|
23
|
+
import { computed, ref } from 'vue'
|
|
24
|
+
import PreviewUnavailable from './PreviewUnavailable.vue'
|
|
25
|
+
import type { Resource } from '../../types/resources'
|
|
26
|
+
import { getResourceFilesize } from '../../functions/resources'
|
|
27
|
+
import { useTranslation } from '../../composables/useTranslation'
|
|
28
|
+
import { useComponentsConfig } from '../../config'
|
|
29
|
+
|
|
30
|
+
const props = defineProps<{
|
|
31
|
+
resource: Resource
|
|
32
|
+
}>()
|
|
33
|
+
|
|
34
|
+
const { t } = useTranslation()
|
|
35
|
+
const config = useComponentsConfig()
|
|
36
|
+
|
|
37
|
+
const hasError = ref(false)
|
|
38
|
+
|
|
39
|
+
const fileType = computed(() => props.resource.format?.toUpperCase() ?? t('Fichier'))
|
|
40
|
+
const fileSizeBytes = computed(() => getResourceFilesize(props.resource))
|
|
41
|
+
|
|
42
|
+
const isSizeAllowed = computed(() => {
|
|
43
|
+
const size = fileSizeBytes.value
|
|
44
|
+
const max = config.maxImagePreviewByteSize
|
|
45
|
+
if (!size || !max) return false
|
|
46
|
+
return size <= max
|
|
47
|
+
})
|
|
48
|
+
</script>
|
|
@@ -1,48 +1,31 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
</div>
|
|
20
|
-
<PreviewUnavailable v-else-if="fileTooLarge">
|
|
21
|
-
{{ fileSizeBytes
|
|
22
|
-
? t("Le fichier JSON est trop volumineux pour être prévisualisé. Téléchargez-le depuis l'onglet Téléchargements.")
|
|
23
|
-
: t("La taille du fichier est inconnue, l'aperçu n'est pas disponible. Téléchargez-le depuis l'onglet Téléchargements.")
|
|
24
|
-
}}
|
|
25
|
-
</PreviewUnavailable>
|
|
26
|
-
<PreviewUnavailable v-else-if="error === 'network'">
|
|
27
|
-
{{ t("Ce fichier est hébergé sur un site externe qui ne permet pas la prévisualisation. Téléchargez-le depuis l'onglet Téléchargements.") }}
|
|
28
|
-
</PreviewUnavailable>
|
|
29
|
-
<PreviewUnavailable v-else-if="error">
|
|
30
|
-
{{ t("L'aperçu de ce fichier n'a pas pu être chargé. Téléchargez-le depuis l'onglet Téléchargements.") }}
|
|
31
|
-
</PreviewUnavailable>
|
|
32
|
-
</div>
|
|
2
|
+
<PreviewWrapper
|
|
3
|
+
v-slot="{ data }"
|
|
4
|
+
file-type="JSON"
|
|
5
|
+
:resource="resource"
|
|
6
|
+
:max-size="config.maxJsonPreviewCharSize"
|
|
7
|
+
:load="load"
|
|
8
|
+
>
|
|
9
|
+
<JsonViewer
|
|
10
|
+
:value="data"
|
|
11
|
+
boxed
|
|
12
|
+
sort
|
|
13
|
+
theme="light"
|
|
14
|
+
:max-depth="3"
|
|
15
|
+
:expand-depth="2"
|
|
16
|
+
:indent-width="2"
|
|
17
|
+
/>
|
|
18
|
+
</PreviewWrapper>
|
|
33
19
|
</template>
|
|
34
20
|
|
|
35
21
|
<script setup lang="ts">
|
|
36
|
-
import {
|
|
22
|
+
import { defineAsyncComponent } from 'vue'
|
|
37
23
|
import { useComponentsConfig } from '../../config'
|
|
38
|
-
import
|
|
24
|
+
import PreviewWrapper from './PreviewWrapper.vue'
|
|
39
25
|
import type { Resource } from '../../types/resources'
|
|
40
|
-
import { useTranslation } from '../../composables/useTranslation'
|
|
41
|
-
import { getResourceFilesize } from '../../functions/datasets'
|
|
42
26
|
|
|
43
27
|
const JsonViewer = defineAsyncComponent(() =>
|
|
44
28
|
import('vue3-json-viewer').then((module) => {
|
|
45
|
-
// Import CSS when component loads
|
|
46
29
|
import('vue3-json-viewer/dist/vue3-json-viewer.css')
|
|
47
30
|
return module.JsonViewer
|
|
48
31
|
}),
|
|
@@ -53,74 +36,10 @@ const props = defineProps<{
|
|
|
53
36
|
}>()
|
|
54
37
|
|
|
55
38
|
const config = useComponentsConfig()
|
|
56
|
-
const { t } = useTranslation()
|
|
57
39
|
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const fileSizeBytes = computed(() => getResourceFilesize(props.resource))
|
|
64
|
-
|
|
65
|
-
const shouldLoadJson = computed(() => {
|
|
66
|
-
const size = fileSizeBytes.value
|
|
67
|
-
if (!size) {
|
|
68
|
-
// If we don't know the size, don't risk loading a potentially huge file
|
|
69
|
-
return false
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Check if maxJsonPreviewCharSize is configured
|
|
73
|
-
if (!config.maxJsonPreviewCharSize) {
|
|
74
|
-
// If no limit is set, don't load unknown files
|
|
75
|
-
return false
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Convert maxJsonPreviewCharSize from characters to bytes (rough estimate)
|
|
79
|
-
// Assuming average 1 byte per character for JSON
|
|
80
|
-
const maxByteSize = config.maxJsonPreviewCharSize
|
|
81
|
-
|
|
82
|
-
return size <= maxByteSize
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
const fetchJsonData = async () => {
|
|
86
|
-
// Check if file is too large or size is unknown before making the request
|
|
87
|
-
if (!shouldLoadJson.value) {
|
|
88
|
-
fileTooLarge.value = true
|
|
89
|
-
return
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
loading.value = true
|
|
93
|
-
error.value = null
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
const response = await fetch(props.resource.url)
|
|
97
|
-
// const response = await fetch('/test-data.json') // For testing locally without CORS issues
|
|
98
|
-
if (!response.ok) {
|
|
99
|
-
throw new Error(`HTTP error! status: ${response.status}`)
|
|
100
|
-
}
|
|
101
|
-
const data = await response.json()
|
|
102
|
-
|
|
103
|
-
// Use the original data directly - let the JSON viewer handle large files
|
|
104
|
-
jsonData.value = data
|
|
105
|
-
}
|
|
106
|
-
catch (err) {
|
|
107
|
-
console.error('Error loading JSON:', err)
|
|
108
|
-
|
|
109
|
-
if (err instanceof TypeError) {
|
|
110
|
-
error.value = 'network'
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
error.value = 'generic'
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
jsonData.value = null
|
|
117
|
-
}
|
|
118
|
-
finally {
|
|
119
|
-
loading.value = false
|
|
120
|
-
}
|
|
40
|
+
const load = async () => {
|
|
41
|
+
const response = await fetch(props.resource.url)
|
|
42
|
+
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)
|
|
43
|
+
return response.json()
|
|
121
44
|
}
|
|
122
|
-
|
|
123
|
-
onMounted(() => {
|
|
124
|
-
fetchJsonData()
|
|
125
|
-
})
|
|
126
45
|
</script>
|