Dawnline 0.16.1
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 / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions

- Checking one component for updates in Components no longer fails
  with "XHR request timed out": the check starts at once instead of
  keeping the page waiting twenty seconds
- On a router without curl, updates and the installer download release
  files through GitHub's API: GitHub's own download links can make
  OpenWrt's built-in downloader hang
- Adding a device in the admin offers the same four types as the
  personal page: PC, Mobile, Router and Other (phones and tablets are
  one choice)
This commit is contained in:
Aemeath committed 2026-10-26 06:41:54 +03:00
1 parent 2388603322
commit 0fd22b917a
20 files changed
+179 -73

No files matched your search

+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "dawnline-web",
"version": "0.16.0",
"version": "0.16.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "dawnline-web",
"version": "0.16.0",
"version": "0.16.1",
"license": "MIT",
"dependencies": {
"qrcode-generator": "2.0.4"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "dawnline-web",
"version": "0.16.0",
"version": "0.16.1",
"private": true,
"license": "MIT",
"type": "module",
+27 -12
View File
@@ -17,7 +17,20 @@ import { isOn, sw } from './ui/controls';
import { qrCode } from './ui/qr';
import { deviceNameHelp, type Help } from './netcheck';
import { deviceStatus } from './ui/badges';
import { ago, bytes, defaultName, fitName, homeOf, isoDay, kindLabel, KINDS, netsLabel, todayOf } from '../shared/format';
import {
ago,
bytes,
defaultName,
fitName,
homeOf,
isoDay,
kindLabel,
netsLabel,
pickLabel,
PICKS,
todayOf,
type KindPick,
} from '../shared/format';
import { guardDeviceName } from '../shared/name-guard';
import { fill, fmt, locale, num } from '../shared/i18n';
import { icon } from '../shared/icons';
@@ -610,44 +623,46 @@ export function addDevice(person: Person, o: DeviceOpts) {
while (taken.some((t) => t.toLowerCase() === name.toLowerCase())) name = fitName(base, ` ${++n}`);
return name;
};
let kind: Kind = 'phone';
// Mobile from here is a phone: the admin is never on the device itself (see KindPick).
const kindOf = (p: KindPick): Kind => (p === 'mobile' ? 'phone' : p);
let pick: KindPick = 'mobile';
const nameInput = E('input', {
type: 'text',
class: 'cbi-input-text',
placeholder: suggest(kind),
placeholder: suggest(kindOf(pick)),
}) as HTMLInputElement;
const said = nameGuard(nameInput, () => nameRow.refresh());
const nameRow = liveField(_('Name'), nameInput, () =>
said(
nameInput.value.trim()
? deviceNameHelp(nameInput.value, taken, _('Shown in the portal and in the app.'))
: { text: fmt(_('Named after its type: %s.'), suggest(kind)), bad: false },
: { text: fmt(_('Named after its type: %s.'), suggest(kindOf(pick))), bad: false },
),
);
const kinds = E(
'div',
{ class: 'dl-kinds', role: 'radiogroup', 'aria-label': _('Type') },
KINDS.map((k) =>
PICKS.map((k) =>
E(
'button',
{
type: 'button',
role: 'radio',
class: k === kind ? 'on' : '',
'aria-checked': k === kind ? 'true' : 'false',
class: k === pick ? 'on' : '',
'aria-checked': k === pick ? 'true' : 'false',
'data-kind': k,
click: () => {
kind = k;
pick = k;
kinds.querySelectorAll('button').forEach((c) => {
const on = (c as HTMLElement).dataset.kind === k;
c.classList.toggle('on', on);
c.setAttribute('aria-checked', on ? 'true' : 'false');
});
nameInput.placeholder = suggest(k);
nameInput.placeholder = suggest(kindOf(k));
nameRow.refresh();
},
},
[icon(k), E('span', {}, kindLabel(k))],
[icon(k), E('span', {}, pickLabel(k))],
),
),
);
@@ -704,8 +719,8 @@ export function addDevice(person: Person, o: DeviceOpts) {
notify(h.text, 'warning');
return;
}
const name = nameInput.value.trim() || suggest(kind);
const r = await attempt(() => api.deviceCreate(person.id, name, kind, isOn(bypass)));
const name = nameInput.value.trim() || suggest(kindOf(pick));
const r = await attempt(() => api.deviceCreate(person.id, name, kindOf(pick), isOn(bypass)));
if (!r) return;
closeModal();
notify(fmt(_('%s added'), name), 'success', 3000);
+1 -1
View File
@@ -180,7 +180,7 @@
.dl-fld { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; }
.dl-fld-label { font-size: 13px; font-weight: 500; color: var(--dl-fg); }
.dl-fld .cbi-input-text { width: 100%; box-sizing: border-box; }
.dl-kinds { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.dl-kinds { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.dl-kinds button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
height: 68px; border-radius: 10px; border: 1px solid var(--dl-line); color: var(--dl-fg-muted); font-size: 12px; font-weight: 500; text-align: center; min-width: 0; }
.dl-kinds button .dl-icon { width: 20px; height: 20px; }
+2 -1
View File
@@ -93,7 +93,8 @@ export async function runOperation(what: string | null, o: OpOptions, follow?: U
prevId = before?.job?.id;
since = before?.now ?? 0;
const r = await api.updatesRun(what!);
if (r.job && r.job.state === 'running' && r.job.id !== prevId) {
// A quick check may already be over: still this click's job (updates_run never returns an older one).
if (r.job && r.job.id !== prevId) {
job = r.job;
known(r.job);
}
+8 -15
View File
@@ -7,7 +7,7 @@
// to add it there.
import type { ClientConfig, Kind } from '../../shared/types';
import { defaultName, fitName, kindLabel, netsLabel } from '../../shared/format';
import { defaultName, fitName, netsLabel, pickLabel, pickOf, PICKS, type KindPick } from '../../shared/format';
import { guardDeviceName } from '../../shared/name-guard';
import { shake } from '../../shared/shake';
import { fmt, num, plural } from '../../shared/i18n';
@@ -77,15 +77,8 @@ function guessName(kind: Kind): string {
return defaultName(kind);
}
/*
* Phones and tablets are one choice. The device is still kept as a phone or a
* tablet (the lines say "the tablet"): on the device itself the browser tells
* which; picked from elsewhere it is a phone.
*/
type Pick = 'computer' | 'mobile' | 'router' | 'other';
const pickLabel = (p: Pick): string => (p === 'mobile' ? _('Mobile') : kindLabel(p));
const pickOf = (k: Kind): Pick => (k === 'phone' || k === 'tablet' ? 'mobile' : k);
const kindOf = (p: Pick): Kind => (p !== 'mobile' ? p : guessKind() === 'tablet' ? 'tablet' : 'phone');
// Mobile is a tablet when this page is open on one (see KindPick).
const kindOf = (p: KindPick): Kind => (p !== 'mobile' ? p : guessKind() === 'tablet' ? 'tablet' : 'phone');
/**
* What they chose so far, kept outside the view: Back from "Open on the device"
@@ -93,7 +86,7 @@ const kindOf = (p: Pick): Kind => (p !== 'mobile' ? p : guessKind() === 'tablet'
* typed (unset while the name is still the guess).
*/
interface Draft {
pick?: Pick;
pick?: KindPick;
bypass: boolean;
name?: string;
}
@@ -142,11 +135,11 @@ function vAdd(draft: Draft): View {
const st = state()!;
const p = st.person;
// The kinds this router takes, as the four choices.
const picks = (['computer', 'mobile', 'router', 'other'] as Pick[]).filter((k) => st.kinds.some((x) => pickOf(x) === k));
const picks = PICKS.filter((k) => st.kinds.some((x) => pickOf(x) === k));
const guess = picks.includes(pickOf(guessKind())) ? pickOf(guessKind()) : picks[0];
let pick: Pick = draft.pick && picks.includes(draft.pick) ? draft.pick : guess;
let pick: KindPick = draft.pick && picks.includes(draft.pick) ? draft.pick : guess;
const taken = new Set(p.devices.map((d) => d.name.toLowerCase()));
const suggest = (k: Pick) => {
const suggest = (k: KindPick) => {
const n = k === pickOf(guessKind()) ? guessName(kindOf(k)) : defaultName(k === 'mobile' ? 'phone' : k);
// Stripped of what the router refuses and cut to its limit, the number after it too ("Galaxy S24+ 2").
if (!taken.has(fitName(n).toLowerCase())) return fitName(n);
@@ -230,7 +223,7 @@ function vAdd(draft: Draft): View {
if (draft.name === undefined && pick === pickOf(guessKind())) input.value = suggest(pick);
});
// The picked tile rings itself where it stands (the ring does not travel between tiles).
function choose(k: Pick) {
function choose(k: KindPick) {
pick = draft.pick = k;
tiles.forEach((t, i) => {
const on = picks[i] === k;
+1 -1
View File
@@ -808,7 +808,7 @@ msgstr ""
msgid "Method not allowed."
msgstr ""
#: web/src/portal/flows/add.ts
#: web/src/shared/format.ts
msgid "Mobile"
msgstr ""
+1 -1
View File
@@ -813,7 +813,7 @@ msgstr "Мбит/с"
msgid "Method not allowed."
msgstr "Метод не поддерживается."
#: web/src/portal/flows/add.ts
#: web/src/shared/format.ts
msgid "Mobile"
msgstr "Мобильный"
+13 -3
View File
@@ -222,13 +222,23 @@ export function defaultName(k: Kind): string {
return k === 'other' ? _('Device') : kindLabel(k);
}
/** In picker order. */
export const KINDS: Kind[] = ['computer', 'phone', 'tablet', 'router', 'other'];
export function kindLabel(k: Kind): string {
return { computer: _('PC'), phone: _('Phone'), tablet: _('Tablet'), router: _('Router'), other: _('Other') }[k];
}
/**
* Adding a device, phones and tablets are one choice. The device is still
* kept as a phone or a tablet (the lines say "the tablet"): on the device
* itself the browser tells which; picked from elsewhere it is a phone.
*/
export type KindPick = 'computer' | 'mobile' | 'router' | 'other';
/** In picker order. */
export const PICKS: KindPick[] = ['computer', 'mobile', 'router', 'other'];
export const pickLabel = (p: KindPick): string => (p === 'mobile' ? _('Mobile') : kindLabel(p));
export const pickOf = (k: Kind): KindPick => (k === 'phone' || k === 'tablet' ? 'mobile' : k);
export function stateLabel(s: PersonState): string {
return {
active: _('Active'),
+3
View File
@@ -4,6 +4,9 @@ const P: Record<string, string> = {
phone: '<rect x="7" y="2.5" width="10" height="19" rx="2.2"/><path d="M11 18.5h2"/>',
computer: '<rect x="3" y="4.5" width="18" height="12" rx="1.8"/><path d="M2 19.5h20"/>',
tablet: '<rect x="4.5" y="2.5" width="15" height="19" rx="2.2"/><path d="M11 18.5h2"/>',
// Phones and tablets as one choice (KindPick): a phone in front of a tablet, which stops short of it.
mobile:
'<path d="M9.5 6V4.7a2.2 2.2 0 0 1 2.2-2.2h7.1a2.2 2.2 0 0 1 2.2 2.2v11.6a2.2 2.2 0 0 1-2.2 2.2H14"/><rect x="3" y="8" width="8.5" height="13.5" rx="2.2"/><path d="M6.5 18.5h1.5"/>',
router: '<rect x="3" y="13" width="18" height="7" rx="1.8"/><path d="M7 16.5h.01M10.5 16.5h.01M8 13l-2-6M16 13l2-6"/>',
server:
'<rect x="3" y="4" width="18" height="7" rx="1.8"/><rect x="3" y="13" width="18" height="7" rx="1.8"/><path d="M7 7.5h.01M7 16.5h.01M11 7.5h6M11 16.5h6"/>',