Skip to content

Fixed default date for the particular indicator(signal) dashboard #1263

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

Merged
merged 9 commits into from
Mar 20, 2025
21 changes: 13 additions & 8 deletions src/blocks/IndicatorWarning.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
function switchDate() {
date.set(sensor.timeFrame.max);
}
function preserveUrlParams() {
let params = window.location.search;
console.log(sensor);
let result = new URLSearchParams();
result.append('date', formatAPITime(sensor.timeFrame.max));
result.append('sensor', sensor.key);
let regionParam = new URLSearchParams(params).get('region');
if (regionParam) {
result.append('region', regionParam);
}
return result.toString();
}
</script>

{#if !sensor.value.levels.includes(region.level)}
Expand All @@ -38,14 +50,7 @@
<div data-uk-alert class="uk-alert-warning">
The indicator "{sensor.name}" is not available for {formatDateYearDayOfWeekAbbr(date.value)}, yet. The latest
known data is available on
<!--
window.location.search.split('&').slice(1).join('&') is used to keep the query parameters except the date parameter.
So we are getting query params from url, splitting them by & and removing the first element which is date parameter.
-->
<a
href="?date={formatAPITime(sensor.timeFrame.max)}&{window.location.search.split('&').slice(1).join('&')}"
on:click={switchDate}>{formatDateYearDayOfWeekAbbr(sensor.timeFrame.max)}</a
>.
<a href="?{preserveUrlParams()}" on:click={switchDate}>{formatDateYearDayOfWeekAbbr(sensor.timeFrame.max)}</a>.
</div>
{/if}
{/await}
Expand Down
12 changes: 2 additions & 10 deletions src/modes/summary/IndicatorTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,7 @@
range="sparkLine"
className="mobile-row-annotation"
/>
<a
href="../indicator?sensor={entry.sensor.key}"
class="uk-link-text"
on:click|preventDefault={entry.switchMode}
>
<a href="../indicator?sensor={entry.sensor.key}" class="uk-link-text">
{entry.sensor.name}
<span class="source-name">({cleanSource(entry.sensor.value.dataSourceName)})</span>
</a>
Expand Down Expand Up @@ -199,11 +195,7 @@
</div>
</td>
<td>
<a
href="../indicator?sensor={entry.sensor.key}"
class="uk-link-text details-link"
on:click|preventDefault={entry.switchMode}
>
<a href="../indicator?sensor={entry.sensor.key}" class="uk-link-text details-link">
{@html chevronRightIcon}
</a>
</td>
Expand Down