geonetwork-ui 2.11.0-dev.ca7fb6b05 → 2.11.0-dev.d02d7f3f8

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 (112) hide show
  1. package/fesm2022/geonetwork-ui.mjs +2058 -1186
  2. package/fesm2022/geonetwork-ui.mjs.map +1 -1
  3. package/index.d.ts +386 -139
  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 +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/constant.ts +4 -0
  16. package/src/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts +174 -55
  17. package/src/libs/api/repository/src/lib/gn4/gn4-repository.ts +82 -35
  18. package/src/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.ts +11 -0
  19. package/src/libs/common/domain/src/lib/model/record/flags.model.ts +1 -0
  20. package/src/libs/common/domain/src/lib/model/record/index.ts +1 -0
  21. package/src/libs/common/domain/src/lib/model/record/metadata.model.ts +14 -18
  22. package/src/libs/common/domain/src/lib/model/search/aggregation.model.ts +2 -0
  23. package/src/libs/common/domain/src/lib/model/search/filter.model.ts +24 -2
  24. package/src/libs/common/domain/src/lib/platform.service.interface.ts +1 -0
  25. package/src/libs/common/domain/src/lib/repository/records-repository.interface.ts +20 -1
  26. package/src/libs/common/fixtures/src/lib/records.fixtures.ts +42 -62
  27. package/src/libs/feature/dataviz/src/lib/service/data.service.ts +32 -19
  28. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-constraints/form-field-constraints.component.ts +3 -5
  29. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-contacts/form-field-contacts.component.ts +2 -2
  30. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.html +18 -0
  31. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.ts +86 -0
  32. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html +100 -88
  33. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts +11 -4
  34. package/src/libs/feature/editor/src/lib/components/record-form/record-form.component.ts +18 -4
  35. package/src/libs/feature/editor/src/lib/expressions.ts +67 -0
  36. package/src/libs/feature/editor/src/lib/fields.config.ts +13 -0
  37. package/src/libs/feature/editor/src/lib/models/editor-config.model.ts +10 -4
  38. package/src/libs/feature/map/src/index.ts +0 -2
  39. package/src/libs/feature/map/src/lib/add-layer-from-file/add-layer-from-file.component.html +1 -0
  40. package/src/libs/feature/map/src/lib/feature-map.module.ts +1 -8
  41. package/src/libs/feature/notifications/src/lib/notifications.service.ts +6 -4
  42. package/src/libs/feature/notify-reuse/src/lib/notify-reuse-form/notify-reuse-form.component.ts +8 -3
  43. package/src/libs/feature/record/src/lib/state/mdview.effects.ts +3 -1
  44. package/src/libs/feature/record/src/lib/state/mdview.facade.ts +1 -1
  45. package/src/libs/feature/router/src/lib/default/state/query-params.utils.ts +1 -1
  46. package/src/libs/feature/search/src/index.ts +2 -0
  47. package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.html +18 -4
  48. package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.ts +80 -19
  49. package/src/libs/feature/search/src/lib/geocoding/geocoding.service.ts +105 -0
  50. package/src/libs/feature/search/src/lib/location-search/location-search.component.html +18 -0
  51. package/src/libs/feature/search/src/lib/location-search/location-search.component.ts +114 -0
  52. package/src/libs/feature/search/src/lib/search-filters-summary-item/search-filters-summary-item.component.ts +19 -8
  53. package/src/libs/feature/search/src/lib/state/reducer.ts +1 -4
  54. package/src/libs/feature/search/src/lib/utils/service/fields.service.ts +64 -4
  55. package/src/libs/feature/search/src/lib/utils/service/fields.ts +94 -10
  56. package/src/libs/ui/elements/src/lib/kind-badge/kind-badge.component.html +5 -1
  57. package/src/libs/ui/elements/src/lib/record-feature-catalog/feature-catalog-list/feature-catalog-list.component.html +3 -3
  58. package/src/libs/ui/elements/src/lib/record-feature-catalog/feature-catalog-list/feature-catalog-list.component.ts +2 -2
  59. package/src/libs/ui/elements/src/lib/service-capabilities/service-capabilities.component.ts +2 -1
  60. package/src/libs/ui/elements/src/lib/thumbnail/thumbnail.component.html +1 -1
  61. package/src/libs/ui/inputs/src/index.ts +2 -0
  62. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.css +0 -4
  63. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.html +12 -3
  64. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.ts +11 -3
  65. package/src/libs/ui/inputs/src/lib/date-adapter.providers.ts +30 -0
  66. package/src/libs/ui/inputs/src/lib/date-picker/date-picker.component.ts +3 -24
  67. package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.css +37 -3
  68. package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.html +135 -16
  69. package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.ts +166 -29
  70. package/src/libs/ui/inputs/src/lib/date-range-picker/date-range-picker.component.ts +3 -7
  71. package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.css +1 -0
  72. package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.html +20 -7
  73. package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.ts +46 -5
  74. package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.html +7 -4
  75. package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.ts +12 -9
  76. package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.model.ts +2 -2
  77. package/src/libs/ui/inputs/src/lib/inline-filter/inline-filter.component.html +6 -11
  78. package/src/libs/ui/inputs/src/lib/search-feature-catalog/search-feature-catalog.component.ts +2 -1
  79. package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.css +0 -0
  80. package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.html +117 -0
  81. package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.ts +244 -0
  82. package/src/libs/ui/layout/src/lib/block-list/block-list.component.css +1 -0
  83. package/src/libs/ui/map/src/lib/components/map-container/map-container.component.ts +2 -0
  84. package/src/libs/ui/search/src/lib/results-hits-number/results-hits-number.component.html +1 -0
  85. package/src/libs/util/app-config/src/index.ts +1 -0
  86. package/src/libs/util/app-config/src/lib/app-config.ts +338 -247
  87. package/src/libs/util/app-config/src/lib/fixtures.ts +37 -1
  88. package/src/libs/util/app-config/src/lib/model.ts +42 -1
  89. package/src/libs/util/app-config/src/lib/parse-utils.ts +8 -4
  90. package/src/libs/util/shared/src/index.ts +1 -0
  91. package/src/libs/util/shared/src/lib/autofocus.directive.ts +26 -0
  92. package/src/libs/util/shared/src/lib/links/link-utils.ts +19 -10
  93. package/src/libs/util/shared/src/lib/services/date.service.ts +3 -3
  94. package/src/libs/util/shared/src/lib/utils/file.ts +15 -0
  95. package/src/libs/util/shared/src/lib/utils/geojson.ts +45 -10
  96. package/src/libs/util/shared/src/lib/utils/index.ts +1 -0
  97. package/tailwind.base.css +5 -0
  98. package/translations/de.json +28 -4
  99. package/translations/en.json +27 -3
  100. package/translations/es.json +26 -2
  101. package/translations/fr.json +32 -8
  102. package/translations/it.json +26 -2
  103. package/translations/nl.json +26 -2
  104. package/translations/pt.json +26 -2
  105. package/translations/sk.json +26 -2
  106. package/src/libs/feature/map/src/lib/geocoding/geocoding.component.html +0 -41
  107. package/src/libs/feature/map/src/lib/geocoding/geocoding.component.ts +0 -112
  108. package/src/libs/feature/map/src/lib/geocoding.service.ts +0 -57
  109. package/src/libs/feature/map/src/lib/style/index.ts +0 -2
  110. package/src/libs/feature/map/src/lib/style/map-style.fixtures.ts +0 -47
  111. package/src/libs/feature/map/src/lib/style/map-style.service.ts +0 -108
  112. /package/src/libs/feature/{map/src/lib/geocoding/geocoding.component.css → editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.css} +0 -0
@@ -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,264 +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
- ],
256
- warnings,
257
- errors
258
- )
259
- const parsedSearchParams = parseMultiConfigSection(
260
- parsed,
261
- 'search_preset',
262
- ['name'],
263
- ['sort', 'filters'],
264
- warnings,
265
- errors
266
- )
267
- searchConfig =
268
- parsedSearchSection === null
269
- ? null
270
- : ({
271
- RECORD_KIND_QUICK_FILTER:
272
- parsedSearchSection.record_kind_quick_filter,
273
- FILTER_GEOMETRY_DATA: parsedSearchSection.filter_geometry_data,
274
- FILTER_GEOMETRY_URL: parsedSearchSection.filter_geometry_url,
275
- DO_NOT_USE_DEFAULT_SEARCH_PRESET:
276
- !!parsedSearchSection.do_not_use_default_search_preset,
277
- SEARCH_PRESET: parsedSearchParams.map((param) => ({
278
- sort: param.sort,
279
- name: param.name,
280
- filters: param.filters,
281
- })),
282
- ADVANCED_FILTERS: parsedSearchSection.advanced_filters,
283
- LIMIT: parsedSearchSection.limit,
284
- } as SearchConfig)
285
-
286
- const parsedMetadataQualitySection = parseConfigSection(
287
- parsed,
288
- 'metadata-quality',
289
- [],
290
- ['enabled'],
291
- warnings,
292
- errors
293
- )
294
- metadataQualityConfig =
295
- parsedMetadataQualitySection === null
296
- ? null
297
- : ({
298
- ENABLED: parsedMetadataQualitySection.enabled,
299
- SORTABLE: parsedMetadataQualitySection.sortable,
300
- } as MetadataQualityConfig)
301
-
302
- let parsedEditingSection = parseConfigSection(
303
- parsed,
304
- 'editing',
305
- [],
306
- ['new_record_default_language', 'new_record_standard'],
307
- warnings,
308
- errors
309
- )
310
- if (
311
- parsedEditingSection !== null &&
312
- parsedEditingSection.new_record_default_language !== undefined
313
- ) {
314
- parsedEditingSection = checkNewRecordDefaultLanguage(
315
- parsedEditingSection,
316
- warnings
317
- )
318
- }
319
- if (
320
- parsedEditingSection !== null &&
321
- parsedEditingSection.new_record_standard !== undefined
322
- ) {
323
- parsedEditingSection = checkNewRecordStandard(
324
- parsedEditingSection,
325
- warnings
326
- )
327
- }
328
- editorConfig =
329
- parsedEditingSection === null
330
- ? null
331
- : ({
332
- NEW_RECORD_DEFAULT_LANGUAGE:
333
- parsedEditingSection.new_record_default_language as
334
- | string
335
- | undefined,
336
- NEW_RECORD_STANDARD: parsedEditingSection.new_record_standard as
337
- | EditorConfig['NEW_RECORD_STANDARD']
338
- | undefined,
339
- } as EditorConfig)
340
-
341
- customTranslations = parseTranslationsConfigSection(
342
- parsed,
343
- 'translations'
344
- ) 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>
345
424
 
346
- if (errors.length) {
425
+ if (issues.errors.length) {
347
426
  throw new Error(`One or more mandatory settings were missing from the configuration file.
348
- ${errors.join('\n')}`)
349
- } else if (warnings.length) {
427
+ ${issues.errors.join('\n')}`)
428
+ } else if (issues.warnings.length) {
350
429
  console.warn(`One or more unexpected settings were encountered in the configuration file.
351
- ${warnings.join('\n')}`)
430
+ ${issues.warnings.join('\n')}`)
352
431
  }
353
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 ?? {}
354
440
  appConfigLoaded = true
441
+ return parsed
355
442
  })
356
443
  }
357
444
 
@@ -362,8 +449,12 @@ export function isConfigLoaded() {
362
449
  export function _reset() {
363
450
  globalConfig = null
364
451
  themeConfig = null
452
+ mapConfig = null
453
+ searchConfig = null
454
+ metadataQualityConfig = null
365
455
  editorConfig = null
366
456
  customTranslations = null
457
+ appConfigLoaded = false
367
458
  }
368
459
 
369
460
  export const TRANSLATE_WITH_OVERRIDES_CONFIG: TranslateModuleConfig = {
@@ -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],