diff --git a/conf/default.toml b/conf/default.toml index 1325a05793..df6e051e8e 100644 --- a/conf/default.toml +++ b/conf/default.toml @@ -48,7 +48,7 @@ proxy_path = "" [theme] primary_color = "#c82850" secondary_color = "#001638" -main_color = "#555" # All-purpose text color +main_color = "#555" # All-purpose text color background_color = "#fdfbff" # These optional parameters indicate which background should be used for the main header and the text color used diff --git a/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.ts b/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.ts index 3cbfce4b74..03c2d5d2b7 100644 --- a/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.ts +++ b/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.ts @@ -202,4 +202,9 @@ export interface Gn4Record { featured?: boolean guestdownload?: boolean selected?: boolean + related?: Gn4RecordRelated +} + +export interface Gn4RecordRelated { + fcats?: Gn4Record[] } diff --git a/libs/api/repository/src/lib/gn4/gn4-repository.ts b/libs/api/repository/src/lib/gn4/gn4-repository.ts index f6f79a6786..1b44809310 100644 --- a/libs/api/repository/src/lib/gn4/gn4-repository.ts +++ b/libs/api/repository/src/lib/gn4/gn4-repository.ts @@ -128,7 +128,7 @@ export class Gn4Repository implements RecordsRepositoryInterface { return this.gn4SearchApi .search( 'bucket', - null, + ['fcats'], JSON.stringify( this.gn4SearchHelper.getMetadataByIdPayload(uniqueIdentifier) ) @@ -142,34 +142,19 @@ export class Gn4Repository implements RecordsRepositoryInterface { } getFeatureCatalog( - metadata: CatalogRecord, - approvedVersion?: boolean + record: CatalogRecord ): Observable { - const featureTypes = metadata.extras['featureTypes'] as any[] - if (!featureTypes || featureTypes.length === 0) { - return this.gn4RecordsApi - .getFeatureCatalog(metadata.uniqueIdentifier, approvedVersion) - .pipe( - map((results: FeatureResponseApiModel) => { - if (results.decodeMap) { - const features = Object.keys(results.decodeMap).map((key) => { - const feature = results.decodeMap[key] - return { name: feature[0], title: feature[1] } - }) - return { features } as DatasetFeatureCatalog - } - return null - }), - switchMap((record) => (record ? of(record) : of(null))) - ) - } else { - return of({ - features: featureTypes[0]?.attributeTable?.map((attr) => ({ - name: attr.typeName, - title: attr.definition, - })), - } as DatasetFeatureCatalog) - } + const featureTypes = record.extras['featureTypes'] + return of( + featureTypes[0] + ? ({ + features: featureTypes[0]?.attributeTable?.map((attr) => ({ + name: attr.typeName, + title: attr.definition, + })), + } as DatasetFeatureCatalog) + : null + ) } getSimilarRecords(similarTo: CatalogRecord): Observable { diff --git a/libs/common/domain/src/lib/model/record/metadata.model.ts b/libs/common/domain/src/lib/model/record/metadata.model.ts index 92ae35b8fb..8ad3ccd072 100644 --- a/libs/common/domain/src/lib/model/record/metadata.model.ts +++ b/libs/common/domain/src/lib/model/record/metadata.model.ts @@ -143,6 +143,7 @@ export interface BaseRecord { // to add: is open data ? } + // TODO: handle actual codelists export type ServiceProtocol = | 'wms' @@ -229,7 +230,6 @@ export interface DatasetRecord extends BaseRecord { export type DatasetFeatureCatalog = { features: Array<{ name: string; title: string }> } - export interface ServiceEndpoint { endpointUrl: URL protocol: string diff --git a/libs/common/domain/src/lib/repository/records-repository.interface.ts b/libs/common/domain/src/lib/repository/records-repository.interface.ts index 9072c9ca0e..39c4d33b9c 100644 --- a/libs/common/domain/src/lib/repository/records-repository.interface.ts +++ b/libs/common/domain/src/lib/repository/records-repository.interface.ts @@ -13,8 +13,7 @@ export abstract class RecordsRepositoryInterface { abstract getMatchesCount(filters: FieldFilters): Observable abstract getRecord(uniqueIdentifier: string): Observable abstract getFeatureCatalog( - metadata: CatalogRecord, - approvedVersion?: boolean + record: CatalogRecord ): Observable abstract aggregate(params: AggregationsParams): Observable abstract getSimilarRecords( diff --git a/libs/feature/record/src/lib/state/mdview.actions.ts b/libs/feature/record/src/lib/state/mdview.actions.ts index cad7130046..f941edbf43 100644 --- a/libs/feature/record/src/lib/state/mdview.actions.ts +++ b/libs/feature/record/src/lib/state/mdview.actions.ts @@ -29,18 +29,18 @@ export const loadFullMetadataFailure = createAction( props<{ otherError?: string; notFound?: boolean }>() ) -export const loadFeatureCatalogAttributes = createAction( - '[Metadata view] Load catalog attributes of the metadata', - props<{ metadata: CatalogRecord; approvedVersion?: boolean }>() +export const loadFeatureCatalog = createAction( + '[Metadata view] Load metadata\'s feature catalog', + props<{ metadata: CatalogRecord }>() ) export const loadFeatureCatalogAttributesSuccess = createAction( - '[Metadata view] Load full metadata success', + '[Metadata view] Load metadata feature catalog success', props<{ datasetCatalog: DatasetFeatureCatalog }>() ) export const loadFeatureCatalogAttributesFailure = createAction( - '[Metadata view] Load full metadata failure', + '[Metadata view] Load metadata feature catalog failure', props<{ otherError?: string; notFound?: boolean }>() ) diff --git a/libs/feature/record/src/lib/state/mdview.effects.ts b/libs/feature/record/src/lib/state/mdview.effects.ts index 2a7ab8a332..bc9a42ecce 100644 --- a/libs/feature/record/src/lib/state/mdview.effects.ts +++ b/libs/feature/record/src/lib/state/mdview.effects.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core' import { Actions, createEffect, ofType } from '@ngrx/effects' import { exhaustMap, mergeMap, of } from 'rxjs' -import { catchError, map, switchMap } from 'rxjs/operators' +import { catchError, filter, map, switchMap, take } from 'rxjs/operators' import * as MdViewActions from './mdview.actions' import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' @@ -11,7 +11,7 @@ export class MdViewEffects { private actions$: Actions, private recordsRepository: RecordsRepositoryInterface, private platformServiceInterface: PlatformServiceInterface - ) {} + ) { } /* Metadata effects @@ -31,25 +31,32 @@ export class MdViewEffects { ) ) ) - /* - Feature Catalog effects - */ - loadCatalogAttributes = createEffect(() => + + loadFeatureCatalog$ = createEffect(() => this.actions$.pipe( - ofType(MdViewActions.loadFeatureCatalogAttributes), - switchMap(({ metadata, approvedVersion }) => - this.recordsRepository.getFeatureCatalog(metadata, approvedVersion) - ), - map((record) => { - if (record === null) { - return MdViewActions.loadFeatureCatalogAttributesFailure({ - notFound: true, + ofType(MdViewActions.loadFullMetadataSuccess), + filter(({ full }) => full !== undefined), + switchMap(({ full }) => + this.recordsRepository.getFeatureCatalog(full).pipe( + switchMap((featureCatalog) => { + // if (featureCatalog === null) { + // return this.recordsRepository.getFeatureCatalog(full).pipe( + // // take(1) // Garantit que l'observable se complète après une émission + // ); + // } + return of(featureCatalog); }) - } - + ) + ), + map((featureCatalog) => { + // if (featureCatalog === null) { + // return MdViewActions.loadFeatureCatalogAttributesFailure({ + // notFound: true, + // }); + // } return MdViewActions.loadFeatureCatalogAttributesSuccess({ - datasetCatalog: record, - }) + datasetCatalog: featureCatalog, + }); }), catchError((error) => of( @@ -59,7 +66,37 @@ export class MdViewEffects { ) ) ) - ) + ); + + /* + Feature Catalog effects + */ + // loadCatalogAttributes = createEffect(() => + // this.actions$.pipe( + // ofType(MdViewActions.loadFeatureCatalogAttributes), + // switchMap(({ metadata }) => + // this.recordsRepository.getFeatureCatalog(metadata) + // ), + // map((record) => { + // if (record === null) { + // return MdViewActions.loadFeatureCatalogAttributesFailure({ + // notFound: true, + // }) + // } + + // return MdViewActions.loadFeatureCatalogAttributesSuccess({ + // datasetCatalog: record, + // }) + // }), + // catchError((error) => + // of( + // MdViewActions.loadFeatureCatalogAttributesFailure({ + // otherError: error.message, + // }) + // ) + // ) + // ) + // ) /* Related effects diff --git a/libs/feature/record/src/lib/state/mdview.facade.ts b/libs/feature/record/src/lib/state/mdview.facade.ts index cbae8033d0..840f5cb662 100644 --- a/libs/feature/record/src/lib/state/mdview.facade.ts +++ b/libs/feature/record/src/lib/state/mdview.facade.ts @@ -36,7 +36,7 @@ export class MdViewFacade { public linkClassifier: LinkClassifierService, private avatarService: AvatarServiceInterface, public dataService: DataService - ) {} + ) { } isPresent$ = this.store.pipe( select(MdViewSelectors.getMetadataUuid), @@ -213,12 +213,10 @@ export class MdViewFacade { /** * FeatureCatalog */ - - loadFeatureCatalog(metadataUuid: string, approvedVersion = false) { + loadFeatureCatalog(metadata: CatalogRecord) { this.store.dispatch( - MdViewActions.loadFeatureCatalogAttributes({ - metadataUuid, - approvedVersion, + MdViewActions.loadFeatureCatalog({ + metadata }) ) } diff --git a/libs/feature/record/src/lib/state/mdview.reducer.ts b/libs/feature/record/src/lib/state/mdview.reducer.ts index 236f78a441..b8bde27538 100644 --- a/libs/feature/record/src/lib/state/mdview.reducer.ts +++ b/libs/feature/record/src/lib/state/mdview.reducer.ts @@ -115,8 +115,9 @@ const metadataViewReducer = createReducer( * FeatureCatalog reducers */ - on(MetadataViewActions.loadFeatureCatalogAttributes, (state) => ({ + on(MetadataViewActions.loadFeatureCatalog, (state) => ({ ...state, + error: null, featureCatalogLoading: true, })), on( diff --git a/libs/feature/router/src/lib/default/state/router.effects.ts b/libs/feature/router/src/lib/default/state/router.effects.ts index c74a1120be..9897a987c6 100644 --- a/libs/feature/router/src/lib/default/state/router.effects.ts +++ b/libs/feature/router/src/lib/default/state/router.effects.ts @@ -32,7 +32,7 @@ export class RouterEffects { private facade: RouterFacade, @Inject(ROUTER_CONFIG) private routerConfig: RouterConfigModel, private fieldsService: FieldsService - ) {} + ) { } navigate$ = createEffect( () => @@ -121,9 +121,6 @@ export class RouterEffects { title: '', }, }), - MdViewActions.loadFeatureCatalogAttributes({ - metadataUuid: activatedRouteSnapshot.params.metadataUuid, - }), MdViewActions.loadFullMetadata({ uuid: activatedRouteSnapshot.params.metadataUuid, })