geonetwork-ui 2.11.0-dev.aed5b2e5b → 2.11.0-dev.bd615f629

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 (29) hide show
  1. package/fesm2022/geonetwork-ui.mjs +137 -52
  2. package/fesm2022/geonetwork-ui.mjs.map +1 -1
  3. package/index.d.ts +48 -31
  4. package/index.d.ts.map +1 -1
  5. package/package.json +2 -1
  6. package/src/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts +76 -34
  7. package/src/libs/common/domain/src/lib/model/search/filter.model.ts +13 -1
  8. package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.html +3 -0
  9. package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.ts +13 -1
  10. package/src/libs/feature/search/src/lib/search-filters-summary-item/search-filters-summary-item.component.ts +1 -0
  11. package/src/libs/feature/search/src/lib/utils/service/fields.service.ts +8 -2
  12. package/src/libs/feature/search/src/lib/utils/service/fields.ts +31 -5
  13. package/src/libs/ui/elements/src/lib/service-capabilities/service-capabilities.component.ts +2 -1
  14. package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.html +7 -4
  15. package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.ts +12 -9
  16. package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.model.ts +2 -2
  17. package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.html +3 -9
  18. package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.ts +26 -2
  19. package/src/libs/ui/map/src/lib/components/map-container/map-container.component.ts +2 -0
  20. package/src/libs/util/shared/src/lib/links/link-utils.ts +19 -10
  21. package/src/libs/util/shared/src/lib/utils/geojson.ts +8 -0
  22. package/translations/de.json +6 -2
  23. package/translations/en.json +6 -2
  24. package/translations/es.json +6 -2
  25. package/translations/fr.json +6 -2
  26. package/translations/it.json +6 -2
  27. package/translations/nl.json +6 -2
  28. package/translations/pt.json +6 -2
  29. package/translations/sk.json +6 -2
@@ -34,7 +34,12 @@ import {
34
34
  LanguageCode,
35
35
  } from '../../../../../../../libs/common/domain/src/lib/model/record'
36
36
  import { TranslateService } from '@ngx-translate/core'
37
- import { getGeometryBoundingBox } from '../../../../../../../libs/util/shared/src'
37
+ import {
38
+ bboxToPolygon,
39
+ BoundingBox,
40
+ getGeometryBoundingBox,
41
+ isBoundingBox,
42
+ } from '../../../../../../../libs/util/shared/src'
38
43
  import { getLength as getGeodesicLength } from 'ol/sphere.js'
39
44
  import { LineString } from 'ol/geom.js'
40
45
 
@@ -49,7 +54,10 @@ export class ElasticsearchService {
49
54
 
50
55
  // runtime fields are computed using a Painless script
51
56
  // see: https://www.elastic.co/guide/en/elasticsearch/reference/current/runtime-mapping-fields.html
52
- private runtimeFields: Record<string, string> = {}
57
+ private runtimeFields: Record<
58
+ string,
59
+ { script: string; type: 'keyword' | 'date' }
60
+ > = {}
53
61
 
54
62
  // we're using getters in case the defined languages change over time
55
63
  private get metadataLang(): LanguageCode {
@@ -91,8 +99,8 @@ export class ElasticsearchService {
91
99
  const addMapping = (fieldName: string) => {
92
100
  if (!payload.runtime_mappings) payload.runtime_mappings = {}
93
101
  payload.runtime_mappings[fieldName] = {
94
- type: 'keyword',
95
- script: this.runtimeFields[fieldName],
102
+ type: this.runtimeFields[fieldName].type,
103
+ script: this.runtimeFields[fieldName].script,
96
104
  }
97
105
  }
98
106
  const lookForField = (node: unknown) => {
@@ -113,6 +121,14 @@ export class ElasticsearchService {
113
121
  ) {
114
122
  addMapping(runtimeField)
115
123
  }
124
+ if (
125
+ runtimeField in node &&
126
+ typeof node[runtimeField] === 'object' &&
127
+ node[runtimeField] !== null &&
128
+ ('gte' in node[runtimeField] || 'lte' in node[runtimeField])
129
+ ) {
130
+ addMapping(runtimeField)
131
+ }
116
132
  if (
117
133
  'query' in node &&
118
134
  typeof node.query === 'string' &&
@@ -131,8 +147,12 @@ export class ElasticsearchService {
131
147
  return payload
132
148
  }
133
149
 
134
- registerRuntimeField(fieldName: string, expression: string) {
135
- this.runtimeFields[fieldName] = expression
150
+ registerRuntimeField(
151
+ fieldName: string,
152
+ expression: string,
153
+ type: 'keyword' | 'date' = 'keyword'
154
+ ) {
155
+ this.runtimeFields[fieldName] = { script: expression, type }
136
156
  }
137
157
 
138
158
  getMetadataByIdsPayload(uuids: string[]): EsSearchParams {
@@ -264,8 +284,18 @@ export class ElasticsearchService {
264
284
  return this.metadataLang === 'current'
265
285
  }
266
286
 
267
- private filtersToQuery(
287
+ private findSpatialFilterExtent(
268
288
  filters: FieldFilters | FiltersAggregationParams | string
289
+ ): BoundingBox | undefined {
290
+ if (typeof filters === 'string') {
291
+ return undefined
292
+ }
293
+ return Object.values(filters).find(isBoundingBox)
294
+ }
295
+
296
+ private filtersToQuery(
297
+ filters: FieldFilters | FiltersAggregationParams | string,
298
+ spatialFilterExtent = this.findSpatialFilterExtent(filters)
269
299
  ): FilterQuery {
270
300
  const addQuote = (key: string) => (/^\/.+\/$/.test(key) ? key : `"${key}"`)
271
301
  const makeQuery = (filter: FieldFilter): string => {
@@ -286,7 +316,9 @@ export class ElasticsearchService {
286
316
  ? filters
287
317
  : Object.keys(filters)
288
318
  .filter((fieldname) => fieldname !== 'gn-ui-crossFieldFilter')
319
+ .filter((fieldname) => !isBoundingBox(filters[fieldname]))
289
320
  .filter((fieldname) => !isDateRange(filters[fieldname]))
321
+ .filter((fieldname) => !Array.isArray(filters[fieldname]))
290
322
  .filter(
291
323
  (fieldname) =>
292
324
  filters[fieldname] &&
@@ -299,37 +331,39 @@ export class ElasticsearchService {
299
331
  if (filters['gn-ui-crossFieldFilter']) {
300
332
  queryString = `${queryString} AND (${filters['gn-ui-crossFieldFilter']})`
301
333
  }
302
- const queryRange = Object.entries(filters)
303
- .filter(([, value]) => isDateRange(value))
304
- .map(([searchField, dateRange]) => {
305
- return {
306
- searchField,
307
- dateRange,
308
- } as {
309
- searchField: string
310
- dateRange: DateRange
311
- }
312
- })[0]
334
+ const queryRanges = Object.entries(filters).filter(([, value]) =>
335
+ isDateRange(value)
336
+ ) as [string, DateRange][]
313
337
  const queryParts = [
314
338
  queryString && {
315
339
  query_string: {
316
340
  query: queryString,
317
341
  },
318
342
  },
319
- queryRange &&
320
- queryRange.dateRange && {
321
- range: {
322
- [queryRange.searchField]: {
323
- ...(queryRange.dateRange.start && {
324
- gte: formatDate(queryRange.dateRange.start),
325
- }),
326
- ...(queryRange.dateRange.end && {
327
- lte: formatDate(queryRange.dateRange.end),
328
- }),
329
- format: 'yyyy-MM-dd',
343
+ ...queryRanges.map(([searchField, dateRange]) => ({
344
+ range: {
345
+ [searchField]: {
346
+ ...(dateRange.start && { gte: formatDate(dateRange.start) }),
347
+ ...(dateRange.end && { lte: formatDate(dateRange.end) }),
348
+ format: 'yyyy-MM-dd',
349
+ },
350
+ },
351
+ })),
352
+ spatialFilterExtent && {
353
+ geo_shape: {
354
+ geom: {
355
+ shape: {
356
+ type: 'envelope',
357
+ // spatialFilterExtent is [minX, minY, maxX, maxY]; envelope coordinates are [top-left, bottom-right]
358
+ coordinates: [
359
+ [spatialFilterExtent[0], spatialFilterExtent[3]],
360
+ [spatialFilterExtent[2], spatialFilterExtent[1]],
361
+ ],
330
362
  },
363
+ relation: 'intersects',
331
364
  },
332
365
  },
366
+ },
333
367
  ].filter(Boolean)
334
368
  return queryParts.length > 0 ? (queryParts as FilterQuery) : undefined
335
369
  }
@@ -368,7 +402,12 @@ export class ElasticsearchService {
368
402
  },
369
403
  })
370
404
  }
371
- const queryFilters = this.filtersToQuery(fieldSearchFilters)
405
+ // a spatial extent filter takes precedence over the preference geometry for boosting
406
+ const spatialFilterExtent = this.findSpatialFilterExtent(fieldSearchFilters)
407
+ const queryFilters = this.filtersToQuery(
408
+ fieldSearchFilters,
409
+ spatialFilterExtent
410
+ )
372
411
  if (queryFilters) {
373
412
  filter.push(...queryFilters)
374
413
  }
@@ -379,7 +418,10 @@ export class ElasticsearchService {
379
418
  },
380
419
  })
381
420
  }
382
- if (geometry) {
421
+ const boostGeometry = spatialFilterExtent
422
+ ? bboxToPolygon(spatialFilterExtent)
423
+ : geometry
424
+ if (boostGeometry) {
383
425
  // boosts applied using the filter geometry:
384
426
  // * records completely within the geometry receive a boost of 5
385
427
  // * records intersecting the geometry receive a boost of 2
@@ -389,7 +431,7 @@ export class ElasticsearchService {
389
431
  {
390
432
  geo_shape: {
391
433
  geom: {
392
- shape: geometry,
434
+ shape: boostGeometry,
393
435
  relation: 'within',
394
436
  },
395
437
  boost: 5.0,
@@ -398,7 +440,7 @@ export class ElasticsearchService {
398
440
  {
399
441
  geo_shape: {
400
442
  geom: {
401
- shape: geometry,
443
+ shape: boostGeometry,
402
444
  relation: 'intersects',
403
445
  },
404
446
  boost: 2.0,
@@ -409,7 +451,7 @@ export class ElasticsearchService {
409
451
  // this will boost the results variably depending on their distance from the given geometry
410
452
  // note: this takes into account the `location` field of a record; this is generally the center of all spatial extents
411
453
  // combined, and thus the actual size/coverage of the record spatial extent isn't relevant here
412
- const bbox = getGeometryBoundingBox(geometry)
454
+ const bbox = getGeometryBoundingBox(boostGeometry)
413
455
  const center = [(bbox[0] + bbox[2]) / 2, (bbox[1] + bbox[3]) / 2]
414
456
  const northToCenter = new LineString([
415
457
  [center[0], bbox[3]],
@@ -6,11 +6,15 @@ export type FieldFilterByRange = {
6
6
  start?: Date
7
7
  end?: Date
8
8
  }
9
+ // matches util/shared's BoundingBox; duplicated here to avoid a circular
10
+ // dependency (util/shared already depends on common/domain)
11
+ export type FieldFilterByBoundingBox = [number, number, number, number]
9
12
 
10
13
  export type FieldFilter =
11
14
  | FieldFilterByExpression
12
15
  | FieldFilterByValues
13
16
  | FieldFilterByRange
17
+ | FieldFilterByBoundingBox
14
18
  export type FieldFilters = Record<FieldName, FieldFilter>
15
19
 
16
20
  export type QueryString = {
@@ -19,4 +23,12 @@ export type QueryString = {
19
23
  export type QueryRange = {
20
24
  range: Record<string, { format: string; gte: string; lte: string }>
21
25
  }
22
- export type FilterQuery = Array<QueryString | QueryRange>
26
+ export type QueryGeoShape = {
27
+ geo_shape: {
28
+ geom: {
29
+ shape: { type: string; coordinates: number[][] }
30
+ relation: string
31
+ }
32
+ }
33
+ }
34
+ export type FilterQuery = Array<QueryString | QueryRange | QueryGeoShape>
@@ -3,13 +3,16 @@
3
3
  [title]="title"
4
4
  [dateRange]="(selectedDateRange$ | async) ?? {}"
5
5
  (dateRangeChange)="onDateRangeChange($event)"
6
+ [attr.data-cy-field]="fieldName"
6
7
  ></gn-ui-date-range-dropdown>
7
8
  } @else if (fieldType === 'spatialExtent') {
8
9
  <gn-ui-spatial-extent-dropdown
9
10
  [title]="title"
11
+ [initialBbox]="(selectedBoundingBox$ | async) ?? null"
10
12
  [maxFileSizeMb]="spatialExtentMaxFileSize"
11
13
  (bboxChange)="onBboxChange($event)"
12
14
  (errorChange)="onSpatialExtentError($event)"
15
+ [attr.data-cy-field]="fieldName"
13
16
  ></gn-ui-spatial-extent-dropdown>
14
17
  } @else {
15
18
  <gn-ui-dropdown-multiselect
@@ -71,6 +71,14 @@ export class FilterDropdownComponent implements OnInit {
71
71
  map((selected) => (Array.isArray(selected) ? {} : (selected as DateRange)))
72
72
  ) as Observable<DateRange>
73
73
 
74
+ selectedBoundingBox$ = this.selected$.pipe(
75
+ map((selected) =>
76
+ Array.isArray(selected) && selected.length > 0
77
+ ? (selected as BoundingBox)
78
+ : null
79
+ )
80
+ ) as Observable<BoundingBox | null>
81
+
74
82
  onSelectedValues(values: unknown[]) {
75
83
  this.fieldsService
76
84
  .buildFiltersFromFieldValues({ [this.fieldName]: values as FieldValue[] })
@@ -80,7 +88,11 @@ export class FilterDropdownComponent implements OnInit {
80
88
  private spatialExtentErrorNotificationId: number | null = null
81
89
 
82
90
  onBboxChange(bbox: BoundingBox | null) {
83
- console.log(bbox)
91
+ this.fieldsService
92
+ .buildFiltersFromFieldValues({
93
+ [this.fieldName]: bbox,
94
+ })
95
+ .subscribe((filters) => this.searchService.updateFilters(filters))
84
96
  this.clearSpatialExtentErrorNotification()
85
97
  }
86
98
 
@@ -20,6 +20,7 @@ import { marker } from '@biesbjerg/ngx-translate-extract-marker'
20
20
 
21
21
  marker('search.filters.summaryLabel.user')
22
22
  marker('search.filters.summaryLabel.changeDate')
23
+ marker('search.filters.summaryLabel.resourceCreationRevisionDate')
23
24
 
24
25
  const OPEN_BOUND = '…'
25
26
 
@@ -2,6 +2,7 @@ import { Injectable, Injector, inject } from '@angular/core'
2
2
  import {
3
3
  AbstractSearchField,
4
4
  AvailableServicesField,
5
+ BoundingBoxSearchField,
5
6
  DateRangeSearchField,
6
7
  FieldValue,
7
8
  FullTextSearchField,
@@ -10,12 +11,12 @@ import {
10
11
  MultilingualSearchField,
11
12
  OrganizationSearchField,
12
13
  OwnerSearchField,
14
+ ResourceCreationRevisionDateSearchField,
13
15
  ResourceTypeLegacyField,
14
16
  SimpleSearchField,
15
17
  TranslatedSearchField,
16
18
  RecordKindField,
17
19
  UserSearchField,
18
- SpatialExtentSearchField,
19
20
  } from './fields'
20
21
  import { forkJoin, Observable, of } from 'rxjs'
21
22
  import { map } from 'rxjs/operators'
@@ -43,6 +44,7 @@ marker('search.filters.producerOrg')
43
44
  marker('search.filters.publisherOrg')
44
45
  marker('search.filters.user')
45
46
  marker('search.filters.changeDate')
47
+ marker('search.filters.resourceCreationRevisionDate')
46
48
  marker('search.filters.spatialExtent')
47
49
  @Injectable({
48
50
  providedIn: 'root',
@@ -95,8 +97,12 @@ export class FieldsService {
95
97
  ),
96
98
  user: new UserSearchField(this.injector),
97
99
  changeDate: new DateRangeSearchField('changeDate', this.injector, 'desc'),
100
+ resourceCreationRevisionDate: new ResourceCreationRevisionDateSearchField(
101
+ this.injector,
102
+ 'desc'
103
+ ),
98
104
  availableServices: new AvailableServicesField(this.injector),
99
- spatialExtent: new SpatialExtentSearchField(this.injector),
105
+ spatialExtent: new BoundingBoxSearchField('spatialExtent', this.injector),
100
106
  } as Record<string, AbstractSearchField>
101
107
 
102
108
  get supportedFields() {
@@ -20,7 +20,11 @@ import {
20
20
  isDateRange,
21
21
  METADATA_LANGUAGE,
22
22
  } from '../../../../../../../libs/api/repository/src'
23
- import { formatUserInfo } from '../../../../../../../libs/util/shared/src'
23
+ import {
24
+ BoundingBox,
25
+ formatUserInfo,
26
+ isBoundingBox,
27
+ } from '../../../../../../../libs/util/shared/src'
24
28
  import { PossibleResourceTypes } from '../../../../../../../libs/api/metadata-converter/src'
25
29
 
26
30
  export type FieldType = 'values' | 'dateRange' | 'spatialExtent'
@@ -431,16 +435,38 @@ export class DateRangeSearchField extends SimpleSearchField {
431
435
  }
432
436
  }
433
437
 
434
- export class SpatialExtentSearchField extends SimpleSearchField {
435
- constructor(injector: Injector) {
436
- super('spatialExtent', injector, 'asc')
438
+ export class ResourceCreationRevisionDateSearchField extends DateRangeSearchField {
439
+ constructor(injector: Injector, order: 'asc' | 'desc' = 'desc') {
440
+ super('resourceCreationRevisionDate', injector, order)
441
+ this.esService.registerRuntimeField(
442
+ 'resourceCreationRevisionDate',
443
+ `if (doc.containsKey('creationDateForResource') && doc['creationDateForResource'].size() > 0) {
444
+ for (def date : doc['creationDateForResource']) { emit(date.millis); }
445
+ }
446
+ if (doc.containsKey('revisionDateForResource') && doc['revisionDateForResource'].size() > 0) {
447
+ for (def date : doc['revisionDateForResource']) { emit(date.millis); }
448
+ }`,
449
+ 'date'
450
+ )
437
451
  }
452
+ }
438
453
 
454
+ export class BoundingBoxSearchField extends SimpleSearchField {
439
455
  getAvailableValues(): Observable<FieldAvailableValue[]> {
440
- // TODO: return an array of spatial extents to show which ones are available in the dropdown
441
456
  return of([])
442
457
  }
443
458
 
459
+ getFiltersForValues(values: FieldValue[]): Observable<FieldFilters> {
460
+ return of({
461
+ [this.esFieldName]: values.map(Number) as BoundingBox,
462
+ })
463
+ }
464
+
465
+ getValuesForFilter(filters: FieldFilters): Observable<FieldValue[]> {
466
+ const filter = filters[this.esFieldName]
467
+ return of(isBoundingBox(filter) ? filter : [])
468
+ }
469
+
444
470
  getType(): FieldType {
445
471
  return 'spatialExtent'
446
472
  }
@@ -128,7 +128,8 @@ export class ServiceCapabilitiesComponent implements OnInit {
128
128
  this.loading = true
129
129
  this.availableLayers = await getLayers(
130
130
  this.apiLinks[0].url.href,
131
- this.apiLinks[0].accessServiceProtocol
131
+ this.apiLinks[0].accessServiceProtocol,
132
+ true
132
133
  )
133
134
  this.loading = false
134
135
  this.cdr.detectChanges()
@@ -20,10 +20,13 @@
20
20
  </div>
21
21
  }
22
22
  </div>
23
- <button class="h-6 w-6" data-test="dropdown-clear">
23
+ <button
24
+ class="h-6 w-6 flex items-center justify-center"
25
+ data-test="dropdown-clear"
26
+ >
24
27
  @if (hasSelectedChoices && !overlayOpen) {
25
28
  <ng-icon
26
- class="shrink-0 opacity-40 mr-1.5 hover:opacity-80 transition-colors clear-btn"
29
+ class="shrink-0 opacity-40 hover:opacity-80 transition-colors clear-btn"
27
30
  (click)="clearSelection($event)"
28
31
  name="matClose"
29
32
  ></ng-icon>
@@ -61,13 +64,13 @@
61
64
  #overlayContainer
62
65
  >
63
66
  <div
64
- class="border border-gray-300 rounded mb-2 mx-2 min-h-[44px] flex flex-row gap-[2px] flex-wrap p-2 focus-within:rounded focus-within:border-2 focus-within:border-primary"
67
+ class="border border-gray-300 rounded mb-2 mx-2 min-h-[44px] flex flex-row gap-1 flex-wrap p-2 focus-within:rounded focus-within:border-2 focus-within:border-primary"
65
68
  >
66
69
  @for (selected of selectedChoices; track selected) {
67
70
  <button
68
71
  type="button"
69
72
  [title]="selected.label"
70
- class="max-w-full bg-main text-white rounded pr-[7px] flex gap-1 items-center opacity-70 hover:opacity-100 focus:opacity-100 transition-opacity mb-1"
73
+ class="max-w-full bg-main text-white rounded pr-[7px] flex gap-1 items-center opacity-70 hover:opacity-100 focus:opacity-100 transition-opacity"
71
74
  (click)="select(selected, false)"
72
75
  >
73
76
  <div class="text-sm truncate leading-[26px] px-2">
@@ -24,7 +24,7 @@ import {
24
24
  propagateToDocumentOnly,
25
25
  } from '../../../../../../libs/util/shared/src'
26
26
  import { ButtonComponent } from '../button/button.component'
27
- import { NgIcon, provideIcons } from '@ng-icons/core'
27
+ import { NgIcon, provideIcons, provideNgIconsConfig } from '@ng-icons/core'
28
28
  import { FormsModule } from '@angular/forms'
29
29
  import { TranslatePipe } from '@ngx-translate/core'
30
30
 
@@ -46,19 +46,22 @@ import {
46
46
  matExpandMore,
47
47
  matExpandLess,
48
48
  }),
49
+ provideNgIconsConfig({
50
+ size: '1.5rem',
51
+ }),
49
52
  ],
50
53
  standalone: true,
51
54
  })
52
- export class DropdownMultiselectComponent {
55
+ export class DropdownMultiselectComponent<T = unknown> {
53
56
  private scrollStrategies = inject(ScrollStrategyOptions)
54
57
 
55
58
  @Input() title: string
56
- @Input() choices: Choice[]
57
- @Input() selected: unknown[] = []
59
+ @Input() choices: Choice<T>[]
60
+ @Input() selected: T[] = []
58
61
  @Input() allowSearch = true
59
62
  @Input() maxRows: number
60
63
  @Input() searchInputValue = ''
61
- @Output() selectValues = new EventEmitter<unknown[]>()
64
+ @Output() selectValues = new EventEmitter<T[]>()
62
65
  @ViewChild('overlayOrigin') overlayOrigin: CdkOverlayOrigin
63
66
  @ViewChild(CdkConnectedOverlay) overlay: CdkConnectedOverlay
64
67
  @ViewChild('overlayContainer', { read: ElementRef })
@@ -115,7 +118,7 @@ export class DropdownMultiselectComponent {
115
118
 
116
119
  private setFocus() {
117
120
  setTimeout(() => {
118
- this.searchFieldInput.nativeElement.focus()
121
+ this.searchFieldInput?.nativeElement.focus()
119
122
  }, 0)
120
123
  }
121
124
 
@@ -194,18 +197,18 @@ export class DropdownMultiselectComponent {
194
197
  this.checkboxes.get(newIndex).nativeElement.focus()
195
198
  }
196
199
 
197
- isSelected(choice: Choice) {
200
+ isSelected(choice: Choice<T>) {
198
201
  return this.selected.indexOf(choice.value) > -1
199
202
  }
200
203
 
201
- select(choice: Choice, selected: boolean) {
204
+ select(choice: Choice<T>, selected: boolean) {
202
205
  this.selected = selected
203
206
  ? [...this.selected.filter((v) => v !== choice.value), choice.value]
204
207
  : this.selected.filter((v) => v !== choice.value)
205
208
  this.selectValues.emit(this.selected)
206
209
  }
207
210
 
208
- toggle(choice: Choice) {
211
+ toggle(choice: Choice<T>) {
209
212
  this.select(choice, !this.isSelected(choice))
210
213
  }
211
214
 
@@ -1,4 +1,4 @@
1
- export interface Choice {
2
- value: unknown
1
+ export interface Choice<T = unknown> {
2
+ value: T
3
3
  label: string
4
4
  }
@@ -79,11 +79,7 @@
79
79
  @if (hasSelection) {
80
80
  <gn-ui-button
81
81
  [type]="'primary-light'"
82
- [title]="
83
- ('search.filters.spatialExtent.bboxDelete' | translate) +
84
- ' ' +
85
- fileName
86
- "
82
+ [title]="selectionDeleteLabelKey | translate: selectionLabelParams"
87
83
  (buttonClick)="removeSelection($event)"
88
84
  extraClass="group gap-x-2 w-full h-[28px] px-[8px] py-[4px] mb-[12px] bg-primary-lighter text-white"
89
85
  data-test="spatial-extent-selected-item"
@@ -94,12 +90,10 @@
94
90
  size="15px"
95
91
  ></ng-icon>
96
92
  <span class="group-hover:hidden truncate text-sm m-auto">
97
- {{ 'search.filters.spatialExtent.bboxPrefix' | translate }}
98
- {{ fileName }}
93
+ {{ selectionLabelKey | translate: selectionLabelParams }}
99
94
  </span>
100
95
  <span class="hidden group-hover:block truncate text-sm m-auto">
101
- {{ 'search.filters.spatialExtent.bboxDelete' | translate }}
102
- {{ fileName }}
96
+ {{ selectionDeleteLabelKey | translate: selectionLabelParams }}
103
97
  </span>
104
98
  <ng-icon
105
99
  name="iconoirCheckCircle"
@@ -46,13 +46,20 @@ import {
46
46
  marker('search.filters.spatialExtent.import')
47
47
  marker('search.filters.spatialExtent.helpText')
48
48
  marker('search.filters.spatialExtent.error.title')
49
- marker('search.filters.spatialExtent.bboxPrefix')
49
+
50
+ const LABEL_FROM_FILE = marker('search.filters.spatialExtent.bboxFromFile')
51
+ const LABEL_FROM_FILE_DELETE = marker(
52
+ 'search.filters.spatialExtent.bboxFromFileDelete'
53
+ )
54
+ const LABEL_INITIAL = marker('search.filters.spatialExtent.bboxInitial')
55
+ const LABEL_INITIAL_DELETE = marker(
56
+ 'search.filters.spatialExtent.bboxInitialDelete'
57
+ )
50
58
 
51
59
  export interface SpatialExtentDropdownError {
52
60
  key: string
53
61
  params?: Record<string, string | number>
54
62
  }
55
- marker('search.filters.spatialExtent.bboxDelete')
56
63
 
57
64
  @Component({
58
65
  selector: 'gn-ui-spatial-extent-dropdown',
@@ -85,6 +92,11 @@ export class SpatialExtentDropdownComponent {
85
92
 
86
93
  @Input() title: string
87
94
  @Input() maxFileSizeMb: number | null = null
95
+ @Input() set initialBbox(value: BoundingBox | null) {
96
+ if (!this.bbox && value) {
97
+ this.bbox = value
98
+ }
99
+ }
88
100
 
89
101
  @Output() bboxChange = new EventEmitter<BoundingBox | null>()
90
102
  @Output() errorChange = new EventEmitter<SpatialExtentDropdownError>()
@@ -123,6 +135,18 @@ export class SpatialExtentDropdownComponent {
123
135
  return !!this.bbox
124
136
  }
125
137
 
138
+ get selectionLabelKey() {
139
+ return this.fileName ? LABEL_FROM_FILE : LABEL_INITIAL
140
+ }
141
+
142
+ get selectionDeleteLabelKey() {
143
+ return this.fileName ? LABEL_FROM_FILE_DELETE : LABEL_INITIAL_DELETE
144
+ }
145
+
146
+ get selectionLabelParams() {
147
+ return { fileName: this.fileName }
148
+ }
149
+
126
150
  openOverlay() {
127
151
  this.overlayMinWidth =
128
152
  this.overlayOrigin.elementRef.nativeElement.getBoundingClientRect()
@@ -58,6 +58,8 @@ import { transformExtent } from 'ol/proj.js'
58
58
  export const DEFAULT_BASEMAP_LAYER: MapContextLayerMapLibreStyle = {
59
59
  type: 'maplibre-style',
60
60
  styleUrl: `https://basemaps.cartocdn.com/gl/positron-gl-style/style.json`,
61
+ clickable: false,
62
+ hoverable: false,
61
63
  }
62
64
 
63
65
  const DEFAULT_VIEW: MapContextView = {
@@ -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': {
@@ -38,6 +38,14 @@ export function getGeometryFromGeoJSON(
38
38
  // FIXME: this type should be more generic across the project
39
39
  export type BoundingBox = [number, number, number, number]
40
40
 
41
+ export function isBoundingBox(value: unknown): value is BoundingBox {
42
+ return (
43
+ Array.isArray(value) &&
44
+ value.length === 4 &&
45
+ value.every((item) => typeof item === 'number')
46
+ )
47
+ }
48
+
41
49
  export function getGeometryBoundingBox(geometry: Geometry): BoundingBox {
42
50
  // use the bounding box if specified in the GeoJSON object
43
51
  if (geometry.bbox) {