Files
dawnline/web/src/admin/pages/components/packages.ts
T
Aemeath 2f2aaf6c34
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Canceled after 0s
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Canceled after 0s
CI / ucode static checks (push) Canceled after 0s
CI / ShellCheck (push) Canceled after 0s
CI / Web (format, types, tests, bundles) (push) Canceled after 0s
Build packages / CI (push) Canceled after 0s
Build packages / Version (push) Canceled after 0s
Build packages / Build apk (push) Canceled after 0s
Build packages / Build ipk (push) Canceled after 0s
Build packages / Release (push) Canceled after 0s
Dawnline 0.11.0
- Russian translation. The admin pages, the LuCI menu and the router's
  messages (errors, Health checks, update steps, the service log) come in
  Russian with the new luci-i18n-dawnline-ru package, released beside the
  app. LuCI shows it when its language is Russian, or "auto" with a Russian
  browser
- The translation installs with install.sh when LuCI is in Russian (or with
  --lang ru), follows every Dawnline update and rollback, and can be added
  or removed in Components → Dawnline → Translation
- The portal speaks the visitor's language: it opens in the system's
  language and switches between English and Russian in place, from the
  language pill beside its QR code. It carries its own translation and needs
  no package
- Set-up steps quote the apps' own menus word for word, in Russian too:
  AmneziaVPN is "+ → Insert → Continue" (it has no "Add server"), and the
  Mac and Windows menus of WireGuard and AmneziaWG have their real names
- Questions in the portal (Reconnect, Remove) read from the left edge and
  close with Cancel, without ×
- Numbers, sizes and dates follow the page's language. A server that can't
  start says why in one sentence; event details and service log lines read
  as whole sentences
- README in Russian (README_ru.md). rules/i18n.md: how strings are written
  and translated; CI checks the catalogs (npm run i18n:check)
2026-10-20 19:33:52 +03:00

110 lines
3.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Components → system packages: one row per feature in use (the home-like
// link; HTTPS and certificates while the portal is on).
import type { UpdateComponent } from '../../api';
import { button } from '../../ui/button';
import { confirmDialog } from '../../ui/modal';
import { E } from '../../e';
import { fmt } from '../../../shared/i18n';
import type { ComponentsPage, MenuEntry } from './index';
interface SysItem {
title: string;
sub: string;
pkgs: string[];
feature: 'home' | 'https' | 'acme';
optional?: boolean;
}
function sysItems(): SysItem[] {
return [
{ title: _('Home-like link'), sub: _('Policy routing and the veth pair'), pkgs: ['ip-full', 'kmod-veth'], feature: 'home' },
{ title: _('HTTPS for the portal'), sub: _('OpenSSL for uhttpd'), pkgs: ['libustream-openssl', 'openssl-util'], feature: 'https' },
{
title: _('Certificates (ACME)'),
sub: _('Let’s Encrypt certificate for the portal'),
pkgs: ['acme', 'acme-acmesh-dnsapi'],
feature: 'acme',
optional: true,
},
];
}
const ICONS: Record<string, string> = { home: 'network', https: 'lock', acme: 'file' };
export function packageRows(page: ComponentsPage, p: UpdateComponent | undefined): { rows: Node[]; updates: number; total: number } {
const st = page.st;
const pkgs = p?.pkgs ?? {};
const items = sysItems().filter((it) => (it.feature === 'home' ? st.home : st.portal));
const runPkgs = async (names: string[], what: string, shown = names) => {
const ok = await confirmDialog(
fmt(_('Update %s?'), what),
fmt(_('%s from the OpenWrt feeds. Services that use them restart for a moment.'), shown.join(', ')),
_('Update'),
);
if (ok) void page.op(`pkgs:${names.join(',')}`, fmt(_('Updating %s'), what));
};
const menu: (MenuEntry | null)[] = [
{ label: _('Check system packages'), ic: 'refresh', run: () => page.op('check:packages', _('Checking system packages')) },
{
label: _('Open the OpenWrt package list'),
ic: 'globe',
run: () => window.open('https://openwrt.org/packages/start', '_blank', 'noopener'),
},
];
let updates = 0;
const rows = items.map((it) => {
const present = it.pkgs.filter((x) => pkgs[x]?.installed);
const upd = [...new Set(present.flatMap((x) => [...(pkgs[x]?.latest ? [x] : []), ...(pkgs[x]?.with ?? [])]))];
const lacks = st.needs?.[it.feature] ?? it.pkgs.filter((x) => !pkgs[x]?.installed);
const main = present.find((x) => pkgs[x]?.latest);
const vers = present.map((x) => `${x} ${pkgs[x]?.installed ?? ''}`).join(', ');
if (lacks.length)
return page.row(
ICONS[it.feature],
it.title,
[it.optional ? _('not installed') : fmt(_('missing %s'), lacks.join(', '))],
[
button(
_('Install'),
() => page.op(`pkgs:${lacks.join(',')}`, fmt(_('Installing %s'), it.title)),
it.optional ? 'neutral' : 'positive',
{
disabled: page.busy,
},
),
E('span', { class: 'dl-comp-ic' }, page.more(menu)),
],
);
if (p && upd.length) {
updates++;
return page.row(
ICONS[it.feature],
it.title,
main ? [`${pkgs[main]!.installed} → ${pkgs[main]!.latest}`, upd.length > 1 ? ` · +${upd.length - 1}` : ''] : [upd.join(', ')],
[
button(
_('Update'),
() =>
runPkgs(
present.filter((x) => pkgs[x]?.latest || pkgs[x]?.with?.length),
it.title,
upd,
),
'neutral',
{ disabled: page.busy },
),
E('span', { class: 'dl-comp-ic' }, page.more(menu)),
],
);
}
return page.row(
ICONS[it.feature],
it.title,
[vers || it.sub],
[page.state('pkgs', p, ''), E('span', { class: 'dl-comp-ic' }, page.more(menu))],
);
});
return { rows, updates, total: items.length };
}