First load: the sidebar's sections from last time, one empty state #62
No files matched your search
@@ -1,10 +1,11 @@
|
||||
<script lang="ts">
|
||||
/** Which slice of a long list is showing, and buttons to the next and previous. */
|
||||
/** Which slice of a long list is showing, and buttons to the next and previous.
|
||||
* Nothing when the list is empty: the table above says so, once (#44). */
|
||||
let { offset = $bindable(0), limit, total, what }: { offset: number; limit: number; total: number; what: string } = $props();
|
||||
</script>
|
||||
|
||||
<div class="pager">
|
||||
<span>{total ? `${offset + 1}–${Math.min(offset + limit, total)} of ${total} ${what}` : `No ${what}`}</span>
|
||||
<span>{total ? `${offset + 1}–${Math.min(offset + limit, total)} of ${total} ${what}` : ''}</span>
|
||||
{#if total > limit}
|
||||
<button class="btn sm" disabled={offset === 0} onclick={() => (offset = Math.max(0, offset - limit))}>Previous</button>
|
||||
<button class="btn sm" disabled={offset + limit >= total} onclick={() => (offset += limit)}>Next</button>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import Icon from './Icon.svelte';
|
||||
import type { IconName } from './icons';
|
||||
import Mark from './Mark.svelte';
|
||||
import { post } from './api';
|
||||
import { post, type Features } from './api';
|
||||
import { live } from './live.svelte';
|
||||
import { hms, zone } from './format';
|
||||
|
||||
@@ -39,7 +39,22 @@
|
||||
// control plane, for admins. The switch remembers where you were.
|
||||
const admin = $derived(live.seesAll); // operators see Configure read-only
|
||||
const configuring = $derived(path === '/configure' || path.startsWith('/configure/'));
|
||||
const f = $derived(live.overview?.features);
|
||||
// Until the first overview arrives, the sections from last time, so a
|
||||
// page loaded straight from its address doesn't flash a short sidebar
|
||||
// that then grows (#44). A convenience: without storage it just waits.
|
||||
const remembered = (() => {
|
||||
try {
|
||||
return (JSON.parse(localStorage.getItem('cairnobs.features') ?? 'null') as Features | null) ?? undefined;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
})();
|
||||
const f = $derived(live.overview?.features ?? remembered);
|
||||
$effect(() => {
|
||||
const now = live.overview?.features;
|
||||
if (!now) return;
|
||||
try { localStorage.setItem('cairnobs.features', JSON.stringify(now)); } catch { /* private window, storage off */ }
|
||||
});
|
||||
let lastWatch = $state('/');
|
||||
let lastConfigure = $state('/configure');
|
||||
$effect(() => {
|
||||
|
||||
Reference in new issue
Block a user