geonetwork-ui 2.11.0-dev.4c200c0a1 → 2.11.0-dev.55f3852c7

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