geonetwork-ui 2.11.0-dev.2478042b2 → 2.11.0-dev.30db8c2d6

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 (89) hide show
  1. package/fesm2022/geonetwork-ui.mjs +2052 -1468
  2. package/fesm2022/geonetwork-ui.mjs.map +1 -1
  3. package/index.d.ts +303 -124
  4. package/index.d.ts.map +1 -1
  5. package/package.json +7 -5
  6. package/src/libs/api/metadata-converter/src/lib/dcat-ap/dcat-ap.converter.ts +2 -0
  7. package/src/libs/api/metadata-converter/src/lib/fixtures/mel.records.dataset+featurecatalog.ts +317 -0
  8. package/src/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts +35 -8
  9. package/src/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.ts +19 -0
  10. package/src/libs/api/metadata-converter/src/lib/iso19115-3/iso19115-3.converter.ts +2 -0
  11. package/src/libs/api/metadata-converter/src/lib/iso19115-3/read-parts.ts +98 -0
  12. package/src/libs/api/metadata-converter/src/lib/iso19139/iso19139.converter.ts +7 -0
  13. package/src/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts +2 -1
  14. package/src/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts +134 -35
  15. package/src/libs/api/repository/src/lib/gn4/gn4-repository.ts +5 -34
  16. package/src/libs/common/domain/src/lib/model/record/metadata.model.ts +6 -13
  17. package/src/libs/common/domain/src/lib/model/search/aggregation.model.ts +2 -0
  18. package/src/libs/common/domain/src/lib/model/search/filter.model.ts +24 -2
  19. package/src/libs/common/domain/src/lib/repository/records-repository.interface.ts +1 -1
  20. package/src/libs/common/fixtures/src/lib/records.fixtures.ts +42 -62
  21. package/src/libs/feature/dataviz/src/lib/service/data.service.ts +32 -19
  22. package/src/libs/feature/map/src/index.ts +0 -2
  23. package/src/libs/feature/map/src/lib/add-layer-from-file/add-layer-from-file.component.html +1 -0
  24. package/src/libs/feature/map/src/lib/feature-map.module.ts +1 -8
  25. package/src/libs/feature/notifications/src/lib/notifications.service.ts +6 -4
  26. package/src/libs/feature/notify-reuse/src/lib/notify-reuse-form/notify-reuse-form.component.ts +8 -3
  27. package/src/libs/feature/record/src/lib/state/mdview.effects.ts +3 -1
  28. package/src/libs/feature/record/src/lib/state/mdview.facade.ts +1 -1
  29. package/src/libs/feature/router/src/lib/default/state/query-params.utils.ts +1 -1
  30. package/src/libs/feature/search/src/index.ts +2 -0
  31. package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.html +18 -4
  32. package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.ts +80 -19
  33. package/src/libs/feature/search/src/lib/geocoding/geocoding.service.ts +105 -0
  34. package/src/libs/feature/search/src/lib/location-search/location-search.component.html +18 -0
  35. package/src/libs/feature/search/src/lib/location-search/location-search.component.ts +114 -0
  36. package/src/libs/feature/search/src/lib/search-filters-summary-item/search-filters-summary-item.component.ts +19 -8
  37. package/src/libs/feature/search/src/lib/state/reducer.ts +1 -4
  38. package/src/libs/feature/search/src/lib/utils/service/fields.service.ts +64 -4
  39. package/src/libs/feature/search/src/lib/utils/service/fields.ts +92 -9
  40. package/src/libs/ui/elements/src/lib/record-feature-catalog/feature-catalog-list/feature-catalog-list.component.html +2 -2
  41. package/src/libs/ui/elements/src/lib/record-feature-catalog/feature-catalog-list/feature-catalog-list.component.ts +2 -2
  42. package/src/libs/ui/elements/src/lib/service-capabilities/service-capabilities.component.ts +2 -1
  43. package/src/libs/ui/inputs/src/index.ts +2 -0
  44. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.css +0 -4
  45. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.html +12 -3
  46. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.ts +11 -3
  47. package/src/libs/ui/inputs/src/lib/date-adapter.providers.ts +30 -0
  48. package/src/libs/ui/inputs/src/lib/date-picker/date-picker.component.ts +3 -24
  49. package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.css +37 -3
  50. package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.html +135 -16
  51. package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.ts +166 -29
  52. package/src/libs/ui/inputs/src/lib/date-range-picker/date-range-picker.component.ts +3 -7
  53. package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.css +1 -0
  54. package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.html +20 -7
  55. package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.ts +46 -5
  56. package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.html +7 -4
  57. package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.ts +12 -9
  58. package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.model.ts +2 -2
  59. package/src/libs/ui/inputs/src/lib/search-feature-catalog/search-feature-catalog.component.ts +2 -1
  60. package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.html +117 -0
  61. package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.ts +244 -0
  62. package/src/libs/ui/layout/src/lib/block-list/block-list.component.css +1 -0
  63. package/src/libs/ui/map/src/lib/components/map-container/map-container.component.ts +6 -5
  64. package/src/libs/util/app-config/src/lib/app-config.ts +37 -0
  65. package/src/libs/util/app-config/src/lib/fixtures.ts +37 -1
  66. package/src/libs/util/app-config/src/lib/model.ts +25 -1
  67. package/src/libs/util/shared/src/index.ts +1 -0
  68. package/src/libs/util/shared/src/lib/autofocus.directive.ts +26 -0
  69. package/src/libs/util/shared/src/lib/links/link-utils.ts +19 -10
  70. package/src/libs/util/shared/src/lib/services/date.service.ts +3 -3
  71. package/src/libs/util/shared/src/lib/utils/file.ts +15 -0
  72. package/src/libs/util/shared/src/lib/utils/geojson.ts +24 -0
  73. package/src/libs/util/shared/src/lib/utils/index.ts +1 -0
  74. package/tailwind.base.css +5 -0
  75. package/translations/de.json +24 -4
  76. package/translations/en.json +23 -3
  77. package/translations/es.json +22 -2
  78. package/translations/fr.json +28 -8
  79. package/translations/it.json +22 -2
  80. package/translations/nl.json +22 -2
  81. package/translations/pt.json +22 -2
  82. package/translations/sk.json +22 -2
  83. package/src/libs/feature/map/src/lib/geocoding/geocoding.component.html +0 -41
  84. package/src/libs/feature/map/src/lib/geocoding/geocoding.component.ts +0 -112
  85. package/src/libs/feature/map/src/lib/geocoding.service.ts +0 -57
  86. package/src/libs/feature/map/src/lib/style/index.ts +0 -2
  87. package/src/libs/feature/map/src/lib/style/map-style.fixtures.ts +0 -47
  88. package/src/libs/feature/map/src/lib/style/map-style.service.ts +0 -108
  89. /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,117 @@
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 flex flex-col gap-[8px]'
62
+ "
63
+ style="
64
+ --gn-ui-text-input-rounded: 8px;
65
+ --gn-ui-text-input-border-size: 1px;
66
+ --gn-ui-text-input-padding: 6px;
67
+ "
68
+ >
69
+ <gn-ui-drag-and-drop-file-input
70
+ accept=".json,.geojson"
71
+ [placeholder]="'search.filters.spatialExtent.import' | translate"
72
+ [maxFileSizeMb]="maxFileSizeMb"
73
+ [showFileName]="false"
74
+ textClass="text-black truncate"
75
+ dropzoneBackgroundColor="transparent"
76
+ icon="iconoirUpload"
77
+ extraClass="gn-ui-gray-outline-input w-full !h-[32px] px-[8px] py-[4px] justify-between"
78
+ (fileChange)="handleFileSelected($event)"
79
+ (errorChange)="handleFileError($event)"
80
+ data-cy="importGeojson"
81
+ ></gn-ui-drag-and-drop-file-input>
82
+ <ng-content></ng-content>
83
+ </div>
84
+
85
+ @if (hasSelection) {
86
+ <gn-ui-button
87
+ [type]="'primary-light'"
88
+ [title]="selectionDeleteLabelKey | translate: selectionLabelParams"
89
+ (buttonClick)="removeSelection($event)"
90
+ extraClass="group gap-x-2 w-full h-[28px] px-[8px] py-[4px] mb-[12px] bg-primary-lighter text-white"
91
+ data-test="spatial-extent-selected-item"
92
+ >
93
+ <ng-icon
94
+ name="iconoirSquareDashed"
95
+ class="shrink-0"
96
+ size="15px"
97
+ ></ng-icon>
98
+ <span class="group-hover:hidden truncate text-sm m-auto">
99
+ {{ selectionLabelKey | translate: selectionLabelParams }}
100
+ </span>
101
+ <span class="hidden group-hover:block truncate text-sm m-auto">
102
+ {{ selectionDeleteLabelKey | translate: selectionLabelParams }}
103
+ </span>
104
+ <ng-icon
105
+ name="iconoirCheckCircle"
106
+ class="group-hover:hidden shrink-0"
107
+ size="14px"
108
+ ></ng-icon>
109
+ <ng-icon
110
+ name="iconoirTrash"
111
+ class="!hidden group-hover:!block shrink-0"
112
+ size="15px"
113
+ ></ng-icon>
114
+ </gn-ui-button>
115
+ }
116
+ </div>
117
+ </ng-template>
@@ -0,0 +1,244 @@
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_FROM_LOCATION = marker(
57
+ 'search.filters.spatialExtent.bboxFromLocation'
58
+ )
59
+ const LABEL_FROM_LOCATION_DELETE = marker(
60
+ 'search.filters.spatialExtent.bboxFromLocationDelete'
61
+ )
62
+ const LABEL_INITIAL = marker('search.filters.spatialExtent.bboxInitial')
63
+ const LABEL_INITIAL_DELETE = marker(
64
+ 'search.filters.spatialExtent.bboxInitialDelete'
65
+ )
66
+
67
+ export interface SpatialExtentDropdownError {
68
+ key: string
69
+ params?: Record<string, string | number>
70
+ }
71
+
72
+ @Component({
73
+ selector: 'gn-ui-spatial-extent-dropdown',
74
+ standalone: true,
75
+ imports: [
76
+ ButtonComponent,
77
+ NgIcon,
78
+ OverlayModule,
79
+ TranslatePipe,
80
+ DragAndDropFileInputComponent,
81
+ ],
82
+ providers: [
83
+ provideIcons({
84
+ iconoirCheckCircle,
85
+ iconoirSquareDashed,
86
+ iconoirTrash,
87
+ iconoirUpload,
88
+ matClose,
89
+ matExpandLess,
90
+ matExpandMore,
91
+ }),
92
+ ],
93
+ templateUrl: './spatial-extent-dropdown.component.html',
94
+ styleUrls: ['./spatial-extent-dropdown.component.css'],
95
+ changeDetection: ChangeDetectionStrategy.OnPush,
96
+ })
97
+ export class SpatialExtentDropdownComponent {
98
+ private cd = inject(ChangeDetectorRef)
99
+ private scrollStrategies = inject(ScrollStrategyOptions)
100
+
101
+ @Input() title: string
102
+ @Input() maxFileSizeMb: number | null = null
103
+ @Input() set initialBbox(value: BoundingBox | null) {
104
+ if (!this.bbox && value) {
105
+ this.bbox = value
106
+ }
107
+ }
108
+
109
+ @Output() bboxChange = new EventEmitter<BoundingBox | null>()
110
+ @Output() errorChange = new EventEmitter<SpatialExtentDropdownError>()
111
+
112
+ bbox: BoundingBox | null = null
113
+ fileName = ''
114
+ locationName = ''
115
+
116
+ @ViewChild('overlayOrigin') overlayOrigin: CdkOverlayOrigin
117
+ @ViewChild(CdkConnectedOverlay) overlay: CdkConnectedOverlay
118
+ @ViewChild(DragAndDropFileInputComponent)
119
+ fileInput: DragAndDropFileInputComponent
120
+
121
+ overlayPositions: ConnectedPosition[] = [
122
+ {
123
+ originX: 'start',
124
+ originY: 'bottom',
125
+ overlayX: 'start',
126
+ overlayY: 'top',
127
+ offsetY: 8,
128
+ },
129
+ {
130
+ originX: 'start',
131
+ originY: 'top',
132
+ overlayX: 'start',
133
+ overlayY: 'bottom',
134
+ offsetY: -8,
135
+ },
136
+ ]
137
+ scrollStrategy = this.scrollStrategies.reposition()
138
+ overlayOpen = false
139
+ overlayMinWidth = 'none'
140
+
141
+ errorKey: string | null = null
142
+
143
+ get hasSelection() {
144
+ return !!this.bbox
145
+ }
146
+
147
+ get selectionLabelKey() {
148
+ if (this.fileName) return LABEL_FROM_FILE
149
+ if (this.locationName) return LABEL_FROM_LOCATION
150
+ return LABEL_INITIAL
151
+ }
152
+
153
+ get selectionDeleteLabelKey() {
154
+ if (this.fileName) return LABEL_FROM_FILE_DELETE
155
+ if (this.locationName) return LABEL_FROM_LOCATION_DELETE
156
+ return LABEL_INITIAL_DELETE
157
+ }
158
+
159
+ get selectionLabelParams() {
160
+ return { fileName: this.fileName, locationName: this.locationName }
161
+ }
162
+
163
+ openOverlay() {
164
+ this.overlayMinWidth =
165
+ this.overlayOrigin.elementRef.nativeElement.getBoundingClientRect()
166
+ .width + 'px'
167
+ this.overlayOpen = true
168
+ }
169
+
170
+ closeOverlay() {
171
+ this.overlayOpen = false
172
+ }
173
+
174
+ toggleOverlay() {
175
+ if (this.overlayOpen) {
176
+ this.closeOverlay()
177
+ } else {
178
+ this.openOverlay()
179
+ }
180
+ }
181
+
182
+ async handleFileSelected(file: File) {
183
+ this.errorKey = null
184
+ let content: string
185
+ try {
186
+ content = await readFileAsText(file)
187
+ const parsed = JSON.parse(content)
188
+ const geometry = getGeometryFromGeoJSON(parsed)
189
+ if (!geometry) {
190
+ this.setError(marker('search.filters.spatialExtent.error.noGeometry'))
191
+ return
192
+ }
193
+ const bbox = getGeometryBoundingBox(geometry)
194
+ if (!isBoundingBoxWithinWorldExtent(bbox)) {
195
+ this.setError(marker('search.filters.spatialExtent.error.outOfBounds'))
196
+ return
197
+ }
198
+ this.bbox = bbox
199
+ this.fileName = file.name
200
+ this.locationName = ''
201
+ this.bboxChange.emit(bbox)
202
+ this.cd.markForCheck()
203
+ } catch {
204
+ this.setError(marker('search.filters.spatialExtent.error.invalidFormat'))
205
+ return
206
+ }
207
+ }
208
+
209
+ setLocationBbox(bbox: BoundingBox, name: string) {
210
+ this.errorKey = null
211
+ this.bbox = bbox
212
+ this.locationName = name
213
+ this.fileName = ''
214
+ this.fileInput?.clear()
215
+ this.bboxChange.emit(bbox)
216
+ this.cd.markForCheck()
217
+ }
218
+
219
+ handleFileError(error: DragAndDropFileInputError) {
220
+ if (error === 'file-too-large') {
221
+ this.setError(marker('search.filters.spatialExtent.error.fileTooLarge'), {
222
+ maxSize: this.maxFileSizeMb,
223
+ })
224
+ } else {
225
+ this.setError(marker('search.filters.spatialExtent.error.invalidFormat'))
226
+ }
227
+ }
228
+
229
+ private setError(errorKey: string, params?: Record<string, string | number>) {
230
+ this.errorKey = errorKey
231
+ this.errorChange.emit({ key: errorKey, params })
232
+ this.cd.markForCheck()
233
+ }
234
+
235
+ removeSelection(event: Event) {
236
+ this.bbox = null
237
+ this.fileName = ''
238
+ this.locationName = ''
239
+ this.errorKey = null
240
+ this.fileInput?.clear()
241
+ this.bboxChange.emit(null)
242
+ propagateToDocumentOnly(event)
243
+ }
244
+ }
@@ -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,10 @@ 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',
258
+ 'geocoding_provider_labels',
255
259
  ],
256
260
  warnings,
257
261
  errors
@@ -264,6 +268,18 @@ export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
264
268
  warnings,
265
269
  errors
266
270
  )
271
+ const parsedCustomFilters = parseMultiConfigSection(
272
+ parsed,
273
+ 'custom_filter',
274
+ ['name', 'base_filter'],
275
+ ['exclude_values', 'include_values', 'label_key'],
276
+ warnings,
277
+ errors
278
+ )
279
+ const parsedGeocodingProviderLabels =
280
+ parsedSearchSection?.geocoding_provider_labels as
281
+ | Record<string, string>
282
+ | undefined
267
283
  searchConfig =
268
284
  parsedSearchSection === null
269
285
  ? null
@@ -280,7 +296,28 @@ export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
280
296
  filters: param.filters,
281
297
  })),
282
298
  ADVANCED_FILTERS: parsedSearchSection.advanced_filters,
299
+ CUSTOM_FILTERS: (parsedCustomFilters ?? []).map(
300
+ (customFilter) => ({
301
+ name: customFilter.name,
302
+ baseFilter: customFilter.base_filter,
303
+ excludeValues: customFilter.exclude_values,
304
+ includeValues: customFilter.include_values,
305
+ labelKey: customFilter.label_key,
306
+ })
307
+ ),
283
308
  LIMIT: parsedSearchSection.limit,
309
+ SPATIAL_EXTENT_MAX_FILE_SIZE:
310
+ parsedSearchSection.spatial_extent_max_file_size,
311
+ GEOCODING_PROVIDER: parsedSearchSection.geocoding_provider,
312
+ GEOCODING_PROVIDER_OPTIONS:
313
+ parsedSearchSection.geocoding_provider_options,
314
+ GEOCODING_PROVIDER_LABELS: parsedGeocodingProviderLabels
315
+ ? {
316
+ MAIN: parsedGeocodingProviderLabels.main,
317
+ SECONDARY: parsedGeocodingProviderLabels.secondary,
318
+ TERTIARY: parsedGeocodingProviderLabels.tertiary,
319
+ }
320
+ : undefined,
284
321
  } as SearchConfig)
285
322
 
286
323
  const parsedMetadataQualitySection = parseConfigSection(
@@ -41,7 +41,26 @@ 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.index = "poi"
46
+ geocoding_provider_options.category = "administratif"
47
+ geocoding_provider_options.limit = 5
48
+ geocoding_provider_labels.main = '/properties/name/0'
49
+ geocoding_provider_labels.secondary = '/properties/citycode/0'
50
+ geocoding_provider_labels.tertiary = '/properties/category/1'
51
+ advanced_filters = ['publicationYear', 'documentStandard', 'inspireKeyword', 'topic', 'license', 'myOrg:firstCustomFilter', 'myOrg:secondCustomFilter']
52
+
53
+ [[custom_filter]]
54
+ name = 'myOrg:firstCustomFilter'
55
+ base_filter = 'keyword'
56
+ exclude_values = ['my keyword 1', 'my keyword 2']
57
+ label_key = 'myOrg.firstCustomFilter'
58
+
59
+ [[custom_filter]]
60
+ name = 'myOrg:secondCustomFilter'
61
+ base_filter = 'keyword'
62
+ include_values = ['my keyword 3', 'my keyword 4']
63
+ label_key = 'myOrg.secondCustomFilter'
45
64
 
46
65
  [[search_preset]]
47
66
  sort = "-createDate"
@@ -81,6 +100,23 @@ main_color = "#212029" # All-purpose text color
81
100
  background_color = "#fdfbff"
82
101
  `
83
102
 
103
+ export const customFilterMissingMandatoryConfigFixture = () => `
104
+ [global]
105
+ geonetwork4_api_url = "/geonetwork/srv/api"
106
+
107
+ [theme]
108
+ primary_color = "#093564"
109
+ secondary_color = "#c2e9dc"
110
+ main_color = "#212029" # All-purpose text color
111
+ background_color = "#fdfbff"
112
+
113
+ [search]
114
+ advanced_filters = ['myOrg:firstCustomFilter']
115
+
116
+ [[custom_filter]]
117
+ name = 'myOrg:firstCustomFilter'
118
+ `
119
+
84
120
  export const mapConfigFixture = (): MapConfig => ({
85
121
  MAX_ZOOM: 10,
86
122
  MAX_EXTENT: [-418263.418776, 5251529.591305, 961272.067714, 6706890.609855],
@@ -55,14 +55,38 @@ 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
+
68
+ export interface GeocodingProviderLabelsConfig {
69
+ MAIN?: string
70
+ SECONDARY?: string
71
+ TERTIARY?: string
72
+ }
73
+
58
74
  export interface SearchConfig {
59
75
  RECORD_KIND_QUICK_FILTER?: boolean
60
76
  FILTER_GEOMETRY_URL?: string
61
77
  FILTER_GEOMETRY_DATA?: string
62
78
  DO_NOT_USE_DEFAULT_SEARCH_PRESET?: boolean
63
79
  SEARCH_PRESET?: SearchPreset[]
64
- ADVANCED_FILTERS?: []
80
+ ADVANCED_FILTERS?: string[]
81
+ CUSTOM_FILTERS?: CustomSearchFieldConfig[]
65
82
  LIMIT?: number
83
+ SPATIAL_EXTENT_MAX_FILE_SIZE?: number
84
+ GEOCODING_PROVIDER?: GeocodingProviderName
85
+ GEOCODING_PROVIDER_OPTIONS?: Record<
86
+ string,
87
+ string | number | boolean | string[]
88
+ >
89
+ GEOCODING_PROVIDER_LABELS?: GeocodingProviderLabelsConfig
66
90
  }
67
91
 
68
92
  export interface MetadataQualityConfig {
@@ -1,6 +1,7 @@
1
1
  export * from './lib/services'
2
2
  export * from './lib/utils'
3
3
  export * from './lib/links'
4
+ export * from './lib/autofocus.directive'
4
5
  export * from './lib/image-fallback.directive'
5
6
  export * from './lib/gn-ui-version'
6
7
  export * from './lib/record'
@@ -0,0 +1,26 @@
1
+ import {
2
+ Directive,
3
+ ElementRef,
4
+ Injector,
5
+ Input,
6
+ afterNextRender,
7
+ booleanAttribute,
8
+ inject,
9
+ } from '@angular/core'
10
+
11
+ @Directive({
12
+ selector: '[gnUiAutofocus]',
13
+ standalone: true,
14
+ })
15
+ export class AutofocusDirective {
16
+ private el = inject<ElementRef<HTMLElement>>(ElementRef)
17
+ private injector = inject(Injector)
18
+
19
+ @Input({ alias: 'gnUiAutofocus', transform: booleanAttribute })
20
+ set autofocus(active: boolean) {
21
+ if (!active) return
22
+ afterNextRender(() => this.el.nativeElement.focus(), {
23
+ injector: this.injector,
24
+ })
25
+ }
26
+ }
@@ -344,7 +344,11 @@ export function getLinkLabel(
344
344
  return format ? `${label} (${format})` : label
345
345
  }
346
346
 
347
- export async function getLayers(url: string, serviceProtocol: ServiceProtocol) {
347
+ export async function getLayers(
348
+ url: string,
349
+ serviceProtocol: ServiceProtocol,
350
+ deep = false
351
+ ) {
348
352
  switch (serviceProtocol) {
349
353
  case 'ogcFeatures': {
350
354
  const layers = await new OgcApiEndpoint(url).allCollections
@@ -352,7 +356,10 @@ export async function getLayers(url: string, serviceProtocol: ServiceProtocol) {
352
356
  }
353
357
  case 'wfs': {
354
358
  const endpointWfs = await new WfsEndpoint(url).isReady()
355
- const featureTypes = await endpointWfs.getFeatureTypes()
359
+ const featureTypes = endpointWfs.getFeatureTypes()
360
+ if (!deep) {
361
+ return featureTypes
362
+ }
356
363
  const layers = (
357
364
  await Promise.allSettled(
358
365
  featureTypes.map((collection) => {
@@ -366,14 +373,16 @@ export async function getLayers(url: string, serviceProtocol: ServiceProtocol) {
366
373
  }
367
374
  case 'wms': {
368
375
  const endpointWms = await new WmsEndpoint(url).isReady()
369
- const layers = (
370
- await endpointWms
371
- .getLayers()
372
- .flatMap(wmsLayerFlatten)
373
- .filter((l) => l.name)
374
- ).map((collection) => {
375
- return endpointWms.getLayerByName(collection.name)
376
- })
376
+ const layersSummary = endpointWms
377
+ .getLayers()
378
+ .flatMap(wmsLayerFlatten)
379
+ .filter((l) => l.name)
380
+ if (!deep) {
381
+ return layersSummary
382
+ }
383
+ const layers = layersSummary.map((collection) =>
384
+ endpointWms.getLayerByName(collection.name)
385
+ )
377
386
  return layers
378
387
  }
379
388
  case 'wmts': {
@@ -35,10 +35,10 @@ export class DateService {
35
35
  return { locale, dateObj }
36
36
  }
37
37
 
38
- private async getDateLocale(): Promise<Locale> {
38
+ async getDateFnsLocale(): Promise<Locale> {
39
39
  const lang = this.translateService.getCurrentLang() || DEFAULT_LANGUAGE
40
40
  const locales = await this.dateLocales
41
- return locales[lang]
41
+ return locales[lang] ?? locales[DEFAULT_LANGUAGE]
42
42
  }
43
43
 
44
44
  formatDate(
@@ -61,7 +61,7 @@ export class DateService {
61
61
  const dateObj = this.getDateObject(date)
62
62
 
63
63
  const now = new Date()
64
- const locale = await this.getDateLocale()
64
+ const locale = await this.getDateFnsLocale()
65
65
 
66
66
  return formatDistance(dateObj, now, {
67
67
  addSuffix: true,
@@ -0,0 +1,15 @@
1
+ export function isFileExtensionValid(
2
+ fileName: string,
3
+ acceptedExtensions: string[]
4
+ ): boolean {
5
+ return acceptedExtensions.some((ext) => fileName.toLowerCase().endsWith(ext))
6
+ }
7
+
8
+ export function readFileAsText(file: File): Promise<string> {
9
+ return new Promise((resolve, reject) => {
10
+ const reader = new FileReader()
11
+ reader.onload = () => resolve(reader.result as string)
12
+ reader.onerror = () => reject(reader.error)
13
+ reader.readAsText(file)
14
+ })
15
+ }