@datagouv/components-next 1.0.2-dev.9 → 1.1.1
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/assets/main.css +4 -0
- package/dist/Datafair.client-BzW-ctDf.js +30 -0
- package/dist/JsonPreview.client-BfMSzR07.js +40 -0
- package/dist/{MapContainer.client-CUmKyByc.js → MapContainer.client-CLs-im9i.js} +34 -39
- package/dist/{PdfPreview.client-BVjPxlPu.js → PdfPreview.client-C13PQCU_.js} +822 -865
- package/dist/{Pmtiles.client-CRJ56yX2.js → Pmtiles.client-CL7PXXDl.js} +574 -579
- package/dist/PreviewWrapper.vue_vue_type_script_setup_true_lang-C6XnsZ-7.js +61 -0
- package/dist/XmlPreview.client-KaENrbbG.js +34 -0
- package/dist/components-next.css +3 -3
- package/dist/components-next.js +166 -148
- package/dist/components.css +1 -1
- package/dist/{index-BZsAZ7iw.js → index-C7WVVGgD.js} +1 -1
- package/dist/{main-qc4CO9Kn.js → main-K-42Oe8-.js} +91315 -75834
- package/dist/{vue3-xml-viewer.common-CCOV_ohP.js → vue3-xml-viewer.common-sHPSE-jD.js} +1 -1
- package/package.json +17 -10
- package/src/components/ActivityList/ActivityList.vue +0 -2
- package/src/components/Chart/ChartViewer.vue +226 -0
- package/src/components/Chart/ChartViewerWrapper.vue +170 -0
- package/src/components/Form/Listbox.vue +101 -0
- package/src/components/Form/SearchableSelect.vue +2 -1
- package/src/components/InfiniteLoader.vue +53 -0
- 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 +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 +4 -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 +16 -21
- 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 +5 -7
- package/src/components/ResourceAccordion/XmlPreview.client.vue +16 -115
- package/src/components/ResourceExplorer/ResourceExplorer.vue +81 -13
- package/src/components/ResourceExplorer/ResourceExplorerSidebar.vue +2 -2
- package/src/components/ResourceExplorer/ResourceExplorerViewer.vue +30 -11
- package/src/components/Search/GlobalSearch.vue +173 -108
- package/src/components/Search/SearchInput.vue +3 -3
- package/src/components/TabularExplorer/TabularCell.vue +51 -0
- package/src/components/TabularExplorer/TabularCellPopover.vue +170 -0
- package/src/components/TabularExplorer/TabularExplorer.vue +870 -0
- package/src/components/TabularExplorer/TabularFilterContent.vue +351 -0
- package/src/components/TabularExplorer/TabularFilterPopover.vue +111 -0
- package/src/components/TabularExplorer/types.ts +83 -0
- package/src/composables/useHasTabularData.ts +6 -0
- package/src/composables/useResourceCapabilities.ts +1 -1
- package/src/composables/useSearchFilter.ts +118 -0
- package/src/composables/useStableQueryParams.ts +31 -3
- package/src/config.ts +3 -0
- package/src/functions/api.ts +34 -33
- package/src/functions/api.types.ts +1 -0
- package/src/functions/charts.ts +68 -0
- package/src/functions/datasets.ts +0 -17
- package/src/functions/resources.ts +56 -1
- package/src/functions/tabular.ts +60 -0
- package/src/functions/tabularApi.ts +138 -11
- package/src/main.ts +55 -7
- package/src/types/dataservices.ts +2 -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/search.ts +52 -1
- package/src/types/site.ts +5 -3
- package/src/types/users.ts +2 -1
- package/src/types/visualizations.ts +89 -0
- package/assets/swagger-themes/newspaper.css +0 -1670
- package/dist/Datafair.client-0UYUu5yf.js +0 -35
- package/dist/JsonPreview.client-BrTMBWHZ.js +0 -87
- package/dist/Swagger.client-2Yn7iF0A.js +0 -4
- package/dist/XmlPreview.client-DxqlVnKu.js +0 -79
- 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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="flex items-center gap-2 mb-2">
|
|
4
|
+
<button
|
|
5
|
+
type="button"
|
|
6
|
+
class="text-xs font-medium px-2 py-0.5 rounded"
|
|
7
|
+
:class="view === 'schema' ? 'bg-gray-200 text-gray-title' : 'text-gray-medium hover:text-gray-title'"
|
|
8
|
+
@click="view = 'schema'"
|
|
9
|
+
>
|
|
10
|
+
{{ t("Schéma") }}
|
|
11
|
+
</button>
|
|
12
|
+
<button
|
|
13
|
+
type="button"
|
|
14
|
+
class="text-xs font-medium px-2 py-0.5 rounded"
|
|
15
|
+
:class="view === 'example' ? 'bg-gray-200 text-gray-title' : 'text-gray-medium hover:text-gray-title'"
|
|
16
|
+
@click="view = 'example'"
|
|
17
|
+
>
|
|
18
|
+
{{ t("Exemple") }}
|
|
19
|
+
</button>
|
|
20
|
+
</div>
|
|
21
|
+
<SchemaTree
|
|
22
|
+
v-if="view === 'schema'"
|
|
23
|
+
:spec="spec"
|
|
24
|
+
:schema="schema"
|
|
25
|
+
/>
|
|
26
|
+
<pre
|
|
27
|
+
v-else
|
|
28
|
+
class="text-xs font-mono bg-gray-50 rounded p-3 overflow-x-auto m-0 text-gray-title"
|
|
29
|
+
>{{ exampleJson }}</pre>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import { ref, computed } from 'vue'
|
|
35
|
+
import SchemaTree from './SchemaTree.vue'
|
|
36
|
+
import { useTranslation } from '../../composables/useTranslation'
|
|
37
|
+
import { generateExample } from './openapi'
|
|
38
|
+
import type { OpenAPIV3 } from 'openapi-types'
|
|
39
|
+
|
|
40
|
+
const props = defineProps<{
|
|
41
|
+
spec: OpenAPIV3.Document
|
|
42
|
+
schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject
|
|
43
|
+
}>()
|
|
44
|
+
|
|
45
|
+
const { t } = useTranslation()
|
|
46
|
+
|
|
47
|
+
const view = ref<'schema' | 'example'>('schema')
|
|
48
|
+
|
|
49
|
+
const exampleJson = computed(() => {
|
|
50
|
+
const example = generateExample(props.spec, props.schema)
|
|
51
|
+
return JSON.stringify(example, null, 2)
|
|
52
|
+
})
|
|
53
|
+
</script>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="text-xs overflow-hidden">
|
|
3
|
+
<div
|
|
4
|
+
v-for="prop in properties"
|
|
5
|
+
:key="prop.name"
|
|
6
|
+
class="border-b border-gray-100 last:border-0"
|
|
7
|
+
>
|
|
8
|
+
<div class="flex items-baseline gap-2 py-1.5 min-w-0">
|
|
9
|
+
<button
|
|
10
|
+
v-if="hasNestedProperties(spec, prop.schema)"
|
|
11
|
+
type="button"
|
|
12
|
+
class="shrink-0 flex items-center gap-1 font-mono text-gray-title hover:text-gray-800"
|
|
13
|
+
@click="toggle(prop.name)"
|
|
14
|
+
>
|
|
15
|
+
<RiArrowRightSLine
|
|
16
|
+
class="size-3 text-gray-medium transition-transform"
|
|
17
|
+
:class="{ 'rotate-90': expanded.has(prop.name) }"
|
|
18
|
+
/>
|
|
19
|
+
{{ prop.name }}
|
|
20
|
+
<span
|
|
21
|
+
v-if="prop.required"
|
|
22
|
+
class="text-red-600"
|
|
23
|
+
>*</span>
|
|
24
|
+
</button>
|
|
25
|
+
<span
|
|
26
|
+
v-else
|
|
27
|
+
class="font-mono text-gray-title pl-4"
|
|
28
|
+
>
|
|
29
|
+
{{ prop.name }}
|
|
30
|
+
<span
|
|
31
|
+
v-if="prop.required"
|
|
32
|
+
class="text-red-600"
|
|
33
|
+
>*</span>
|
|
34
|
+
</span>
|
|
35
|
+
<span class="font-mono text-gray-medium whitespace-nowrap">{{ prop.type }}</span>
|
|
36
|
+
<span
|
|
37
|
+
v-if="prop.description"
|
|
38
|
+
class="text-gray-medium truncate"
|
|
39
|
+
>{{ prop.description }}</span>
|
|
40
|
+
</div>
|
|
41
|
+
<div
|
|
42
|
+
v-if="expanded.has(prop.name) && hasNestedProperties(spec, prop.schema)"
|
|
43
|
+
class="pl-4 ml-1.5 border-l border-gray-200"
|
|
44
|
+
>
|
|
45
|
+
<SchemaTree
|
|
46
|
+
:spec="spec"
|
|
47
|
+
:schema="getNestedSchema(spec, prop.schema)!"
|
|
48
|
+
/>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script setup lang="ts">
|
|
55
|
+
import { computed, reactive } from 'vue'
|
|
56
|
+
import { RiArrowRightSLine } from '@remixicon/vue'
|
|
57
|
+
import { getSchemaProperties, hasNestedProperties, getNestedSchema } from './openapi'
|
|
58
|
+
import type { OpenAPIV3 } from 'openapi-types'
|
|
59
|
+
|
|
60
|
+
const props = defineProps<{
|
|
61
|
+
spec: OpenAPIV3.Document
|
|
62
|
+
schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject
|
|
63
|
+
}>()
|
|
64
|
+
|
|
65
|
+
const properties = computed(() => getSchemaProperties(props.spec, props.schema))
|
|
66
|
+
|
|
67
|
+
const expanded = reactive(new Set<string>())
|
|
68
|
+
|
|
69
|
+
function toggle(name: string) {
|
|
70
|
+
if (expanded.has(name)) {
|
|
71
|
+
expanded.delete(name)
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
expanded.add(name)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
</script>
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { OpenAPIV3 } from 'openapi-types'
|
|
2
|
+
|
|
3
|
+
export interface Endpoint {
|
|
4
|
+
method: string
|
|
5
|
+
path: string
|
|
6
|
+
summary: string
|
|
7
|
+
tags: string[]
|
|
8
|
+
parameters: OpenAPIV3.ParameterObject[]
|
|
9
|
+
requestBody: OpenAPIV3.RequestBodyObject | null
|
|
10
|
+
responses: Record<string, OpenAPIV3.ResponseObject>
|
|
11
|
+
spec: OpenAPIV3.Document
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function resolveRef<T>(spec: OpenAPIV3.Document, obj: T | OpenAPIV3.ReferenceObject): T | null {
|
|
15
|
+
if (!obj || typeof obj !== 'object') return obj as T | null
|
|
16
|
+
if (!('$ref' in obj)) return obj as T
|
|
17
|
+
const path = (obj as OpenAPIV3.ReferenceObject).$ref.replace('#/', '').split('/')
|
|
18
|
+
let resolved: unknown = spec
|
|
19
|
+
for (const segment of path) {
|
|
20
|
+
if (resolved && typeof resolved === 'object') {
|
|
21
|
+
resolved = (resolved as Record<string, unknown>)[segment]
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return null
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return resolved as T
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function getSchemaType(spec: OpenAPIV3.Document, schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject): string {
|
|
31
|
+
if (!schema) return ''
|
|
32
|
+
const resolved = resolveRef<OpenAPIV3.SchemaObject>(spec, schema)
|
|
33
|
+
if (!resolved) return ''
|
|
34
|
+
if (resolved.type === 'array' && resolved.items) {
|
|
35
|
+
const itemType = getSchemaType(spec, resolved.items)
|
|
36
|
+
return `${itemType}[]`
|
|
37
|
+
}
|
|
38
|
+
if (resolved.format) return `${resolved.type} (${resolved.format})`
|
|
39
|
+
return resolved.type || ''
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const CONTENT_TYPE_LABELS: Record<string, string> = {
|
|
43
|
+
'application/json': 'JSON',
|
|
44
|
+
'application/xml': 'XML',
|
|
45
|
+
'application/x-www-form-urlencoded': 'Form',
|
|
46
|
+
'multipart/form-data': 'Multipart',
|
|
47
|
+
'text/plain': 'Text',
|
|
48
|
+
'text/html': 'HTML',
|
|
49
|
+
'text/csv': 'CSV',
|
|
50
|
+
'application/octet-stream': 'Binary',
|
|
51
|
+
'application/pdf': 'PDF',
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function contentTypeLabel(raw: string): string {
|
|
55
|
+
const base = raw.split(';')[0]!.trim()
|
|
56
|
+
return CONTENT_TYPE_LABELS[base] || base
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface SchemaProperty {
|
|
60
|
+
name: string
|
|
61
|
+
type: string
|
|
62
|
+
description: string
|
|
63
|
+
required: boolean
|
|
64
|
+
schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject | undefined
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function getSchemaProperties(spec: OpenAPIV3.Document, schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject): SchemaProperty[] {
|
|
68
|
+
if (!schema) return []
|
|
69
|
+
const resolved = resolveRef<OpenAPIV3.SchemaObject>(spec, schema)
|
|
70
|
+
if (!resolved?.properties) return []
|
|
71
|
+
const requiredFields = resolved.required || []
|
|
72
|
+
return Object.entries(resolved.properties).map(([name, propSchema]) => {
|
|
73
|
+
const prop = resolveRef<OpenAPIV3.SchemaObject>(spec, propSchema)
|
|
74
|
+
return {
|
|
75
|
+
name,
|
|
76
|
+
type: getSchemaType(spec, propSchema),
|
|
77
|
+
description: prop?.description || '',
|
|
78
|
+
required: requiredFields.includes(name),
|
|
79
|
+
schema: propSchema,
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function hasNestedProperties(spec: OpenAPIV3.Document, schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject): boolean {
|
|
85
|
+
if (!schema) return false
|
|
86
|
+
const resolved = resolveRef<OpenAPIV3.SchemaObject>(spec, schema)
|
|
87
|
+
if (!resolved) return false
|
|
88
|
+
if (resolved.properties) return true
|
|
89
|
+
if (resolved.type === 'array' && resolved.items) {
|
|
90
|
+
return hasNestedProperties(spec, resolved.items)
|
|
91
|
+
}
|
|
92
|
+
return false
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function getNestedSchema(spec: OpenAPIV3.Document, schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject): OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject | undefined {
|
|
96
|
+
if (!schema) return undefined
|
|
97
|
+
const resolved = resolveRef<OpenAPIV3.SchemaObject>(spec, schema)
|
|
98
|
+
if (!resolved) return undefined
|
|
99
|
+
if (resolved.properties) return schema
|
|
100
|
+
if (resolved.type === 'array' && resolved.items) return resolved.items
|
|
101
|
+
return undefined
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const MAX_EXAMPLE_DEPTH = 4
|
|
105
|
+
|
|
106
|
+
function defaultForType(type?: string, format?: string): unknown {
|
|
107
|
+
switch (type) {
|
|
108
|
+
case 'string':
|
|
109
|
+
if (format === 'date') return '2024-01-01'
|
|
110
|
+
if (format === 'date-time') return '2024-01-01T00:00:00Z'
|
|
111
|
+
if (format === 'email') return 'user@example.com'
|
|
112
|
+
if (format === 'uri' || format === 'url') return 'https://example.com'
|
|
113
|
+
return 'string'
|
|
114
|
+
case 'integer': return 0
|
|
115
|
+
case 'number': return 0.0
|
|
116
|
+
case 'boolean': return true
|
|
117
|
+
case 'null': return null
|
|
118
|
+
default: return {}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function generateExample(spec: OpenAPIV3.Document, schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject, depth = 0): unknown {
|
|
123
|
+
if (!schema || depth > MAX_EXAMPLE_DEPTH) return undefined
|
|
124
|
+
const resolved = resolveRef<OpenAPIV3.SchemaObject>(spec, schema)
|
|
125
|
+
if (!resolved) return undefined
|
|
126
|
+
|
|
127
|
+
if (resolved.example !== undefined) return resolved.example
|
|
128
|
+
|
|
129
|
+
if (resolved.type === 'array' && resolved.items) {
|
|
130
|
+
const item = generateExample(spec, resolved.items, depth + 1)
|
|
131
|
+
return item !== undefined ? [item] : []
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (resolved.properties) {
|
|
135
|
+
const obj: Record<string, unknown> = {}
|
|
136
|
+
for (const [name, propSchema] of Object.entries(resolved.properties)) {
|
|
137
|
+
const prop = resolveRef<OpenAPIV3.SchemaObject>(spec, propSchema)
|
|
138
|
+
if (prop?.example !== undefined) {
|
|
139
|
+
obj[name] = prop.example
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
const val = generateExample(spec, propSchema, depth + 1)
|
|
143
|
+
if (val !== undefined) obj[name] = val
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return obj
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return defaultForType(resolved.type as string, resolved.format)
|
|
150
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<component
|
|
8
8
|
:is="as"
|
|
9
9
|
class="mb-0 truncate flex-initial"
|
|
10
|
-
:class="[colorClass, { 'text-xs': size === 'xs', 'text-sm': size === 'sm', 'text-base': size === 'base' }]"
|
|
10
|
+
:class="[colorClass, { 'text-xs': size === 'xs', 'text-sm': size === 'sm', 'text-base': size === 'base', 'text-xl sm:text-2xl': size === 'xl' }]"
|
|
11
11
|
>
|
|
12
12
|
{{ organization.name }}
|
|
13
13
|
<small
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
'size-3': size === 'xs',
|
|
25
25
|
'size-4': size === 'sm',
|
|
26
26
|
'size-5': size === 'base',
|
|
27
|
+
'size-6': size === 'xl',
|
|
27
28
|
}"
|
|
28
29
|
:aria-label="t(`L'identité de ce service public est certifiée par {certifier}`, { certifier: config.name })"
|
|
29
30
|
aria-hidden="true"
|
|
@@ -53,7 +54,7 @@ withDefaults(defineProps<{
|
|
|
53
54
|
organization: Organization | OrganizationReference
|
|
54
55
|
showAcronym?: boolean
|
|
55
56
|
showType?: boolean
|
|
56
|
-
size?: 'base' | 'sm' | 'xs'
|
|
57
|
+
size?: 'xl' | 'base' | 'sm' | 'xs'
|
|
57
58
|
colorClass?: string
|
|
58
59
|
as?: string
|
|
59
60
|
}>(), {
|
|
@@ -101,6 +101,7 @@
|
|
|
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'
|
|
105
106
|
|
|
106
107
|
type Props = {
|
|
@@ -112,10 +113,6 @@ type Props = {
|
|
|
112
113
|
* The page size.
|
|
113
114
|
*/
|
|
114
115
|
pageSize?: number
|
|
115
|
-
/**
|
|
116
|
-
* Customize the links used
|
|
117
|
-
*/
|
|
118
|
-
link?: (page: number) => string
|
|
119
116
|
/**
|
|
120
117
|
* The number of items in the collection. It's used to calculated the number of pages.
|
|
121
118
|
*/
|
|
@@ -174,6 +171,7 @@ function getVisiblePages(currentPage: number, pageCount: number) {
|
|
|
174
171
|
}
|
|
175
172
|
|
|
176
173
|
const { t } = useTranslation()
|
|
174
|
+
const route = useRoute()
|
|
177
175
|
const pageCount = computed(() => Math.ceil(props.totalResults / props.pageSize))
|
|
178
176
|
const visiblePages = computed(() => getVisiblePages(props.page, pageCount.value))
|
|
179
177
|
|
|
@@ -211,6 +209,11 @@ function getHref(forPage: number) {
|
|
|
211
209
|
if (forPage < 1 || forPage > pageCount.value) {
|
|
212
210
|
return undefined
|
|
213
211
|
}
|
|
214
|
-
|
|
212
|
+
if (props.page === forPage) {
|
|
213
|
+
return undefined
|
|
214
|
+
}
|
|
215
|
+
const search = new URLSearchParams(route.query as Record<string, string>)
|
|
216
|
+
search.set('page', forPage.toFixed(0))
|
|
217
|
+
return `${route.path}?${search.toString()}`
|
|
215
218
|
}
|
|
216
219
|
</script>
|
|
@@ -9,21 +9,15 @@
|
|
|
9
9
|
border: none;"
|
|
10
10
|
/>
|
|
11
11
|
</div>
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class="flex items-center space-x-2"
|
|
16
|
-
>
|
|
17
|
-
<RiErrorWarningLine class="shrink-0 size-6" />
|
|
18
|
-
<span>{{ t("Erreur lors de l'affichage de l'aperçu.") }}</span>
|
|
19
|
-
</SimpleBanner>
|
|
12
|
+
<PreviewUnavailable v-else>
|
|
13
|
+
{{ t("L'aperçu de ce fichier n'a pas pu être chargé. Téléchargez-le depuis l'onglet Téléchargements.") }}
|
|
14
|
+
</PreviewUnavailable>
|
|
20
15
|
</div>
|
|
21
16
|
</template>
|
|
22
17
|
|
|
23
18
|
<script setup lang="ts">
|
|
24
19
|
import { computed } from 'vue'
|
|
25
|
-
import
|
|
26
|
-
import SimpleBanner from '../SimpleBanner.vue'
|
|
20
|
+
import PreviewUnavailable from './PreviewUnavailable.vue'
|
|
27
21
|
import type { Resource } from '../../types/resources'
|
|
28
22
|
import type { Dataset, DatasetV2 } from '../../types/datasets'
|
|
29
23
|
import { useTranslation } from '../../composables/useTranslation'
|
|
@@ -1,65 +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
|
-
<SimpleBanner
|
|
21
|
-
v-else-if="fileTooLarge"
|
|
22
|
-
type="warning"
|
|
23
|
-
class="flex items-center space-x-2"
|
|
24
|
-
>
|
|
25
|
-
<RiErrorWarningLine class="shrink-0 size-6" />
|
|
26
|
-
<span>{{ fileSizeBytes
|
|
27
|
-
? t("Fichier JSON 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.")
|
|
28
|
-
: 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.")
|
|
29
|
-
}}</span>
|
|
30
|
-
</SimpleBanner>
|
|
31
|
-
<SimpleBanner
|
|
32
|
-
v-else-if="error === 'network'"
|
|
33
|
-
type="warning"
|
|
34
|
-
class="flex items-center space-x-2"
|
|
35
|
-
>
|
|
36
|
-
<RiErrorWarningLine class="shrink-0 size-6" />
|
|
37
|
-
<span>{{ t("Ce fichier JSON 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>
|
|
38
|
-
</SimpleBanner>
|
|
39
|
-
<SimpleBanner
|
|
40
|
-
v-else-if="error"
|
|
41
|
-
type="warning"
|
|
42
|
-
class="flex items-center space-x-2"
|
|
43
|
-
>
|
|
44
|
-
<RiErrorWarningLine class="shrink-0 size-6" />
|
|
45
|
-
<span>{{ t("Erreur lors du chargement de l'aperçu JSON.") }}</span>
|
|
46
|
-
</SimpleBanner>
|
|
47
|
-
</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>
|
|
48
19
|
</template>
|
|
49
20
|
|
|
50
21
|
<script setup lang="ts">
|
|
51
|
-
import {
|
|
52
|
-
import { RiErrorWarningLine } from '@remixicon/vue'
|
|
53
|
-
|
|
22
|
+
import { defineAsyncComponent } from 'vue'
|
|
54
23
|
import { useComponentsConfig } from '../../config'
|
|
55
|
-
import
|
|
24
|
+
import PreviewWrapper from './PreviewWrapper.vue'
|
|
56
25
|
import type { Resource } from '../../types/resources'
|
|
57
|
-
import { useTranslation } from '../../composables/useTranslation'
|
|
58
|
-
import { getResourceFilesize } from '../../functions/datasets'
|
|
59
26
|
|
|
60
27
|
const JsonViewer = defineAsyncComponent(() =>
|
|
61
28
|
import('vue3-json-viewer').then((module) => {
|
|
62
|
-
// Import CSS when component loads
|
|
63
29
|
import('vue3-json-viewer/dist/vue3-json-viewer.css')
|
|
64
30
|
return module.JsonViewer
|
|
65
31
|
}),
|
|
@@ -70,74 +36,10 @@ const props = defineProps<{
|
|
|
70
36
|
}>()
|
|
71
37
|
|
|
72
38
|
const config = useComponentsConfig()
|
|
73
|
-
const { t } = useTranslation()
|
|
74
|
-
|
|
75
|
-
const jsonData = ref<unknown>(null)
|
|
76
|
-
const loading = ref(false)
|
|
77
|
-
const error = ref<string | null>(null)
|
|
78
|
-
const fileTooLarge = ref(false)
|
|
79
|
-
|
|
80
|
-
const fileSizeBytes = computed(() => getResourceFilesize(props.resource))
|
|
81
|
-
|
|
82
|
-
const shouldLoadJson = computed(() => {
|
|
83
|
-
const size = fileSizeBytes.value
|
|
84
|
-
if (!size) {
|
|
85
|
-
// If we don't know the size, don't risk loading a potentially huge file
|
|
86
|
-
return false
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Check if maxJsonPreviewCharSize is configured
|
|
90
|
-
if (!config.maxJsonPreviewCharSize) {
|
|
91
|
-
// If no limit is set, don't load unknown files
|
|
92
|
-
return false
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Convert maxJsonPreviewCharSize from characters to bytes (rough estimate)
|
|
96
|
-
// Assuming average 1 byte per character for JSON
|
|
97
|
-
const maxByteSize = config.maxJsonPreviewCharSize
|
|
98
|
-
|
|
99
|
-
return size <= maxByteSize
|
|
100
|
-
})
|
|
101
39
|
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
if (!
|
|
105
|
-
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
loading.value = true
|
|
110
|
-
error.value = null
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
const response = await fetch(props.resource.url)
|
|
114
|
-
// const response = await fetch('/test-data.json') // For testing locally without CORS issues
|
|
115
|
-
if (!response.ok) {
|
|
116
|
-
throw new Error(`HTTP error! status: ${response.status}`)
|
|
117
|
-
}
|
|
118
|
-
const data = await response.json()
|
|
119
|
-
|
|
120
|
-
// Use the original data directly - let the JSON viewer handle large files
|
|
121
|
-
jsonData.value = data
|
|
122
|
-
}
|
|
123
|
-
catch (err) {
|
|
124
|
-
console.error('Error loading JSON:', err)
|
|
125
|
-
|
|
126
|
-
if (err instanceof TypeError) {
|
|
127
|
-
error.value = 'network'
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
error.value = 'generic'
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
jsonData.value = null
|
|
134
|
-
}
|
|
135
|
-
finally {
|
|
136
|
-
loading.value = false
|
|
137
|
-
}
|
|
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()
|
|
138
44
|
}
|
|
139
|
-
|
|
140
|
-
onMounted(() => {
|
|
141
|
-
fetchJsonData()
|
|
142
|
-
})
|
|
143
45
|
</script>
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class="flex items-center space-x-2"
|
|
6
|
-
>
|
|
7
|
-
<RiErrorWarningLine class="shrink-0 size-6" />
|
|
8
|
-
<span>{{ t("L'aperçu cartographique de ce fichier n'a pas pu être chargé.") }}</span>
|
|
9
|
-
</SimpleBanner>
|
|
2
|
+
<PreviewUnavailable v-if="hasError">
|
|
3
|
+
{{ t("L'aperçu cartographique de ce fichier n'a pas pu être chargé.") }}
|
|
4
|
+
</PreviewUnavailable>
|
|
10
5
|
<div
|
|
11
6
|
v-else
|
|
12
7
|
id="map"
|
|
@@ -16,9 +11,7 @@
|
|
|
16
11
|
|
|
17
12
|
<script setup lang = "ts">
|
|
18
13
|
import { onMounted, ref, useTemplateRef } from 'vue'
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
import SimpleBanner from '../SimpleBanner.vue'
|
|
14
|
+
import PreviewUnavailable from './PreviewUnavailable.vue'
|
|
22
15
|
import type { Resource } from '../../types/resources'
|
|
23
16
|
import { useTranslation } from '../../composables/useTranslation'
|
|
24
17
|
|
|
@@ -7,9 +7,8 @@ import DescriptionTerm from '../DescriptionTerm.vue'
|
|
|
7
7
|
import { useFormatDate } from '../../functions/dates'
|
|
8
8
|
import { filesize } from '../../functions/helpers'
|
|
9
9
|
import ExtraAccordion from '../ExtraAccordion.vue'
|
|
10
|
-
import { getResourceTitleId, getResourceLabel } from '../../functions/resources'
|
|
10
|
+
import { getResourceTitleId, getResourceLabel, getResourceFilesize } from '../../functions/resources'
|
|
11
11
|
import { useTranslation } from '../../composables/useTranslation'
|
|
12
|
-
import { getResourceFilesize } from '../../functions/datasets'
|
|
13
12
|
|
|
14
13
|
const props = defineProps<{
|
|
15
14
|
resource: Resource
|