geonetwork-ui 2.9.0 → 2.10.0-dev.0d4a494fa

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.
@@ -3,7 +3,7 @@ import {
3
3
  HttpErrorResponse,
4
4
  HttpHeaders,
5
5
  } from '@angular/common/http'
6
- import { Injectable, inject } from '@angular/core'
6
+ import { Injectable, InjectionToken, inject } from '@angular/core'
7
7
  import {
8
8
  assertValidXml,
9
9
  findConverterForDocument,
@@ -57,6 +57,10 @@ const TEMPORARY_ID_PREFIX = 'TEMP-ID-'
57
57
 
58
58
  export type RecordAsXml = string
59
59
 
60
+ export const DISABLE_DRAFT = new InjectionToken<boolean>('gnDisableDraft', {
61
+ factory: () => false,
62
+ })
63
+
60
64
  @Injectable()
61
65
  export class Gn4Repository implements RecordsRepositoryInterface {
62
66
  private httpClient = inject(HttpClient)
@@ -67,6 +71,7 @@ export class Gn4Repository implements RecordsRepositoryInterface {
67
71
  private platformService = inject(PlatformServiceInterface)
68
72
  private gn4LanguagesApi = inject(LanguagesApiService)
69
73
  private settingsService = inject(Gn4SettingsService)
74
+ private disableDraft = inject(DISABLE_DRAFT, { optional: true }) ?? false
70
75
 
71
76
  _draftsChanged = new Subject<void>()
72
77
  draftsChanged$ = this._draftsChanged.asObservable()
@@ -350,7 +355,9 @@ export class Gn4Repository implements RecordsRepositoryInterface {
350
355
  openRecordForEdition(
351
356
  uniqueIdentifier: string
352
357
  ): Observable<[CatalogRecord, string, boolean] | null> {
353
- const draft$ = of(this.getRecordFromLocalStorage(uniqueIdentifier))
358
+ const draft$ = this.disableDraft
359
+ ? of(null)
360
+ : of(this.getRecordFromLocalStorage(uniqueIdentifier))
354
361
  const recordAsXml$ = this.getRecordAsXml(uniqueIdentifier)
355
362
 
356
363
  return combineLatest([draft$, recordAsXml$]).pipe(
@@ -475,6 +482,7 @@ export class Gn4Repository implements RecordsRepositoryInterface {
475
482
  record: CatalogRecord,
476
483
  referenceRecordSource?: string
477
484
  ): Observable<string> {
485
+ if (this.disableDraft) return of('')
478
486
  return this.serializeRecordToXml(record, referenceRecordSource).pipe(
479
487
  tap((recordXml) => {
480
488
  this.saveRecordToLocalStorage(recordXml, record.uniqueIdentifier)
@@ -484,16 +492,19 @@ export class Gn4Repository implements RecordsRepositoryInterface {
484
492
  }
485
493
 
486
494
  clearRecordDraft(uniqueIdentifier: string): void {
495
+ if (this.disableDraft) return
487
496
  this.removeRecordFromLocalStorage(uniqueIdentifier)
488
497
  this._draftsChanged.next()
489
498
  }
490
499
 
491
500
  recordHasDraft(uniqueIdentifier: string): boolean {
501
+ if (this.disableDraft) return false
492
502
  return this.getRecordFromLocalStorage(uniqueIdentifier) !== null
493
503
  }
494
504
 
495
505
  // generated by copilot
496
506
  getAllDrafts(): Observable<CatalogRecord[]> {
507
+ if (this.disableDraft) return of([])
497
508
  const items = { ...window.localStorage }
498
509
  const drafts = Object.keys(items)
499
510
  .filter((key) => key.startsWith('geonetwork-ui-draft-'))
@@ -509,6 +520,7 @@ export class Gn4Repository implements RecordsRepositoryInterface {
509
520
  }
510
521
 
511
522
  getDraftsCount(): Observable<number> {
523
+ if (this.disableDraft) return of(0)
512
524
  const items = { ...window.localStorage }
513
525
  const draftCount = Object.keys(items)
514
526
  .filter((key) => key.startsWith('geonetwork-ui-draft-'))
@@ -6,7 +6,7 @@ import {
6
6
  } from './platform/gn4-platform.service'
7
7
  import { Gn4PlatformMapper } from './platform/gn4-platform.mapper'
8
8
  import { RecordsRepositoryInterface } from '../../../../../../libs/common/domain/src/lib/repository/records-repository.interface'
9
- import { Gn4Repository } from './gn4-repository'
9
+ import { Gn4Repository, DISABLE_DRAFT } from './gn4-repository'
10
10
  import { AvatarServiceInterface, GravatarService } from './auth'
11
11
  import { OrganizationsServiceInterface } from '../../../../../../libs/common/domain/src/lib/organizations.service.interface'
12
12
  import {
@@ -22,6 +22,7 @@ import { TranslateService } from '@ngx-translate/core'
22
22
 
23
23
  interface Gn4ProvideOptions {
24
24
  disableAuth?: boolean
25
+ disableDraft?: boolean
25
26
  }
26
27
 
27
28
  export function provideGn4(provideOptions?: Gn4ProvideOptions): Provider[] {
@@ -30,6 +31,10 @@ export function provideGn4(provideOptions?: Gn4ProvideOptions): Provider[] {
30
31
  provide: DISABLE_AUTH,
31
32
  useValue: provideOptions?.disableAuth,
32
33
  },
34
+ {
35
+ provide: DISABLE_DRAFT,
36
+ useValue: provideOptions?.disableDraft,
37
+ },
33
38
  {
34
39
  provide: PlatformServiceInterface,
35
40
  useClass: Gn4PlatformService,
@@ -2,3 +2,4 @@ export * from './lib/model/index'
2
2
  export * from './lib/organizations.service.interface'
3
3
  export * from './lib/platform.service.interface'
4
4
  export * from './lib/repository/records-repository.interface'
5
+ export * from './lib/model/record/metadata.model'
@@ -8,6 +8,8 @@ export * from './lib/components/metadata-quality-panel/metadata-quality-panel.co
8
8
  export * from './lib/components/multilingual-panel/multilingual-panel.component'
9
9
  export * from './lib/components/record-form/form-field'
10
10
  export * from './lib/components/record-form/record-form.component'
11
+ export * from './lib/components/online-service-resource-input/online-service-resource-input.component'
12
+ export * from './lib/components/online-resource-card/online-resource-card.component'
11
13
  export * from './lib/feature-editor.module'
12
14
  export * from './lib/fields.config'
13
15
  export * from './lib/services/editor.service'
@@ -12,7 +12,6 @@ import {
12
12
  } from './editor.selectors'
13
13
  import { RecordsRepositoryInterface } from '../../../../../../libs/common/domain/src/lib/repository/records-repository.interface'
14
14
  import { PlatformServiceInterface } from '../../../../../../libs/common/domain/src/lib/platform.service.interface'
15
-
16
15
  @Injectable()
17
16
  export class EditorEffects {
18
17
  private actions$ = inject(Actions)
@@ -20,7 +20,7 @@
20
20
  [disabled]="disabled"
21
21
  (change)="resetAllFormFields()"
22
22
  >
23
- @for (protocolOption of protocolOptions; track protocolOption) {
23
+ @for (protocolOption of availableProtocolOptions; track protocolOption) {
24
24
  <mat-radio-button [value]="protocolOption.value">
25
25
  {{ protocolOption.label | translate }}
26
26
  </mat-radio-button>
@@ -45,6 +45,11 @@
45
45
  }
46
46
  </gn-ui-url-input>
47
47
 
48
+ @if (loading) {
49
+ <div class="flex justify-center w-full py-4">
50
+ <gn-ui-spinning-loader></gn-ui-spinning-loader>
51
+ </div>
52
+ }
48
53
  @if (errorMessage) {
49
54
  <p class="text-sm text-red-500 pl-4" translate>
50
55
  editor.record.form.field.onlineResource.edit.identifier.error
@@ -22,6 +22,7 @@ import {
22
22
  TextInputComponent,
23
23
  UrlInputComponent,
24
24
  } from '../../../../../../../libs/ui/inputs/src'
25
+ import { SpinningLoaderComponent } from '../../../../../../../libs/ui/widgets/src'
25
26
  import { createFuzzyFilter, getLayers } from '../../../../../../../libs/util/shared/src'
26
27
  import {
27
28
  NgIconComponent,
@@ -57,6 +58,7 @@ marker(
57
58
  MatTooltipModule,
58
59
  MatRadioModule,
59
60
  NgIconComponent,
61
+ SpinningLoaderComponent,
60
62
  TextInputComponent,
61
63
  TranslateDirective,
62
64
  TranslatePipe,
@@ -79,17 +81,19 @@ export class OnlineServiceResourceInputComponent {
79
81
  @Input() protocolHint?: string
80
82
  @Input() disabled? = false
81
83
  @Input() modifyMode? = false
84
+ @Input() protocolOptions?: ServiceProtocol[]
82
85
  @Output() serviceChange: EventEmitter<DatasetServiceDistribution> =
83
86
  new EventEmitter()
84
87
 
85
88
  errorMessage = false
89
+ loading = false
86
90
  resetUrlOnChange = Math.random()
87
91
 
88
92
  layersSubject = new BehaviorSubject<{ name?: string; title?: string }[]>([])
89
93
  layers$: Observable<{ name?: string; title?: string }[]> =
90
94
  this.layersSubject.asObservable()
91
95
 
92
- protocolOptions: {
96
+ allProtocolOptions: {
93
97
  label: string
94
98
  value: ServiceProtocol
95
99
  }[] = [
@@ -123,6 +127,13 @@ export class OnlineServiceResourceInputComponent {
123
127
  },
124
128
  ]
125
129
 
130
+ get availableProtocolOptions() {
131
+ if (!this.protocolOptions) return this.allProtocolOptions
132
+ return this.protocolOptions.flatMap(
133
+ (v) => this.allProtocolOptions.find((o) => o.value === v) ?? []
134
+ )
135
+ }
136
+
126
137
  get activeLayerSuggestion() {
127
138
  return !['wps', 'GPFDL', 'esriRest', 'other'].includes(
128
139
  this._service.accessServiceProtocol
@@ -135,6 +146,8 @@ export class OnlineServiceResourceInputComponent {
135
146
  }
136
147
 
137
148
  async handleUploadClick(url: string) {
149
+ this.loading = true
150
+ this.cdr.detectChanges()
138
151
  try {
139
152
  const layers = await getLayers(url, this._service.accessServiceProtocol)
140
153
 
@@ -148,6 +161,7 @@ export class OnlineServiceResourceInputComponent {
148
161
  this.layersSubject.next([])
149
162
  }
150
163
 
164
+ this.loading = false
151
165
  this.cdr.detectChanges()
152
166
  }
153
167
 
@@ -159,6 +173,7 @@ export class OnlineServiceResourceInputComponent {
159
173
 
160
174
  resetLayersSuggestion() {
161
175
  this.errorMessage = false
176
+ this.loading = false
162
177
  this.layersSubject.next([])
163
178
  this._service.identifierInService = null
164
179
  }
@@ -62,7 +62,10 @@ export class UrlInputComponent implements OnChanges {
62
62
  inputValue = ''
63
63
 
64
64
  ngOnChanges(changes: SimpleChanges) {
65
- if (changes['resetUrlOnChange']) {
65
+ if (
66
+ changes['resetUrlOnChange'] &&
67
+ !changes['resetUrlOnChange'].firstChange
68
+ ) {
66
69
  this.inputValue = ''
67
70
  }
68
71
  }