geonetwork-ui 2.11.0-dev.e430b2fe8 → 2.11.0-dev.f5ee66b24
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 +782 -356
- package/fesm2022/geonetwork-ui.mjs.map +1 -1
- package/index.d.ts +199 -76
- package/index.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts +107 -34
- package/src/libs/common/domain/src/lib/model/search/filter.model.ts +20 -1
- package/src/libs/feature/map/src/index.ts +0 -1
- package/src/libs/feature/map/src/lib/add-layer-from-file/add-layer-from-file.component.html +1 -0
- package/src/libs/feature/map/src/lib/feature-map.module.ts +1 -8
- package/src/libs/feature/notifications/src/lib/notifications.service.ts +6 -4
- package/src/libs/feature/router/src/lib/default/state/query-params.utils.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 +12 -4
- package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.ts +58 -19
- package/src/libs/feature/{map/src/lib → search/src/lib/geocoding}/geocoding.service.ts +5 -1
- package/src/libs/feature/search/src/lib/location-search/location-search.component.html +8 -0
- package/src/libs/feature/search/src/lib/location-search/location-search.component.ts +40 -0
- package/src/libs/feature/search/src/lib/search-filters-summary-item/search-filters-summary-item.component.ts +18 -8
- package/src/libs/feature/search/src/lib/utils/service/fields.service.ts +9 -1
- package/src/libs/feature/search/src/lib/utils/service/fields.ts +61 -2
- package/src/libs/ui/elements/src/lib/service-capabilities/service-capabilities.component.ts +2 -1
- package/src/libs/ui/inputs/src/index.ts +2 -0
- package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.html +10 -1
- package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.ts +8 -0
- package/src/libs/ui/inputs/src/lib/date-adapter.providers.ts +30 -0
- package/src/libs/ui/inputs/src/lib/date-picker/date-picker.component.ts +3 -24
- package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.css +37 -3
- package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.html +135 -16
- package/src/libs/ui/inputs/src/lib/date-range-dropdown/date-range-dropdown.component.ts +166 -29
- package/src/libs/ui/inputs/src/lib/date-range-picker/date-range-picker.component.ts +3 -7
- package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.css +1 -0
- package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.html +20 -7
- package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.ts +46 -5
- 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/spatial-extent-dropdown/spatial-extent-dropdown.component.html +111 -0
- package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.ts +215 -0
- package/src/libs/ui/map/src/lib/components/map-container/map-container.component.ts +2 -0
- package/src/libs/util/app-config/src/lib/app-config.ts +3 -0
- package/src/libs/util/app-config/src/lib/model.ts +1 -0
- package/src/libs/util/shared/src/index.ts +1 -0
- package/src/libs/util/shared/src/lib/autofocus.directive.ts +26 -0
- package/src/libs/util/shared/src/lib/links/link-utils.ts +19 -10
- package/src/libs/util/shared/src/lib/services/date.service.ts +3 -3
- package/src/libs/util/shared/src/lib/utils/file.ts +15 -0
- package/src/libs/util/shared/src/lib/utils/geojson.ts +8 -0
- package/src/libs/util/shared/src/lib/utils/index.ts +1 -0
- package/tailwind.base.css +5 -0
- package/translations/de.json +16 -3
- package/translations/en.json +15 -2
- package/translations/es.json +14 -1
- package/translations/fr.json +16 -3
- package/translations/it.json +14 -1
- package/translations/nl.json +14 -1
- package/translations/pt.json +14 -1
- package/translations/sk.json +14 -1
- 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/geocoding.component.css → ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.css} +0 -0
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
Input,
|
|
6
6
|
Output,
|
|
7
7
|
} from '@angular/core'
|
|
8
|
-
import { MatNativeDateModule } from '@angular/material/core'
|
|
9
8
|
import { MatDatepickerModule } from '@angular/material/datepicker'
|
|
10
9
|
import { ButtonComponent } from '../button/button.component'
|
|
11
10
|
import {
|
|
@@ -14,6 +13,7 @@ import {
|
|
|
14
13
|
provideNgIconsConfig,
|
|
15
14
|
} from '@ng-icons/core'
|
|
16
15
|
import { iconoirCalendar } from '@ng-icons/iconoir'
|
|
16
|
+
import { provideLocalizedDateAdapter } from '../date-adapter.providers'
|
|
17
17
|
|
|
18
18
|
@Component({
|
|
19
19
|
selector: 'gn-ui-date-range-picker',
|
|
@@ -21,17 +21,13 @@ import { iconoirCalendar } from '@ng-icons/iconoir'
|
|
|
21
21
|
styleUrls: ['./date-range-picker.component.css'],
|
|
22
22
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
23
23
|
standalone: true,
|
|
24
|
-
imports: [
|
|
25
|
-
MatNativeDateModule,
|
|
26
|
-
MatDatepickerModule,
|
|
27
|
-
ButtonComponent,
|
|
28
|
-
NgIconComponent,
|
|
29
|
-
],
|
|
24
|
+
imports: [MatDatepickerModule, ButtonComponent, NgIconComponent],
|
|
30
25
|
providers: [
|
|
31
26
|
provideIcons({ iconoirCalendar }),
|
|
32
27
|
provideNgIconsConfig({
|
|
33
28
|
size: '1.5rem',
|
|
34
29
|
}),
|
|
30
|
+
provideLocalizedDateAdapter(),
|
|
35
31
|
],
|
|
36
32
|
})
|
|
37
33
|
export class DateRangePickerComponent {
|
package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.html
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
-
<div
|
|
1
|
+
<div
|
|
2
|
+
class="flex h-full items-center"
|
|
3
|
+
[class]="extraClass"
|
|
4
|
+
(click)="openFileSelector()"
|
|
5
|
+
>
|
|
2
6
|
<ngx-dropzone
|
|
3
|
-
class="flex-1"
|
|
7
|
+
class="flex-1 overflow-hidden"
|
|
4
8
|
[multiple]="false"
|
|
5
|
-
|
|
9
|
+
[disableClick]="true"
|
|
6
10
|
[accept]="accept"
|
|
11
|
+
[maxFileSize]="maxFileSizeBytes"
|
|
12
|
+
[style.background-color]="dropzoneBackgroundColor"
|
|
13
|
+
(change)="selectFile($event)"
|
|
7
14
|
>
|
|
8
|
-
@if (!fileName) {
|
|
9
|
-
<div class="
|
|
15
|
+
@if (!fileName || !showFileName) {
|
|
16
|
+
<div [class]="textClass">
|
|
10
17
|
{{ placeholder }}
|
|
11
18
|
</div>
|
|
12
19
|
}
|
|
13
20
|
|
|
14
|
-
@if (fileName) {
|
|
15
|
-
<div class="
|
|
21
|
+
@if (fileName && showFileName) {
|
|
22
|
+
<div [class]="textClass">
|
|
23
|
+
{{ fileName }}
|
|
24
|
+
</div>
|
|
16
25
|
}
|
|
17
26
|
</ngx-dropzone>
|
|
27
|
+
|
|
28
|
+
@if (icon) {
|
|
29
|
+
<ng-icon [name]="icon" class="shrink-0 text-gray-950"></ng-icon>
|
|
30
|
+
}
|
|
18
31
|
</div>
|
package/src/libs/ui/inputs/src/lib/drag-and-drop-file-input/drag-and-drop-file-input.component.ts
CHANGED
|
@@ -1,30 +1,71 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
EventEmitter,
|
|
4
|
+
Input,
|
|
5
|
+
Output,
|
|
6
|
+
ViewChild,
|
|
7
|
+
} from '@angular/core'
|
|
2
8
|
import { marker } from '@biesbjerg/ngx-translate-extract-marker'
|
|
3
|
-
import { NgxDropzoneModule } from 'ngx-dropzone'
|
|
9
|
+
import { NgxDropzoneComponent, NgxDropzoneModule } from 'ngx-dropzone'
|
|
10
|
+
import { NgIcon } from '@ng-icons/core'
|
|
11
|
+
import { megabytesToBytes } from '../../../../../../libs/util/shared/src'
|
|
4
12
|
|
|
5
13
|
export const placeholder = 'dropFile'
|
|
6
14
|
marker('dropFile')
|
|
7
15
|
|
|
16
|
+
export type DragAndDropFileInputError = 'invalid-extension' | 'file-too-large'
|
|
17
|
+
|
|
8
18
|
@Component({
|
|
9
19
|
selector: 'gn-ui-drag-and-drop-file-input',
|
|
10
20
|
templateUrl: './drag-and-drop-file-input.component.html',
|
|
11
21
|
styleUrls: ['./drag-and-drop-file-input.component.css'],
|
|
12
22
|
standalone: true,
|
|
13
|
-
imports: [NgxDropzoneModule],
|
|
23
|
+
imports: [NgxDropzoneModule, NgIcon],
|
|
14
24
|
})
|
|
15
25
|
export class DragAndDropFileInputComponent {
|
|
16
26
|
@Input() placeholder = placeholder
|
|
17
27
|
@Input() accept = '*'
|
|
18
|
-
@
|
|
28
|
+
@Input() maxFileSizeMb: number | null = null
|
|
29
|
+
@Input() icon: string | null = null
|
|
30
|
+
@Input() dropzoneBackgroundColor: string | null = null
|
|
31
|
+
@Input() textClass = ''
|
|
32
|
+
@Input() extraClass = ''
|
|
33
|
+
@Input() showFileName = true
|
|
34
|
+
|
|
35
|
+
@Output() fileChange = new EventEmitter<File>()
|
|
36
|
+
@Output() errorChange = new EventEmitter<DragAndDropFileInputError>()
|
|
37
|
+
|
|
19
38
|
selectedFile: File = null
|
|
20
39
|
|
|
40
|
+
@ViewChild(NgxDropzoneComponent) private dropzone: NgxDropzoneComponent
|
|
41
|
+
|
|
21
42
|
get fileName(): string | null {
|
|
22
43
|
return this.selectedFile && this.selectedFile.name
|
|
23
44
|
}
|
|
24
45
|
|
|
46
|
+
get maxFileSizeBytes(): number | null {
|
|
47
|
+
return typeof this.maxFileSizeMb === 'number'
|
|
48
|
+
? megabytesToBytes(this.maxFileSizeMb)
|
|
49
|
+
: null
|
|
50
|
+
}
|
|
51
|
+
|
|
25
52
|
selectFile(event) {
|
|
53
|
+
if (event.rejectedFiles?.length) {
|
|
54
|
+
const reason = event.rejectedFiles[0].reason
|
|
55
|
+
this.errorChange.emit(
|
|
56
|
+
reason === 'size' ? 'file-too-large' : 'invalid-extension'
|
|
57
|
+
)
|
|
58
|
+
return
|
|
59
|
+
}
|
|
26
60
|
this.selectedFile = event.addedFiles[0]
|
|
27
|
-
|
|
28
61
|
this.fileChange.emit(this.selectedFile)
|
|
29
62
|
}
|
|
63
|
+
|
|
64
|
+
openFileSelector() {
|
|
65
|
+
this.dropzone.showFileSelector()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
clear() {
|
|
69
|
+
this.selectedFile = null
|
|
70
|
+
}
|
|
30
71
|
}
|
|
@@ -20,10 +20,13 @@
|
|
|
20
20
|
</div>
|
|
21
21
|
}
|
|
22
22
|
</div>
|
|
23
|
-
<button
|
|
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
|
|
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-
|
|
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
|
|
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:
|
|
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<
|
|
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
|
|
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
|
|
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
|
|
package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.html
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<gn-ui-button
|
|
2
|
+
type="outline"
|
|
3
|
+
extraClass="bg-background w-full !p-[8px] !pl-[16px]"
|
|
4
|
+
[title]="title"
|
|
5
|
+
(buttonClick)="toggleOverlay()"
|
|
6
|
+
cdkOverlayOrigin
|
|
7
|
+
#overlayOrigin="cdkOverlayOrigin"
|
|
8
|
+
>
|
|
9
|
+
<div class="grow flex items-center mr-2 gap-2 overflow-hidden">
|
|
10
|
+
<div class="text-left font-medium truncate py-1">
|
|
11
|
+
{{ title }}
|
|
12
|
+
</div>
|
|
13
|
+
@if (hasSelection) {
|
|
14
|
+
<div
|
|
15
|
+
class="bg-primary-lighter text-white shrink-0 rounded-full font-bold text-[12px] w-[22px] h-[22px] flex items-center justify-center"
|
|
16
|
+
>
|
|
17
|
+
1
|
|
18
|
+
</div>
|
|
19
|
+
}
|
|
20
|
+
</div>
|
|
21
|
+
<button class="h-6 w-6 flex items-center" data-cy="clearSelection">
|
|
22
|
+
@if (hasSelection && !overlayOpen) {
|
|
23
|
+
<ng-icon
|
|
24
|
+
class="shrink-0 opacity-40 mr-1.5 hover:opacity-80 transition-colors clear-btn"
|
|
25
|
+
(click)="removeSelection($event)"
|
|
26
|
+
name="matClose"
|
|
27
|
+
></ng-icon>
|
|
28
|
+
}
|
|
29
|
+
</button>
|
|
30
|
+
<ng-icon
|
|
31
|
+
[name]="overlayOpen ? 'matExpandLess' : 'matExpandMore'"
|
|
32
|
+
class="shrink-0 opacity-40"
|
|
33
|
+
>
|
|
34
|
+
</ng-icon>
|
|
35
|
+
</gn-ui-button>
|
|
36
|
+
|
|
37
|
+
<ng-template
|
|
38
|
+
cdkConnectedOverlay
|
|
39
|
+
cdkConnectedOverlayHasBackdrop
|
|
40
|
+
cdkConnectedOverlayBackdropClass="cdk-overlay-transparent-backdrop"
|
|
41
|
+
[cdkConnectedOverlayOrigin]="overlayOrigin"
|
|
42
|
+
[cdkConnectedOverlayOpen]="overlayOpen"
|
|
43
|
+
[cdkConnectedOverlayPositions]="overlayPositions"
|
|
44
|
+
[cdkConnectedOverlayScrollStrategy]="scrollStrategy"
|
|
45
|
+
[cdkConnectedOverlayFlexibleDimensions]="true"
|
|
46
|
+
(overlayOutsideClick)="closeOverlay()"
|
|
47
|
+
(detach)="closeOverlay()"
|
|
48
|
+
>
|
|
49
|
+
<div
|
|
50
|
+
class="bg-white border border-gray-400 rounded shadow-lg pt-[12px] px-[16px] overlay-container w-[280px] flex flex-col gap-2"
|
|
51
|
+
[style.min-width]="overlayMinWidth"
|
|
52
|
+
>
|
|
53
|
+
<div class="text-xs text-black">
|
|
54
|
+
{{ 'search.filters.spatialExtent.helpText' | translate }}
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<div
|
|
58
|
+
[class]="
|
|
59
|
+
(hasSelection
|
|
60
|
+
? 'border-b-[1px] border-gray-400 pb-[20px]'
|
|
61
|
+
: 'pb-[8px]') + ' text-black'
|
|
62
|
+
"
|
|
63
|
+
>
|
|
64
|
+
<gn-ui-drag-and-drop-file-input
|
|
65
|
+
accept=".json,.geojson"
|
|
66
|
+
[placeholder]="'search.filters.spatialExtent.import' | translate"
|
|
67
|
+
[maxFileSizeMb]="maxFileSizeMb"
|
|
68
|
+
[showFileName]="false"
|
|
69
|
+
textClass="text-black truncate"
|
|
70
|
+
dropzoneBackgroundColor="transparent"
|
|
71
|
+
icon="iconoirImport"
|
|
72
|
+
extraClass="gn-ui-gray-outline-input w-full !h-[32px] px-[8px] py-[4px] justify-between"
|
|
73
|
+
(fileChange)="handleFileSelected($event)"
|
|
74
|
+
(errorChange)="handleFileError($event)"
|
|
75
|
+
data-cy="importGeojson"
|
|
76
|
+
></gn-ui-drag-and-drop-file-input>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
@if (hasSelection) {
|
|
80
|
+
<gn-ui-button
|
|
81
|
+
[type]="'primary-light'"
|
|
82
|
+
[title]="selectionDeleteLabelKey | translate: selectionLabelParams"
|
|
83
|
+
(buttonClick)="removeSelection($event)"
|
|
84
|
+
extraClass="group gap-x-2 w-full h-[28px] px-[8px] py-[4px] mb-[12px] bg-primary-lighter text-white"
|
|
85
|
+
data-test="spatial-extent-selected-item"
|
|
86
|
+
>
|
|
87
|
+
<ng-icon
|
|
88
|
+
name="iconoirSquareDashed"
|
|
89
|
+
class="shrink-0"
|
|
90
|
+
size="15px"
|
|
91
|
+
></ng-icon>
|
|
92
|
+
<span class="group-hover:hidden truncate text-sm m-auto">
|
|
93
|
+
{{ selectionLabelKey | translate: selectionLabelParams }}
|
|
94
|
+
</span>
|
|
95
|
+
<span class="hidden group-hover:block truncate text-sm m-auto">
|
|
96
|
+
{{ selectionDeleteLabelKey | translate: selectionLabelParams }}
|
|
97
|
+
</span>
|
|
98
|
+
<ng-icon
|
|
99
|
+
name="iconoirCheckCircle"
|
|
100
|
+
class="group-hover:hidden shrink-0"
|
|
101
|
+
size="14px"
|
|
102
|
+
></ng-icon>
|
|
103
|
+
<ng-icon
|
|
104
|
+
name="iconoirTrash"
|
|
105
|
+
class="!hidden group-hover:!block shrink-0"
|
|
106
|
+
size="15px"
|
|
107
|
+
></ng-icon>
|
|
108
|
+
</gn-ui-button>
|
|
109
|
+
}
|
|
110
|
+
</div>
|
|
111
|
+
</ng-template>
|
package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.ts
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
ChangeDetectorRef,
|
|
4
|
+
Component,
|
|
5
|
+
EventEmitter,
|
|
6
|
+
Input,
|
|
7
|
+
Output,
|
|
8
|
+
ViewChild,
|
|
9
|
+
inject,
|
|
10
|
+
} from '@angular/core'
|
|
11
|
+
import {
|
|
12
|
+
CdkConnectedOverlay,
|
|
13
|
+
CdkOverlayOrigin,
|
|
14
|
+
ConnectedPosition,
|
|
15
|
+
OverlayModule,
|
|
16
|
+
ScrollStrategyOptions,
|
|
17
|
+
} from '@angular/cdk/overlay'
|
|
18
|
+
|
|
19
|
+
import { ButtonComponent } from '../button/button.component'
|
|
20
|
+
import { NgIcon, provideIcons } from '@ng-icons/core'
|
|
21
|
+
import {
|
|
22
|
+
iconoirCheckCircle,
|
|
23
|
+
iconoirImport,
|
|
24
|
+
iconoirSquareDashed,
|
|
25
|
+
iconoirTrash,
|
|
26
|
+
} from '@ng-icons/iconoir'
|
|
27
|
+
import {
|
|
28
|
+
matClose,
|
|
29
|
+
matExpandLess,
|
|
30
|
+
matExpandMore,
|
|
31
|
+
} from '@ng-icons/material-icons/baseline'
|
|
32
|
+
import { TranslatePipe } from '@ngx-translate/core'
|
|
33
|
+
import { marker } from '@biesbjerg/ngx-translate-extract-marker'
|
|
34
|
+
import {
|
|
35
|
+
BoundingBox,
|
|
36
|
+
getGeometryBoundingBox,
|
|
37
|
+
getGeometryFromGeoJSON,
|
|
38
|
+
propagateToDocumentOnly,
|
|
39
|
+
readFileAsText,
|
|
40
|
+
} from '../../../../../../libs/util/shared/src'
|
|
41
|
+
import {
|
|
42
|
+
DragAndDropFileInputComponent,
|
|
43
|
+
DragAndDropFileInputError,
|
|
44
|
+
} from '../drag-and-drop-file-input/drag-and-drop-file-input.component'
|
|
45
|
+
|
|
46
|
+
marker('search.filters.spatialExtent.import')
|
|
47
|
+
marker('search.filters.spatialExtent.helpText')
|
|
48
|
+
marker('search.filters.spatialExtent.error.title')
|
|
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
|
+
)
|
|
58
|
+
|
|
59
|
+
export interface SpatialExtentDropdownError {
|
|
60
|
+
key: string
|
|
61
|
+
params?: Record<string, string | number>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Component({
|
|
65
|
+
selector: 'gn-ui-spatial-extent-dropdown',
|
|
66
|
+
standalone: true,
|
|
67
|
+
imports: [
|
|
68
|
+
ButtonComponent,
|
|
69
|
+
NgIcon,
|
|
70
|
+
OverlayModule,
|
|
71
|
+
TranslatePipe,
|
|
72
|
+
DragAndDropFileInputComponent,
|
|
73
|
+
],
|
|
74
|
+
providers: [
|
|
75
|
+
provideIcons({
|
|
76
|
+
iconoirCheckCircle,
|
|
77
|
+
iconoirImport,
|
|
78
|
+
iconoirSquareDashed,
|
|
79
|
+
iconoirTrash,
|
|
80
|
+
matClose,
|
|
81
|
+
matExpandLess,
|
|
82
|
+
matExpandMore,
|
|
83
|
+
}),
|
|
84
|
+
],
|
|
85
|
+
templateUrl: './spatial-extent-dropdown.component.html',
|
|
86
|
+
styleUrls: ['./spatial-extent-dropdown.component.css'],
|
|
87
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
88
|
+
})
|
|
89
|
+
export class SpatialExtentDropdownComponent {
|
|
90
|
+
private cd = inject(ChangeDetectorRef)
|
|
91
|
+
private scrollStrategies = inject(ScrollStrategyOptions)
|
|
92
|
+
|
|
93
|
+
@Input() title: string
|
|
94
|
+
@Input() maxFileSizeMb: number | null = null
|
|
95
|
+
@Input() set initialBbox(value: BoundingBox | null) {
|
|
96
|
+
if (!this.bbox && value) {
|
|
97
|
+
this.bbox = value
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@Output() bboxChange = new EventEmitter<BoundingBox | null>()
|
|
102
|
+
@Output() errorChange = new EventEmitter<SpatialExtentDropdownError>()
|
|
103
|
+
|
|
104
|
+
bbox: BoundingBox | null = null
|
|
105
|
+
fileName = ''
|
|
106
|
+
|
|
107
|
+
@ViewChild('overlayOrigin') overlayOrigin: CdkOverlayOrigin
|
|
108
|
+
@ViewChild(CdkConnectedOverlay) overlay: CdkConnectedOverlay
|
|
109
|
+
@ViewChild(DragAndDropFileInputComponent)
|
|
110
|
+
fileInput: DragAndDropFileInputComponent
|
|
111
|
+
|
|
112
|
+
overlayPositions: ConnectedPosition[] = [
|
|
113
|
+
{
|
|
114
|
+
originX: 'start',
|
|
115
|
+
originY: 'bottom',
|
|
116
|
+
overlayX: 'start',
|
|
117
|
+
overlayY: 'top',
|
|
118
|
+
offsetY: 8,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
originX: 'start',
|
|
122
|
+
originY: 'top',
|
|
123
|
+
overlayX: 'start',
|
|
124
|
+
overlayY: 'bottom',
|
|
125
|
+
offsetY: -8,
|
|
126
|
+
},
|
|
127
|
+
]
|
|
128
|
+
scrollStrategy = this.scrollStrategies.reposition()
|
|
129
|
+
overlayOpen = false
|
|
130
|
+
overlayMinWidth = 'none'
|
|
131
|
+
|
|
132
|
+
errorKey: string | null = null
|
|
133
|
+
|
|
134
|
+
get hasSelection() {
|
|
135
|
+
return !!this.bbox
|
|
136
|
+
}
|
|
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
|
+
|
|
150
|
+
openOverlay() {
|
|
151
|
+
this.overlayMinWidth =
|
|
152
|
+
this.overlayOrigin.elementRef.nativeElement.getBoundingClientRect()
|
|
153
|
+
.width + 'px'
|
|
154
|
+
this.overlayOpen = true
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
closeOverlay() {
|
|
158
|
+
this.overlayOpen = false
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
toggleOverlay() {
|
|
162
|
+
if (this.overlayOpen) {
|
|
163
|
+
this.closeOverlay()
|
|
164
|
+
} else {
|
|
165
|
+
this.openOverlay()
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
async handleFileSelected(file: File) {
|
|
170
|
+
this.errorKey = null
|
|
171
|
+
let content: string
|
|
172
|
+
try {
|
|
173
|
+
content = await readFileAsText(file)
|
|
174
|
+
const parsed = JSON.parse(content)
|
|
175
|
+
const geometry = getGeometryFromGeoJSON(parsed)
|
|
176
|
+
if (!geometry) {
|
|
177
|
+
this.setError(marker('search.filters.spatialExtent.error.noGeometry'))
|
|
178
|
+
return
|
|
179
|
+
}
|
|
180
|
+
const bbox = getGeometryBoundingBox(geometry)
|
|
181
|
+
this.bbox = bbox
|
|
182
|
+
this.fileName = file.name
|
|
183
|
+
this.bboxChange.emit(bbox)
|
|
184
|
+
this.cd.markForCheck()
|
|
185
|
+
} catch {
|
|
186
|
+
this.setError(marker('search.filters.spatialExtent.error.invalidFormat'))
|
|
187
|
+
return
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
handleFileError(error: DragAndDropFileInputError) {
|
|
192
|
+
if (error === 'file-too-large') {
|
|
193
|
+
this.setError(marker('search.filters.spatialExtent.error.fileTooLarge'), {
|
|
194
|
+
maxSize: this.maxFileSizeMb,
|
|
195
|
+
})
|
|
196
|
+
} else {
|
|
197
|
+
this.setError(marker('search.filters.spatialExtent.error.invalidFormat'))
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
private setError(errorKey: string, params?: Record<string, string | number>) {
|
|
202
|
+
this.errorKey = errorKey
|
|
203
|
+
this.errorChange.emit({ key: errorKey, params })
|
|
204
|
+
this.cd.markForCheck()
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
removeSelection(event: Event) {
|
|
208
|
+
this.bbox = null
|
|
209
|
+
this.fileName = ''
|
|
210
|
+
this.errorKey = null
|
|
211
|
+
this.fileInput?.clear()
|
|
212
|
+
this.bboxChange.emit(null)
|
|
213
|
+
propagateToDocumentOnly(event)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -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 = {
|
|
@@ -252,6 +252,7 @@ export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
|
|
|
252
252
|
'search_preset',
|
|
253
253
|
'advanced_filters',
|
|
254
254
|
'limit',
|
|
255
|
+
'spatial_extent_max_file_size',
|
|
255
256
|
],
|
|
256
257
|
warnings,
|
|
257
258
|
errors
|
|
@@ -281,6 +282,8 @@ export function loadAppConfig(configUrl = 'assets/configuration/default.toml') {
|
|
|
281
282
|
})),
|
|
282
283
|
ADVANCED_FILTERS: parsedSearchSection.advanced_filters,
|
|
283
284
|
LIMIT: parsedSearchSection.limit,
|
|
285
|
+
SPATIAL_EXTENT_MAX_FILE_SIZE:
|
|
286
|
+
parsedSearchSection.spatial_extent_max_file_size,
|
|
284
287
|
} as SearchConfig)
|
|
285
288
|
|
|
286
289
|
const parsedMetadataQualitySection = parseConfigSection(
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Directive,
|
|
3
|
+
ElementRef,
|
|
4
|
+
Injector,
|
|
5
|
+
Input,
|
|
6
|
+
afterNextRender,
|
|
7
|
+
booleanAttribute,
|
|
8
|
+
inject,
|
|
9
|
+
} from '@angular/core'
|
|
10
|
+
|
|
11
|
+
@Directive({
|
|
12
|
+
selector: '[gnUiAutofocus]',
|
|
13
|
+
standalone: true,
|
|
14
|
+
})
|
|
15
|
+
export class AutofocusDirective {
|
|
16
|
+
private el = inject<ElementRef<HTMLElement>>(ElementRef)
|
|
17
|
+
private injector = inject(Injector)
|
|
18
|
+
|
|
19
|
+
@Input({ alias: 'gnUiAutofocus', transform: booleanAttribute })
|
|
20
|
+
set autofocus(active: boolean) {
|
|
21
|
+
if (!active) return
|
|
22
|
+
afterNextRender(() => this.el.nativeElement.focus(), {
|
|
23
|
+
injector: this.injector,
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}
|