Skip to content

Commit

Permalink
Period from actions response should be used as fallback for download. (
Browse files Browse the repository at this point in the history
…#854)

* Period from actions response should be used as fallback for download.

* review: simplify parsePiDateTime.

---------

Co-authored-by: ekkelenk <[email protected]>
  • Loading branch information
ekkelenkamp and rudieekkelenkamp authored May 6, 2024
1 parent 6eaa22e commit 55c9409
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/components/download/TimeSeriesFileDownloadComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

<script lang="ts" setup>
import {
ActionsPeriodDate,
DocumentFormat,
filterActionsFilter,
TimeSeriesFilter,
Expand Down Expand Up @@ -133,15 +134,30 @@ function isFilterActionsFilter(
const baseUrl = configManager.get('VITE_FEWS_WEBSERVICES_URL')
function parsePiDateTime(dateTime: ActionsPeriodDate | undefined) {
return dateTime ? `${dateTime.date}T${dateTime.time}Z` : dateTime
}
// use startTime and endTime if set, otherwise use the options from the store, otherwise use the period form the config
function determineViewPeriod(): string {
const _options = toValue(viewPeriodFromStore)
let viewPeriod: string = ''
const startDate: Date | null | undefined = props.startTime
let startDate: Date | null | undefined = props.startTime
? props.startTime
: _options?.startTime
const endDate: Date | null | undefined = props.endTime
let endDate: Date | null | undefined = props.endTime
? props.endTime
: _options?.endTime
if (!startDate) {
const parsedStartDate = parsePiDateTime(props.config?.period?.startDate)
if (parsedStartDate) startDate = new Date(parsedStartDate)
}
if (!endDate) {
const parsedEndDate = parsePiDateTime(props.config?.period?.endDate)
if (parsedEndDate) endDate = new Date(parsedEndDate)
}
if (startDate || endDate) {
// if either startTime or endTime is set, use it.
if (startDate) {
Expand Down Expand Up @@ -198,6 +214,7 @@ const downloadFile = (downloadFormat: string) => {
return
}
}
const timeSeriesFilter: TimeSeriesTopologyActionsFilter = {
documentFormat: downloadFormat,
nodeId: props.config?.nodeId ?? '',
Expand Down
2 changes: 2 additions & 0 deletions src/components/timeseries/TimeSeriesComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const props = withDefaults(defineProps<Props>(), {
class: '',
requests: [],
subplots: [],
period: undefined,
}
},
elevationChartConfig: () => {
Expand All @@ -98,6 +99,7 @@ const props = withDefaults(defineProps<Props>(), {
class: '',
requests: [],
subplots: [],
period: undefined,
}
},
displayType: DisplayType.TimeSeriesChart,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/display/DisplayConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChartConfig } from '../charts/types/ChartConfig.js'
import { ActionPeriod } from '@deltares/fews-pi-requests'

export enum DisplayType {
TimeSeriesChart = 'TimeSeriesChart',
Expand All @@ -13,5 +14,6 @@ export interface DisplayConfig {
title: string
class: string
requests: any[]
period: ActionPeriod | undefined
subplots: ChartConfig[]
}
1 change: 1 addition & 0 deletions src/services/useDisplayConfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function actionsResponseToDisplayConfig(
class: 'singles',
index: timeSeriesDisplayIndex,
requests: result.requests,
period: result.config.timeSeriesDisplay.period,
subplots,
}
displays.push(display)
Expand Down
1 change: 1 addition & 0 deletions src/services/useSsdPi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export function useSsdPi(
title,
class: 'singles',
requests: result.requests,
period: undefined,
subplots,
}
_displays.push(display)
Expand Down

0 comments on commit 55c9409

Please sign in to comment.