Skip to content

Commit

Permalink
webapp/escalated: default to all time view
Browse files Browse the repository at this point in the history
On escalated view load, set time range to all. When leaving, reset it
back to what it was.
  • Loading branch information
jasonish committed Mar 11, 2023
1 parent d1a8b8b commit 30e54fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions webapp/src/Alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
useNavigate,
useSearchParams,
} from "@solidjs/router";
import { SET_TIME_RANGE, TIME_RANGE, Top } from "./Top";
import { _SET_TIME_RANGE, SET_TIME_RANGE, TIME_RANGE, Top } from "./Top";
import {
Badge,
Button,
Expand Down Expand Up @@ -135,7 +135,7 @@ export function Alerts() {
if (view == View.Escalated) {
untrack(() => {
savedTimeRange = TIME_RANGE();
SET_TIME_RANGE("");
_SET_TIME_RANGE("");
});
}

Expand Down Expand Up @@ -254,6 +254,7 @@ export function Alerts() {
idleTimer.stop();
untrack(() => {
if (savedTimeRange) {
console.log("Restoring time range of " + savedTimeRange);
SET_TIME_RANGE(savedTimeRange);
}
});
Expand Down
16 changes: 8 additions & 8 deletions webapp/src/Top.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ function getInitialTimeRange(): string {
}

/* START: Init TIME_RANGE */
export const [TIME_RANGE, SET_TIME_RANGE] =
export const [TIME_RANGE, _SET_TIME_RANGE] =
createSignal<string>(DEFAULT_TIME_RANGE);

export function SET_TIME_RANGE(range: string) {
_SET_TIME_RANGE(range);
localStorage.setItem("TIME_RANGE", range);
}

export function Top(props: { brand?: string; disableRange?: boolean }) {
console.log("Top");
console.log(`Top: disableRange=${props.disableRange}`);
Expand All @@ -78,12 +83,7 @@ export function Top(props: { brand?: string; disableRange?: boolean }) {
// in the dropdown will not cause the dropdown to close.
let [toolDropDownOpen, setToolDropDownOpen] = createSignal(false);

SET_TIME_RANGE(getInitialTimeRange());

function updateTimeRange(range: string) {
SET_TIME_RANGE(range);
localStorage.setItem("TIME_RANGE", range);
}
_SET_TIME_RANGE(getInitialTimeRange());

onMount(() => {
tinykeys(window, {
Expand Down Expand Up @@ -208,7 +208,7 @@ export function Top(props: { brand?: string; disableRange?: boolean }) {
<>
<Dropdown.Item
onClick={(e) => {
updateTimeRange(o[0] as string);
SET_TIME_RANGE(o[0] as string);
e.currentTarget.blur();
}}
>
Expand Down

0 comments on commit 30e54fd

Please sign in to comment.