From 07b5a9bd14d52261791983c5560ca627dcd1d2af Mon Sep 17 00:00:00 2001 From: hvangeffen Date: Tue, 18 Jun 2024 13:33:45 +0200 Subject: [PATCH] Hide analysis time when not present in GetCapabilities --- src/components/spatialdisplay/SpatialDisplayComponent.vue | 7 +++---- src/components/wms/InformationPanel.vue | 6 +++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/spatialdisplay/SpatialDisplayComponent.vue b/src/components/spatialdisplay/SpatialDisplayComponent.vue index 396b790c2..7d16bd41d 100644 --- a/src/components/spatialdisplay/SpatialDisplayComponent.vue +++ b/src/components/spatialdisplay/SpatialDisplayComponent.vue @@ -345,10 +345,9 @@ const layerHasElevation = computed(() => { watch( () => props.layerCapabilities, (layer) => { - if (layer?.keywordList !== undefined) { - forecastTime.value = - new Date(layer?.keywordList[0].forecastTime as string) ?? null - } + const _forecastTime = layer?.keywordList?.[0].forecastTime + forecastTime.value = _forecastTime ? new Date(_forecastTime) : undefined + legendLayerName.value = props.layerName legendLayerStyles.value = props.layerCapabilities?.styles if (legendLayerStyles.value === undefined && props.layerName) { diff --git a/src/components/wms/InformationPanel.vue b/src/components/wms/InformationPanel.vue index 63e6ade41..16c9f5f25 100644 --- a/src/components/wms/InformationPanel.vue +++ b/src/components/wms/InformationPanel.vue @@ -203,8 +203,12 @@ const rules = { } const analysisTime = computed(() => { - if (!props.forecastTime || isNaN(props.forecastTime.getTime())) + if (!props.forecastTime) return undefined + + if (isNaN(props.forecastTime.getTime())) { return 'Analysis time not available' + } + return ( 'Analysis time: ' + DateTime.fromJSDate(props.forecastTime).toFormat('dd/MM/yyyy, HH:mm:ss')