geonetwork-ui 2.11.0-dev.57f4be358 → 2.11.0-dev.5a8170627

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 (66) hide show
  1. package/fesm2022/geonetwork-ui.mjs +717 -281
  2. package/fesm2022/geonetwork-ui.mjs.map +1 -1
  3. package/index.d.ts +152 -44
  4. package/index.d.ts.map +1 -1
  5. package/package.json +6 -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 +395 -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 +17 -6
  11. package/src/libs/api/metadata-converter/src/lib/iso19115-3/read-parts.ts +110 -0
  12. package/src/libs/api/metadata-converter/src/lib/iso19115-3/write-parts.ts +131 -0
  13. package/src/libs/api/metadata-converter/src/lib/iso19139/iso19139.converter.ts +9 -0
  14. package/src/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts +2 -1
  15. package/src/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts +29 -23
  16. package/src/libs/api/repository/src/lib/gn4/gn4-repository.ts +79 -35
  17. package/src/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.ts +11 -0
  18. package/src/libs/common/domain/src/lib/model/record/flags.model.ts +1 -0
  19. package/src/libs/common/domain/src/lib/model/record/index.ts +1 -0
  20. package/src/libs/common/domain/src/lib/model/record/metadata.model.ts +14 -18
  21. package/src/libs/common/domain/src/lib/platform.service.interface.ts +1 -0
  22. package/src/libs/common/domain/src/lib/repository/records-repository.interface.ts +20 -1
  23. package/src/libs/common/fixtures/src/lib/records.fixtures.ts +42 -62
  24. package/src/libs/feature/dataviz/src/lib/service/data.service.ts +32 -19
  25. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-constraints/form-field-constraints.component.ts +3 -5
  26. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-contacts/form-field-contacts.component.ts +2 -2
  27. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.css +0 -0
  28. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.html +18 -0
  29. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.ts +86 -0
  30. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html +100 -88
  31. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts +11 -4
  32. package/src/libs/feature/editor/src/lib/components/record-form/record-form.component.ts +18 -4
  33. package/src/libs/feature/editor/src/lib/expressions.ts +67 -0
  34. package/src/libs/feature/editor/src/lib/fields.config.ts +13 -0
  35. package/src/libs/feature/editor/src/lib/models/editor-config.model.ts +10 -4
  36. package/src/libs/feature/record/src/lib/state/mdview.effects.ts +3 -1
  37. package/src/libs/feature/record/src/lib/state/mdview.facade.ts +1 -1
  38. package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.html +7 -1
  39. package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.ts +18 -1
  40. package/src/libs/feature/search/src/lib/geocoding/geocoding.service.ts +41 -2
  41. package/src/libs/feature/search/src/lib/location-search/location-search.component.html +11 -1
  42. package/src/libs/feature/search/src/lib/location-search/location-search.component.ts +77 -3
  43. package/src/libs/feature/search/src/lib/utils/service/fields.service.ts +6 -0
  44. package/src/libs/feature/search/src/lib/utils/service/fields.ts +2 -1
  45. package/src/libs/ui/elements/src/lib/record-feature-catalog/feature-catalog-list/feature-catalog-list.component.html +3 -3
  46. package/src/libs/ui/elements/src/lib/record-feature-catalog/feature-catalog-list/feature-catalog-list.component.ts +2 -2
  47. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.css +0 -4
  48. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.html +2 -2
  49. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.ts +3 -3
  50. package/src/libs/ui/inputs/src/lib/search-feature-catalog/search-feature-catalog.component.ts +2 -1
  51. package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.html +7 -1
  52. package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.ts +26 -3
  53. package/src/libs/util/app-config/src/index.ts +1 -0
  54. package/src/libs/util/app-config/src/lib/app-config.ts +338 -272
  55. package/src/libs/util/app-config/src/lib/fixtures.ts +4 -0
  56. package/src/libs/util/app-config/src/lib/model.ts +28 -1
  57. package/src/libs/util/app-config/src/lib/parse-utils.ts +8 -4
  58. package/src/libs/util/shared/src/lib/utils/geojson.ts +21 -10
  59. package/translations/de.json +8 -1
  60. package/translations/en.json +8 -1
  61. package/translations/es.json +8 -1
  62. package/translations/fr.json +9 -2
  63. package/translations/it.json +8 -1
  64. package/translations/nl.json +8 -1
  65. package/translations/pt.json +8 -1
  66. package/translations/sk.json +8 -1
@@ -8,6 +8,9 @@ import {
8
8
  parseTranslationsConfigSection,
9
9
  } from './parse-utils'
10
10
  import {
11
+ AppConfig,
12
+ ConfigIssues,
13
+ ConfigSectionName,
11
14
  CustomTranslations,
12
15
  CustomTranslationsAllLanguages,
13
16
  EditorConfig,
@@ -84,7 +87,319 @@ export function getCustomTranslations(langCode: string): CustomTranslations {
84
87
 
85
88
  let appConfigLoaded = false
86
89
 
87
- export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
90
+ function parseGlobalSection(
91
+ parsed: Record<string, unknown>,
92
+ { warnings, errors }: ConfigIssues
93
+ ): GlobalConfig | null {
94
+ let parsedGlobalSection = parseConfigSection(
95
+ parsed,
96
+ 'global',
97
+ ['geonetwork4_api_url'],
98
+ [
99
+ 'datahub_url',
100
+ 'edit_url_template',
101
+ 'proxy_path',
102
+ 'metadata_language',
103
+ 'login_url',
104
+ 'logout_url',
105
+ 'settings_url',
106
+ 'web_component_embedder_url',
107
+ 'languages',
108
+ 'contact_email',
109
+ 'reuse_form_url',
110
+ ],
111
+ warnings,
112
+ errors
113
+ )
114
+ if (parsedGlobalSection?.metadata_language) {
115
+ parsedGlobalSection = checkMetadataLanguage(parsedGlobalSection, warnings)
116
+ }
117
+ return parsedGlobalSection === null
118
+ ? null
119
+ : ({
120
+ GN4_API_URL: parsedGlobalSection.geonetwork4_api_url,
121
+ DATAHUB_URL: parsedGlobalSection.datahub_url,
122
+ EDIT_URL_TEMPLATE: parsedGlobalSection.edit_url_template,
123
+ PROXY_PATH: parsedGlobalSection.proxy_path,
124
+ METADATA_LANGUAGE: parsedGlobalSection.metadata_language
125
+ ? (parsedGlobalSection.metadata_language as string).toLowerCase()
126
+ : undefined,
127
+ LOGIN_URL: parsedGlobalSection.login_url,
128
+ LOGOUT_URL: parsedGlobalSection.logout_url,
129
+ SETTINGS_URL: parsedGlobalSection.settings_url,
130
+ WEB_COMPONENT_EMBEDDER_URL:
131
+ parsedGlobalSection.web_component_embedder_url,
132
+ LANGUAGES: parsedGlobalSection.languages,
133
+ CONTACT_EMAIL: parsedGlobalSection.contact_email,
134
+ REUSE_FORM_URL: parsedGlobalSection.reuse_form_url,
135
+ } as GlobalConfig)
136
+ }
137
+
138
+ function parseMapSection(
139
+ parsed: Record<string, unknown>,
140
+ { warnings, errors }: ConfigIssues
141
+ ): MapConfig | null {
142
+ const parsedLayersSections = parseMultiConfigSection(
143
+ parsed,
144
+ 'map_layer',
145
+ ['type'],
146
+ ['name', 'url', 'data', 'styleUrl', 'accessToken'],
147
+ warnings,
148
+ errors
149
+ )
150
+ const parsedMapSection = parseConfigSection(
151
+ parsed,
152
+ 'map',
153
+ [],
154
+ [
155
+ 'max_zoom',
156
+ 'do_not_tile_wms',
157
+ 'max_extent',
158
+ 'max_feature_count',
159
+ 'baselayer',
160
+ 'do_not_use_default_basemap',
161
+ 'external_viewer_url_template',
162
+ 'external_viewer_open_new_tab',
163
+ ],
164
+ warnings,
165
+ errors
166
+ )
167
+ return parsedMapSection === null || parsedLayersSections === null
168
+ ? null
169
+ : ({
170
+ MAX_ZOOM: parsedMapSection.max_zoom,
171
+ DO_NOT_TILE_WMS: parsedMapSection.do_not_tile_wms,
172
+ MAX_EXTENT: parsedMapSection.max_extent,
173
+ MAX_FEATURE_COUNT: parsedMapSection.max_feature_count,
174
+ EXTERNAL_VIEWER_URL_TEMPLATE:
175
+ parsedMapSection.external_viewer_url_template,
176
+ EXTERNAL_VIEWER_OPEN_NEW_TAB:
177
+ parsedMapSection.external_viewer_open_new_tab,
178
+ DO_NOT_USE_DEFAULT_BASEMAP:
179
+ !!parsedMapSection.do_not_use_default_basemap,
180
+ MAP_LAYERS: parsedLayersSections.map(
181
+ (map_layer) =>
182
+ ({
183
+ TYPE: map_layer.type,
184
+ URL: map_layer.url,
185
+ NAME: map_layer.name,
186
+ DATA: map_layer.data,
187
+ STYLE_URL: map_layer.styleUrl,
188
+ ACCESS_TOKEN: map_layer.accessToken,
189
+ }) as LayerConfig
190
+ ),
191
+ } as MapConfig)
192
+ }
193
+
194
+ function parseThemeSection(
195
+ parsed: Record<string, unknown>,
196
+ { warnings, errors }: ConfigIssues
197
+ ): ThemeConfig | null {
198
+ const parsedThemeSection = parseConfigSection(
199
+ parsed,
200
+ 'theme',
201
+ ['primary_color', 'secondary_color', 'main_color', 'background_color'],
202
+ [
203
+ 'header_foreground_color',
204
+ 'main_font',
205
+ 'title_font',
206
+ 'fonts_stylesheet_url',
207
+ 'thumbnail_placeholder',
208
+ 'header_background',
209
+ 'favicon',
210
+ ],
211
+ warnings,
212
+ errors
213
+ )
214
+ return parsedThemeSection === null
215
+ ? null
216
+ : ({
217
+ PRIMARY_COLOR: parsedThemeSection.primary_color,
218
+ SECONDARY_COLOR: parsedThemeSection.secondary_color,
219
+ MAIN_COLOR: parsedThemeSection.main_color,
220
+ BACKGROUND_COLOR: parsedThemeSection.background_color,
221
+ HEADER_FOREGROUND_COLOR: parsedThemeSection.header_foreground_color,
222
+ THUMBNAIL_PLACEHOLDER: parsedThemeSection.thumbnail_placeholder,
223
+ HEADER_BACKGROUND: parsedThemeSection.header_background,
224
+ TITLE_FONT: parsedThemeSection.title_font,
225
+ MAIN_FONT: parsedThemeSection.main_font,
226
+ FONTS_STYLESHEET_URL: parsedThemeSection.fonts_stylesheet_url,
227
+ FAVICON: parsedThemeSection.favicon,
228
+ } as ThemeConfig)
229
+ }
230
+
231
+ function parseSearchSection(
232
+ parsed: Record<string, unknown>,
233
+ { warnings, errors }: ConfigIssues
234
+ ): SearchConfig | null {
235
+ const parsedSearchSection = parseConfigSection(
236
+ parsed,
237
+ 'search',
238
+ [],
239
+ [
240
+ 'record_kind_quick_filter',
241
+ 'filter_geometry_data',
242
+ 'filter_geometry_url',
243
+ 'do_not_use_default_search_preset',
244
+ 'search_preset',
245
+ 'advanced_filters',
246
+ 'limit',
247
+ 'spatial_extent_max_file_size',
248
+ 'geocoding_provider',
249
+ 'geocoding_provider_options',
250
+ 'geocoding_provider_labels',
251
+ ],
252
+ warnings,
253
+ errors
254
+ )
255
+ const parsedSearchParams = parseMultiConfigSection(
256
+ parsed,
257
+ 'search_preset',
258
+ ['name'],
259
+ ['sort', 'filters'],
260
+ warnings,
261
+ errors
262
+ )
263
+ const parsedCustomFilters = parseMultiConfigSection(
264
+ parsed,
265
+ 'custom_filter',
266
+ ['name', 'base_filter'],
267
+ ['exclude_values', 'include_values', 'label_key'],
268
+ warnings,
269
+ errors
270
+ )
271
+ const parsedGeocodingProviderLabels =
272
+ parsedSearchSection?.geocoding_provider_labels as
273
+ | Record<string, string>
274
+ | undefined
275
+ return parsedSearchSection === null
276
+ ? null
277
+ : ({
278
+ RECORD_KIND_QUICK_FILTER: parsedSearchSection.record_kind_quick_filter,
279
+ FILTER_GEOMETRY_DATA: parsedSearchSection.filter_geometry_data,
280
+ FILTER_GEOMETRY_URL: parsedSearchSection.filter_geometry_url,
281
+ DO_NOT_USE_DEFAULT_SEARCH_PRESET:
282
+ !!parsedSearchSection.do_not_use_default_search_preset,
283
+ SEARCH_PRESET: parsedSearchParams.map((param) => ({
284
+ sort: param.sort,
285
+ name: param.name,
286
+ filters: param.filters,
287
+ })),
288
+ ADVANCED_FILTERS: parsedSearchSection.advanced_filters,
289
+ CUSTOM_FILTERS: (parsedCustomFilters ?? []).map((customFilter) => ({
290
+ name: customFilter.name,
291
+ baseFilter: customFilter.base_filter,
292
+ excludeValues: customFilter.exclude_values,
293
+ includeValues: customFilter.include_values,
294
+ labelKey: customFilter.label_key,
295
+ })),
296
+ LIMIT: parsedSearchSection.limit,
297
+ SPATIAL_EXTENT_MAX_FILE_SIZE:
298
+ parsedSearchSection.spatial_extent_max_file_size,
299
+ GEOCODING_PROVIDER: parsedSearchSection.geocoding_provider,
300
+ GEOCODING_PROVIDER_OPTIONS:
301
+ parsedSearchSection.geocoding_provider_options,
302
+ GEOCODING_PROVIDER_LABELS: parsedGeocodingProviderLabels
303
+ ? {
304
+ MAIN: parsedGeocodingProviderLabels.main,
305
+ SECONDARY: parsedGeocodingProviderLabels.secondary,
306
+ TERTIARY: parsedGeocodingProviderLabels.tertiary,
307
+ }
308
+ : undefined,
309
+ } as SearchConfig)
310
+ }
311
+
312
+ function parseMetadataQualitySection(
313
+ parsed: Record<string, unknown>,
314
+ { warnings, errors }: ConfigIssues
315
+ ): MetadataQualityConfig | null {
316
+ const parsedMetadataQualitySection = parseConfigSection(
317
+ parsed,
318
+ 'metadata-quality',
319
+ [],
320
+ ['enabled'],
321
+ warnings,
322
+ errors
323
+ )
324
+ return parsedMetadataQualitySection === null
325
+ ? null
326
+ : ({
327
+ ENABLED: parsedMetadataQualitySection.enabled,
328
+ SORTABLE: parsedMetadataQualitySection.sortable,
329
+ } as MetadataQualityConfig)
330
+ }
331
+
332
+ function parseEditingSection(
333
+ parsed: Record<string, unknown>,
334
+ { warnings, errors }: ConfigIssues
335
+ ): EditorConfig | null {
336
+ let parsedEditingSection = parseConfigSection(
337
+ parsed,
338
+ 'editing',
339
+ [],
340
+ ['new_record_default_language', 'new_record_standard'],
341
+ warnings,
342
+ errors
343
+ )
344
+ if (
345
+ parsedEditingSection !== null &&
346
+ parsedEditingSection.new_record_default_language !== undefined
347
+ ) {
348
+ parsedEditingSection = checkNewRecordDefaultLanguage(
349
+ parsedEditingSection,
350
+ warnings
351
+ )
352
+ }
353
+ if (
354
+ parsedEditingSection !== null &&
355
+ parsedEditingSection.new_record_standard !== undefined
356
+ ) {
357
+ parsedEditingSection = checkNewRecordStandard(
358
+ parsedEditingSection,
359
+ warnings
360
+ )
361
+ }
362
+ return parsedEditingSection === null
363
+ ? null
364
+ : ({
365
+ NEW_RECORD_DEFAULT_LANGUAGE:
366
+ parsedEditingSection.new_record_default_language as
367
+ | string
368
+ | undefined,
369
+ NEW_RECORD_STANDARD: parsedEditingSection.new_record_standard as
370
+ | EditorConfig['NEW_RECORD_STANDARD']
371
+ | undefined,
372
+ } as EditorConfig)
373
+ }
374
+
375
+ const SECTION_PARSERS: {
376
+ [name in ConfigSectionName]: (
377
+ parsed: Record<string, unknown>,
378
+ issues: ConfigIssues
379
+ ) => AppConfig[name]
380
+ } = {
381
+ global: parseGlobalSection,
382
+ map: parseMapSection,
383
+ theme: parseThemeSection,
384
+ search: parseSearchSection,
385
+ metadataQuality: parseMetadataQualitySection,
386
+ editor: parseEditingSection,
387
+ translations: (parsed) =>
388
+ parseTranslationsConfigSection(
389
+ parsed,
390
+ 'translations'
391
+ ) as CustomTranslationsAllLanguages,
392
+ }
393
+
394
+ /**
395
+ * Loads the configuration file and stores the given sections (all by default);
396
+ * omitted sections are reset (their getters will throw or return null);
397
+ * resolves with the parsed configuration file, e.g. to read sections with a custom parser
398
+ */
399
+ export function loadAppConfig(
400
+ configUrl = 'assets/configuration/default.toml',
401
+ sections = Object.keys(SECTION_PARSERS) as ConfigSectionName[]
402
+ ): Promise<Record<string, unknown>> {
88
403
  console.log(
89
404
  `[geonetwork-ui] Loading application configuration from ${configUrl}`
90
405
  )
@@ -94,289 +409,36 @@ export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
94
409
  return resp.text()
95
410
  })
96
411
  .then((conf) => {
97
- let parsed
412
+ let parsed: Record<string, unknown>
98
413
  try {
99
- parsed = TOML.parse(conf, { joiner: '\n', bigint: false }) as any
414
+ parsed = TOML.parse(conf, { joiner: '\n', bigint: false })
100
415
  } catch (e: any) {
101
416
  throw new Error(
102
417
  `An error occurred when parsing the configuration file: ${e.message}`
103
418
  )
104
419
  }
105
- const errors = []
106
- const warnings = []
107
-
108
- let parsedGlobalSection = parseConfigSection(
109
- parsed,
110
- 'global',
111
- ['geonetwork4_api_url'],
112
- [
113
- 'datahub_url',
114
- 'edit_url_template',
115
- 'proxy_path',
116
- 'metadata_language',
117
- 'login_url',
118
- 'logout_url',
119
- 'settings_url',
120
- 'web_component_embedder_url',
121
- 'languages',
122
- 'contact_email',
123
- 'reuse_form_url',
124
- ],
125
- warnings,
126
- errors
127
- )
128
- if (parsedGlobalSection?.metadata_language) {
129
- parsedGlobalSection = checkMetadataLanguage(
130
- parsedGlobalSection,
131
- warnings
132
- )
133
- }
134
- globalConfig =
135
- parsedGlobalSection === null
136
- ? null
137
- : ({
138
- GN4_API_URL: parsedGlobalSection.geonetwork4_api_url,
139
- DATAHUB_URL: parsedGlobalSection.datahub_url,
140
- EDIT_URL_TEMPLATE: parsedGlobalSection.edit_url_template,
141
- PROXY_PATH: parsedGlobalSection.proxy_path,
142
- METADATA_LANGUAGE: parsedGlobalSection.metadata_language
143
- ? (
144
- parsedGlobalSection.metadata_language as string
145
- ).toLowerCase()
146
- : undefined,
147
- LOGIN_URL: parsedGlobalSection.login_url,
148
- LOGOUT_URL: parsedGlobalSection.logout_url,
149
- SETTINGS_URL: parsedGlobalSection.settings_url,
150
- WEB_COMPONENT_EMBEDDER_URL:
151
- parsedGlobalSection.web_component_embedder_url,
152
- LANGUAGES: parsedGlobalSection.languages,
153
- CONTACT_EMAIL: parsedGlobalSection.contact_email,
154
- REUSE_FORM_URL: parsedGlobalSection.reuse_form_url,
155
- } as GlobalConfig)
156
-
157
- const parsedLayersSections = parseMultiConfigSection(
158
- parsed,
159
- 'map_layer',
160
- ['type'],
161
- ['name', 'url', 'data', 'styleUrl', 'accessToken'],
162
- warnings,
163
- errors
164
- )
165
- const parsedMapSection = parseConfigSection(
166
- parsed,
167
- 'map',
168
- [],
169
- [
170
- 'max_zoom',
171
- 'do_not_tile_wms',
172
- 'max_extent',
173
- 'max_feature_count',
174
- 'baselayer',
175
- 'do_not_use_default_basemap',
176
- 'external_viewer_url_template',
177
- 'external_viewer_open_new_tab',
178
- ],
179
- warnings,
180
- errors
181
- )
182
- mapConfig =
183
- parsedMapSection === null || parsedLayersSections === null
184
- ? null
185
- : ({
186
- MAX_ZOOM: parsedMapSection.max_zoom,
187
- DO_NOT_TILE_WMS: parsedMapSection.do_not_tile_wms,
188
- MAX_EXTENT: parsedMapSection.max_extent,
189
- MAX_FEATURE_COUNT: parsedMapSection.max_feature_count,
190
- EXTERNAL_VIEWER_URL_TEMPLATE:
191
- parsedMapSection.external_viewer_url_template,
192
- EXTERNAL_VIEWER_OPEN_NEW_TAB:
193
- parsedMapSection.external_viewer_open_new_tab,
194
- DO_NOT_USE_DEFAULT_BASEMAP:
195
- !!parsedMapSection.do_not_use_default_basemap,
196
- MAP_LAYERS: parsedLayersSections.map(
197
- (map_layer) =>
198
- ({
199
- TYPE: map_layer.type,
200
- URL: map_layer.url,
201
- NAME: map_layer.name,
202
- DATA: map_layer.data,
203
- STYLE_URL: map_layer.styleUrl,
204
- ACCESS_TOKEN: map_layer.accessToken,
205
- }) as LayerConfig
206
- ),
207
- } as MapConfig)
208
-
209
- const parsedThemeSection = parseConfigSection(
210
- parsed,
211
- 'theme',
212
- ['primary_color', 'secondary_color', 'main_color', 'background_color'],
213
- [
214
- 'header_foreground_color',
215
- 'main_font',
216
- 'title_font',
217
- 'fonts_stylesheet_url',
218
- 'thumbnail_placeholder',
219
- 'header_background',
220
- 'favicon',
221
- ],
222
- warnings,
223
- errors
224
- )
225
- themeConfig =
226
- parsedThemeSection === null
227
- ? null
228
- : ({
229
- PRIMARY_COLOR: parsedThemeSection.primary_color,
230
- SECONDARY_COLOR: parsedThemeSection.secondary_color,
231
- MAIN_COLOR: parsedThemeSection.main_color,
232
- BACKGROUND_COLOR: parsedThemeSection.background_color,
233
- HEADER_FOREGROUND_COLOR:
234
- parsedThemeSection.header_foreground_color,
235
- THUMBNAIL_PLACEHOLDER: parsedThemeSection.thumbnail_placeholder,
236
- HEADER_BACKGROUND: parsedThemeSection.header_background,
237
- TITLE_FONT: parsedThemeSection.title_font,
238
- MAIN_FONT: parsedThemeSection.main_font,
239
- FONTS_STYLESHEET_URL: parsedThemeSection.fonts_stylesheet_url,
240
- FAVICON: parsedThemeSection.favicon,
241
- } as ThemeConfig)
242
-
243
- const parsedSearchSection = parseConfigSection(
244
- parsed,
245
- 'search',
246
- [],
247
- [
248
- 'record_kind_quick_filter',
249
- 'filter_geometry_data',
250
- 'filter_geometry_url',
251
- 'do_not_use_default_search_preset',
252
- 'search_preset',
253
- 'advanced_filters',
254
- 'limit',
255
- 'spatial_extent_max_file_size',
256
- 'geocoding_provider',
257
- 'geocoding_provider_options',
258
- ],
259
- warnings,
260
- errors
261
- )
262
- const parsedSearchParams = parseMultiConfigSection(
263
- parsed,
264
- 'search_preset',
265
- ['name'],
266
- ['sort', 'filters'],
267
- warnings,
268
- errors
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
- )
278
- searchConfig =
279
- parsedSearchSection === null
280
- ? null
281
- : ({
282
- RECORD_KIND_QUICK_FILTER:
283
- parsedSearchSection.record_kind_quick_filter,
284
- FILTER_GEOMETRY_DATA: parsedSearchSection.filter_geometry_data,
285
- FILTER_GEOMETRY_URL: parsedSearchSection.filter_geometry_url,
286
- DO_NOT_USE_DEFAULT_SEARCH_PRESET:
287
- !!parsedSearchSection.do_not_use_default_search_preset,
288
- SEARCH_PRESET: parsedSearchParams.map((param) => ({
289
- sort: param.sort,
290
- name: param.name,
291
- filters: param.filters,
292
- })),
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
- ),
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,
309
- } as SearchConfig)
310
-
311
- const parsedMetadataQualitySection = parseConfigSection(
312
- parsed,
313
- 'metadata-quality',
314
- [],
315
- ['enabled'],
316
- warnings,
317
- errors
318
- )
319
- metadataQualityConfig =
320
- parsedMetadataQualitySection === null
321
- ? null
322
- : ({
323
- ENABLED: parsedMetadataQualitySection.enabled,
324
- SORTABLE: parsedMetadataQualitySection.sortable,
325
- } as MetadataQualityConfig)
326
-
327
- let parsedEditingSection = parseConfigSection(
328
- parsed,
329
- 'editing',
330
- [],
331
- ['new_record_default_language', 'new_record_standard'],
332
- warnings,
333
- errors
334
- )
335
- if (
336
- parsedEditingSection !== null &&
337
- parsedEditingSection.new_record_default_language !== undefined
338
- ) {
339
- parsedEditingSection = checkNewRecordDefaultLanguage(
340
- parsedEditingSection,
341
- warnings
342
- )
343
- }
344
- if (
345
- parsedEditingSection !== null &&
346
- parsedEditingSection.new_record_standard !== undefined
347
- ) {
348
- parsedEditingSection = checkNewRecordStandard(
349
- parsedEditingSection,
350
- warnings
351
- )
352
- }
353
- editorConfig =
354
- parsedEditingSection === null
355
- ? null
356
- : ({
357
- NEW_RECORD_DEFAULT_LANGUAGE:
358
- parsedEditingSection.new_record_default_language as
359
- | string
360
- | undefined,
361
- NEW_RECORD_STANDARD: parsedEditingSection.new_record_standard as
362
- | EditorConfig['NEW_RECORD_STANDARD']
363
- | undefined,
364
- } as EditorConfig)
365
-
366
- customTranslations = parseTranslationsConfigSection(
367
- parsed,
368
- 'translations'
369
- ) as CustomTranslationsAllLanguages
420
+ const issues: ConfigIssues = { warnings: [], errors: [] }
421
+ const config = Object.fromEntries(
422
+ sections.map((name) => [name, SECTION_PARSERS[name](parsed, issues)])
423
+ ) as Partial<AppConfig>
370
424
 
371
- if (errors.length) {
425
+ if (issues.errors.length) {
372
426
  throw new Error(`One or more mandatory settings were missing from the configuration file.
373
- ${errors.join('\n')}`)
374
- } else if (warnings.length) {
427
+ ${issues.errors.join('\n')}`)
428
+ } else if (issues.warnings.length) {
375
429
  console.warn(`One or more unexpected settings were encountered in the configuration file.
376
- ${warnings.join('\n')}`)
430
+ ${issues.warnings.join('\n')}`)
377
431
  }
378
432
 
433
+ globalConfig = config.global ?? null
434
+ themeConfig = config.theme ?? null
435
+ mapConfig = config.map ?? null
436
+ searchConfig = config.search ?? null
437
+ metadataQualityConfig = config.metadataQuality ?? null
438
+ editorConfig = config.editor ?? null
439
+ customTranslations = config.translations ?? {}
379
440
  appConfigLoaded = true
441
+ return parsed
380
442
  })
381
443
  }
382
444
 
@@ -387,8 +449,12 @@ export function isConfigLoaded() {
387
449
  export function _reset() {
388
450
  globalConfig = null
389
451
  themeConfig = null
452
+ mapConfig = null
453
+ searchConfig = null
454
+ metadataQualityConfig = null
390
455
  editorConfig = null
391
456
  customTranslations = null
457
+ appConfigLoaded = false
392
458
  }
393
459
 
394
460
  export const TRANSLATE_WITH_OVERRIDES_CONFIG: TranslateModuleConfig = {
@@ -42,8 +42,12 @@ 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
44
  geocoding_provider = "geoplateforme"
45
+ geocoding_provider_options.index = "poi"
45
46
  geocoding_provider_options.category = "administratif"
46
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'
47
51
  advanced_filters = ['publicationYear', 'documentStandard', 'inspireKeyword', 'topic', 'license', 'myOrg:firstCustomFilter', 'myOrg:secondCustomFilter']
48
52
 
49
53
  [[custom_filter]]
@@ -65,6 +65,12 @@ export interface CustomSearchFieldConfig {
65
65
  labelKey?: string
66
66
  }
67
67
 
68
+ export interface GeocodingProviderLabelsConfig {
69
+ MAIN?: string
70
+ SECONDARY?: string
71
+ TERTIARY?: string
72
+ }
73
+
68
74
  export interface SearchConfig {
69
75
  RECORD_KIND_QUICK_FILTER?: boolean
70
76
  FILTER_GEOMETRY_URL?: string
@@ -76,7 +82,11 @@ export interface SearchConfig {
76
82
  LIMIT?: number
77
83
  SPATIAL_EXTENT_MAX_FILE_SIZE?: number
78
84
  GEOCODING_PROVIDER?: GeocodingProviderName
79
- GEOCODING_PROVIDER_OPTIONS?: Record<string, string | number>
85
+ GEOCODING_PROVIDER_OPTIONS?: Record<
86
+ string,
87
+ string | number | boolean | string[]
88
+ >
89
+ GEOCODING_PROVIDER_LABELS?: GeocodingProviderLabelsConfig
80
90
  }
81
91
 
82
92
  export interface MetadataQualityConfig {
@@ -95,6 +105,23 @@ export type CustomTranslationsAllLanguages = {
95
105
  [lang: string]: CustomTranslations
96
106
  }
97
107
 
108
+ export interface ConfigIssues {
109
+ warnings: string[]
110
+ errors: string[]
111
+ }
112
+
113
+ export interface AppConfig {
114
+ global: GlobalConfig | null
115
+ theme: ThemeConfig | null
116
+ map: MapConfig | null
117
+ search: SearchConfig | null
118
+ metadataQuality: MetadataQualityConfig | null
119
+ editor: EditorConfig | null
120
+ translations: CustomTranslationsAllLanguages
121
+ }
122
+
123
+ export type ConfigSectionName = keyof AppConfig
124
+
98
125
  export interface SearchConfig {
99
126
  FILTER_GEOMETRY?: Geometry
100
127
  }