From de6c18fcca8d21538fcd11321f10946003bab290 Mon Sep 17 00:00:00 2001 From: Olivia Guyot Date: Wed, 29 May 2024 15:55:11 +0200 Subject: [PATCH] fix(api-form): read from allcollections instead of features only --- .../dataviz/src/lib/service/data.service.spec.ts | 2 +- libs/feature/dataviz/src/lib/service/data.service.ts | 4 ++-- .../lib/record-api-form/record-api-form.component.ts | 10 ++++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/libs/feature/dataviz/src/lib/service/data.service.spec.ts b/libs/feature/dataviz/src/lib/service/data.service.spec.ts index 9a367ce61a..c54e86d8d7 100644 --- a/libs/feature/dataviz/src/lib/service/data.service.spec.ts +++ b/libs/feature/dataviz/src/lib/service/data.service.spec.ts @@ -92,7 +92,7 @@ jest.mock('@camptocamp/ogc-client', () => ({ bulkDownloadLinks: { json: 'http://json', csv: 'http://csv' }, }) } - featureCollections = Promise.resolve(['collection1']) + allCollections = Promise.resolve([{ name: 'collection1' }]) }, })) diff --git a/libs/feature/dataviz/src/lib/service/data.service.ts b/libs/feature/dataviz/src/lib/service/data.service.ts index 4bf3368058..8380d0503e 100644 --- a/libs/feature/dataviz/src/lib/service/data.service.ts +++ b/libs/feature/dataviz/src/lib/service/data.service.ts @@ -175,9 +175,9 @@ export class DataService { async getDownloadUrlsFromOgcApi(url: string): Promise { const endpoint = new OgcApiEndpoint(this.proxy.getProxiedUrl(url)) - return await endpoint.featureCollections + return await endpoint.allCollections .then((collections) => { - return endpoint.getCollectionInfo(collections[0]) + return endpoint.getCollectionInfo(collections[0].name) }) .catch((error) => { throw new Error(`ogc.unreachable.unknown`) diff --git a/libs/ui/elements/src/lib/record-api-form/record-api-form.component.ts b/libs/ui/elements/src/lib/record-api-form/record-api-form.component.ts index 8a13579cdf..e0c61e5cee 100644 --- a/libs/ui/elements/src/lib/record-api-form/record-api-form.component.ts +++ b/libs/ui/elements/src/lib/record-api-form/record-api-form.component.ts @@ -121,11 +121,9 @@ export class RecordApiFormComponent { this.supportOffset = this.endpoint.supportsStartIndex() return this.endpoint.getServiceInfo() as OutputFormats } else { - { - return (await this.endpoint.getCollectionInfo( - this.firstCollection - )) as OutputFormats - } + return (await this.endpoint.getCollectionInfo( + this.firstCollection + )) as OutputFormats } } @@ -136,7 +134,7 @@ export class RecordApiFormComponent { await (this.endpoint as WfsEndpoint).isReady() } else { this.endpoint = new OgcApiEndpoint(this.apiBaseUrl) - this.firstCollection = (await this.endpoint.featureCollections)[0] + this.firstCollection = (await this.endpoint.allCollections)[0].name } this.endpoint$.next(this.endpoint) }