Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
AlitaBernachot committed Feb 27, 2025
1 parent 8ea13ca commit 590eff1
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 67 deletions.
2 changes: 1 addition & 1 deletion conf/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,9 @@ export interface Gn4Record {
featured?: boolean
guestdownload?: boolean
selected?: boolean
related?: Gn4RecordRelated
}

export interface Gn4RecordRelated {
fcats?: Gn4Record[]
}
41 changes: 13 additions & 28 deletions libs/api/repository/src/lib/gn4/gn4-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class Gn4Repository implements RecordsRepositoryInterface {
return this.gn4SearchApi
.search(
'bucket',
null,
['fcats'],
JSON.stringify(
this.gn4SearchHelper.getMetadataByIdPayload(uniqueIdentifier)
)
Expand All @@ -142,34 +142,19 @@ export class Gn4Repository implements RecordsRepositoryInterface {
}

getFeatureCatalog(
metadata: CatalogRecord,
approvedVersion?: boolean
record: CatalogRecord
): Observable<DatasetFeatureCatalog | null> {
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<CatalogRecord[]> {
Expand Down
2 changes: 1 addition & 1 deletion libs/common/domain/src/lib/model/record/metadata.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export interface BaseRecord {
// to add: is open data ?
}


// TODO: handle actual codelists
export type ServiceProtocol =
| 'wms'
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ export abstract class RecordsRepositoryInterface {
abstract getMatchesCount(filters: FieldFilters): Observable<number>
abstract getRecord(uniqueIdentifier: string): Observable<CatalogRecord | null>
abstract getFeatureCatalog(
metadata: CatalogRecord,
approvedVersion?: boolean
record: CatalogRecord
): Observable<DatasetFeatureCatalog | null>
abstract aggregate(params: AggregationsParams): Observable<Aggregations>
abstract getSimilarRecords(
Expand Down
10 changes: 5 additions & 5 deletions libs/feature/record/src/lib/state/mdview.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>()
)

Expand Down
75 changes: 56 additions & 19 deletions libs/feature/record/src/lib/state/mdview.effects.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -11,7 +11,7 @@ export class MdViewEffects {
private actions$: Actions,
private recordsRepository: RecordsRepositoryInterface,
private platformServiceInterface: PlatformServiceInterface
) {}
) { }

/*
Metadata effects
Expand All @@ -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(
Expand All @@ -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
Expand Down
10 changes: 4 additions & 6 deletions libs/feature/record/src/lib/state/mdview.facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class MdViewFacade {
public linkClassifier: LinkClassifierService,
private avatarService: AvatarServiceInterface,
public dataService: DataService
) {}
) { }

isPresent$ = this.store.pipe(
select(MdViewSelectors.getMetadataUuid),
Expand Down Expand Up @@ -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
})
)
}
Expand Down
3 changes: 2 additions & 1 deletion libs/feature/record/src/lib/state/mdview.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ const metadataViewReducer = createReducer(
* FeatureCatalog reducers
*/

on(MetadataViewActions.loadFeatureCatalogAttributes, (state) => ({
on(MetadataViewActions.loadFeatureCatalog, (state) => ({
...state,
error: null,
featureCatalogLoading: true,
})),
on(
Expand Down
5 changes: 1 addition & 4 deletions libs/feature/router/src/lib/default/state/router.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class RouterEffects {
private facade: RouterFacade,
@Inject(ROUTER_CONFIG) private routerConfig: RouterConfigModel,
private fieldsService: FieldsService
) {}
) { }

navigate$ = createEffect(
() =>
Expand Down Expand Up @@ -121,9 +121,6 @@ export class RouterEffects {
title: '',
},
}),
MdViewActions.loadFeatureCatalogAttributes({
metadataUuid: activatedRouteSnapshot.params.metadataUuid,
}),
MdViewActions.loadFullMetadata({
uuid: activatedRouteSnapshot.params.metadataUuid,
})
Expand Down

0 comments on commit 590eff1

Please sign in to comment.