Dawnline 0.20.0
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / Backend (Go: vet, tests, a real ubusd and uhttpd) (push) Blocked by required conditions
CI / Package files (push) Blocked by required conditions
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / Backend (Go: vet, tests, a real ubusd and uhttpd) (push) Blocked by required conditions
CI / Package files (push) Blocked by required conditions
- **Backend rewritten in Go.** One daemon, `dawnlined`, replaces the whole ucode backend: the rpcd plugin, the agent, the CLI and the updater. The package no longer depends on ucode. - **Per-architecture builds.** The release carries the backend for arm64, ARMv7, mips, mipsle and amd64; the router fetches its own after the package is installed and checks its sha256. Dawnline does not run on other architectures (older ARM, 32-bit x86, RISC-V). - **Faster on the router.** A firewall sync takes 0.06 s instead of 0.9 s; a full apply takes about 300 ms. The portal is served by the daemon itself, without a CGI process per request. - **Live pages.** The admin and the portal follow a live stream from the router instead of re-fetching the whole state every 30 seconds. - **Admin redesigned in the portal's style.** Three sections (Overview · Log · Settings); a server is a page of its own with People, Places and Settings; a device opens as a dialog over its person. - **Changes wait for «Apply».** Every setting, and a person's access, is staged in one dock before it reaches the router. - **Configuration rollout.** After a change that makes devices fetch their configuration again, the admin shows how many have fetched it and who has not. Every setting shows beforehand (⟳N) how many devices it will touch. - **Waiting for a decision.** Overview and People put first the people who need one (access ended, limit reached, a device that does not connect), each with its one action a tap away. - **Bulk actions on people.** «Select» (or a long press on a card) picks several people to extend by a month, pause or resume at once. - **Undo.** An action done from a card or a request is undone from its toast. - **Update dialogs redesigned.** An update is one view from its question to its result; Dawnline's own update runs in it like every other, and the page reloads itself once the new version answers. Other versions are a list, each with its notes and Install on a page of its own. - **Site to site: networks behind a router.** A router connected as a device can have networks behind it (up to eight, /16 to /30): the server routes them and applies the router's access to them. A network that shares addresses with a tunnel, the router's own networks or another site is refused by name. - **Routers from the portal.** People can add a router and name its networks on their own page; the admin accepts or declines with a reason, or lets them through without asking. - **Check access and Health know the networks behind routers.** - **Usage limits reworked.** A monthly limit no longer follows the calendar. A person's month starts with their first traffic and ends a month later; the next one starts only when they connect again, so time away uses up none of it. Before, everyone's limit reset on the 1st. - Extra data lasts until that person's month ends; «Reset usage» starts the month anew. - A limit is for a month or for the whole term; the admin and the portal show when it resets. - Charts that said «this month» show the last 30 days. - After the update nobody loses what was counted: the month that was running becomes the person's first and ends on the 1st. - **Access by time of day removed.** The Hours limit is gone from the admin, the portal and the backend; saved hours are dropped. - **Expiry simplified.** An end date always stops access, with a heads-up three days before; the per-person choice is gone. - **No false disconnects from sleeping phones.** A phone or a tablet stays online through ten minutes of silence. - **Mobile Safari fixes.** Pressing a control no longer sends the page to its top; tab tracks that do not fit scroll; switches animate after a press.
This commit is contained in:
1 parent
f8130e39a8
commit
ac90575b0b
788 files changed
+139244
-41720
No files matched your search
@@ -0,0 +1,258 @@
|
||||
// Overview › Health (the anchor `health`, where the head's phrase and the old
|
||||
// Health address lead): the router's checks as a visible list, nothing folded.
|
||||
// The most pressing check that did not pass is the page's one notice, the
|
||||
// other failing ones are rows under it, and every check that passed stays on
|
||||
// the page by what it is about: a row for the router, one a server, one for
|
||||
// the portal, each naming its checks in one quiet line (a skipped one
|
||||
// fainter, why in its title) and counting them at its end. A cloud of two
|
||||
// dozen ticked phrases that repeat the core's and the server's name told
|
||||
// nothing apart (the owner, 2026-11-11). A failing
|
||||
// check that a Settings section is about is a signal: the whole notice or row
|
||||
// leads to that section, where its fix is (overview/model.ts fixPlace); only
|
||||
// a check nothing in Settings is about keeps its fix here as a button, or its
|
||||
// advice as its words (ownFix; flows/health-fix.ts runs it). The foot: the
|
||||
// watchdog in one line (its repair today, the agent gone quiet, or that it
|
||||
// had nothing to do) with its switch, and «Check again», which stays one button for the page's life, so its
|
||||
// busy orb and the focus hold through the repaint its answer brings.
|
||||
// A read-only login gets no fix buttons; the links and «Check again» stay.
|
||||
|
||||
import { refill } from '../../ui/reshape';
|
||||
import { flipping } from '../../ui/edit-rows';
|
||||
import type { HealthCheck } from '../../../shared/types';
|
||||
import { api } from '../../api';
|
||||
import { h } from '../../../portal/dom';
|
||||
import { once } from '../../../portal/ui/feedback';
|
||||
import { fmt, num, plural } from '../../../shared/i18n';
|
||||
import { glass } from '../../ui/glass';
|
||||
import { ic } from '../../ui/icons';
|
||||
import { secHead } from '../../ui/page-head';
|
||||
import { errorText, notify } from '../../ui/toast';
|
||||
import { whenAt } from '../../events/clock';
|
||||
import { fixLabel } from '../../servers/fixes';
|
||||
import { focusInside } from '../../state/poller';
|
||||
import { compRow } from '../../ui/comp-row';
|
||||
import { checkGroups, checkList, fixPlace, ownFix, systemNews, type CheckGroup } from '../../overview/model';
|
||||
import type { OverviewCtx } from './ctx';
|
||||
import { flippedNow } from '../../../portal/ui/carry';
|
||||
|
||||
export interface HealthSection {
|
||||
el: HTMLElement;
|
||||
/** Draw the checks as they stand; a `quiet` (background) repaint leaves the list alone while the focus is in it. */
|
||||
/** Draw the checks; false: left as it was, a background repaint under the keyboard focus. */
|
||||
update(c: OverviewCtx, quiet: boolean): void | boolean;
|
||||
}
|
||||
|
||||
const bad = (k: HealthCheck) => k.status === 'error';
|
||||
const words = (k: HealthCheck) => [h('b', {}, k.problem ?? k.title), k.detail ? h('span', {}, k.detail) : null];
|
||||
|
||||
/** The way to where a check is fixed, said at its notice's or row's end (a phone: the chevron alone). */
|
||||
const toFix = (): HTMLElement => h('span', { class: 'ov-fix' }, h('span', {}, _('Fix in Settings')), ic('chevron'));
|
||||
|
||||
/** A check's own fix as its button; null: none, or a read-only login. */
|
||||
function fixButton(c: OverviewCtx, k: HealthCheck, servers: string[]): HTMLButtonElement | null {
|
||||
const fix = ownFix(k, servers);
|
||||
if (!c.write || !fix) return null;
|
||||
const b = h('button', { type: 'button', class: `btn ${bad(k) ? 'tint' : 'soft'} sm` }, h('span', {}, fixLabel(fix))) as HTMLButtonElement;
|
||||
b.addEventListener('click', () => void once(b, () => c.fix(fix)));
|
||||
return b;
|
||||
}
|
||||
|
||||
/** The one notice: a link as a whole to the check's Settings section, or (nothing there is about it) its own fix. */
|
||||
function notice(c: OverviewCtx, k: HealthCheck, servers: string[]): HTMLElement {
|
||||
const to = fixPlace(k, servers);
|
||||
const box = h(
|
||||
'div',
|
||||
{ class: `notice ${bad(k) ? 'bad' : 'warn'}` },
|
||||
glass('pulse', bad(k) ? 'red' : 'orange'),
|
||||
// its own fix stands under its words: beside them it would squeeze them in the column
|
||||
h('div', { class: 't' }, ...words(k), to ? null : fixButton(c, k, servers)),
|
||||
to ? toFix() : null,
|
||||
);
|
||||
return to ? h('a', { class: 'notice-a', href: to }, box) : box;
|
||||
}
|
||||
|
||||
/** A failing check as a row: the same, in the list. */
|
||||
function row(c: OverviewCtx, k: HealthCheck, servers: string[]): HTMLElement {
|
||||
const to = fixPlace(k, servers);
|
||||
const kids = [h('span', { class: 'dg-m' }, ic(bad(k) ? 'x' : 'alert')), h('span', { class: 'chk-t' }, ...words(k))];
|
||||
return to
|
||||
? h('a', { class: `chk ${k.status} ov-chk`, href: to }, ...kids, toFix())
|
||||
: h('div', { class: `chk ${k.status}` }, ...kids, fixButton(c, k, servers));
|
||||
}
|
||||
|
||||
const GROUP_ICON = { router: 'router', server: 'server', portal: 'portal' } as const;
|
||||
const GROUP_TONE = { ok: 'green', warn: 'orange', bad: 'red', off: 'grey' } as const;
|
||||
|
||||
/** What a group is about, as its row: its checks that passed named in one line, counted at the row's end. */
|
||||
function groupRow(g: CheckGroup): HTMLElement {
|
||||
const title = g.kind === 'router' ? _('Router') : g.kind === 'portal' ? _('Personal portal') : (g.name ?? '');
|
||||
const names = g.passed.flatMap(({ check, title: t }, i) => [
|
||||
i ? ' · ' : '',
|
||||
// not the status as a class: `.skip` is the page's skip link (page.css)
|
||||
h('span', { class: check.status === 'skip' ? 'ov-idle' : null, title: check.detail || null }, t),
|
||||
]);
|
||||
const count =
|
||||
g.tone === 'off'
|
||||
? h('span', { class: 'ov-gn' }, _('off', 'server'))
|
||||
: h(
|
||||
'span',
|
||||
{
|
||||
class: `ov-gn num ${g.tone}-t`,
|
||||
title: plural(g.ok, '%s check passed', '%s checks passed'),
|
||||
},
|
||||
ic(g.tone === 'ok' ? 'check' : 'alert'),
|
||||
fmt(_('%s of %s'), num(g.ok), num(g.of)),
|
||||
);
|
||||
return compRow({
|
||||
icon: GROUP_ICON[g.kind],
|
||||
tone: GROUP_TONE[g.tone],
|
||||
title,
|
||||
// a server turned off: «off» at the row's end says why nothing of it ran
|
||||
line: names.length && g.tone !== 'off' ? names : undefined,
|
||||
acts: [count],
|
||||
cls: 'ov-grp',
|
||||
});
|
||||
}
|
||||
|
||||
/** What passed, all of it on the page: a row for each thing the checks are about. */
|
||||
function groups(c: OverviewCtx): HTMLElement | null {
|
||||
const gs = checkGroups(c.checks ?? [], c.st.servers);
|
||||
return gs.length ? h('div', { class: 'checks ov-groups' }, ...gs.map(groupRow)) : null;
|
||||
}
|
||||
|
||||
/** The watchdog in one line; null: its state could not be read. */
|
||||
function watchdogLine(c: OverviewCtx): HTMLElement | null {
|
||||
const wd = c.sl?.watchdog;
|
||||
if (!wd) return null;
|
||||
const news = systemNews(c.sl);
|
||||
const quiet = news?.kind === 'quiet';
|
||||
const text = quiet
|
||||
? fmt(_('The agent has not checked in for %s min; cron restarts it after 5.'), num(news.minutes))
|
||||
: news
|
||||
? fmt(_('The watchdog repaired %s %s.'), news.name, whenAt(news.ts, c.now(), c.st.tz))
|
||||
: wd.enabled
|
||||
? _('The watchdog is on: nothing needed a repair today.')
|
||||
: _('The watchdog is off.');
|
||||
const kids = [
|
||||
quiet ? glass('pulse', 'orange') : glass('refresh', wd.enabled ? 'green' : 'grey'),
|
||||
h('span', { class: quiet ? 'warn-t' : null }, text),
|
||||
];
|
||||
if (!c.write) return h('span', { class: 'ov-wd' }, ...kids);
|
||||
// its switch: this line is the watchdog's one home
|
||||
const sw = h(
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
class: `swrow ov-wd ov-wd-sw${wd.enabled ? ' on' : ''}`,
|
||||
role: 'switch',
|
||||
'aria-checked': String(wd.enabled),
|
||||
'aria-label': _('Watchdog'),
|
||||
title: _('Looks every minute and repairs the tunnels and services it can. It never reboots the router.'),
|
||||
},
|
||||
...kids,
|
||||
h('span', { class: 'sw' }),
|
||||
) as HTMLButtonElement;
|
||||
sw.addEventListener('click', () => {
|
||||
if (sw.classList.contains('wait')) return;
|
||||
const on = !wd.enabled;
|
||||
sw.classList.toggle('on', on);
|
||||
sw.setAttribute('aria-checked', String(on));
|
||||
flippedNow(sw);
|
||||
void flipping(sw, () =>
|
||||
api
|
||||
.settingsUpdate({ watchdog: on ? '1' : '0' })
|
||||
.then(() => c.reload())
|
||||
.then(
|
||||
() => true,
|
||||
(e) => {
|
||||
notify(errorText(e), 'error', 10000);
|
||||
return false;
|
||||
},
|
||||
),
|
||||
).then((ok) => {
|
||||
if (ok) return;
|
||||
sw.classList.toggle('on', !on);
|
||||
sw.setAttribute('aria-checked', String(!on));
|
||||
});
|
||||
});
|
||||
return sw;
|
||||
}
|
||||
|
||||
/** The checks still running, or the run the router did not answer. */
|
||||
const running = (failed: boolean): HTMLElement =>
|
||||
h(
|
||||
'div',
|
||||
{ class: 'checks' },
|
||||
h(
|
||||
'div',
|
||||
{ class: 'chk run' },
|
||||
h('span', { class: 'dg-m' }, ic(failed ? 'alert' : 'clock')),
|
||||
h(
|
||||
'span',
|
||||
{ class: 'chk-t' },
|
||||
h('b', {}, failed ? _('The checks did not run') : _('Running checks…')),
|
||||
h(
|
||||
'span',
|
||||
{},
|
||||
failed ? _('The router did not answer. Check again in a moment.') : _('DNS, ports, certificates: it takes a moment.'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
function body(c: OverviewCtx, again: HTMLElement): HTMLElement[] {
|
||||
const foot = (first: HTMLElement | null) => h('div', { class: 'ov-hfoot' }, first, again);
|
||||
if (!c.checks)
|
||||
return [
|
||||
secHead(_('Health')),
|
||||
// nothing to press while the first run is on its way
|
||||
h('div', { class: 'card ov-checks' }, running(c.checksFailed), c.checksFailed ? foot(null) : null),
|
||||
];
|
||||
const servers = c.st.servers.map((s) => s.id);
|
||||
const l = checkList(c.checks);
|
||||
const rows = l.failing.map((k) => row(c, k, servers));
|
||||
return [
|
||||
secHead(_('Health'), fmt(_('%s of %s passed'), num(l.ok), num(l.of))),
|
||||
...(l.top ? [notice(c, l.top, servers)] : []),
|
||||
h('div', { class: 'card ov-checks' }, rows.length ? h('div', { class: 'checks' }, ...rows) : null, groups(c), foot(watchdogLine(c))),
|
||||
];
|
||||
}
|
||||
|
||||
export function healthSection(): HealthSection {
|
||||
const el = h('section', { class: 'ov-health', id: 'health' });
|
||||
let cur: OverviewCtx | null = null;
|
||||
const again = h(
|
||||
'button',
|
||||
{ type: 'button', class: 'pill-link ov-again' },
|
||||
ic('refresh'),
|
||||
h('span', {}, _('Check again')),
|
||||
) as HTMLButtonElement;
|
||||
const root = () => el.getRootNode() as Document | ShadowRoot;
|
||||
again.addEventListener(
|
||||
'click',
|
||||
() =>
|
||||
void once(again, async () => {
|
||||
await cur?.recheck();
|
||||
}).then(() => {
|
||||
// busy, the button could not hold the focus, and the repaint took it out and put it back: once it can be
|
||||
// pressed again the focus is on it, unless it went elsewhere meanwhile
|
||||
const a = root().activeElement;
|
||||
if (again.isConnected && (!a || a === document.body)) again.focus({ preventScroll: true });
|
||||
}),
|
||||
);
|
||||
return {
|
||||
el,
|
||||
update(c, quiet) {
|
||||
cur = c;
|
||||
const held = focusInside(again);
|
||||
// left as it is under the focus: the page draws it once the focus leaves (state/regions.ts drawn)
|
||||
if (quiet && !held && focusInside(el)) return false;
|
||||
// checks coming, going or changing their state unfold, fold and morph (ui/reshape.ts)
|
||||
refill(
|
||||
el,
|
||||
body(c, again).filter((x): x is HTMLElement => !!x),
|
||||
);
|
||||
if (held && again.isConnected) again.focus({ preventScroll: true });
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user