Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix download for empty qualifierId array #1052

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions src/components/download/DataDownloadDisplayComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
</v-card-actions>
</v-card>
<TimeSeriesFileDownloadComponent
v-model="showFileDownloadDialog"
v-model="downloadDialogStore.showDialog"
:options="options"
:startTime="downloadStartTime"
:endTime="downloadEndTime"
Expand Down Expand Up @@ -165,14 +165,15 @@ import { ParameterQualifiersHeader } from '@/lib/download/types'
import { isEqual, uniqWith } from 'lodash-es'
import { filterToParams } from '@/lib/download/downloadFiles.ts'
import { DataDownloadFilter } from '@/lib/download/types/DataDownloadFilter.ts'
import { useDownloadDialogStore } from '@/stores/downloadDialog'

interface Props {
nodeId?: string | string[]
topologyNode: TopologyNode
}

const props = defineProps<Props>()
const showFileDownloadDialog = ref(false)
const downloadDialogStore = useDownloadDialogStore()
const settings = useUserSettingsStore()
const options = computed<UseDisplayConfigOptions>(() => {
return {
Expand Down Expand Up @@ -381,21 +382,27 @@ function downloadData() {
errors.value = validateUserInput(startTimeRequest, endTimeRequest)
if (errors.value.length !== 0) return

const parameterIds = selectedParameterQualifiers.value.map(
(parameterQualifier) => parameterQualifier.parameterId,
)
const qualifiersIds = selectedParameterQualifiers.value
.filter((parameterQualifier) => parameterQualifier.qualifiers !== undefined)
const selectedParameterIds = selectedParameterQualifiers.value
.map((parameterQualifier) => parameterQualifier.parameterId)
.filter((parameterId) => parameterId !== undefined)

const selectedQualifierIds = selectedParameterQualifiers.value
.map((parameterQualifier) => parameterQualifier.qualifiers)
.flatMap((item) => item)
.filter((qualifier) => qualifier !== undefined)

const selectedLocationIds = selectedLocations.value.map(
(location) => location.locationId,
)

const joinUniqueStrings = (stringArray: string[]) =>
stringArray.length > 0 ? uniqWith(stringArray).join(',') : undefined

timeSeriesFilter.value = {
filterId: filterId,
locationIds: selectedLocations.value
.map((location) => location.locationId)
.join(','),
parameterIds: uniqWith(parameterIds).join(','),
qualifierIds: uniqWith(qualifiersIds).join(','),
locationIds: joinUniqueStrings(selectedLocationIds),
parameterIds: joinUniqueStrings(selectedParameterIds),
qualifierIds: joinUniqueStrings(selectedQualifierIds),
onlyHeaders: onlyDownloadMetaData.value,
}
const queryParameters = filterToParams(timeSeriesFilter.value)
Expand All @@ -407,7 +414,7 @@ function downloadData() {
downloadStartTime.value = startTimeRequest.toJSDate()
downloadEndTime.value = endTimeRequest.toJSDate()

showFileDownloadDialog.value = true
downloadDialogStore.showDialog = true
}

function getLocationName(location: Location): string {
Expand Down
Loading