From ec67fd5f3b0eda8b627e31465757f5fa981757f1 Mon Sep 17 00:00:00 2001 From: Tobias Kohr Date: Wed, 18 Oct 2023 15:46:16 +0200 Subject: [PATCH 1/2] fix(md-info): only display abstract if defined --- .../lib/metadata-info/metadata-info.component.html | 2 +- .../metadata-info/metadata-info.component.spec.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libs/ui/elements/src/lib/metadata-info/metadata-info.component.html b/libs/ui/elements/src/lib/metadata-info/metadata-info.component.html index 33d6c46c72..f24145348a 100644 --- a/libs/ui/elements/src/lib/metadata-info/metadata-info.component.html +++ b/libs/ui/elements/src/lib/metadata-info/metadata-info.component.html @@ -4,7 +4,7 @@ > record.metadata.about

-
+

{ component = fixture.componentInstance component.metadata = { ...DATASET_RECORDS[0], + abstract: null, useLimitations: null, accessConstraints: null, extras: { @@ -40,6 +41,11 @@ describe('MetadataInfoComponent', () => { fixture.nativeElement.querySelector('ng-container') expect(displayedElement).toBeFalsy() }) + it('should not display the abstract section', () => { + const displayedElement = + fixture.nativeElement.querySelector('.md-description') + expect(displayedElement).toBeFalsy() + }) }) describe('When a section is not empty', () => { @@ -53,7 +59,6 @@ describe('MetadataInfoComponent', () => { const displayedElement = fixture.nativeElement.querySelector('.noUsage') expect(displayedElement).toBeFalsy() }) - it('should display the keywords section', () => { // Use waitForAsync to handle asynchronous changes in the DOM. fixture.whenStable().then(() => { @@ -62,5 +67,10 @@ describe('MetadataInfoComponent', () => { expect(displayedElement).toBeTruthy() }) }) + it('should display the abstract section', () => { + const displayedElement = + fixture.nativeElement.querySelector('.md-description') + expect(displayedElement).toBeTruthy() + }) }) }) From 446a63cd3b94fcd73889ce40f3f229bdc9e11f56 Mon Sep 17 00:00:00 2001 From: Tobias Kohr Date: Thu, 19 Oct 2023 16:03:29 +0200 Subject: [PATCH 2/2] fix(data-service): prevent calling proxying ESRI rest URL twice to ensure query params encoding otherwise first call encodes URL without query params and second call returns unmodified URL, since the host is already the window host for more clarity also prevents double proxification for WFS, that did not fail thanks to ogc-client --- .../dataviz/src/lib/service/data.service.spec.ts | 15 +++++++++++++-- .../dataviz/src/lib/service/data.service.ts | 11 +++++++---- 2 files changed, 20 insertions(+), 6 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 ee9944f100..cb126ef076 100644 --- a/libs/feature/dataviz/src/lib/service/data.service.spec.ts +++ b/libs/feature/dataviz/src/lib/service/data.service.spec.ts @@ -593,11 +593,22 @@ describe('DataService', () => { it('builds a proxied url', () => { expect( service.getDownloadUrlFromEsriRest( - 'http://esri.rest/local/', + 'http://esri.rest/local', 'geojson' ) ).toBe( - 'http://proxy.local/?url=http%3A%2F%2Fesri.rest%2Flocal%2F%2Fquery%3Ff%3Dgeojson%26where%3D1%3D1%26outFields%3D*' + 'http://proxy.local/?url=http%3A%2F%2Fesri.rest%2Flocal%2Fquery%3Ff%3Dgeojson%26where%3D1%3D1%26outFields%3D*' + ) + }) + it('calls DataFetcher.openDataset with a proxied url', () => { + service.getDataset({ + url: new URL('http://esri.rest/local'), + accessServiceProtocol: 'esriRest', + type: 'service', + }) + expect(openDataset).toHaveBeenCalledWith( + 'http://proxy.local/?url=http%3A%2F%2Fesri.rest%2Flocal%2Fquery%3Ff%3Dgeojson%26where%3D1%3D1%26outFields%3D*', + 'geojson' ) }) }) diff --git a/libs/feature/dataviz/src/lib/service/data.service.ts b/libs/feature/dataviz/src/lib/service/data.service.ts index 5ed9dffad2..a8f7cb2b99 100644 --- a/libs/feature/dataviz/src/lib/service/data.service.ts +++ b/libs/feature/dataviz/src/lib/service/data.service.ts @@ -168,9 +168,8 @@ export class DataService { } getDataset(link: DatasetDistribution): Observable { - const linkUrl = this.proxy.getProxiedUrl(link.url.toString()) if (link.type === 'service' && link.accessServiceProtocol === 'wfs') { - return this.getDownloadUrlsFromWfs(linkUrl, link.name).pipe( + return this.getDownloadUrlsFromWfs(link.url.toString(), link.name).pipe( switchMap((urls) => { if (urls.geojson) return openDataset(urls.geojson, 'geojson') if (urls.gml) @@ -187,17 +186,21 @@ export class DataService { }) ) } else if (link.type === 'download') { + const linkProxifiedUrl = this.proxy.getProxiedUrl(link.url.toString()) const format = getFileFormat(link) const supportedType = SupportedTypes.indexOf(format as any) > -1 ? (format as SupportedType) : undefined - return from(openDataset(linkUrl, supportedType)).pipe() + return from(openDataset(linkProxifiedUrl, supportedType)).pipe() } else if ( link.type === 'service' && link.accessServiceProtocol === 'esriRest' ) { - const url = this.getDownloadUrlFromEsriRest(linkUrl, 'geojson') + const url = this.getDownloadUrlFromEsriRest( + link.url.toString(), + 'geojson' + ) return from(openDataset(url, 'geojson')).pipe() } return throwError(() => 'protocol not supported')