diff --git a/src/blocks/IndicatorWarning.svelte b/src/blocks/IndicatorWarning.svelte index bc6e7826..770da385 100644 --- a/src/blocks/IndicatorWarning.svelte +++ b/src/blocks/IndicatorWarning.svelte @@ -38,8 +38,13 @@
The indicator "{sensor.name}" is not available for {formatDateYearDayOfWeekAbbr(date.value)}, yet. The latest known data is available on - {formatDateYearDayOfWeekAbbr(sensor.timeFrame.max)} + {formatDateYearDayOfWeekAbbr(sensor.timeFrame.max)}.
{/if} diff --git a/src/blocks/NoRecentDataWarning.svelte b/src/blocks/NoRecentDataWarning.svelte new file mode 100644 index 00000000..1b4d21cb --- /dev/null +++ b/src/blocks/NoRecentDataWarning.svelte @@ -0,0 +1,48 @@ + + +{#if warningType === 1} +
+

+ This date, {formatDateYearDayOfWeekAbbr(minMaxDate)}, is the most recent that has data for all three of the + highlighted indicators. You can mouse over the tooltips just below this message to see the latest available date + for each indicator. Note that the latest available date may be different for each indicator. +

+
+{/if} + +{#if warningType === 2} +
+

+ This date ({formatDateYearDayOfWeekAbbr(date.value)}) does not yet have data for all of the highlighted + indicators. +
+ + {formatDateYearDayOfWeekAbbr(minMaxDate)} + is the most recent that has data for all three. You can mouse over the tooltips just below this message to see the + latest available date for each indicator. Note that the latest available date may be different for each indicator. +

+
+{/if} diff --git a/src/modes/summary/Overview.svelte b/src/modes/summary/Overview.svelte index 677e9300..fc4b4a8a 100644 --- a/src/modes/summary/Overview.svelte +++ b/src/modes/summary/Overview.svelte @@ -1,14 +1,12 @@ - - + let minMaxDate = new Date(); + + onMount(() => { + [CASES, HOSPITAL_ADMISSION].map((s) => { + if (s.timeFrame.max < minMaxDate) { + minMaxDate = s.timeFrame.max; + } + }); + let urlSearchParams = new URLSearchParams(window.location.search); + if (!urlSearchParams.has('date')) { + // if no date is specified in the URL, default to the latest day before today with data from all 3 highlighted indicators + date.set(minMaxDate); + } + }); + + // warningType is indicator of which exact warning message should be shown. + // By default, when user opens page with no specified date, the date will be set to the latest date we have data for all 3 indicators. + // In this case, warningType should be set to 1. + // In case selected date is set to future date (date > minMaxDate, where we don't have recent data for all 3 indicators), the warningType will be set to 2 + // which has different warning message. + // In case selected date is set to some date which is < minMaxDate, the warningType will be set to 0 which means that we will not show + // any warning message. + + // warningType should be set in beforeUpdate() method, to guess correct warningType. + + let warningType = 1; + beforeUpdate(() => { + if (date.value > minMaxDate) { + warningType = 2; + } else if (date.value < minMaxDate) { + warningType = 0; + } else { + warningType = 1; + } + }); + -

- On {formatDateDayOfWeek(date.value)} - - the {CASES.valueUnit}s were: -

+
-

Doctor Visits

+

+ Doctor Visits + +

{#await casesTrend} @@ -66,12 +87,15 @@
-

Hospital Admissions

+

+ Hospital Admissions + +

{#await hospitalTrend} {:then d} - + {/await}
@@ -79,7 +103,10 @@
-

Deaths

+

+ Deaths + +

{#await deathTrend} @@ -111,10 +138,7 @@ {#await hospitalTrend} {:then d} - + {/await}
Relative change to 7 days ago
@@ -130,5 +154,3 @@
Relative change to 7 days ago
- - diff --git a/src/modes/summary/Summary.svelte b/src/modes/summary/Summary.svelte index 46bd5b0e..4eec3cca 100644 --- a/src/modes/summary/Summary.svelte +++ b/src/modes/summary/Summary.svelte @@ -1,7 +1,6 @@