Skip to content
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

feat: admin listeners small improvements #181

Merged
merged 4 commits into from
Oct 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions front/admin/src/routes/(online)/(app)/listeners/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,24 @@
}))}`
}

let navigating = true;
let navigating = false;

const toggle_deployment = (item: Item) => {
const target = deployment_toggle_link(item);
history.replaceState(history.state, "", target);
navigating = true;
token++;
last_update = Date.now();
searchParams = new URLSearchParams(location.search)
sleep(5).then(() => navigating = false)
}

const toggle_station = (item: Item) => {
const target = station_toggle_link(item);
history.replaceState(history.state, "", target);
navigating = true;
token++;
last_update = Date.now();
searchParams = new URLSearchParams(location.search)
sleep(5).then(() => navigating = false)
}
Expand All @@ -122,6 +127,8 @@
const target = referer_toggle_link(ref);
history.replaceState(history.state, "", target);
navigating = true;
token++;
last_update = Date.now();
searchParams = new URLSearchParams(location.search)
sleep(5).then(() => navigating = false)
}
Expand All @@ -134,8 +141,9 @@
const ms = item.duration_ms != null ? item.duration_ms : (+$now - +new Date(item.created_at));
if(ms >= DAY) {
const d = Math.floor(ms / DAY);
const h = Math.round((ms % DAY) / HOUR);
return `${d}d ${h}h`;
const h = Math.floor((ms % DAY) / HOUR);
const m = Math.round((ms % HOUR) / MIN);
return `${d}d ${h}h ${m}m`;
} else if (ms >= HOUR) {
const h = Math.floor(ms / HOUR);
const m = Math.round((ms % HOUR) / MIN);
Expand All @@ -157,6 +165,9 @@
afterNavigate(() => {
token++;
last_update = Date.now();
if(String(new URLSearchParams(location.search)) !== String(searchParams)) {
searchParams = new URLSearchParams(location.search);
}
})

beforeNavigate(() => {
Expand Down