geonetwork-ui 2.11.0-dev.5c2e5295e → 2.11.0-dev.6804f3b43

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.
Files changed (99) hide show
  1. package/fesm2022/geonetwork-ui.mjs +2533 -1984
  2. package/fesm2022/geonetwork-ui.mjs.map +1 -1
  3. package/index.d.ts +323 -153
  4. package/index.d.ts.map +1 -1
  5. package/package.json +12 -11
  6. package/src/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts +43 -13
  7. package/src/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts +135 -35
  8. package/src/libs/api/repository/src/lib/gn4/gn4-repository.ts +40 -16
  9. package/src/libs/common/domain/src/lib/model/record/metadata.model.ts +12 -0
  10. package/src/libs/common/domain/src/lib/model/search/aggregation.model.ts +2 -0
  11. package/src/libs/common/domain/src/lib/model/search/filter.model.ts +24 -2
  12. package/src/libs/common/domain/src/lib/repository/records-repository.interface.ts +2 -2
  13. package/src/libs/feature/dataviz/src/lib/chart-view/chart-view.component.ts +3 -2
  14. package/src/libs/feature/dataviz/src/lib/geo-table-view/geo-table-view.component.ts +2 -1
  15. package/src/libs/feature/dataviz/src/lib/service/data.service.ts +22 -22
  16. package/src/libs/feature/map/src/index.ts +0 -2
  17. package/src/libs/feature/map/src/lib/add-layer-from-file/add-layer-from-file.component.html +1 -0
  18. package/src/libs/feature/map/src/lib/feature-map.module.ts +1 -8
  19. package/src/libs/feature/notifications/src/lib/notifications.service.ts +6 -4
  20. package/src/libs/feature/notify-reuse/src/lib/notify-reuse-form/notify-reuse-form.component.ts +8 -3
  21. package/src/libs/feature/record/src/lib/state/mdview.actions.ts +4 -8
  22. package/src/libs/feature/record/src/lib/state/mdview.effects.ts +7 -16
  23. package/src/libs/feature/record/src/lib/state/mdview.facade.ts +1 -3
  24. package/src/libs/feature/record/src/lib/state/mdview.reducer.ts +4 -9
  25. package/src/libs/feature/record/src/lib/state/mdview.selectors.ts +2 -7
  26. package/src/libs/feature/router/src/lib/default/state/query-params.utils.ts +1 -1
  27. package/src/libs/feature/search/src/index.ts +2 -0
  28. package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.html +12 -4
  29. package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.ts +63 -19
  30. package/src/libs/feature/{map/src/lib → search/src/lib/geocoding}/geocoding.service.ts +16 -7
  31. package/src/libs/feature/search/src/lib/location-search/location-search.component.html +8 -0
  32. package/src/libs/feature/search/src/lib/location-search/location-search.component.ts +40 -0
  33. package/src/libs/feature/search/src/lib/search-filters-summary-item/search-filters-summary-item.component.ts +19 -8
  34. package/src/libs/feature/search/src/lib/state/reducer.ts +1 -4
  35. package/src/libs/feature/search/src/lib/utils/service/fields.service.ts +58 -4
  36. package/src/libs/feature/search/src/lib/utils/service/fields.ts +92 -9
  37. package/src/libs/ui/dataviz/src/lib/data-table/data-table.component.html +6 -7
  38. package/src/libs/ui/dataviz/src/lib/data-table/data-table.component.ts +31 -19
  39. package/src/libs/ui/dataviz/src/lib/data-table/data-table.fixtures.ts +2 -2
  40. package/src/libs/ui/elements/src/lib/service-capabilities/service-capabilities.component.ts +2 -1
  41. package/src/libs/ui/inputs/src/index.ts +2 -0
  42. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.html +10 -1
  43. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.ts +8 -0
  44. package/src/libs/ui/inputs/src/lib/date-adapter.providers.ts +30 -0
  45. package/src/libs/ui/inputs/src/lib/date-picker/date-picker.component.ts +3 -24
  46. package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.css +37 -3
  47. package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.html +135 -16
  48. package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.ts +166 -29
  49. package/src/libs/ui/inputs/src/lib/date-range-picker/date-range-picker.component.ts +3 -7
  50. package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.css +1 -0
  51. package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.html +20 -7
  52. package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.ts +46 -5
  53. package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.html +7 -4
  54. package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.ts +12 -9
  55. package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.model.ts +2 -2
  56. package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.html +111 -0
  57. package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.ts +221 -0
  58. package/src/libs/ui/layout/src/lib/block-list/block-list.component.css +1 -0
  59. package/src/libs/ui/map/src/lib/components/map-container/map-container.component.ts +6 -5
  60. package/src/libs/util/app-config/src/lib/app-config.ts +25 -0
  61. package/src/libs/util/app-config/src/lib/fixtures.ts +33 -1
  62. package/src/libs/util/app-config/src/lib/model.ts +15 -1
  63. package/src/libs/util/data-fetcher/src/lib/data-fetcher.ts +19 -22
  64. package/src/libs/util/data-fetcher/src/lib/engine/duckdb.ts +185 -0
  65. package/src/libs/util/data-fetcher/src/lib/engine/results.ts +63 -0
  66. package/src/libs/util/data-fetcher/src/lib/{sql-utils.ts → engine/sql-utils.ts} +28 -13
  67. package/src/libs/util/data-fetcher/src/lib/model.ts +2 -1
  68. package/src/libs/util/data-fetcher/src/lib/readers/base-file.ts +53 -38
  69. package/src/libs/util/data-fetcher/src/lib/readers/base.ts +11 -0
  70. package/src/libs/util/data-fetcher/src/lib/readers/csv.ts +9 -47
  71. package/src/libs/util/data-fetcher/src/lib/readers/excel.ts +27 -27
  72. package/src/libs/util/data-fetcher/src/lib/readers/geojson.ts +5 -24
  73. package/src/libs/util/data-fetcher/src/lib/readers/gml.ts +5 -49
  74. package/src/libs/util/data-fetcher/src/lib/readers/json.ts +5 -23
  75. package/src/libs/util/data-fetcher/src/lib/readers/wfs.ts +184 -128
  76. package/src/libs/util/data-fetcher/src/lib/utils.ts +0 -143
  77. package/src/libs/util/shared/src/index.ts +1 -0
  78. package/src/libs/util/shared/src/lib/autofocus.directive.ts +26 -0
  79. package/src/libs/util/shared/src/lib/links/link-utils.ts +19 -10
  80. package/src/libs/util/shared/src/lib/services/date.service.ts +3 -3
  81. package/src/libs/util/shared/src/lib/utils/file.ts +15 -0
  82. package/src/libs/util/shared/src/lib/utils/geojson.ts +24 -0
  83. package/src/libs/util/shared/src/lib/utils/index.ts +1 -0
  84. package/tailwind.base.css +5 -0
  85. package/translations/de.json +22 -4
  86. package/translations/en.json +21 -3
  87. package/translations/es.json +19 -1
  88. package/translations/fr.json +26 -8
  89. package/translations/it.json +20 -2
  90. package/translations/nl.json +19 -1
  91. package/translations/pt.json +19 -1
  92. package/translations/sk.json +20 -2
  93. package/src/libs/feature/map/src/lib/geocoding/geocoding.component.html +0 -41
  94. package/src/libs/feature/map/src/lib/geocoding/geocoding.component.ts +0 -112
  95. package/src/libs/feature/map/src/lib/style/index.ts +0 -2
  96. package/src/libs/feature/map/src/lib/style/map-style.fixtures.ts +0 -47
  97. package/src/libs/feature/map/src/lib/style/map-style.service.ts +0 -108
  98. package/src/libs/util/data-fetcher/src/lib/readers/base-cache.ts +0 -14
  99. /package/src/libs/{feature/map/src/lib/geocoding/geocoding.component.css → ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.css} +0 -0
@@ -0,0 +1,111 @@
1
+ <gn-ui-button
2
+ type="outline"
3
+ extraClass="bg-background w-full !p-[8px] !pl-[16px]"
4
+ [title]="title"
5
+ (buttonClick)="toggleOverlay()"
6
+ cdkOverlayOrigin
7
+ #overlayOrigin="cdkOverlayOrigin"
8
+ >
9
+ <div class="grow flex items-center mr-2 gap-2 overflow-hidden">
10
+ <div class="text-left font-medium truncate py-1">
11
+ {{ title }}
12
+ </div>
13
+ @if (hasSelection) {
14
+ <div
15
+ class="bg-primary-lighter text-white shrink-0 rounded-full font-bold text-[12px] w-[22px] h-[22px] flex items-center justify-center"
16
+ >
17
+ 1
18
+ </div>
19
+ }
20
+ </div>
21
+ <button class="h-6 w-6 flex items-center" data-cy="clearSelection">
22
+ @if (hasSelection && !overlayOpen) {
23
+ <ng-icon
24
+ class="shrink-0 opacity-40 mr-1.5 hover:opacity-80 transition-colors clear-btn"
25
+ (click)="removeSelection($event)"
26
+ name="matClose"
27
+ ></ng-icon>
28
+ }
29
+ </button>
30
+ <ng-icon
31
+ [name]="overlayOpen ? 'matExpandLess' : 'matExpandMore'"
32
+ class="shrink-0 opacity-40"
33
+ >
34
+ </ng-icon>
35
+ </gn-ui-button>
36
+
37
+ <ng-template
38
+ cdkConnectedOverlay
39
+ cdkConnectedOverlayHasBackdrop
40
+ cdkConnectedOverlayBackdropClass="cdk-overlay-transparent-backdrop"
41
+ [cdkConnectedOverlayOrigin]="overlayOrigin"
42
+ [cdkConnectedOverlayOpen]="overlayOpen"
43
+ [cdkConnectedOverlayPositions]="overlayPositions"
44
+ [cdkConnectedOverlayScrollStrategy]="scrollStrategy"
45
+ [cdkConnectedOverlayFlexibleDimensions]="true"
46
+ (overlayOutsideClick)="closeOverlay()"
47
+ (detach)="closeOverlay()"
48
+ >
49
+ <div
50
+ class="bg-white border border-gray-400 rounded shadow-lg pt-[12px] px-[16px] overlay-container w-[280px] flex flex-col gap-2"
51
+ [style.min-width]="overlayMinWidth"
52
+ >
53
+ <div class="text-xs text-black">
54
+ {{ 'search.filters.spatialExtent.helpText' | translate }}
55
+ </div>
56
+
57
+ <div
58
+ [class]="
59
+ (hasSelection
60
+ ? 'border-b-[1px] border-gray-400 pb-[20px]'
61
+ : 'pb-[12px]') + ' text-black'
62
+ "
63
+ >
64
+ <gn-ui-drag-and-drop-file-input
65
+ accept=".json,.geojson"
66
+ [placeholder]="'search.filters.spatialExtent.import' | translate"
67
+ [maxFileSizeMb]="maxFileSizeMb"
68
+ [showFileName]="false"
69
+ textClass="text-black truncate"
70
+ dropzoneBackgroundColor="transparent"
71
+ icon="iconoirUpload"
72
+ extraClass="gn-ui-gray-outline-input w-full !h-[32px] px-[8px] py-[4px] justify-between"
73
+ (fileChange)="handleFileSelected($event)"
74
+ (errorChange)="handleFileError($event)"
75
+ data-cy="importGeojson"
76
+ ></gn-ui-drag-and-drop-file-input>
77
+ </div>
78
+
79
+ @if (hasSelection) {
80
+ <gn-ui-button
81
+ [type]="'primary-light'"
82
+ [title]="selectionDeleteLabelKey | translate: selectionLabelParams"
83
+ (buttonClick)="removeSelection($event)"
84
+ extraClass="group gap-x-2 w-full h-[28px] px-[8px] py-[4px] mb-[12px] bg-primary-lighter text-white"
85
+ data-test="spatial-extent-selected-item"
86
+ >
87
+ <ng-icon
88
+ name="iconoirSquareDashed"
89
+ class="shrink-0"
90
+ size="15px"
91
+ ></ng-icon>
92
+ <span class="group-hover:hidden truncate text-sm m-auto">
93
+ {{ selectionLabelKey | translate: selectionLabelParams }}
94
+ </span>
95
+ <span class="hidden group-hover:block truncate text-sm m-auto">
96
+ {{ selectionDeleteLabelKey | translate: selectionLabelParams }}
97
+ </span>
98
+ <ng-icon
99
+ name="iconoirCheckCircle"
100
+ class="group-hover:hidden shrink-0"
101
+ size="14px"
102
+ ></ng-icon>
103
+ <ng-icon
104
+ name="iconoirTrash"
105
+ class="!hidden group-hover:!block shrink-0"
106
+ size="15px"
107
+ ></ng-icon>
108
+ </gn-ui-button>
109
+ }
110
+ </div>
111
+ </ng-template>
@@ -0,0 +1,221 @@
1
+ import {
2
+ ChangeDetectionStrategy,
3
+ ChangeDetectorRef,
4
+ Component,
5
+ EventEmitter,
6
+ Input,
7
+ Output,
8
+ ViewChild,
9
+ inject,
10
+ } from '@angular/core'
11
+ import {
12
+ CdkConnectedOverlay,
13
+ CdkOverlayOrigin,
14
+ ConnectedPosition,
15
+ OverlayModule,
16
+ ScrollStrategyOptions,
17
+ } from '@angular/cdk/overlay'
18
+
19
+ import { ButtonComponent } from '../button/button.component'
20
+ import { NgIcon, provideIcons } from '@ng-icons/core'
21
+ import {
22
+ iconoirCheckCircle,
23
+ iconoirSquareDashed,
24
+ iconoirTrash,
25
+ iconoirUpload,
26
+ } from '@ng-icons/iconoir'
27
+ import {
28
+ matClose,
29
+ matExpandLess,
30
+ matExpandMore,
31
+ } from '@ng-icons/material-icons/baseline'
32
+ import { TranslatePipe } from '@ngx-translate/core'
33
+ import { marker } from '@biesbjerg/ngx-translate-extract-marker'
34
+ import {
35
+ BoundingBox,
36
+ getGeometryBoundingBox,
37
+ getGeometryFromGeoJSON,
38
+ isBoundingBoxWithinWorldExtent,
39
+ propagateToDocumentOnly,
40
+ readFileAsText,
41
+ } from '../../../../../../libs/util/shared/src'
42
+ import {
43
+ DragAndDropFileInputComponent,
44
+ DragAndDropFileInputError,
45
+ } from '../drag-and-drop-file-input/drag-and-drop-file-input.component'
46
+
47
+ marker('search.filters.spatialExtent.import')
48
+ marker('search.filters.spatialExtent.helpText')
49
+ marker('search.filters.spatialExtent.error.title')
50
+ marker('search.filters.spatialExtent.error.outOfBounds')
51
+
52
+ const LABEL_FROM_FILE = marker('search.filters.spatialExtent.bboxFromFile')
53
+ const LABEL_FROM_FILE_DELETE = marker(
54
+ 'search.filters.spatialExtent.bboxFromFileDelete'
55
+ )
56
+ const LABEL_INITIAL = marker('search.filters.spatialExtent.bboxInitial')
57
+ const LABEL_INITIAL_DELETE = marker(
58
+ 'search.filters.spatialExtent.bboxInitialDelete'
59
+ )
60
+
61
+ export interface SpatialExtentDropdownError {
62
+ key: string
63
+ params?: Record<string, string | number>
64
+ }
65
+
66
+ @Component({
67
+ selector: 'gn-ui-spatial-extent-dropdown',
68
+ standalone: true,
69
+ imports: [
70
+ ButtonComponent,
71
+ NgIcon,
72
+ OverlayModule,
73
+ TranslatePipe,
74
+ DragAndDropFileInputComponent,
75
+ ],
76
+ providers: [
77
+ provideIcons({
78
+ iconoirCheckCircle,
79
+ iconoirSquareDashed,
80
+ iconoirTrash,
81
+ iconoirUpload,
82
+ matClose,
83
+ matExpandLess,
84
+ matExpandMore,
85
+ }),
86
+ ],
87
+ templateUrl: './spatial-extent-dropdown.component.html',
88
+ styleUrls: ['./spatial-extent-dropdown.component.css'],
89
+ changeDetection: ChangeDetectionStrategy.OnPush,
90
+ })
91
+ export class SpatialExtentDropdownComponent {
92
+ private cd = inject(ChangeDetectorRef)
93
+ private scrollStrategies = inject(ScrollStrategyOptions)
94
+
95
+ @Input() title: string
96
+ @Input() maxFileSizeMb: number | null = null
97
+ @Input() set initialBbox(value: BoundingBox | null) {
98
+ if (!this.bbox && value) {
99
+ this.bbox = value
100
+ }
101
+ }
102
+
103
+ @Output() bboxChange = new EventEmitter<BoundingBox | null>()
104
+ @Output() errorChange = new EventEmitter<SpatialExtentDropdownError>()
105
+
106
+ bbox: BoundingBox | null = null
107
+ fileName = ''
108
+
109
+ @ViewChild('overlayOrigin') overlayOrigin: CdkOverlayOrigin
110
+ @ViewChild(CdkConnectedOverlay) overlay: CdkConnectedOverlay
111
+ @ViewChild(DragAndDropFileInputComponent)
112
+ fileInput: DragAndDropFileInputComponent
113
+
114
+ overlayPositions: ConnectedPosition[] = [
115
+ {
116
+ originX: 'start',
117
+ originY: 'bottom',
118
+ overlayX: 'start',
119
+ overlayY: 'top',
120
+ offsetY: 8,
121
+ },
122
+ {
123
+ originX: 'start',
124
+ originY: 'top',
125
+ overlayX: 'start',
126
+ overlayY: 'bottom',
127
+ offsetY: -8,
128
+ },
129
+ ]
130
+ scrollStrategy = this.scrollStrategies.reposition()
131
+ overlayOpen = false
132
+ overlayMinWidth = 'none'
133
+
134
+ errorKey: string | null = null
135
+
136
+ get hasSelection() {
137
+ return !!this.bbox
138
+ }
139
+
140
+ get selectionLabelKey() {
141
+ return this.fileName ? LABEL_FROM_FILE : LABEL_INITIAL
142
+ }
143
+
144
+ get selectionDeleteLabelKey() {
145
+ return this.fileName ? LABEL_FROM_FILE_DELETE : LABEL_INITIAL_DELETE
146
+ }
147
+
148
+ get selectionLabelParams() {
149
+ return { fileName: this.fileName }
150
+ }
151
+
152
+ openOverlay() {
153
+ this.overlayMinWidth =
154
+ this.overlayOrigin.elementRef.nativeElement.getBoundingClientRect()
155
+ .width + 'px'
156
+ this.overlayOpen = true
157
+ }
158
+
159
+ closeOverlay() {
160
+ this.overlayOpen = false
161
+ }
162
+
163
+ toggleOverlay() {
164
+ if (this.overlayOpen) {
165
+ this.closeOverlay()
166
+ } else {
167
+ this.openOverlay()
168
+ }
169
+ }
170
+
171
+ async handleFileSelected(file: File) {
172
+ this.errorKey = null
173
+ let content: string
174
+ try {
175
+ content = await readFileAsText(file)
176
+ const parsed = JSON.parse(content)
177
+ const geometry = getGeometryFromGeoJSON(parsed)
178
+ if (!geometry) {
179
+ this.setError(marker('search.filters.spatialExtent.error.noGeometry'))
180
+ return
181
+ }
182
+ const bbox = getGeometryBoundingBox(geometry)
183
+ if (!isBoundingBoxWithinWorldExtent(bbox)) {
184
+ this.setError(marker('search.filters.spatialExtent.error.outOfBounds'))
185
+ return
186
+ }
187
+ this.bbox = bbox
188
+ this.fileName = file.name
189
+ this.bboxChange.emit(bbox)
190
+ this.cd.markForCheck()
191
+ } catch {
192
+ this.setError(marker('search.filters.spatialExtent.error.invalidFormat'))
193
+ return
194
+ }
195
+ }
196
+
197
+ handleFileError(error: DragAndDropFileInputError) {
198
+ if (error === 'file-too-large') {
199
+ this.setError(marker('search.filters.spatialExtent.error.fileTooLarge'), {
200
+ maxSize: this.maxFileSizeMb,
201
+ })
202
+ } else {
203
+ this.setError(marker('search.filters.spatialExtent.error.invalidFormat'))
204
+ }
205
+ }
206
+
207
+ private setError(errorKey: string, params?: Record<string, string | number>) {
208
+ this.errorKey = errorKey
209
+ this.errorChange.emit({ key: errorKey, params })
210
+ this.cd.markForCheck()
211
+ }
212
+
213
+ removeSelection(event: Event) {
214
+ this.bbox = null
215
+ this.fileName = ''
216
+ this.errorKey = null
217
+ this.fileInput?.clear()
218
+ this.bboxChange.emit(null)
219
+ propagateToDocumentOnly(event)
220
+ }
221
+ }
@@ -3,6 +3,7 @@
3
3
  }
4
4
 
5
5
  :host {
6
+ display: block;
6
7
  position: relative;
7
8
  }
8
9
 
@@ -29,11 +29,11 @@ import {
29
29
  MapExtentChangeEvent,
30
30
  MapExtentChangeEventType,
31
31
  MapContext,
32
- MapContextLayerXyz,
33
32
  MapContextView,
34
33
  MapEventsByType,
35
34
  SourceLoadErrorEvent,
36
35
  SourceLoadErrorType,
36
+ MapContextLayerMapLibreStyle,
37
37
  } from '@geospatial-sdk/core'
38
38
  import {
39
39
  applyContextDiffToMap,
@@ -55,10 +55,11 @@ import {
55
55
  import { matSwipeOutline } from '@ng-icons/material-icons/outline'
56
56
  import { transformExtent } from 'ol/proj.js'
57
57
 
58
- const DEFAULT_BASEMAP_LAYER: MapContextLayerXyz = {
59
- type: 'xyz',
60
- url: `https://{a-c}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}.png`,
61
- attributions: `<span>© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="https://carto.com/">Carto</a></span>`,
58
+ export const DEFAULT_BASEMAP_LAYER: MapContextLayerMapLibreStyle = {
59
+ type: 'maplibre-style',
60
+ styleUrl: `https://basemaps.cartocdn.com/gl/positron-gl-style/style.json`,
61
+ clickable: false,
62
+ hoverable: false,
62
63
  }
63
64
 
64
65
  const DEFAULT_VIEW: MapContextView = {
@@ -252,6 +252,9 @@ export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
252
252
  'search_preset',
253
253
  'advanced_filters',
254
254
  'limit',
255
+ 'spatial_extent_max_file_size',
256
+ 'geocoding_provider',
257
+ 'geocoding_provider_options',
255
258
  ],
256
259
  warnings,
257
260
  errors
@@ -264,6 +267,14 @@ export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
264
267
  warnings,
265
268
  errors
266
269
  )
270
+ const parsedCustomFilters = parseMultiConfigSection(
271
+ parsed,
272
+ 'custom_filter',
273
+ ['name', 'base_filter'],
274
+ ['exclude_values', 'include_values', 'label_key'],
275
+ warnings,
276
+ errors
277
+ )
267
278
  searchConfig =
268
279
  parsedSearchSection === null
269
280
  ? null
@@ -280,7 +291,21 @@ export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
280
291
  filters: param.filters,
281
292
  })),
282
293
  ADVANCED_FILTERS: parsedSearchSection.advanced_filters,
294
+ CUSTOM_FILTERS: (parsedCustomFilters ?? []).map(
295
+ (customFilter) => ({
296
+ name: customFilter.name,
297
+ baseFilter: customFilter.base_filter,
298
+ excludeValues: customFilter.exclude_values,
299
+ includeValues: customFilter.include_values,
300
+ labelKey: customFilter.label_key,
301
+ })
302
+ ),
283
303
  LIMIT: parsedSearchSection.limit,
304
+ SPATIAL_EXTENT_MAX_FILE_SIZE:
305
+ parsedSearchSection.spatial_extent_max_file_size,
306
+ GEOCODING_PROVIDER: parsedSearchSection.geocoding_provider,
307
+ GEOCODING_PROVIDER_OPTIONS:
308
+ parsedSearchSection.geocoding_provider_options,
284
309
  } as SearchConfig)
285
310
 
286
311
  const parsedMetadataQualitySection = parseConfigSection(
@@ -41,7 +41,22 @@ fonts_stylesheet_url = "https://fonts.googleapis.com/css2?family=Open+Sans"
41
41
  record_kind_quick_filter = false
42
42
  filter_geometry_url = 'https://my.domain.org/geom.json'
43
43
  do_not_use_default_search_preset = false
44
- advanced_filters = ['publicationYear', 'documentStandard', 'inspireKeyword', 'topic', 'license']
44
+ geocoding_provider = "geoplateforme"
45
+ geocoding_provider_options.category = "administratif"
46
+ geocoding_provider_options.limit = 5
47
+ advanced_filters = ['publicationYear', 'documentStandard', 'inspireKeyword', 'topic', 'license', 'myOrg:firstCustomFilter', 'myOrg:secondCustomFilter']
48
+
49
+ [[custom_filter]]
50
+ name = 'myOrg:firstCustomFilter'
51
+ base_filter = 'keyword'
52
+ exclude_values = ['my keyword 1', 'my keyword 2']
53
+ label_key = 'myOrg.firstCustomFilter'
54
+
55
+ [[custom_filter]]
56
+ name = 'myOrg:secondCustomFilter'
57
+ base_filter = 'keyword'
58
+ include_values = ['my keyword 3', 'my keyword 4']
59
+ label_key = 'myOrg.secondCustomFilter'
45
60
 
46
61
  [[search_preset]]
47
62
  sort = "-createDate"
@@ -81,6 +96,23 @@ main_color = "#212029" # All-purpose text color
81
96
  background_color = "#fdfbff"
82
97
  `
83
98
 
99
+ export const customFilterMissingMandatoryConfigFixture = () => `
100
+ [global]
101
+ geonetwork4_api_url = "/geonetwork/srv/api"
102
+
103
+ [theme]
104
+ primary_color = "#093564"
105
+ secondary_color = "#c2e9dc"
106
+ main_color = "#212029" # All-purpose text color
107
+ background_color = "#fdfbff"
108
+
109
+ [search]
110
+ advanced_filters = ['myOrg:firstCustomFilter']
111
+
112
+ [[custom_filter]]
113
+ name = 'myOrg:firstCustomFilter'
114
+ `
115
+
84
116
  export const mapConfigFixture = (): MapConfig => ({
85
117
  MAX_ZOOM: 10,
86
118
  MAX_EXTENT: [-418263.418776, 5251529.591305, 961272.067714, 6706890.609855],
@@ -55,14 +55,28 @@ export interface SearchPreset {
55
55
  filters: Record<string, string[] | string>
56
56
  }
57
57
 
58
+ export type GeocodingProviderName = 'geoadmin' | 'geonames' | 'geoplateforme'
59
+
60
+ export interface CustomSearchFieldConfig {
61
+ name: string
62
+ baseFilter: string
63
+ excludeValues?: string[]
64
+ includeValues?: string[]
65
+ labelKey?: string
66
+ }
67
+
58
68
  export interface SearchConfig {
59
69
  RECORD_KIND_QUICK_FILTER?: boolean
60
70
  FILTER_GEOMETRY_URL?: string
61
71
  FILTER_GEOMETRY_DATA?: string
62
72
  DO_NOT_USE_DEFAULT_SEARCH_PRESET?: boolean
63
73
  SEARCH_PRESET?: SearchPreset[]
64
- ADVANCED_FILTERS?: []
74
+ ADVANCED_FILTERS?: string[]
75
+ CUSTOM_FILTERS?: CustomSearchFieldConfig[]
65
76
  LIMIT?: number
77
+ SPATIAL_EXTENT_MAX_FILE_SIZE?: number
78
+ GEOCODING_PROVIDER?: GeocodingProviderName
79
+ GEOCODING_PROVIDER_OPTIONS?: Record<string, string | number>
66
80
  }
67
81
 
68
82
  export interface MetadataQualityConfig {
@@ -7,20 +7,19 @@ import { DataItem, DatasetHeaders, FetchError, SupportedType } from './model'
7
7
  import { inferDatasetType } from './utils'
8
8
  import { BaseReader } from './readers/base'
9
9
  import { GmlReader } from './readers/gml'
10
- import { WfsVersion } from '@camptocamp/ogc-client'
11
10
  import { WfsReader } from './readers/wfs'
12
11
 
12
+ interface OpenDatasetOptions {
13
+ typeHint?: SupportedType
14
+ wfsFeatureType?: string
15
+ enableCache?: boolean // by default cache will be used if this is not set to false
16
+ }
17
+
13
18
  export async function openDataset(
14
19
  url: string,
15
- typeHint?: SupportedType,
16
- options?: {
17
- namespace?: string
18
- wfsVersion?: WfsVersion
19
- wfsFeatureType?: string
20
- },
21
- cacheActive?: boolean
20
+ options?: OpenDatasetOptions
22
21
  ): Promise<BaseReader> {
23
- const fileType = await inferDatasetType(url, typeHint)
22
+ const fileType = await inferDatasetType(url, options?.typeHint)
24
23
  let reader:
25
24
  | CsvReader
26
25
  | JsonReader
@@ -43,19 +42,19 @@ export async function openDataset(
43
42
  reader = new ExcelReader(url)
44
43
  break
45
44
  case 'gml':
46
- reader = new GmlReader(url, options.namespace, options.wfsVersion)
45
+ reader = new GmlReader(url)
47
46
  break
48
47
  case 'wfs':
49
- reader = await WfsReader.createReader(url, options.wfsFeatureType)
48
+ reader = new WfsReader(url, options?.wfsFeatureType)
50
49
  break
51
50
  }
52
- reader.setCacheActive(cacheActive)
51
+ reader.enableCache(options?.enableCache ?? true)
53
52
  reader.load()
54
53
  return reader
55
- } catch (e: any) {
56
- //WfsReader may already raise a FetchError
54
+ } catch (e: unknown) {
55
+ // WfsReader may already raise a FetchError
57
56
  if (e instanceof FetchError) throw e
58
- else throw FetchError.parsingFailed(e.message)
57
+ else throw FetchError.parsingFailed((e as Error).message)
59
58
  }
60
59
  }
61
60
 
@@ -63,22 +62,20 @@ export async function openDataset(
63
62
  * This fetches the full dataset at the given URL and parses it according to its mime type.
64
63
  * All items in the dataset are converted to GeoJSON features, even if they do not bear any spatial geometry.
65
64
  * File type can be either inferred (from the HTTP headers or the URL), or hinted using the 2nd argument
66
- * File type is determined liked so:
65
+ * File type is determined like so:
67
66
  * 1. if a type hint is given, use it
68
67
  * 2. otherwise, look for a Content-Type header in the response with a supported mime type
69
68
  * 3. if no valid mime type was found, look for an explicit file extension in the url (.csv, .geojson etc.)
70
69
  */
71
70
  export async function readDataset(
72
71
  url: string,
73
- typeHint?: SupportedType,
74
- options?: any,
75
- cacheActive = true
72
+ options?: OpenDatasetOptions
76
73
  ): Promise<DataItem[]> {
77
- const reader = await openDataset(url, typeHint, options, cacheActive)
74
+ const reader = await openDataset(url, options)
78
75
  try {
79
76
  return await reader.read()
80
- } catch (e: any) {
81
- throw FetchError.parsingFailed(e.message)
77
+ } catch (e: unknown) {
78
+ throw FetchError.parsingFailed((e as Error).message)
82
79
  }
83
80
  }
84
81