geonetwork-ui 2.11.0-dev.4c200c0a1 → 2.11.0-dev.4f2b4fd55
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.
- package/fesm2022/geonetwork-ui.mjs +1465 -1022
- package/fesm2022/geonetwork-ui.mjs.map +1 -1
- package/index.d.ts +258 -114
- package/index.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/libs/api/metadata-converter/src/lib/dcat-ap/dcat-ap.converter.ts +2 -0
- package/src/libs/api/metadata-converter/src/lib/fixtures/mel.records.dataset+featurecatalog.ts +395 -0
- package/src/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts +35 -8
- package/src/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.ts +19 -0
- package/src/libs/api/metadata-converter/src/lib/iso19115-3/iso19115-3.converter.ts +17 -6
- package/src/libs/api/metadata-converter/src/lib/iso19115-3/read-parts.ts +110 -0
- package/src/libs/api/metadata-converter/src/lib/iso19115-3/write-parts.ts +131 -0
- package/src/libs/api/metadata-converter/src/lib/iso19139/iso19139.converter.ts +9 -0
- package/src/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts +2 -1
- package/src/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts +118 -53
- package/src/libs/api/repository/src/lib/gn4/gn4-repository.ts +79 -35
- package/src/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.ts +11 -0
- package/src/libs/common/domain/src/lib/model/record/flags.model.ts +1 -0
- package/src/libs/common/domain/src/lib/model/record/index.ts +1 -0
- package/src/libs/common/domain/src/lib/model/record/metadata.model.ts +14 -18
- package/src/libs/common/domain/src/lib/model/search/aggregation.model.ts +2 -0
- package/src/libs/common/domain/src/lib/model/search/filter.model.ts +12 -2
- package/src/libs/common/domain/src/lib/platform.service.interface.ts +1 -0
- package/src/libs/common/domain/src/lib/repository/records-repository.interface.ts +20 -1
- package/src/libs/common/fixtures/src/lib/records.fixtures.ts +42 -62
- package/src/libs/feature/dataviz/src/lib/service/data.service.ts +32 -19
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-constraints/form-field-constraints.component.ts +3 -5
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-contacts/form-field-contacts.component.ts +2 -2
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.html +18 -0
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.ts +86 -0
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html +100 -88
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts +11 -4
- package/src/libs/feature/editor/src/lib/components/record-form/record-form.component.ts +18 -4
- package/src/libs/feature/editor/src/lib/expressions.ts +67 -0
- package/src/libs/feature/editor/src/lib/fields.config.ts +13 -0
- package/src/libs/feature/editor/src/lib/models/editor-config.model.ts +10 -4
- package/src/libs/feature/map/src/index.ts +0 -2
- package/src/libs/feature/map/src/lib/feature-map.module.ts +1 -8
- package/src/libs/feature/notify-reuse/src/lib/notify-reuse-form/notify-reuse-form.component.ts +8 -3
- package/src/libs/feature/record/src/lib/state/mdview.effects.ts +3 -1
- package/src/libs/feature/record/src/lib/state/mdview.facade.ts +1 -1
- package/src/libs/feature/search/src/index.ts +2 -0
- package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.html +10 -1
- package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.ts +39 -5
- package/src/libs/feature/search/src/lib/geocoding/geocoding.service.ts +105 -0
- package/src/libs/feature/search/src/lib/location-search/location-search.component.html +18 -0
- package/src/libs/feature/search/src/lib/location-search/location-search.component.ts +114 -0
- package/src/libs/feature/search/src/lib/search-filters-summary-item/search-filters-summary-item.component.ts +2 -0
- package/src/libs/feature/search/src/lib/state/reducer.ts +1 -4
- package/src/libs/feature/search/src/lib/utils/service/fields.service.ts +62 -4
- package/src/libs/feature/search/src/lib/utils/service/fields.ts +69 -10
- package/src/libs/ui/elements/src/lib/record-feature-catalog/feature-catalog-list/feature-catalog-list.component.html +3 -3
- package/src/libs/ui/elements/src/lib/record-feature-catalog/feature-catalog-list/feature-catalog-list.component.ts +2 -2
- package/src/libs/ui/elements/src/lib/service-capabilities/service-capabilities.component.ts +2 -1
- package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.css +0 -4
- package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.html +12 -3
- package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.ts +11 -3
- package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.html +7 -4
- package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.component.ts +12 -9
- package/src/libs/ui/inputs/src/lib/dropdown-multiselect/dropdown-multiselect.model.ts +2 -2
- package/src/libs/ui/inputs/src/lib/search-feature-catalog/search-feature-catalog.component.ts +2 -1
- package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.html +11 -11
- package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.ts +57 -4
- package/src/libs/ui/layout/src/lib/block-list/block-list.component.css +1 -0
- package/src/libs/util/app-config/src/index.ts +1 -0
- package/src/libs/util/app-config/src/lib/app-config.ts +338 -250
- package/src/libs/util/app-config/src/lib/fixtures.ts +37 -1
- package/src/libs/util/app-config/src/lib/model.ts +41 -1
- package/src/libs/util/app-config/src/lib/parse-utils.ts +8 -4
- package/src/libs/util/shared/src/lib/links/link-utils.ts +19 -10
- package/src/libs/util/shared/src/lib/utils/geojson.ts +37 -10
- package/translations/de.json +18 -4
- package/translations/en.json +19 -5
- package/translations/es.json +18 -4
- package/translations/fr.json +24 -10
- package/translations/it.json +18 -4
- package/translations/nl.json +18 -4
- package/translations/pt.json +18 -4
- package/translations/sk.json +18 -4
- package/src/libs/feature/map/src/lib/geocoding/geocoding.component.html +0 -41
- package/src/libs/feature/map/src/lib/geocoding/geocoding.component.ts +0 -112
- package/src/libs/feature/map/src/lib/geocoding.service.ts +0 -57
- package/src/libs/feature/map/src/lib/style/index.ts +0 -2
- package/src/libs/feature/map/src/lib/style/map-style.fixtures.ts +0 -47
- package/src/libs/feature/map/src/lib/style/map-style.service.ts +0 -108
- /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
|
@@ -162,7 +162,7 @@ export class MdViewFacade {
|
|
|
162
162
|
link.accessServiceProtocol === 'ogcFeatures'
|
|
163
163
|
) {
|
|
164
164
|
return from(
|
|
165
|
-
this.dataService.getItemsFromOgcApi(link.url.href, 1)
|
|
165
|
+
this.dataService.getItemsFromOgcApi(link.url.href, link.name, 1)
|
|
166
166
|
).pipe(
|
|
167
167
|
map((collectionRecords: OgcApiRecord[]) => {
|
|
168
168
|
return collectionRecords &&
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from './lib/feature-search.module'
|
|
2
|
+
export * from './lib/geocoding/geocoding.service'
|
|
3
|
+
export * from './lib/location-search/location-search.component'
|
|
2
4
|
export * from './lib/filter-geometry.token'
|
|
3
5
|
export * from './lib/record-url.token'
|
|
4
6
|
export * from './lib/state/actions'
|
|
@@ -3,14 +3,23 @@
|
|
|
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)"
|
|
13
|
-
|
|
15
|
+
[attr.data-cy-field]="fieldName"
|
|
16
|
+
>
|
|
17
|
+
<gn-ui-location-search
|
|
18
|
+
[placeholder]="'search.filters.spatialExtent.searchLocation' | translate"
|
|
19
|
+
(bboxSelected)="onLocationSelected($event)"
|
|
20
|
+
data-cy="locationSearch"
|
|
21
|
+
></gn-ui-location-search>
|
|
22
|
+
</gn-ui-spatial-extent-dropdown>
|
|
14
23
|
} @else {
|
|
15
24
|
<gn-ui-dropdown-multiselect
|
|
16
25
|
class="w-full"
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ChangeDetectionStrategy,
|
|
3
3
|
Component,
|
|
4
|
+
InjectionToken,
|
|
4
5
|
Input,
|
|
5
6
|
OnInit,
|
|
7
|
+
ViewChild,
|
|
6
8
|
inject,
|
|
7
9
|
} from '@angular/core'
|
|
8
10
|
import {
|
|
@@ -26,8 +28,20 @@ import { DateRange } from '../../../../../../libs/api/repository/src'
|
|
|
26
28
|
import { CommonModule } from '@angular/common'
|
|
27
29
|
import { BoundingBox } from '../../../../../../libs/util/shared/src'
|
|
28
30
|
import { NotificationsService } from '../../../../../../libs/feature/notifications/src'
|
|
29
|
-
import { TranslateService } from '@ngx-translate/core'
|
|
30
|
-
import {
|
|
31
|
+
import { TranslatePipe, TranslateService } from '@ngx-translate/core'
|
|
32
|
+
import { marker } from '@biesbjerg/ngx-translate-extract-marker'
|
|
33
|
+
import {
|
|
34
|
+
LocationBbox,
|
|
35
|
+
LocationSearchComponent,
|
|
36
|
+
} from '../location-search/location-search.component'
|
|
37
|
+
|
|
38
|
+
marker('search.filters.spatialExtent.searchLocation')
|
|
39
|
+
|
|
40
|
+
// in MB, null means no limit
|
|
41
|
+
export const SPATIAL_EXTENT_MAX_FILE_SIZE = new InjectionToken<number | null>(
|
|
42
|
+
'spatialExtentMaxFileSize',
|
|
43
|
+
{ factory: () => null }
|
|
44
|
+
)
|
|
31
45
|
|
|
32
46
|
@Component({
|
|
33
47
|
selector: 'gn-ui-filter-dropdown',
|
|
@@ -40,6 +54,8 @@ import { getOptionalSearchConfig } from '../../../../../../libs/util/app-config/
|
|
|
40
54
|
DateRangeDropdownComponent,
|
|
41
55
|
DropdownMultiselectComponent,
|
|
42
56
|
SpatialExtentDropdownComponent,
|
|
57
|
+
LocationSearchComponent,
|
|
58
|
+
TranslatePipe,
|
|
43
59
|
],
|
|
44
60
|
})
|
|
45
61
|
export class FilterDropdownComponent implements OnInit {
|
|
@@ -52,8 +68,10 @@ export class FilterDropdownComponent implements OnInit {
|
|
|
52
68
|
@Input() fieldName: string
|
|
53
69
|
@Input() title: string
|
|
54
70
|
|
|
55
|
-
|
|
56
|
-
|
|
71
|
+
@ViewChild(SpatialExtentDropdownComponent)
|
|
72
|
+
spatialExtentDropdown: SpatialExtentDropdownComponent
|
|
73
|
+
|
|
74
|
+
spatialExtentMaxFileSize = inject(SPATIAL_EXTENT_MAX_FILE_SIZE)
|
|
57
75
|
|
|
58
76
|
fieldType: FieldType
|
|
59
77
|
choices$: Observable<Choice[]>
|
|
@@ -71,6 +89,14 @@ export class FilterDropdownComponent implements OnInit {
|
|
|
71
89
|
map((selected) => (Array.isArray(selected) ? {} : (selected as DateRange)))
|
|
72
90
|
) as Observable<DateRange>
|
|
73
91
|
|
|
92
|
+
selectedBoundingBox$ = this.selected$.pipe(
|
|
93
|
+
map((selected) =>
|
|
94
|
+
Array.isArray(selected) && selected.length > 0
|
|
95
|
+
? (selected as BoundingBox)
|
|
96
|
+
: null
|
|
97
|
+
)
|
|
98
|
+
) as Observable<BoundingBox | null>
|
|
99
|
+
|
|
74
100
|
onSelectedValues(values: unknown[]) {
|
|
75
101
|
this.fieldsService
|
|
76
102
|
.buildFiltersFromFieldValues({ [this.fieldName]: values as FieldValue[] })
|
|
@@ -80,10 +106,18 @@ export class FilterDropdownComponent implements OnInit {
|
|
|
80
106
|
private spatialExtentErrorNotificationId: number | null = null
|
|
81
107
|
|
|
82
108
|
onBboxChange(bbox: BoundingBox | null) {
|
|
83
|
-
|
|
109
|
+
this.fieldsService
|
|
110
|
+
.buildFiltersFromFieldValues({
|
|
111
|
+
[this.fieldName]: bbox,
|
|
112
|
+
})
|
|
113
|
+
.subscribe((filters) => this.searchService.updateFilters(filters))
|
|
84
114
|
this.clearSpatialExtentErrorNotification()
|
|
85
115
|
}
|
|
86
116
|
|
|
117
|
+
onLocationSelected({ bbox, label }: LocationBbox) {
|
|
118
|
+
this.spatialExtentDropdown.setLocationBbox(bbox, label)
|
|
119
|
+
}
|
|
120
|
+
|
|
87
121
|
onSpatialExtentError(error: SpatialExtentDropdownError) {
|
|
88
122
|
this.clearSpatialExtentErrorNotification()
|
|
89
123
|
this.spatialExtentErrorNotificationId =
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Injectable, InjectionToken, inject } from '@angular/core'
|
|
2
|
+
import {
|
|
3
|
+
queryGeoadmin,
|
|
4
|
+
GeoadminOptions,
|
|
5
|
+
GeocodingResult,
|
|
6
|
+
queryGeonames,
|
|
7
|
+
GeonamesOptions,
|
|
8
|
+
GeoplateformeOptions,
|
|
9
|
+
queryGeoplateforme,
|
|
10
|
+
} from '@geospatial-sdk/geocoding'
|
|
11
|
+
import { from, Observable, throwError } from 'rxjs'
|
|
12
|
+
import { catchError } from 'rxjs/operators'
|
|
13
|
+
|
|
14
|
+
type GeoadminGeocodingProvider = ['geoadmin', GeoadminOptions]
|
|
15
|
+
type GeonamesGeocodingProvider = ['geonames', GeonamesOptions]
|
|
16
|
+
type GeoplateformeGeocodingProvider = ['geoplateforme', GeoplateformeOptions]
|
|
17
|
+
export type GeocodingProvider =
|
|
18
|
+
| GeoadminGeocodingProvider
|
|
19
|
+
| GeonamesGeocodingProvider
|
|
20
|
+
| GeoplateformeGeocodingProvider
|
|
21
|
+
|
|
22
|
+
export const DEFAULT_GEOCODING_PROVIDER = [
|
|
23
|
+
'geonames',
|
|
24
|
+
{ maxRows: 5 },
|
|
25
|
+
] as GeocodingProvider
|
|
26
|
+
|
|
27
|
+
export const GEOCODING_PROVIDER = new InjectionToken<GeocodingProvider>(
|
|
28
|
+
'geocoding-provider',
|
|
29
|
+
{
|
|
30
|
+
providedIn: 'root',
|
|
31
|
+
factory: (): GeocodingProvider => DEFAULT_GEOCODING_PROVIDER,
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
// these options are arrays in the providers, but they can be configured
|
|
36
|
+
// with a single value for simplicity
|
|
37
|
+
const GEOCODING_PROVIDER_ARRAY_OPTIONS: {
|
|
38
|
+
geoadmin: (keyof GeoadminOptions)[]
|
|
39
|
+
geoplateforme: (keyof GeoplateformeOptions)[]
|
|
40
|
+
} = {
|
|
41
|
+
geoadmin: ['origins', 'features'],
|
|
42
|
+
geoplateforme: [
|
|
43
|
+
'index',
|
|
44
|
+
'category',
|
|
45
|
+
'type',
|
|
46
|
+
'postCode',
|
|
47
|
+
'cityCode',
|
|
48
|
+
'depCode',
|
|
49
|
+
],
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function wrapArrayOptions<T extends object>(options: T, keys: (keyof T)[]): T {
|
|
53
|
+
const wrapped = { ...options }
|
|
54
|
+
for (const key of keys) {
|
|
55
|
+
if (typeof wrapped[key] === 'string') {
|
|
56
|
+
wrapped[key] = [wrapped[key]] as T[keyof T]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return wrapped
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@Injectable({
|
|
63
|
+
providedIn: 'root',
|
|
64
|
+
})
|
|
65
|
+
export class GeocodingService {
|
|
66
|
+
private provider = inject<GeocodingProvider>(GEOCODING_PROVIDER)
|
|
67
|
+
|
|
68
|
+
query(text: string): Observable<GeocodingResult[]> {
|
|
69
|
+
let queryObservable: Observable<GeocodingResult[]>
|
|
70
|
+
switch (this.provider[0]) {
|
|
71
|
+
case 'geoadmin':
|
|
72
|
+
queryObservable = from(
|
|
73
|
+
queryGeoadmin(
|
|
74
|
+
text,
|
|
75
|
+
wrapArrayOptions(
|
|
76
|
+
this.provider[1] as GeoadminOptions,
|
|
77
|
+
GEOCODING_PROVIDER_ARRAY_OPTIONS.geoadmin
|
|
78
|
+
)
|
|
79
|
+
)
|
|
80
|
+
)
|
|
81
|
+
break
|
|
82
|
+
case 'geonames':
|
|
83
|
+
queryObservable = from(
|
|
84
|
+
queryGeonames(text, this.provider[1] as GeonamesOptions)
|
|
85
|
+
)
|
|
86
|
+
break
|
|
87
|
+
case 'geoplateforme':
|
|
88
|
+
queryObservable = from(
|
|
89
|
+
queryGeoplateforme(text, {
|
|
90
|
+
...wrapArrayOptions(
|
|
91
|
+
this.provider[1] as GeoplateformeOptions,
|
|
92
|
+
GEOCODING_PROVIDER_ARRAY_OPTIONS.geoplateforme
|
|
93
|
+
),
|
|
94
|
+
returnTrueGeometry: true,
|
|
95
|
+
})
|
|
96
|
+
)
|
|
97
|
+
break
|
|
98
|
+
default:
|
|
99
|
+
return throwError(
|
|
100
|
+
() => new Error(`Unsupported geocoding provider: ${this.provider[0]}`)
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
return queryObservable.pipe(catchError((error) => throwError(error)))
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<gn-ui-autocomplete
|
|
2
|
+
[action]="searchAction"
|
|
3
|
+
[displayWithFn]="displayWithFn"
|
|
4
|
+
[placeholder]="placeholder"
|
|
5
|
+
[displayWithTemplate]="defaultItemTpl"
|
|
6
|
+
[clearOnSelection]="true"
|
|
7
|
+
(itemSelected)="handleItemSelected($event)"
|
|
8
|
+
>
|
|
9
|
+
</gn-ui-autocomplete>
|
|
10
|
+
|
|
11
|
+
<ng-template #defaultItemTpl let-result>
|
|
12
|
+
<div class="py-2">
|
|
13
|
+
@if (getSecondaryLabel(result)) {
|
|
14
|
+
<div class="gn-ui-card-detail">{{ getSecondaryLabel(result) }}</div>
|
|
15
|
+
}
|
|
16
|
+
<div class="gn-ui-card-title">{{ getDisplayLabel(result) }}</div>
|
|
17
|
+
</div>
|
|
18
|
+
</ng-template>
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
EventEmitter,
|
|
5
|
+
inject,
|
|
6
|
+
InjectionToken,
|
|
7
|
+
Input,
|
|
8
|
+
Output,
|
|
9
|
+
} from '@angular/core'
|
|
10
|
+
import { Observable } from 'rxjs'
|
|
11
|
+
import pointer from 'jsonpointer'
|
|
12
|
+
import { GeocodingResult } from '@geospatial-sdk/geocoding'
|
|
13
|
+
import { Geometry } from 'geojson'
|
|
14
|
+
import {
|
|
15
|
+
AutocompleteComponent,
|
|
16
|
+
AutocompleteItem,
|
|
17
|
+
} from '../../../../../../libs/ui/inputs/src'
|
|
18
|
+
import { BoundingBox, getGeometryBoundingBox } from '../../../../../../libs/util/shared/src'
|
|
19
|
+
import { GeocodingService } from '../geocoding/geocoding.service'
|
|
20
|
+
|
|
21
|
+
// JSON Pointers resolved against a geocoding result to build the labels shown in the dropdown
|
|
22
|
+
export interface GeocodingProviderLabels {
|
|
23
|
+
main?: string
|
|
24
|
+
secondary?: string
|
|
25
|
+
tertiary?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface LocationBbox {
|
|
29
|
+
bbox: BoundingBox
|
|
30
|
+
label: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const GEOCODING_PROVIDER_LABELS =
|
|
34
|
+
new InjectionToken<GeocodingProviderLabels>('geocodingProviderLabels', {
|
|
35
|
+
factory: () => ({}),
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
@Component({
|
|
39
|
+
selector: 'gn-ui-location-search',
|
|
40
|
+
templateUrl: './location-search.component.html',
|
|
41
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
42
|
+
standalone: true,
|
|
43
|
+
imports: [AutocompleteComponent],
|
|
44
|
+
})
|
|
45
|
+
export class LocationSearchComponent {
|
|
46
|
+
private geocodingService = inject(GeocodingService)
|
|
47
|
+
private labels = inject(GEOCODING_PROVIDER_LABELS)
|
|
48
|
+
|
|
49
|
+
@Input() placeholder = ''
|
|
50
|
+
@Output() resultSelected = new EventEmitter<GeocodingResult>()
|
|
51
|
+
@Output() bboxSelected = new EventEmitter<LocationBbox>()
|
|
52
|
+
|
|
53
|
+
displayWithFn = (item: AutocompleteItem) => (item as GeocodingResult).label
|
|
54
|
+
|
|
55
|
+
searchAction = (text: string): Observable<AutocompleteItem[]> =>
|
|
56
|
+
this.geocodingService.query(text)
|
|
57
|
+
|
|
58
|
+
getSecondaryLabel(result: GeocodingResult): string | undefined {
|
|
59
|
+
return this.resolveLabel(result, this.labels.secondary)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getMainLabel(result: GeocodingResult): string {
|
|
63
|
+
return this.resolveLabel(result, this.labels.main) ?? result.label
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getTertiaryLabel(result: GeocodingResult): string | undefined {
|
|
67
|
+
return this.resolveLabel(result, this.labels.tertiary)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getDisplayLabel(result: GeocodingResult): string {
|
|
71
|
+
const tertiary = this.getTertiaryLabel(result)
|
|
72
|
+
return this.getMainLabel(result) + (tertiary ? ', ' + tertiary : '')
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private resolveLabel(
|
|
76
|
+
result: GeocodingResult,
|
|
77
|
+
path?: string
|
|
78
|
+
): string | undefined {
|
|
79
|
+
if (!path) return undefined
|
|
80
|
+
let value: unknown
|
|
81
|
+
try {
|
|
82
|
+
value = pointer.get(result, path)
|
|
83
|
+
} catch {
|
|
84
|
+
return undefined
|
|
85
|
+
}
|
|
86
|
+
const values = Array.isArray(value) ? value : [value]
|
|
87
|
+
const label = values
|
|
88
|
+
.filter((v) => typeof v === 'string' || typeof v === 'number')
|
|
89
|
+
.join(', ')
|
|
90
|
+
return label || undefined
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// geoplateforme keeps a simplified geometry in geom and puts the real one,
|
|
94
|
+
// as a JSON string, in properties.truegeometry when returnTrueGeometry is set
|
|
95
|
+
private getGeometry(result: GeocodingResult): Geometry | null {
|
|
96
|
+
const trueGeometry = result.properties?.['truegeometry']
|
|
97
|
+
if (typeof trueGeometry === 'string') {
|
|
98
|
+
return JSON.parse(trueGeometry)
|
|
99
|
+
}
|
|
100
|
+
return (trueGeometry as Geometry) ?? result.geom
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
handleItemSelected(item: AutocompleteItem) {
|
|
104
|
+
const result = item as GeocodingResult
|
|
105
|
+
this.resultSelected.emit(result)
|
|
106
|
+
const geometry = this.getGeometry(result)
|
|
107
|
+
if (geometry) {
|
|
108
|
+
this.bboxSelected.emit({
|
|
109
|
+
bbox: getGeometryBoundingBox(geometry),
|
|
110
|
+
label: this.getDisplayLabel(result),
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -20,6 +20,8 @@ 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')
|
|
24
|
+
marker('search.filters.summaryLabel.temporalExtent')
|
|
23
25
|
|
|
24
26
|
const OPEN_BOUND = '…'
|
|
25
27
|
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
SortByField,
|
|
9
9
|
} from '../../../../../../libs/common/domain/src/lib/model/search'
|
|
10
10
|
import { DEFAULT_PAGE_SIZE, FIELDS_SUMMARY } from '../constants'
|
|
11
|
-
import { getOptionalSearchConfig } from '../../../../../../libs/util/app-config/src'
|
|
12
11
|
import { CatalogRecord } from '../../../../../../libs/common/domain/src/lib/model/record'
|
|
13
12
|
|
|
14
13
|
export const SEARCH_FEATURE_KEY = 'searchState'
|
|
@@ -56,9 +55,7 @@ export const initSearch = (): SearchStateSearch => {
|
|
|
56
55
|
},
|
|
57
56
|
params: {
|
|
58
57
|
filters: {},
|
|
59
|
-
pageSize:
|
|
60
|
-
? getOptionalSearchConfig().LIMIT
|
|
61
|
-
: DEFAULT_PAGE_SIZE,
|
|
58
|
+
pageSize: DEFAULT_PAGE_SIZE,
|
|
62
59
|
currentPage: 0,
|
|
63
60
|
favoritesOnly: false,
|
|
64
61
|
useSpatialFilter: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable,
|
|
1
|
+
import { inject, Injectable, InjectionToken, Injector } from '@angular/core'
|
|
2
2
|
import {
|
|
3
3
|
AbstractSearchField,
|
|
4
4
|
AvailableServicesField,
|
|
@@ -11,10 +11,11 @@ import {
|
|
|
11
11
|
MultilingualSearchField,
|
|
12
12
|
OrganizationSearchField,
|
|
13
13
|
OwnerSearchField,
|
|
14
|
+
RecordKindField,
|
|
15
|
+
ResourceCreationRevisionDateSearchField,
|
|
14
16
|
ResourceTypeLegacyField,
|
|
15
17
|
SimpleSearchField,
|
|
16
18
|
TranslatedSearchField,
|
|
17
|
-
RecordKindField,
|
|
18
19
|
UserSearchField,
|
|
19
20
|
} from './fields'
|
|
20
21
|
import { forkJoin, Observable, of } from 'rxjs'
|
|
@@ -43,14 +44,30 @@ 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')
|
|
48
|
+
marker('search.filters.temporalExtent')
|
|
46
49
|
marker('search.filters.spatialExtent')
|
|
50
|
+
marker('search.filters.documentStandard')
|
|
51
|
+
|
|
52
|
+
export interface CustomSearchField {
|
|
53
|
+
name: string
|
|
54
|
+
baseFilter: string
|
|
55
|
+
excludeValues?: string[]
|
|
56
|
+
includeValues?: string[]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const CUSTOM_FIELDS = new InjectionToken<CustomSearchField[]>(
|
|
60
|
+
'custom-fields'
|
|
61
|
+
)
|
|
47
62
|
@Injectable({
|
|
48
63
|
providedIn: 'root',
|
|
49
64
|
})
|
|
50
65
|
export class FieldsService {
|
|
51
66
|
protected injector = inject(Injector)
|
|
67
|
+
private customFields =
|
|
68
|
+
inject<CustomSearchField[]>(CUSTOM_FIELDS, { optional: true }) ?? []
|
|
52
69
|
|
|
53
|
-
|
|
70
|
+
private baseFields: Record<string, AbstractSearchField> = {
|
|
54
71
|
organization: new OrganizationSearchField(this.injector),
|
|
55
72
|
format: new SimpleSearchField('format', this.injector, 'asc'),
|
|
56
73
|
resourceType: new ResourceTypeLegacyField(this.injector), // Deprecated, use `recordKind` instead
|
|
@@ -95,9 +112,50 @@ export class FieldsService {
|
|
|
95
112
|
),
|
|
96
113
|
user: new UserSearchField(this.injector),
|
|
97
114
|
changeDate: new DateRangeSearchField('changeDate', this.injector, 'desc'),
|
|
115
|
+
resourceCreationRevisionDate: new ResourceCreationRevisionDateSearchField(
|
|
116
|
+
this.injector,
|
|
117
|
+
'desc'
|
|
118
|
+
),
|
|
119
|
+
temporalExtent: new DateRangeSearchField(
|
|
120
|
+
'resourceTemporalExtentDateRange',
|
|
121
|
+
this.injector,
|
|
122
|
+
'desc'
|
|
123
|
+
),
|
|
98
124
|
availableServices: new AvailableServicesField(this.injector),
|
|
99
125
|
spatialExtent: new BoundingBoxSearchField('spatialExtent', this.injector),
|
|
100
|
-
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
protected fields: Record<string, AbstractSearchField>
|
|
129
|
+
|
|
130
|
+
constructor() {
|
|
131
|
+
this.fields = { ...this.baseFields }
|
|
132
|
+
for (const customField of this.customFields) {
|
|
133
|
+
const baseField = this.baseFields[customField.baseFilter]
|
|
134
|
+
if (!(baseField instanceof SimpleSearchField)) {
|
|
135
|
+
console.warn(
|
|
136
|
+
`The custom field '${customField.name}' relies on a base field '${
|
|
137
|
+
customField.baseFilter
|
|
138
|
+
}' that is not supported. This field will be ignored.`
|
|
139
|
+
)
|
|
140
|
+
continue
|
|
141
|
+
}
|
|
142
|
+
if (!customField.name.includes(':')) {
|
|
143
|
+
console.warn(
|
|
144
|
+
`The custom field '${customField.name}' is not scoped with a prefix. Custom fields must have their names prefixed, for instance "myOrg:myKeywords". This field will be ignored.`
|
|
145
|
+
)
|
|
146
|
+
continue
|
|
147
|
+
}
|
|
148
|
+
const newField = baseField.clone()
|
|
149
|
+
newField.setFieldIdentifier(customField.name)
|
|
150
|
+
if (customField.includeValues) {
|
|
151
|
+
newField.includeValues = customField.includeValues
|
|
152
|
+
}
|
|
153
|
+
if (customField.excludeValues) {
|
|
154
|
+
newField.excludeValues = customField.excludeValues
|
|
155
|
+
}
|
|
156
|
+
this.fields[customField.name] = newField
|
|
157
|
+
}
|
|
158
|
+
}
|
|
101
159
|
|
|
102
160
|
get supportedFields() {
|
|
103
161
|
return Object.keys(this.fields)
|
|
@@ -53,6 +53,15 @@ export class SimpleSearchField implements AbstractSearchField {
|
|
|
53
53
|
// FIXME: this is required to register runtime fields; abstract this as well
|
|
54
54
|
protected esService = this.injector.get(ElasticsearchService)
|
|
55
55
|
|
|
56
|
+
private customIdentifier?: string
|
|
57
|
+
|
|
58
|
+
protected get fieldIdentifier(): string {
|
|
59
|
+
return this.customIdentifier ?? this.esFieldName
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public includeValues: string[] = []
|
|
63
|
+
public excludeValues: string[] = []
|
|
64
|
+
|
|
56
65
|
constructor(
|
|
57
66
|
protected esFieldName: string,
|
|
58
67
|
protected injector: Injector,
|
|
@@ -60,13 +69,24 @@ export class SimpleSearchField implements AbstractSearchField {
|
|
|
60
69
|
protected orderType: 'key' | 'count' = 'key'
|
|
61
70
|
) {}
|
|
62
71
|
|
|
72
|
+
public setFieldIdentifier(fieldIdentifier: string) {
|
|
73
|
+
this.customIdentifier = fieldIdentifier
|
|
74
|
+
this.esService.registerFieldAlias(fieldIdentifier, this.esFieldName)
|
|
75
|
+
}
|
|
76
|
+
|
|
63
77
|
protected getAggregations(): AggregationsParams {
|
|
64
78
|
return {
|
|
65
|
-
[this.
|
|
79
|
+
[this.fieldIdentifier]: {
|
|
66
80
|
type: 'terms',
|
|
67
81
|
field: this.esFieldName,
|
|
68
82
|
limit: 1000,
|
|
69
83
|
sort: [this.order, this.orderType],
|
|
84
|
+
...(this.includeValues?.length && {
|
|
85
|
+
includeValues: this.includeValues,
|
|
86
|
+
}),
|
|
87
|
+
...(this.excludeValues?.length && {
|
|
88
|
+
excludeValues: this.excludeValues,
|
|
89
|
+
}),
|
|
70
90
|
},
|
|
71
91
|
}
|
|
72
92
|
}
|
|
@@ -79,7 +99,7 @@ export class SimpleSearchField implements AbstractSearchField {
|
|
|
79
99
|
return this.repository.aggregate(this.getAggregations()).pipe(
|
|
80
100
|
map(
|
|
81
101
|
(response) =>
|
|
82
|
-
(response[this.
|
|
102
|
+
(response[this.fieldIdentifier] as AggregationBuckets).buckets || []
|
|
83
103
|
),
|
|
84
104
|
switchMap((buckets: TermBucket[]) => {
|
|
85
105
|
const bucketPromises = buckets.map(async (bucket) => ({
|
|
@@ -97,7 +117,7 @@ export class SimpleSearchField implements AbstractSearchField {
|
|
|
97
117
|
// FieldValue[]
|
|
98
118
|
if (this.getType() === 'values') {
|
|
99
119
|
return of({
|
|
100
|
-
[this.
|
|
120
|
+
[this.fieldIdentifier]: (values as FieldValue[]).reduce((acc, val) => {
|
|
101
121
|
const value = val.toString()
|
|
102
122
|
if (value !== '') {
|
|
103
123
|
return { ...acc, [value]: true }
|
|
@@ -108,13 +128,13 @@ export class SimpleSearchField implements AbstractSearchField {
|
|
|
108
128
|
}
|
|
109
129
|
// DateRange
|
|
110
130
|
return of({
|
|
111
|
-
[this.
|
|
131
|
+
[this.fieldIdentifier]: values[0] !== '' ? values[0] : {},
|
|
112
132
|
})
|
|
113
133
|
}
|
|
114
134
|
getValuesForFilter(
|
|
115
135
|
filters: FieldFilters
|
|
116
136
|
): Observable<FieldValue[] | FieldValue | DateRange> {
|
|
117
|
-
const filter = filters[this.
|
|
137
|
+
const filter = filters[this.fieldIdentifier]
|
|
118
138
|
if (!filter) return of([])
|
|
119
139
|
// filter by expression
|
|
120
140
|
if (typeof filter === 'string') {
|
|
@@ -132,6 +152,10 @@ export class SimpleSearchField implements AbstractSearchField {
|
|
|
132
152
|
getType(): FieldType {
|
|
133
153
|
return 'values'
|
|
134
154
|
}
|
|
155
|
+
|
|
156
|
+
clone(): typeof this {
|
|
157
|
+
return Object.create(this)
|
|
158
|
+
}
|
|
135
159
|
}
|
|
136
160
|
|
|
137
161
|
export class TranslatedSearchField extends SimpleSearchField {
|
|
@@ -175,7 +199,8 @@ export class TranslatedSearchField extends SimpleSearchField {
|
|
|
175
199
|
export class MultilingualSearchField extends SimpleSearchField {
|
|
176
200
|
// we're using a getter in case the token value changes over time
|
|
177
201
|
private get searchLanguage() {
|
|
178
|
-
|
|
202
|
+
const language = this.injector.get(METADATA_LANGUAGE, null)
|
|
203
|
+
return typeof language === 'function' ? language() : language
|
|
179
204
|
}
|
|
180
205
|
|
|
181
206
|
constructor(
|
|
@@ -435,6 +460,40 @@ export class DateRangeSearchField extends SimpleSearchField {
|
|
|
435
460
|
}
|
|
436
461
|
}
|
|
437
462
|
|
|
463
|
+
// treats a resource's creation/revision dates as an interval (its min and max), so a record matches
|
|
464
|
+
// when that interval intersects the filter range, not just when a single date falls inside it
|
|
465
|
+
export class ResourceCreationRevisionDateSearchField extends DateRangeSearchField {
|
|
466
|
+
constructor(injector: Injector, order: 'asc' | 'desc' = 'desc') {
|
|
467
|
+
super('resourceCreationRevisionDate', injector, order)
|
|
468
|
+
const dateSourceFields = [
|
|
469
|
+
'creationDateForResource',
|
|
470
|
+
'revisionDateForResource',
|
|
471
|
+
]
|
|
472
|
+
const collectSortedDates = dateSourceFields
|
|
473
|
+
.map(
|
|
474
|
+
(field) => `if (doc.containsKey('${field}')) {
|
|
475
|
+
for (def date : doc['${field}']) { dates.add(date.millis); }
|
|
476
|
+
}`
|
|
477
|
+
)
|
|
478
|
+
.join('\n')
|
|
479
|
+
|
|
480
|
+
this.esService.registerRuntimeField(
|
|
481
|
+
'resourceCreationRevisionDateMin',
|
|
482
|
+
`def dates = [];
|
|
483
|
+
${collectSortedDates}
|
|
484
|
+
if (dates.length > 0) { dates.sort(null); emit(dates[0]); }`,
|
|
485
|
+
'date'
|
|
486
|
+
)
|
|
487
|
+
this.esService.registerRuntimeField(
|
|
488
|
+
'resourceCreationRevisionDateMax',
|
|
489
|
+
`def dates = [];
|
|
490
|
+
${collectSortedDates}
|
|
491
|
+
if (dates.length > 0) { dates.sort(null); emit(dates[dates.length - 1]); }`,
|
|
492
|
+
'date'
|
|
493
|
+
)
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
438
497
|
export class BoundingBoxSearchField extends SimpleSearchField {
|
|
439
498
|
getAvailableValues(): Observable<FieldAvailableValue[]> {
|
|
440
499
|
return of([])
|
|
@@ -442,12 +501,12 @@ export class BoundingBoxSearchField extends SimpleSearchField {
|
|
|
442
501
|
|
|
443
502
|
getFiltersForValues(values: FieldValue[]): Observable<FieldFilters> {
|
|
444
503
|
return of({
|
|
445
|
-
[this.
|
|
504
|
+
[this.fieldIdentifier]: values.map(Number) as BoundingBox,
|
|
446
505
|
})
|
|
447
506
|
}
|
|
448
507
|
|
|
449
508
|
getValuesForFilter(filters: FieldFilters): Observable<FieldValue[]> {
|
|
450
|
-
const filter = filters[this.
|
|
509
|
+
const filter = filters[this.fieldIdentifier]
|
|
451
510
|
return of(isBoundingBox(filter) ? filter : [])
|
|
452
511
|
}
|
|
453
512
|
|
|
@@ -565,7 +624,7 @@ export class RecordKindField extends SimpleSearchField {
|
|
|
565
624
|
|
|
566
625
|
getFiltersForValues(values: FieldValue[]): Observable<FieldFilters | string> {
|
|
567
626
|
const filters: FieldFilters = {
|
|
568
|
-
[this.
|
|
627
|
+
[this.fieldIdentifier]: values.reduce((acc, value) => {
|
|
569
628
|
if (value === '') return { ...acc, [value]: true }
|
|
570
629
|
|
|
571
630
|
const keysToAdd = this.TYPE_MAPPING[value] || [value]
|
|
@@ -592,7 +651,7 @@ export class RecordKindField extends SimpleSearchField {
|
|
|
592
651
|
}
|
|
593
652
|
|
|
594
653
|
getValuesForFilter(filters: FieldFilters): Observable<FieldValue[]> {
|
|
595
|
-
const filter = filters[this.
|
|
654
|
+
const filter = filters[this.fieldIdentifier]
|
|
596
655
|
if (!filter) return of([])
|
|
597
656
|
|
|
598
657
|
const activeValues = Object.keys(filter).filter((v) => filter[v])
|