From 00200b9005e945d32cb9dda1dc40db4b87880e05 Mon Sep 17 00:00:00 2001 From: grijzea Date: Tue, 16 Apr 2024 15:02:03 +0200 Subject: [PATCH 1/2] only retrieve the child locations and the required attributes --- package-lock.json | 8 ++++---- package.json | 2 +- .../download/DataDownloadDisplayComponent.vue | 15 +++++++++------ src/lib/topology/locations.ts | 1 + 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index c3dd0127a..ea279c46a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "fews-weboc", "version": "1.1.0-rc.0", "dependencies": { - "@deltares/fews-pi-requests": "^1.0.10", + "@deltares/fews-pi-requests": "^1.0.11", "@deltares/fews-ssd-requests": "^1.0.1", "@deltares/fews-ssd-webcomponent": "^1.0.1", "@deltares/fews-web-oc-charts": "^3.0.2", @@ -90,9 +90,9 @@ } }, "node_modules/@deltares/fews-pi-requests": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/@deltares/fews-pi-requests/-/fews-pi-requests-1.0.10.tgz", - "integrity": "sha512-MxvdP7qk6b+6uJJzpgD41xZFnz5l8ZqFXAvwofaRNdQeJVlgpdqM/kvto5NofKlk2PcyEpLBQggBcSUfR8bpxQ==", + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@deltares/fews-pi-requests/-/fews-pi-requests-1.0.11.tgz", + "integrity": "sha512-vd5KKsaXjhNPl0xfQPHhGV0NE/hnh8wnMrpG4uLo+Ha4L0BYXytdNAH9WixcDabAoTAJRr8FIaXu0SFaaDs+fQ==", "dependencies": { "@deltares/fews-web-oc-utils": "^1.0.0" }, diff --git a/package.json b/package.json index 5470c7f73..e1be2b2df 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "test-ct": "playwright test -c playwright-ct.config.ts" }, "dependencies": { - "@deltares/fews-pi-requests": "^1.0.10", + "@deltares/fews-pi-requests": "^1.0.11", "@deltares/fews-ssd-requests": "^1.0.1", "@deltares/fews-ssd-webcomponent": "^1.0.1", "@deltares/fews-web-oc-charts": "^3.0.2", diff --git a/src/components/download/DataDownloadDisplayComponent.vue b/src/components/download/DataDownloadDisplayComponent.vue index 83341c5bb..04442965e 100644 --- a/src/components/download/DataDownloadDisplayComponent.vue +++ b/src/components/download/DataDownloadDisplayComponent.vue @@ -408,6 +408,10 @@ function getParameterName(parameter: TimeSeriesParameter): string { async function getLocations(): Promise { const filter: LocationsFilter = { showAttributes: true, + showParentLocations: false, + attributeIds: props.topologyNode.dataDownloadDisplay?.attributes.map( + (item) => item.id, + ), filterId: filterId, documentFormat: DocumentFormat.PI_JSON, } @@ -426,6 +430,7 @@ function getAttributeValues(locations: Location[]): string[][] { const configuredAttributeIds = props.topologyNode.dataDownloadDisplay?.attributes.map((item) => item.id) configuredAttributeIds?.forEach((item) => attributeValuesMap.push([])) + if (configuredAttributeIds == undefined) return attributeValuesMap for (const newLocation of locations) { let attributes = newLocation.attributes if (attributes == undefined) continue @@ -433,12 +438,10 @@ function getAttributeValues(locations: Location[]): string[][] { const attribute = attributes[i] if (attribute.id === undefined) continue if (attribute.value === undefined) continue - if (configuredAttributeIds?.includes(attribute.id)) { - const arrayForAttribute = - attributeValuesMap[configuredAttributeIds.indexOf(attribute.id)] - if (!arrayForAttribute.includes(attribute.value)) { - arrayForAttribute.push(attribute.value) - } + const arrayForAttribute = + attributeValuesMap[configuredAttributeIds.indexOf(attribute.id)] + if (!arrayForAttribute.includes(attribute.value)) { + arrayForAttribute.push(attribute.value) } } } diff --git a/src/lib/topology/locations.ts b/src/lib/topology/locations.ts index f3db017fa..07bc9c382 100644 --- a/src/lib/topology/locations.ts +++ b/src/lib/topology/locations.ts @@ -67,6 +67,7 @@ async function fetchLocationsAsGeoJsonForSingleFilterId( const filter = { documentFormat: DocumentFormat.GEO_JSON, filterId: filterId, + showParentLocations: false, includeIconNames: true, } // TODO: Remove cast to any when fews-pi-requests supports GeoJSON response in LocationResponse From e0f733d9a0d2d1219827819ea62c6c9ff4e87cc2 Mon Sep 17 00:00:00 2001 From: grijzea Date: Wed, 17 Apr 2024 09:04:52 +0200 Subject: [PATCH 2/2] process code and removed obsolete code --- .../download/DataDownloadDisplayComponent.vue | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/components/download/DataDownloadDisplayComponent.vue b/src/components/download/DataDownloadDisplayComponent.vue index 04442965e..5ca94e3be 100644 --- a/src/components/download/DataDownloadDisplayComponent.vue +++ b/src/components/download/DataDownloadDisplayComponent.vue @@ -416,13 +416,7 @@ async function getLocations(): Promise { documentFormat: DocumentFormat.PI_JSON, } const locationsResponse = await piProvider.getLocations(filter) - const allLocations = locationsResponse.locations - const allParentLocations = allLocations.map( - (location) => location.parentLocationId, - ) - return locationsResponse.locations.filter( - (location) => !allParentLocations.includes(location.locationId), - ) + return locationsResponse.locations } function getAttributeValues(locations: Location[]): string[][] { @@ -430,7 +424,7 @@ function getAttributeValues(locations: Location[]): string[][] { const configuredAttributeIds = props.topologyNode.dataDownloadDisplay?.attributes.map((item) => item.id) configuredAttributeIds?.forEach((item) => attributeValuesMap.push([])) - if (configuredAttributeIds == undefined) return attributeValuesMap + if (configuredAttributeIds === undefined) return attributeValuesMap for (const newLocation of locations) { let attributes = newLocation.attributes if (attributes == undefined) continue