Skip to content

Commit

Permalink
Merge pull request #807 from Deltares/DWO-691
Browse files Browse the repository at this point in the history
Only retrieve the child locations and the required attributes
  • Loading branch information
hvangeffen authored Apr 18, 2024
2 parents 824a736 + e0f733d commit b7c7af6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 10 additions & 13 deletions src/components/download/DataDownloadDisplayComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -408,37 +408,34 @@ function getParameterName(parameter: TimeSeriesParameter): string {
async function getLocations(): Promise<Location[]> {
const filter: LocationsFilter = {
showAttributes: true,
showParentLocations: false,
attributeIds: props.topologyNode.dataDownloadDisplay?.attributes.map(
(item) => item.id,
),
filterId: filterId,
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[][] {
const attributeValuesMap: 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
for (let i = 0; i < attributes.length; i++) {
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)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/topology/locations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b7c7af6

Please sign in to comment.