@datagouv/components-next 1.0.2-dev.5 → 1.0.2-dev.50
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/dist/Datafair.client-hLoIoNbP.js +30 -0
- package/dist/JsonPreview.client-BUCeeFKz.js +40 -0
- package/dist/{MapContainer.client-DRkAmdOc.js → MapContainer.client-DrQRSrq_.js} +35 -38
- package/dist/{PdfPreview.client-C-w6-w44.js → PdfPreview.client-vQ4bfJx3.js} +822 -865
- package/dist/{Pmtiles.client-BR7_ldHY.js → Pmtiles.client-DWtu_UNl.js} +574 -579
- package/dist/PreviewWrapper.vue_vue_type_script_setup_true_lang-4Ufr2Kmw.js +61 -0
- package/dist/XmlPreview.client-CEEHnAFF.js +34 -0
- package/dist/components-next.css +3 -3
- package/dist/components-next.js +80 -79
- package/dist/components.css +1 -1
- package/dist/{index-SrYZwgCT.js → index-CsOZmih1.js} +1 -1
- package/dist/main-7DRSPyNj.js +71033 -0
- package/dist/{vue3-xml-viewer.common-BRxsqI9j.js → vue3-xml-viewer.common-DOIGuzsk.js} +1 -1
- package/package.json +14 -9
- package/src/components/ActivityList/ActivityList.vue +0 -2
- package/src/components/Form/SearchableSelect.vue +2 -1
- 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/Pagination.vue +8 -5
- package/src/components/ReadMore.vue +1 -1
- package/src/components/ResourceAccordion/Datafair.client.vue +4 -10
- package/src/components/ResourceAccordion/JsonPreview.client.vue +23 -121
- package/src/components/ResourceAccordion/MapContainer.client.vue +7 -11
- package/src/components/ResourceAccordion/Metadata.vue +1 -2
- package/src/components/ResourceAccordion/PdfPreview.client.vue +24 -103
- package/src/components/ResourceAccordion/Pmtiles.client.vue +5 -10
- package/src/components/ResourceAccordion/Preview.vue +5 -10
- package/src/components/ResourceAccordion/PreviewLoader.vue +1 -2
- package/src/components/ResourceAccordion/PreviewUnavailable.vue +22 -0
- package/src/components/ResourceAccordion/PreviewWrapper.vue +82 -0
- package/src/components/ResourceAccordion/ResourceAccordion.vue +4 -6
- package/src/components/ResourceAccordion/XmlPreview.client.vue +16 -115
- package/src/components/ResourceExplorer/ResourceExplorer.vue +21 -10
- package/src/components/ResourceExplorer/ResourceExplorerViewer.vue +27 -9
- package/src/components/Search/GlobalSearch.vue +29 -4
- package/src/composables/useResourceCapabilities.ts +1 -1
- package/src/config.ts +2 -0
- package/src/functions/datasets.ts +0 -17
- package/src/functions/resources.ts +56 -1
- package/src/main.ts +5 -6
- package/src/types/dataservices.ts +2 -0
- package/src/types/organizations.ts +1 -1
- package/src/types/pages.ts +0 -5
- package/src/types/posts.ts +2 -2
- package/src/types/reports.ts +3 -0
- package/src/types/search.ts +26 -1
- package/src/types/site.ts +5 -3
- package/src/types/users.ts +0 -1
- package/assets/swagger-themes/newspaper.css +0 -1670
- package/dist/Datafair.client-E5D6ePRC.js +0 -35
- package/dist/JsonPreview.client-C-6eBbPw.js +0 -87
- package/dist/Swagger.client-D4-F6yEf.js +0 -4
- package/dist/XmlPreview.client-Dl2VCgXF.js +0 -79
- package/dist/main-B2kXxWRG.js +0 -105833
- package/src/components/ResourceAccordion/Swagger.client.vue +0 -48
- package/src/functions/pagination.ts +0 -9
- /package/assets/illustrations/{_microscope.svg → microscope.svg} +0 -0
|
@@ -1,59 +1,24 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
</div>
|
|
12
|
-
<SimpleBanner
|
|
13
|
-
v-else-if="fileTooLarge"
|
|
14
|
-
type="warning"
|
|
15
|
-
class="flex items-center space-x-2"
|
|
16
|
-
>
|
|
17
|
-
<RiErrorWarningLine class="shrink-0 size-6" />
|
|
18
|
-
<span>{{ fileSizeBytes
|
|
19
|
-
? t("Fichier XML trop volumineux pour l'aperçu. Pour consulter le fichier complet, téléchargez-le en cliquant sur le bouton bleu ou depuis l'onglet Téléchargements.")
|
|
20
|
-
: t("L'aperçu n'est pas disponible car la taille du fichier est inconnue. Pour consulter le fichier complet, téléchargez-le en cliquant sur le bouton bleu ou depuis l'onglet Téléchargements.")
|
|
21
|
-
}}</span>
|
|
22
|
-
</SimpleBanner>
|
|
23
|
-
<SimpleBanner
|
|
24
|
-
v-else-if="error === 'network'"
|
|
25
|
-
type="warning"
|
|
26
|
-
class="flex items-center space-x-2"
|
|
27
|
-
>
|
|
28
|
-
<RiErrorWarningLine class="shrink-0 size-6" />
|
|
29
|
-
<span>{{ t("Ce fichier XML ne peut pas être prévisualisé, peut-être parce qu'il est hébergé sur un autre site qui ne l'autorise pas. Pour le consulter, téléchargez-le en cliquant sur le bouton bleu ou depuis l'onglet Téléchargements.") }}</span>
|
|
30
|
-
</SimpleBanner>
|
|
31
|
-
<SimpleBanner
|
|
32
|
-
v-else-if="error"
|
|
33
|
-
type="warning"
|
|
34
|
-
class="flex items-center space-x-2"
|
|
35
|
-
>
|
|
36
|
-
<RiErrorWarningLine class="shrink-0 size-6" />
|
|
37
|
-
<span>{{ t("Erreur lors du chargement de l'aperçu XML.") }}</span>
|
|
38
|
-
</SimpleBanner>
|
|
39
|
-
</div>
|
|
2
|
+
<PreviewWrapper
|
|
3
|
+
v-slot="{ data }"
|
|
4
|
+
file-type="XML"
|
|
5
|
+
:resource="resource"
|
|
6
|
+
:max-size="config.maxXmlPreviewCharSize"
|
|
7
|
+
:load="load"
|
|
8
|
+
>
|
|
9
|
+
<XmlViewer :xml="(data as string)" />
|
|
10
|
+
</PreviewWrapper>
|
|
40
11
|
</template>
|
|
41
12
|
|
|
42
13
|
<script setup lang="ts">
|
|
43
|
-
import {
|
|
44
|
-
import { RiErrorWarningLine } from '@remixicon/vue'
|
|
45
|
-
|
|
14
|
+
import { defineAsyncComponent } from 'vue'
|
|
46
15
|
import { useComponentsConfig } from '../../config'
|
|
47
|
-
import
|
|
16
|
+
import PreviewWrapper from './PreviewWrapper.vue'
|
|
48
17
|
import type { Resource } from '../../types/resources'
|
|
49
|
-
import { useTranslation } from '../../composables/useTranslation'
|
|
50
18
|
import '../../types/vue3-xml-viewer.d'
|
|
51
|
-
import { getResourceFilesize } from '../../main'
|
|
52
19
|
|
|
53
20
|
const XmlViewer = defineAsyncComponent(() =>
|
|
54
|
-
import('vue3-xml-viewer').then(
|
|
55
|
-
return module.default || module.XmlViewer
|
|
56
|
-
}),
|
|
21
|
+
import('vue3-xml-viewer').then(module => module.default || module.XmlViewer),
|
|
57
22
|
)
|
|
58
23
|
|
|
59
24
|
const props = defineProps<{
|
|
@@ -61,74 +26,10 @@ const props = defineProps<{
|
|
|
61
26
|
}>()
|
|
62
27
|
|
|
63
28
|
const config = useComponentsConfig()
|
|
64
|
-
const { t } = useTranslation()
|
|
65
|
-
|
|
66
|
-
const xmlData = ref<string | null>(null)
|
|
67
|
-
const loading = ref(false)
|
|
68
|
-
const error = ref<string | null>(null)
|
|
69
|
-
const fileTooLarge = ref(false)
|
|
70
|
-
|
|
71
|
-
const fileSizeBytes = computed(() => getResourceFilesize(props.resource))
|
|
72
|
-
|
|
73
|
-
const shouldLoadXml = computed(() => {
|
|
74
|
-
const size = fileSizeBytes.value
|
|
75
|
-
if (!size) {
|
|
76
|
-
// If we don't know the size, don't risk loading a potentially huge file
|
|
77
|
-
return false
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Check if maxXmlPreviewCharSize is configured
|
|
81
|
-
if (!config.maxXmlPreviewCharSize) {
|
|
82
|
-
// If no limit is set, don't load unknown files
|
|
83
|
-
return false
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Convert maxXmlPreviewCharSize from characters to bytes (rough estimate)
|
|
87
|
-
// Assuming average 1 byte per character for XML
|
|
88
|
-
const maxByteSize = config.maxXmlPreviewCharSize
|
|
89
|
-
|
|
90
|
-
return size <= maxByteSize
|
|
91
|
-
})
|
|
92
29
|
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
if (!
|
|
96
|
-
|
|
97
|
-
return
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
loading.value = true
|
|
101
|
-
error.value = null
|
|
102
|
-
|
|
103
|
-
try {
|
|
104
|
-
const response = await fetch(props.resource.url)
|
|
105
|
-
// const response = await fetch('/test-data.xml') // For testing locally without CORS issues
|
|
106
|
-
if (!response.ok) {
|
|
107
|
-
throw new Error(`HTTP error! status: ${response.status}`)
|
|
108
|
-
}
|
|
109
|
-
const data = await response.text()
|
|
110
|
-
|
|
111
|
-
// Use the XML data as string - let the XML viewer handle large files
|
|
112
|
-
xmlData.value = data
|
|
113
|
-
}
|
|
114
|
-
catch (err) {
|
|
115
|
-
console.error('Error loading XML:', err)
|
|
116
|
-
|
|
117
|
-
if (err instanceof TypeError) {
|
|
118
|
-
error.value = 'network'
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
error.value = 'generic'
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
xmlData.value = null
|
|
125
|
-
}
|
|
126
|
-
finally {
|
|
127
|
-
loading.value = false
|
|
128
|
-
}
|
|
30
|
+
const load = async () => {
|
|
31
|
+
const response = await fetch(props.resource.url)
|
|
32
|
+
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)
|
|
33
|
+
return response.text()
|
|
129
34
|
}
|
|
130
|
-
|
|
131
|
-
onMounted(() => {
|
|
132
|
-
fetchXmlData()
|
|
133
|
-
})
|
|
134
35
|
</script>
|
|
@@ -159,6 +159,22 @@ watch(searchDebounced, () => {
|
|
|
159
159
|
}
|
|
160
160
|
})
|
|
161
161
|
|
|
162
|
+
// Separate useFetch for loadMore, initialized at setup time with immediate: false
|
|
163
|
+
// so that it doesn't fetch until execute() is called from the event handler.
|
|
164
|
+
const loadMoreType = ref<ResourceType>('main')
|
|
165
|
+
const loadMorePage = ref(1)
|
|
166
|
+
const loadMoreParams = computed(() => ({
|
|
167
|
+
type: loadMoreType.value,
|
|
168
|
+
page_size: PAGE_SIZE,
|
|
169
|
+
page: loadMorePage.value,
|
|
170
|
+
q: searchDebounced.value || undefined,
|
|
171
|
+
}))
|
|
172
|
+
const { data: loadMoreData, execute: executeLoadMore } = await useFetch<PaginatedArray<Resource>>(url, {
|
|
173
|
+
params: loadMoreParams,
|
|
174
|
+
immediate: false,
|
|
175
|
+
watch: false,
|
|
176
|
+
})
|
|
177
|
+
|
|
162
178
|
const loadMore = async (type: ResourceType) => {
|
|
163
179
|
const index = RESOURCE_TYPE.indexOf(type)
|
|
164
180
|
if (index === -1) return
|
|
@@ -166,17 +182,12 @@ const loadMore = async (type: ResourceType) => {
|
|
|
166
182
|
const extraRef = extraResourcesByType[index]!
|
|
167
183
|
pageRef.value++
|
|
168
184
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
page_size: PAGE_SIZE,
|
|
173
|
-
page: pageRef.value,
|
|
174
|
-
q: searchDebounced.value || undefined,
|
|
175
|
-
},
|
|
176
|
-
})
|
|
185
|
+
loadMoreType.value = type
|
|
186
|
+
loadMorePage.value = pageRef.value
|
|
187
|
+
await executeLoadMore()
|
|
177
188
|
|
|
178
|
-
if (
|
|
179
|
-
extraRef.value = [...extraRef.value, ...
|
|
189
|
+
if (loadMoreData.value) {
|
|
190
|
+
extraRef.value = [...extraRef.value, ...loadMoreData.value.data]
|
|
180
191
|
}
|
|
181
192
|
}
|
|
182
193
|
|
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
/>
|
|
18
18
|
</div>
|
|
19
19
|
<div class="text-gray-medium text-xs flex items-center gap-1">
|
|
20
|
+
<SchemaBadge :resource />
|
|
21
|
+
<RiSubtractLine
|
|
22
|
+
v-if="resource.schema"
|
|
23
|
+
aria-hidden="true"
|
|
24
|
+
class="size-3 fill-gray-medium"
|
|
25
|
+
/>
|
|
20
26
|
<span>{{ t('mis à jour {date}', { date: formatRelativeIfRecentDate(resource.last_modified) }) }}</span>
|
|
21
27
|
<RiSubtractLine
|
|
22
28
|
aria-hidden="true"
|
|
@@ -128,14 +134,28 @@
|
|
|
128
134
|
:resource="resource"
|
|
129
135
|
:dataset="dataset"
|
|
130
136
|
/>
|
|
131
|
-
<
|
|
137
|
+
<OpenApiViewer
|
|
132
138
|
v-else-if="hasOpenAPIPreview"
|
|
133
139
|
:url="resource.extras['apidocUrl'] as string"
|
|
134
140
|
/>
|
|
135
141
|
<Preview
|
|
136
|
-
v-else
|
|
142
|
+
v-else-if="hasTabularData"
|
|
137
143
|
:resource="resource"
|
|
138
144
|
/>
|
|
145
|
+
<PreviewUnavailable v-else>
|
|
146
|
+
<!-- "File too large to download" is the only analysis:error value from hydra for now -->
|
|
147
|
+
<template v-if="resource.extras['analysis:error'] === 'File too large to download'">
|
|
148
|
+
{{ t("Ce fichier est trop volumineux pour être analysé et prévisualisé. Téléchargez-le depuis l'onglet Téléchargements.") }}
|
|
149
|
+
</template>
|
|
150
|
+
<template v-else-if="resource.extras['analysis:parsing:error']">
|
|
151
|
+
{{ t("L'analyse de ce fichier a rencontré une erreur, l'aperçu n'est pas disponible. Téléchargez-le depuis l'onglet Téléchargements.") }}
|
|
152
|
+
<br>
|
|
153
|
+
<span class="text-gray-medium text-xs">{{ resource.extras['analysis:parsing:error'] }}</span>
|
|
154
|
+
</template>
|
|
155
|
+
<template v-else>
|
|
156
|
+
{{ t("Ce fichier ne peut pas être prévisualisé. Téléchargez-le depuis l'onglet Téléchargements.") }}
|
|
157
|
+
</template>
|
|
158
|
+
</PreviewUnavailable>
|
|
139
159
|
</div>
|
|
140
160
|
<div v-if="tab.key === 'description'">
|
|
141
161
|
<MarkdownViewer
|
|
@@ -283,7 +303,7 @@
|
|
|
283
303
|
<p>{{ t("- Si le fichier est supprimé, l'API sera également supprimée.") }}</p>
|
|
284
304
|
<p>{{ t("Pour des usages pérennes, prévoyez que cette API dépend directement du fichier source.") }}</p>
|
|
285
305
|
</div>
|
|
286
|
-
<
|
|
306
|
+
<OpenApiViewer
|
|
287
307
|
v-if="hasTabularData"
|
|
288
308
|
:url="`${config.tabularApiUrl}/api/resources/${resource.id}/swagger/`"
|
|
289
309
|
/>
|
|
@@ -298,12 +318,13 @@
|
|
|
298
318
|
<script setup lang="ts">
|
|
299
319
|
import { computed, defineAsyncComponent } from 'vue'
|
|
300
320
|
import { RiDownloadLine, RiFileCopyLine, RiFileWarningLine, RiInformationLine, RiSubtractLine } from '@remixicon/vue'
|
|
321
|
+
import PreviewUnavailable from '../ResourceAccordion/PreviewUnavailable.vue'
|
|
301
322
|
import { toast } from 'vue-sonner'
|
|
302
323
|
import BrandedButton from '../BrandedButton.vue'
|
|
303
324
|
import CopyButton from '../CopyButton.vue'
|
|
304
325
|
import MarkdownViewer from '../MarkdownViewer.vue'
|
|
305
326
|
import ResourceIcon from '../ResourceAccordion/ResourceIcon.vue'
|
|
306
|
-
import
|
|
327
|
+
import OpenApiViewer from '../OpenApiViewer/OpenApiViewer.vue'
|
|
307
328
|
import TabGroup from '../Tabs/TabGroup.vue'
|
|
308
329
|
import TabList from '../Tabs/TabList.vue'
|
|
309
330
|
import Tab from '../Tabs/Tab.vue'
|
|
@@ -313,9 +334,9 @@ import Tooltip from '../Tooltip.vue'
|
|
|
313
334
|
import Preview from '../ResourceAccordion/Preview.vue'
|
|
314
335
|
import DataStructure from '../ResourceAccordion/DataStructure.vue'
|
|
315
336
|
import Metadata from '../ResourceAccordion/Metadata.vue'
|
|
337
|
+
import SchemaBadge from '../ResourceAccordion/SchemaBadge.vue'
|
|
316
338
|
import { filesize, summarize } from '../../functions/helpers'
|
|
317
|
-
import { getResourceFormatIcon } from '../../functions/resources'
|
|
318
|
-
import { getResourceExternalUrl, getResourceFilesize } from '../../functions/datasets'
|
|
339
|
+
import { getResourceFormatIcon, getResourceExternalUrl, getResourceFilesize } from '../../functions/resources'
|
|
319
340
|
import { trackEvent } from '../../functions/matomo'
|
|
320
341
|
import { useComponentsConfig } from '../../config'
|
|
321
342
|
import { useFormatDate } from '../../functions/dates'
|
|
@@ -342,9 +363,6 @@ const MapContainer = defineAsyncComponent(() =>
|
|
|
342
363
|
const Pmtiles = defineAsyncComponent(() =>
|
|
343
364
|
import('../ResourceAccordion/Pmtiles.client.vue'),
|
|
344
365
|
)
|
|
345
|
-
const SwaggerClient = defineAsyncComponent(() =>
|
|
346
|
-
import('../ResourceAccordion/Swagger.client.vue'),
|
|
347
|
-
)
|
|
348
366
|
|
|
349
367
|
const props = defineProps<{
|
|
350
368
|
dataset: Dataset | DatasetV2
|
|
@@ -263,6 +263,14 @@
|
|
|
263
263
|
<OrganizationHorizontalCard :organization="(result as Organization)" />
|
|
264
264
|
</slot>
|
|
265
265
|
</template>
|
|
266
|
+
<template v-else-if="currentType === 'topics'">
|
|
267
|
+
<slot
|
|
268
|
+
name="topic"
|
|
269
|
+
:topic="result"
|
|
270
|
+
>
|
|
271
|
+
<TopicCard :topic="(result as TopicV2)" />
|
|
272
|
+
</slot>
|
|
273
|
+
</template>
|
|
266
274
|
</li>
|
|
267
275
|
</ul>
|
|
268
276
|
<Pagination
|
|
@@ -271,7 +279,6 @@
|
|
|
271
279
|
:page-size
|
|
272
280
|
:total-results="results.total"
|
|
273
281
|
class="mt-4"
|
|
274
|
-
:link="getLink"
|
|
275
282
|
@change="changePage"
|
|
276
283
|
/>
|
|
277
284
|
</div>
|
|
@@ -335,19 +342,19 @@
|
|
|
335
342
|
<script setup lang="ts">
|
|
336
343
|
import { computed, watch, useTemplateRef, type Ref } from 'vue'
|
|
337
344
|
import { useRouteQuery } from '@vueuse/router'
|
|
338
|
-
import { RiBuilding2Line, RiCloseCircleLine, RiDatabase2Line, RiLightbulbLine, RiLineChartLine, RiRssLine, RiTerminalLine } from '@remixicon/vue'
|
|
345
|
+
import { RiBookShelfLine, RiBuilding2Line, RiCloseCircleLine, RiDatabase2Line, RiLightbulbLine, RiLineChartLine, RiRssLine, RiTerminalLine } from '@remixicon/vue'
|
|
339
346
|
import magnifyingGlassSrc from '../../../assets/illustrations/magnifying_glass.svg?url'
|
|
340
347
|
import { useTranslation } from '../../composables/useTranslation'
|
|
341
348
|
import { useDebouncedRef } from '../../composables/useDebouncedRef'
|
|
342
349
|
import { useStableQueryParams } from '../../composables/useStableQueryParams'
|
|
343
350
|
import { useComponentsConfig } from '../../config'
|
|
344
351
|
import { useFetch } from '../../functions/api'
|
|
345
|
-
import { getLink } from '../../functions/pagination'
|
|
346
352
|
import type { Dataset } from '../../types/datasets'
|
|
347
353
|
import type { Dataservice } from '../../types/dataservices'
|
|
348
354
|
import type { Organization } from '../../types/organizations'
|
|
349
355
|
import type { Reuse } from '../../types/reuses'
|
|
350
|
-
import type {
|
|
356
|
+
import type { TopicV2 } from '../../types/topics'
|
|
357
|
+
import type { GlobalSearchConfig, SearchType, SortOption, DatasetSearchResponse, DataserviceSearchResponse, ReuseSearchResponse, OrganizationSearchResponse, TopicSearchResponse, FacetItem } from '../../types/search'
|
|
351
358
|
import { getDefaultGlobalSearchConfig } from '../../types/search'
|
|
352
359
|
import BrandedButton from '../BrandedButton.vue'
|
|
353
360
|
import LoadingBlock from '../LoadingBlock.vue'
|
|
@@ -358,6 +365,7 @@ import DatasetCard from '../DatasetCard.vue'
|
|
|
358
365
|
import DataserviceCard from '../DataserviceCard.vue'
|
|
359
366
|
import OrganizationHorizontalCard from '../OrganizationHorizontalCard.vue'
|
|
360
367
|
import ReuseHorizontalCard from '../ReuseHorizontalCard.vue'
|
|
368
|
+
import TopicCard from '../TopicCard.vue'
|
|
361
369
|
import SearchInput from './SearchInput.vue'
|
|
362
370
|
import Sidemenu from './Sidemenu.vue'
|
|
363
371
|
import BasicAndAdvancedFilters from './BasicAndAdvancedFilters.vue'
|
|
@@ -500,6 +508,7 @@ const datasetsEnabled = computed(() => props.config.some(c => c.class === 'datas
|
|
|
500
508
|
const dataservicesEnabled = computed(() => props.config.some(c => c.class === 'dataservices'))
|
|
501
509
|
const reusesEnabled = computed(() => props.config.some(c => c.class === 'reuses'))
|
|
502
510
|
const organizationsEnabled = computed(() => props.config.some(c => c.class === 'organizations'))
|
|
511
|
+
const topicsEnabled = computed(() => props.config.some(c => c.class === 'topics'))
|
|
503
512
|
|
|
504
513
|
// Create stable params for each type
|
|
505
514
|
const stableParamsOptions = {
|
|
@@ -526,12 +535,17 @@ const organizationsParams = useStableQueryParams({
|
|
|
526
535
|
...stableParamsOptions,
|
|
527
536
|
typeConfig: props.config.find(c => c.class === 'organizations'),
|
|
528
537
|
})
|
|
538
|
+
const topicsParams = useStableQueryParams({
|
|
539
|
+
...stableParamsOptions,
|
|
540
|
+
typeConfig: props.config.find(c => c.class === 'topics'),
|
|
541
|
+
})
|
|
529
542
|
|
|
530
543
|
// URLs that return null when type is not enabled
|
|
531
544
|
const datasetsUrl = computed(() => datasetsEnabled.value ? '/api/2/datasets/search/' : null)
|
|
532
545
|
const dataservicesUrl = computed(() => dataservicesEnabled.value ? '/api/2/dataservices/search/' : null)
|
|
533
546
|
const reusesUrl = computed(() => reusesEnabled.value ? '/api/2/reuses/search/' : null)
|
|
534
547
|
const organizationsUrl = computed(() => organizationsEnabled.value ? '/api/2/organizations/search/' : null)
|
|
548
|
+
const topicsUrl = computed(() => topicsEnabled.value ? '/api/2/topics/search/' : null)
|
|
535
549
|
|
|
536
550
|
// Reset page on filter/sort change
|
|
537
551
|
const filtersForReset = computed(() => ({
|
|
@@ -615,6 +629,10 @@ const { data: organizationsResults, status: organizationsStatus } = await useFet
|
|
|
615
629
|
organizationsUrl,
|
|
616
630
|
{ params: organizationsParams, lazy: true, server: initialType === 'organizations' },
|
|
617
631
|
)
|
|
632
|
+
const { data: topicsResults, status: topicsStatus } = await useFetch<TopicSearchResponse<TopicV2>>(
|
|
633
|
+
topicsUrl,
|
|
634
|
+
{ params: topicsParams, lazy: true, server: initialType === 'topics' },
|
|
635
|
+
)
|
|
618
636
|
|
|
619
637
|
const typesMeta = {
|
|
620
638
|
datasets: {
|
|
@@ -645,6 +663,13 @@ const typesMeta = {
|
|
|
645
663
|
results: organizationsResults,
|
|
646
664
|
status: organizationsStatus,
|
|
647
665
|
},
|
|
666
|
+
topics: {
|
|
667
|
+
icon: RiBookShelfLine,
|
|
668
|
+
name: t('Thématiques'),
|
|
669
|
+
placeholder: t('Rechercher une thématique'),
|
|
670
|
+
results: topicsResults,
|
|
671
|
+
status: topicsStatus,
|
|
672
|
+
},
|
|
648
673
|
} as const
|
|
649
674
|
|
|
650
675
|
const searchResults = computed(() => typesMeta[currentType.value].results.value)
|
|
@@ -88,7 +88,7 @@ export function useResourceCapabilities(
|
|
|
88
88
|
if (hasTabularData.value) {
|
|
89
89
|
options.push({ key: 'data', label: t('Données') })
|
|
90
90
|
}
|
|
91
|
-
else
|
|
91
|
+
else {
|
|
92
92
|
options.push({ key: 'data', label: t('Aperçu') })
|
|
93
93
|
}
|
|
94
94
|
|
package/src/config.ts
CHANGED
|
@@ -5,6 +5,8 @@ import type { FetchOptions } from 'ofetch'
|
|
|
5
5
|
export type PluginConfig = {
|
|
6
6
|
name: string // Name of the application (ex: data.gouv.fr)
|
|
7
7
|
baseUrl: string
|
|
8
|
+
/** Hostnames allowed in Access-Control-Allow-Origin for resource preview CORS checks (e.g. data.gouv.fr). */
|
|
9
|
+
trustedDomains?: string[]
|
|
8
10
|
apiBase: string
|
|
9
11
|
devApiKey?: string | null
|
|
10
12
|
datasetQualityGuideUrl?: string
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { useComponentsConfig } from '../config'
|
|
2
|
-
import type { Dataset, DatasetV2 } from '../types/datasets'
|
|
3
|
-
import type { CommunityResource, Resource } from '../types/resources'
|
|
4
2
|
|
|
5
3
|
function constructUrl(baseUrl: string, path: string): string {
|
|
6
4
|
const url = new URL(baseUrl)
|
|
@@ -14,18 +12,3 @@ export function getDatasetOEmbedHtml(type: string, id: string): string {
|
|
|
14
12
|
const staticUrl = constructUrl(config.baseUrl, 'oembed.js')
|
|
15
13
|
return `<div data-udata-${type}="${id}"></div><script data-udata="${config.baseUrl}" src="${staticUrl}" async defer></script>`
|
|
16
14
|
}
|
|
17
|
-
|
|
18
|
-
export function isCommunityResource(resource: Resource | CommunityResource): boolean {
|
|
19
|
-
return 'organization' in resource || 'owner' in resource
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function getResourceExternalUrl(dataset: Dataset | DatasetV2 | Omit<Dataset, 'resources' | 'community_resources'>, resource: Resource | CommunityResource): string {
|
|
23
|
-
return `${dataset.page}${isCommunityResource(resource) ? '/community-resources' : ''}?resource_id=${resource.id}`
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function getResourceFilesize(resource: Resource): null | number {
|
|
27
|
-
if (resource.filesize) return resource.filesize
|
|
28
|
-
if ('analysis:content-length' in resource.extras) return resource.extras['analysis:content-length'] as number
|
|
29
|
-
|
|
30
|
-
return null
|
|
31
|
-
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { readonly, type Component } from 'vue'
|
|
2
2
|
|
|
3
3
|
import { RiEarthLine, RiMap2Line } from '@remixicon/vue'
|
|
4
|
+
import { useComponentsConfig } from '../config'
|
|
4
5
|
import Archive from '../components/Icons/Archive.vue'
|
|
5
6
|
import Code from '../components/Icons/Code.vue'
|
|
7
|
+
import type { Dataset, DatasetV2 } from '../types/datasets'
|
|
6
8
|
import Documentation from '../components/Icons/Documentation.vue'
|
|
7
9
|
import Image from '../components/Icons/Image.vue'
|
|
8
10
|
import Link from '../components/Icons/Link.vue'
|
|
9
11
|
import Table from '../components/Icons/Table.vue'
|
|
10
|
-
import type { Resource } from '../types/resources'
|
|
12
|
+
import type { CommunityResource, Resource } from '../types/resources'
|
|
11
13
|
import { useTranslation } from '../composables/useTranslation'
|
|
12
14
|
|
|
13
15
|
export function getResourceFormatIcon(format: string): Component | null {
|
|
@@ -129,3 +131,56 @@ export const detectOgcService = (resource: Resource) => {
|
|
|
129
131
|
}
|
|
130
132
|
return false
|
|
131
133
|
}
|
|
134
|
+
|
|
135
|
+
export function isCommunityResource(resource: Resource | CommunityResource): boolean {
|
|
136
|
+
return 'organization' in resource || 'owner' in resource
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function getResourceExternalUrl(dataset: Dataset | DatasetV2 | Omit<Dataset, 'resources' | 'community_resources'>, resource: Resource | CommunityResource): string {
|
|
140
|
+
return `${dataset.page}${isCommunityResource(resource) ? '/community-resources' : ''}?resource_id=${resource.id}`
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function getResourceFilesize(resource: Resource): null | number {
|
|
144
|
+
if (resource.filesize) return resource.filesize
|
|
145
|
+
if ('analysis:content-length' in resource.extras) return resource.extras['analysis:content-length'] as number
|
|
146
|
+
|
|
147
|
+
return null
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
type CorsStatus = 'allowed' | 'blocked' | 'unknown'
|
|
151
|
+
|
|
152
|
+
export const getResourceCorsStatus = (resource: Resource): CorsStatus => {
|
|
153
|
+
const extras = resource.extras
|
|
154
|
+
if (!extras || !('check:cors:allow-origin' in extras)) {
|
|
155
|
+
return 'unknown'
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const allowOrigin = extras['check:cors:allow-origin'] as string | undefined
|
|
159
|
+
const rawMethods = extras['check:cors:allow-methods'] as string | undefined
|
|
160
|
+
|
|
161
|
+
// Check if allow-origin is '*' or contains one of our trusted domains
|
|
162
|
+
const config = useComponentsConfig()
|
|
163
|
+
const trustedDomains = config.trustedDomains ?? []
|
|
164
|
+
const hasPublicCors = allowOrigin === '*'
|
|
165
|
+
const hasSpecificCors = allowOrigin
|
|
166
|
+
? trustedDomains.some((domain) => {
|
|
167
|
+
try {
|
|
168
|
+
const hostname = new URL(allowOrigin).hostname
|
|
169
|
+
return hostname === domain || hostname.endsWith(`.${domain}`)
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return false
|
|
173
|
+
}
|
|
174
|
+
})
|
|
175
|
+
: false
|
|
176
|
+
|
|
177
|
+
const isOriginAllowed = hasPublicCors || hasSpecificCors
|
|
178
|
+
|
|
179
|
+
// Ensure GET method is allowed
|
|
180
|
+
const allowedMethods = rawMethods
|
|
181
|
+
? rawMethods.split(',').map(m => m.trim().toUpperCase())
|
|
182
|
+
: []
|
|
183
|
+
const supportsGet = allowedMethods.length === 0 || allowedMethods.includes('GET')
|
|
184
|
+
|
|
185
|
+
return isOriginAllowed && supportsGet ? 'allowed' : 'blocked'
|
|
186
|
+
}
|
package/src/main.ts
CHANGED
|
@@ -13,7 +13,7 @@ import type { License } from './types/licenses'
|
|
|
13
13
|
import type { Member, MemberRole, NewOrganization, Organization, OrganizationOrSuggest, OrganizationReference, OrganizationSuggest } from './types/organizations'
|
|
14
14
|
import type { Owned, OwnedWithFullObject, OwnedWithId } from './types/owned'
|
|
15
15
|
import type { Comment, Thread } from './types/discussions'
|
|
16
|
-
import type {
|
|
16
|
+
import type { PageBloc, ContentBloc, BlocWithTitle, DatasetsListBloc, DataservicesListBloc, ReusesListBloc, LinkInBloc, LinksListBloc, MarkdownBloc, AccordionItemBloc, AccordionListBloc, HeroBloc } from './types/pages'
|
|
17
17
|
import type { Post } from './types/posts'
|
|
18
18
|
import type { ReuseReference, NewReuse, Reuse, ReuseTopic, ReuseType } from './types/reuses'
|
|
19
19
|
import type { RegisteredSchema, Schema, SchemaDetails, SchemaField, SchemaPath, SchemaPublicationMode, SchemaResponseData, SchemaVersion, ValidataError } from './types/schemas'
|
|
@@ -24,7 +24,7 @@ import type { Weight, WellType } from './types/ui'
|
|
|
24
24
|
import type { User, UserReference } from './types/users'
|
|
25
25
|
import type { Report, ReportSubject, ReportReason } from './types/reports'
|
|
26
26
|
import type { GlobalSearchConfig, SearchType, SortOption } from './types/search'
|
|
27
|
-
import { getDefaultDatasetConfig, getDefaultDataserviceConfig, getDefaultReuseConfig, getDefaultOrganizationConfig, getDefaultGlobalSearchConfig, defaultDatasetSortOptions, defaultDataserviceSortOptions, defaultReuseSortOptions, defaultOrganizationSortOptions } from './types/search'
|
|
27
|
+
import { getDefaultDatasetConfig, getDefaultDataserviceConfig, getDefaultReuseConfig, getDefaultOrganizationConfig, getDefaultTopicConfig, getDefaultGlobalSearchConfig, defaultDatasetSortOptions, defaultDataserviceSortOptions, defaultReuseSortOptions, defaultOrganizationSortOptions } from './types/search'
|
|
28
28
|
|
|
29
29
|
import ActivityList from './components/ActivityList/ActivityList.vue'
|
|
30
30
|
import UserActivityList from './components/ActivityList/UserActivityList.vue'
|
|
@@ -73,7 +73,7 @@ import ResourceIcon from './components/ResourceAccordion/ResourceIcon.vue'
|
|
|
73
73
|
import ResourceExplorer from './components/ResourceExplorer/ResourceExplorer.vue'
|
|
74
74
|
import ResourceExplorerSidebar from './components/ResourceExplorer/ResourceExplorerSidebar.vue'
|
|
75
75
|
import ResourceExplorerViewer from './components/ResourceExplorer/ResourceExplorerViewer.vue'
|
|
76
|
-
import
|
|
76
|
+
import OpenApiViewer from './components/OpenApiViewer/OpenApiViewer.vue'
|
|
77
77
|
import ReuseCard from './components/ReuseCard.vue'
|
|
78
78
|
import ReuseHorizontalCard from './components/ReuseHorizontalCard.vue'
|
|
79
79
|
import ReuseDetails from './components/ReuseDetails.vue'
|
|
@@ -116,7 +116,6 @@ export * from './functions/metrics'
|
|
|
116
116
|
export * from './functions/never'
|
|
117
117
|
export * from './functions/organizations'
|
|
118
118
|
export * from './functions/owned'
|
|
119
|
-
export * from './functions/pagination'
|
|
120
119
|
export * from './functions/resources'
|
|
121
120
|
export * from './functions/reuses'
|
|
122
121
|
export * from './functions/schemas'
|
|
@@ -168,7 +167,6 @@ export type {
|
|
|
168
167
|
Owned,
|
|
169
168
|
OwnedWithFullObject,
|
|
170
169
|
OwnedWithId,
|
|
171
|
-
Page,
|
|
172
170
|
PageBloc,
|
|
173
171
|
ContentBloc,
|
|
174
172
|
BlocWithTitle,
|
|
@@ -225,6 +223,7 @@ export {
|
|
|
225
223
|
getDefaultDataserviceConfig,
|
|
226
224
|
getDefaultReuseConfig,
|
|
227
225
|
getDefaultOrganizationConfig,
|
|
226
|
+
getDefaultTopicConfig,
|
|
228
227
|
getDefaultGlobalSearchConfig,
|
|
229
228
|
defaultDatasetSortOptions,
|
|
230
229
|
defaultDataserviceSortOptions,
|
|
@@ -303,7 +302,7 @@ export {
|
|
|
303
302
|
SimpleBanner,
|
|
304
303
|
SmallChart,
|
|
305
304
|
StatBox,
|
|
306
|
-
|
|
305
|
+
OpenApiViewer,
|
|
307
306
|
Tab,
|
|
308
307
|
TabGroup,
|
|
309
308
|
TabList,
|
|
@@ -24,6 +24,7 @@ export type BaseDataservice = Owned & WithAccessType & {
|
|
|
24
24
|
license: string | null
|
|
25
25
|
private: boolean
|
|
26
26
|
rate_limiting: string
|
|
27
|
+
rate_limiting_url: string | null
|
|
27
28
|
title: DataserviceReference['title']
|
|
28
29
|
contact_points: Array<ContactPoint>
|
|
29
30
|
}
|
|
@@ -65,6 +66,7 @@ export type Dataservice = Owned & WithAccessType & {
|
|
|
65
66
|
permissions: { edit: boolean, delete: boolean }
|
|
66
67
|
private: boolean
|
|
67
68
|
rate_limiting: string
|
|
69
|
+
rate_limiting_url: string | null
|
|
68
70
|
self_api_url: DataserviceReference['self_api_url']
|
|
69
71
|
self_web_url: DataserviceReference['self_web_url']
|
|
70
72
|
slug: string
|
package/src/types/pages.ts
CHANGED
|
@@ -2,11 +2,6 @@ import type { DatasetV2 } from './datasets'
|
|
|
2
2
|
import type { Dataservice } from './dataservices'
|
|
3
3
|
import type { Reuse } from './reuses'
|
|
4
4
|
|
|
5
|
-
export type Page = {
|
|
6
|
-
id: string
|
|
7
|
-
blocs: Array<PageBloc>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
5
|
export type BlocWithTitle = {
|
|
11
6
|
title: string
|
|
12
7
|
subtitle: string | null
|
package/src/types/posts.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Dataset } from './datasets'
|
|
2
|
-
import type {
|
|
2
|
+
import type { PageBloc } from './pages'
|
|
3
3
|
import type { Reuse } from './reuses'
|
|
4
4
|
import type { User } from './users'
|
|
5
5
|
|
|
6
6
|
export type Post = {
|
|
7
7
|
body_type: 'markdown' | 'html' | 'blocs'
|
|
8
|
+
blocs: Array<PageBloc>
|
|
8
9
|
content: string
|
|
9
|
-
content_as_page: Page | null
|
|
10
10
|
created_at: string
|
|
11
11
|
credit_to: string
|
|
12
12
|
credit_url: string
|
package/src/types/reports.ts
CHANGED
|
@@ -16,11 +16,14 @@ export type Report = {
|
|
|
16
16
|
id: string
|
|
17
17
|
by: User | null
|
|
18
18
|
subject: ReportSubject | null
|
|
19
|
+
subject_embed_id: string | null
|
|
19
20
|
reason: ReportReasonValue
|
|
20
21
|
message: string
|
|
21
22
|
reported_at: string
|
|
22
23
|
self_api_url: string
|
|
23
24
|
subject_deleted_at: string | null
|
|
25
|
+
subject_deleted_by: User | null
|
|
26
|
+
subject_label: string | null
|
|
24
27
|
dismissed_at: string | null
|
|
25
28
|
dismissed_by: User | null
|
|
26
29
|
}
|