Dawnline 0.16.3
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

- Move Dawnline to Services in LuCI and update links and documentation.
- Make activity messages clearer, including device renames and person-specific history.
- Prune redundant frontend tests.
This commit is contained in:
Aemeath committed 2026-10-31 12:21:53 +03:00
1 parent f2b5ba101b
commit b0d9982796
37 files changed
+452 -243

No files matched your search

+1 -1
View File
@@ -64,7 +64,7 @@ follows a modern design.
sh -c "$(wget -qO- https://raw.githubusercontent.com/tickcount/luci-app-dawnline/main/install.sh)"
```
2. **Set up** in LuCI: <kbd>Network</kbd> › <kbd>Dawnline</kbd>, and follow the
2. **Set up** in LuCI: <kbd>Services</kbd> › <kbd>Dawnline</kbd>, and follow the
wizard. It suggests the port, the public address and the networks.
3. **Invite** someone: <kbd>Add person</kbd>, then send them the link or the
invite card with its QR code. They do the rest.
+1 -1
View File
@@ -65,7 +65,7 @@ Dawnline запускает сервер [AmneziaWG] на вашем роуте
sh -c "$(wget -qO- https://raw.githubusercontent.com/tickcount/luci-app-dawnline/main/install.sh)"
```
2. **Настройте** в LuCI: <kbd>Network</kbd> › <kbd>Dawnline</kbd>, дальше по
2. **Настройте** в LuCI: <kbd>Services</kbd> › <kbd>Dawnline</kbd>, дальше по
мастеру. Он предложит порт, публичный адрес и сети.
3. **Пригласите** человека: <kbd>Добавить человека</kbd>, затем отправьте ему
ссылку или карточку приглашения с QR-кодом. Остальное он сделает сам.
+3 -3
View File
@@ -1443,7 +1443,7 @@ on_pipe() {
lan_url() {
_ip="$(uci -q get network.lan.ipaddr 2>/dev/null | cut -d/ -f1 | awk '{ print $1 }')"
[ -n "$_ip" ] || _ip="192.168.1.1"
printf 'http://%s/cgi-bin/luci/admin/network/dawnline/server' "$_ip"
printf 'http://%s/cgi-bin/luci/admin/services/dawnline/server' "$_ip"
}
main() {
@@ -1513,9 +1513,9 @@ main() {
msg "Log: $LOG_FILE"
msg "Recovery snapshot: $SNAPSHOT_DIR"
if [ "$MODE" = install ]; then
msg "Open LuCI → Network → Dawnline and run the setup wizard:"
msg "Open LuCI → Services → Dawnline and run the setup wizard:"
else
msg "Open LuCI → Network → Dawnline:"
msg "Open LuCI → Services → Dawnline:"
fi
msg " $(lan_url)"
awg_netifd_restart
+1 -1
View File
@@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-dawnline
PKG_VERSION:=0.16.2
PKG_VERSION:=0.16.3
PKG_RELEASE:=1
PKG_LICENSE:=MIT
# po/<lang>/dawnline.po becomes luci-i18n-dawnline-<lang> (luci.mk), released
+131
View File
@@ -1239,6 +1239,13 @@ msgstr "Срок доступа"
msgid "Access ends %s"
msgstr "Окончание доступа: %s"
#: web/src/admin/events/render.ts
msgid "Access ends in %s day"
msgid_plural "Access ends in %s days"
msgstr[0] "Доступ закончится через %s день"
msgstr[1] "Доступ закончится через %s дня"
msgstr[2] "Доступ закончится через %s дней"
#: web/src/admin/netcheck.ts
msgid "Access ends in %s day (%s)."
msgid_plural "Access ends in %s days (%s)."
@@ -1246,6 +1253,10 @@ msgstr[0] "Доступ закончится через %s день (%s)."
msgstr[1] "Доступ закончится через %s дня (%s)."
msgstr[2] "Доступ закончится через %s дней (%s)."
#: web/src/admin/events/render.ts
msgid "Access ends in a few days"
msgstr "Доступ закончится через несколько дней"
#: web/src/admin/netcheck.ts
msgid "Access ends today (%s)."
msgstr "Доступ закончится сегодня (%s)."
@@ -1254,6 +1265,22 @@ msgstr "Доступ закончится сегодня (%s)."
msgid "Access must be lan, internet or both."
msgstr "Доступ должен быть lan, internet или both."
#: web/src/admin/events/render.ts
msgid "Access paused"
msgstr "Доступ на паузе"
#: web/src/admin/events/render.ts
msgid "Access paused - %s"
msgstr "Доступ на паузе: %s"
#: web/src/admin/events/render.ts
msgid "Access resumed"
msgstr "Доступ возобновлён"
#: web/src/admin/events/render.ts
msgid "Access resumed - %s"
msgstr "Доступ возобновлён: %s"
#: package/luci-app-dawnline/root/usr/libexec/dawnline/agent
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/watchdog.uc
@@ -1441,6 +1468,10 @@ msgstr "Все проверки пройдены."
msgid "All components"
msgstr "Все компоненты"
#: web/src/admin/events/render.ts
msgid "All devices removed, end date reached"
msgstr "Все устройства удалены: срок доступа закончился"
#: web/src/admin/pages/overview.ts
msgid "All good. Nothing needs you right now."
msgstr "Всё в порядке. Сейчас ничего не требует вашего внимания."
@@ -2579,6 +2610,18 @@ msgstr "Сведения"
msgid "Device"
msgstr "Устройство"
#: web/src/admin/events/render.ts
msgid "Device %s added"
msgstr "Устройство %s добавлено"
#: web/src/admin/events/render.ts
msgid "Device %s added on the portal"
msgstr "Устройство %s добавлено через портал"
#: web/src/admin/events/render.ts
msgid "Device %s changed"
msgstr "Устройство %s: настройки изменены"
#: web/src/admin/events/render.ts
msgid "Device %s changed network %s"
msgstr "Устройство %s сменило сеть %s"
@@ -2643,6 +2686,30 @@ msgstr "Устройство %s (%s): публичный ключ некорре
msgid "Device %s of %s: the public key is the server's own."
msgstr "Устройство %s (%s): публичный ключ совпадает с ключом сервера."
#: web/src/admin/events/render.ts
msgid "Device %s removed"
msgstr "Устройство %s удалено"
#: web/src/admin/events/render.ts
msgid "Device %s removed on the portal"
msgstr "Устройство %s удалено через портал"
#: web/src/admin/events/render.ts
msgid "Device %s renamed"
msgstr "Устройство %s: название изменено"
#: web/src/admin/events/render.ts
msgid "Device %s renamed on the portal"
msgstr "Устройство %s: название изменено через портал"
#: web/src/admin/events/render.ts
msgid "Device %s turned off"
msgstr "Устройство %s выключено"
#: web/src/admin/events/render.ts
msgid "Device %s turned on"
msgstr "Устройство %s включено"
#: web/src/admin/events/render.ts
msgid "Device %s went offline"
msgstr "Устройство %s отключилось"
@@ -2935,6 +3002,10 @@ msgstr "Дата окончания"
msgid "End date must be YYYY-MM-DD."
msgstr "Дата окончания должна быть в формате ГГГГ-ММ-ДД."
#: web/src/admin/events/render.ts
msgid "End date passed (%s) · access kept"
msgstr "Срок доступа закончился (%s) · доступ сохранён"
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
msgid "End dates and quotas use the router clock."
msgstr "Даты окончания и лимиты трафика считаются по часам роутера."
@@ -4282,6 +4353,10 @@ msgstr "Ключи обновлены %s"
msgid "New keys generated"
msgstr "Новые ключи созданы"
#: web/src/admin/events/render.ts
msgid "New keys issued for device %s on the portal"
msgstr "Для устройства %s выпущены новые ключи через портал"
#: web/src/admin/pages/person/header.ts
msgid "New link"
msgstr "Новая ссылка"
@@ -5075,6 +5150,10 @@ msgstr "%s: удалено устройство %s"
msgid "Person %s removed device %s on their portal"
msgstr "%s: удалено устройство %s через портал"
#: web/src/admin/events/render.ts
msgid "Person %s renamed device %s on their portal"
msgstr "Пользователь %s изменил название устройства %s в личном портале"
#: web/src/admin/events/render.ts
msgid "Person %s resumed"
msgstr "%s: доступ возобновлён"
@@ -7338,6 +7417,10 @@ msgstr "Вы"
msgid "You added circle %s"
msgstr "Вы добавили круг %s"
#: web/src/admin/events/render.ts
msgid "You added device %s"
msgstr "Вы добавили устройство %s"
#: web/src/admin/events/render.ts
msgid "You added device %s for %s"
msgstr "Вы добавили устройство %s (%s)"
@@ -7346,10 +7429,18 @@ msgstr "Вы добавили устройство %s (%s)"
msgid "You added person %s"
msgstr "Вы добавили человека %s"
#: web/src/admin/events/render.ts
msgid "You added this person"
msgstr "Вы добавили этого человека"
#: web/src/admin/events/model.ts
msgid "You changed circle %s"
msgstr "Вы изменили круг %s"
#: web/src/admin/events/render.ts
msgid "You changed device %s"
msgstr "Вы изменили устройство %s"
#: web/src/admin/events/render.ts
msgid "You changed device %s of %s"
msgstr "Вы изменили устройство %s (%s)"
@@ -7362,6 +7453,10 @@ msgstr "Вы изменили настройки: %s"
msgid "You changed server %s"
msgstr "Вы изменили сервер %s"
#: web/src/admin/events/render.ts
msgid "You changed settings"
msgstr "Вы изменили настройки"
#: web/src/admin/events/model.ts
msgid "You changed the personal portal"
msgstr "Вы изменили настройки личного портала"
@@ -7390,10 +7485,22 @@ msgstr "Вы импортировали настройки из файла"
msgid "You issued a new link for person %s"
msgstr "Вы выпустили новую личную ссылку: %s"
#: web/src/admin/events/render.ts
msgid "You issued a new personal link"
msgstr "Вы выпустили новую личную ссылку"
#: web/src/admin/events/render.ts
msgid "You issued new keys for device %s"
msgstr "Вы выпустили новые ключи для устройства %s"
#: web/src/admin/events/render.ts
msgid "You issued new keys for device %s of %s"
msgstr "Вы выпустили новые ключи для устройства %s (%s)"
#: web/src/admin/events/render.ts
msgid "You paused access"
msgstr "Вы приостановили доступ"
#: web/src/admin/events/render.ts
msgid "You paused person %s"
msgstr "Вы приостановили доступ: %s"
@@ -7402,6 +7509,10 @@ msgstr "Вы приостановили доступ: %s"
msgid "You removed circle %s"
msgstr "Вы удалили круг %s"
#: web/src/admin/events/render.ts
msgid "You removed device %s"
msgstr "Вы удалили устройство %s"
#: web/src/admin/events/render.ts
msgid "You removed device %s from %s"
msgstr "Вы удалили устройство %s (%s)"
@@ -7414,6 +7525,14 @@ msgstr "Вы удалили человека %s"
msgid "You removed server %s"
msgstr "Вы удалили сервер %s"
#: web/src/admin/events/render.ts
msgid "You removed this person"
msgstr "Вы удалили этого человека"
#: web/src/admin/events/render.ts
msgid "You renamed device %s"
msgstr "Вы изменили название устройства %s"
#: web/src/admin/events/render.ts
msgid "You renamed device %s of %s"
msgstr "Вы переименовали устройство %s (%s)"
@@ -7434,10 +7553,18 @@ msgstr "Вы восстановили резервную копию из фай
msgid "You restored backup %s"
msgstr "Вы восстановили резервную копию %s"
#: web/src/admin/events/render.ts
msgid "You resumed access"
msgstr "Вы возобновили доступ"
#: web/src/admin/events/render.ts
msgid "You resumed person %s"
msgstr "Вы возобновили доступ: %s"
#: web/src/admin/events/render.ts
msgid "You turned off device %s"
msgstr "Вы выключили устройство %s"
#: web/src/admin/events/render.ts
msgid "You turned off device %s of %s"
msgstr "Вы выключили устройство %s (%s)"
@@ -7454,6 +7581,10 @@ msgstr "Вы выключили личный портал"
msgid "You turned off the watchdog"
msgstr "Вы выключили автовосстановление"
#: web/src/admin/events/render.ts
msgid "You turned on device %s"
msgstr "Вы включили устройство %s"
#: web/src/admin/events/render.ts
msgid "You turned on device %s of %s"
msgstr "Вы включили устройство %s (%s)"
@@ -1187,12 +1187,22 @@ msgstr ""
msgid "Access ends %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Access ends in %s day"
msgid_plural "Access ends in %s days"
msgstr[0] ""
msgstr[1] ""
#: web/src/admin/netcheck.ts
msgid "Access ends in %s day (%s)."
msgid_plural "Access ends in %s days (%s)."
msgstr[0] ""
msgstr[1] ""
#: web/src/admin/events/render.ts
msgid "Access ends in a few days"
msgstr ""
#: web/src/admin/netcheck.ts
msgid "Access ends today (%s)."
msgstr ""
@@ -1201,6 +1211,22 @@ msgstr ""
msgid "Access must be lan, internet or both."
msgstr ""
#: web/src/admin/events/render.ts
msgid "Access paused"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Access paused - %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Access resumed"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Access resumed - %s"
msgstr ""
#: package/luci-app-dawnline/root/usr/libexec/dawnline/agent
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/watchdog.uc
@@ -1387,6 +1413,10 @@ msgstr ""
msgid "All components"
msgstr ""
#: web/src/admin/events/render.ts
msgid "All devices removed, end date reached"
msgstr ""
#: web/src/admin/pages/overview.ts
msgid "All good. Nothing needs you right now."
msgstr ""
@@ -2523,6 +2553,18 @@ msgstr ""
msgid "Device"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Device %s added"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Device %s added on the portal"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Device %s changed"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Device %s changed network %s"
msgstr ""
@@ -2587,6 +2629,30 @@ msgstr ""
msgid "Device %s of %s: the public key is the server's own."
msgstr ""
#: web/src/admin/events/render.ts
msgid "Device %s removed"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Device %s removed on the portal"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Device %s renamed"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Device %s renamed on the portal"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Device %s turned off"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Device %s turned on"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Device %s went offline"
msgstr ""
@@ -2879,6 +2945,10 @@ msgstr ""
msgid "End date must be YYYY-MM-DD."
msgstr ""
#: web/src/admin/events/render.ts
msgid "End date passed (%s) · access kept"
msgstr ""
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
msgid "End dates and quotas use the router clock."
msgstr ""
@@ -4226,6 +4296,10 @@ msgstr ""
msgid "New keys generated"
msgstr ""
#: web/src/admin/events/render.ts
msgid "New keys issued for device %s on the portal"
msgstr ""
#: web/src/admin/pages/person/header.ts
msgid "New link"
msgstr ""
@@ -5017,6 +5091,10 @@ msgstr ""
msgid "Person %s removed device %s on their portal"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Person %s renamed device %s on their portal"
msgstr ""
#: web/src/admin/events/render.ts
msgid "Person %s resumed"
msgstr ""
@@ -7270,6 +7348,10 @@ msgstr ""
msgid "You added circle %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You added device %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You added device %s for %s"
msgstr ""
@@ -7278,10 +7360,18 @@ msgstr ""
msgid "You added person %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You added this person"
msgstr ""
#: web/src/admin/events/model.ts
msgid "You changed circle %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You changed device %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You changed device %s of %s"
msgstr ""
@@ -7294,6 +7384,10 @@ msgstr ""
msgid "You changed server %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You changed settings"
msgstr ""
#: web/src/admin/events/model.ts
msgid "You changed the personal portal"
msgstr ""
@@ -7322,10 +7416,22 @@ msgstr ""
msgid "You issued a new link for person %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You issued a new personal link"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You issued new keys for device %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You issued new keys for device %s of %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You paused access"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You paused person %s"
msgstr ""
@@ -7334,6 +7440,10 @@ msgstr ""
msgid "You removed circle %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You removed device %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You removed device %s from %s"
msgstr ""
@@ -7346,6 +7456,14 @@ msgstr ""
msgid "You removed server %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You removed this person"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You renamed device %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You renamed device %s of %s"
msgstr ""
@@ -7366,10 +7484,18 @@ msgstr ""
msgid "You restored backup %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You resumed access"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You resumed person %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You turned off device %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You turned off device %s of %s"
msgstr ""
@@ -7386,6 +7512,10 @@ msgstr ""
msgid "You turned off the watchdog"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You turned on device %s"
msgstr ""
#: web/src/admin/events/render.ts
msgid "You turned on device %s of %s"
msgstr ""
@@ -1,10 +1,10 @@
{
"admin/network/dawnline": {
"admin/services/dawnline": {
"title": "Dawnline",
"order": 65,
"action": {
"type": "alias",
"path": "admin/network/dawnline/server"
"path": "admin/services/dawnline/server"
},
"depends": {
"acl": [
@@ -15,31 +15,31 @@
}
}
},
"admin/network/dawnline/overview": {
"admin/services/dawnline/overview": {
"action": {
"type": "view",
"path": "dawnline/server"
}
},
"admin/network/dawnline/people": {
"admin/services/dawnline/people": {
"action": {
"type": "view",
"path": "dawnline/people"
}
},
"admin/network/dawnline/activity": {
"admin/services/dawnline/activity": {
"action": {
"type": "view",
"path": "dawnline/activity"
}
},
"admin/network/dawnline/person": {
"admin/services/dawnline/person": {
"action": {
"type": "view",
"path": "dawnline/person"
}
},
"admin/network/dawnline/server": {
"admin/services/dawnline/server": {
"title": "Servers",
"order": 10,
"action": {
@@ -47,7 +47,7 @@
"path": "dawnline/server"
}
},
"admin/network/dawnline/diagnostics": {
"admin/services/dawnline/diagnostics": {
"title": "Diagnostics",
"order": 40,
"action": {
@@ -55,13 +55,13 @@
"path": "dawnline/diagnostics"
}
},
"admin/network/dawnline/health": {
"admin/services/dawnline/health": {
"action": {
"type": "view",
"path": "dawnline/health"
}
},
"admin/network/dawnline/settings": {
"admin/services/dawnline/settings": {
"title": "Settings",
"order": 60,
"action": {
@@ -69,7 +69,7 @@
"path": "dawnline/settings"
}
},
"admin/network/dawnline/updates": {
"admin/services/dawnline/updates": {
"title": "Components",
"order": 70,
"action": {
@@ -5,7 +5,7 @@
import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs';
import { _ } from 'dawnline.i18n';
export const VERSION = '0.16.2';
export const VERSION = '0.16.3';
/** GitHub repository with Dawnline releases (updates and the installer). */
export const REPO = 'tickcount/luci-app-dawnline';
export const RUN_DIR = '/var/run/dawnline';
+1 -1
View File
@@ -83,7 +83,7 @@ for (const [real, shown] of args.names)
args.mask.push([real, shown], [real.toLowerCase(), shown.toLowerCase()], [real.toUpperCase(), shown.toUpperCase()]);
const INITIALS = args.names.map(([real, shown]) => [initials(real), initials(shown)]);
const LUCI = `${args.router}/cgi-bin/luci/admin/network/dawnline`;
const LUCI = `${args.router}/cgi-bin/luci/admin/services/dawnline`;
const USER = process.env.LUCI_USER || 'root';
/*
+1 -1
View File
@@ -63,7 +63,7 @@ Install or upgrade on the router (OpenWrt 24.10 with opkg, or 25.12 with apk):
sh -c "\$(wget -qO- https://raw.githubusercontent.com/$REPO/main/install.sh)"
\`\`\`
Or update from LuCI → Network → Dawnline → Components.
Or update from LuCI → Services → Dawnline → Components.
EOF
if [ -n "$PREV" ]; then
printf '\n**Full Changelog**: https://github.com/%s/compare/%s...%s\n' "$REPO" "$PREV" "$TAG"
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "dawnline-web",
"version": "0.16.2",
"version": "0.16.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "dawnline-web",
"version": "0.16.2",
"version": "0.16.3",
"license": "MIT",
"dependencies": {
"qrcode-generator": "2.0.4"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "dawnline-web",
"version": "0.16.2",
"version": "0.16.3",
"private": true,
"license": "MIT",
"type": "module",
+1 -1
View File
@@ -448,7 +448,7 @@ function overviewTile(srv: Server): HTMLElement {
return E('div', { class: 'dl-bento-tile dl-disg' }, [
E('div', { class: 'dl-bento-head' }, [
E('span', { class: 'dl-metric-label' }, _('Disguise')),
E('a', { href: `${L.url('admin/network/dawnline/server')}?server=${encodeURIComponent(srv.id)}&section=awg` }, _('Change')),
E('a', { href: `${L.url('admin/services/dawnline/server')}?server=${encodeURIComponent(srv.id)}&section=awg` }, _('Change')),
]),
E('div', { class: 'dl-disg-id' }, [
E('span', { class: `dl-disg-ic${m?.id === 'off' ? ' off' : ''}` }, icon(m?.ic ?? 'shield')),
+1 -1
View File
@@ -434,7 +434,7 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) {
},
_('Clear'),
),
E('a', { href: `${L.url('admin/network/dawnline/diagnostics')}?tab=log` }, _('All activity')),
E('a', { href: `${L.url('admin/services/dawnline/diagnostics')}?tab=log` }, _('All activity')),
]),
]),
log,
+92 -29
View File
@@ -69,7 +69,8 @@ function eventIcon(st: Names, e: LogEvent): string {
/** A router day (YYYY-MM-DD) in the page's language; anything else as it came. */
const routerDay = (s: string) => (/^\d{4}-\d{2}-\d{2}$/.test(s) ? fmtDay(s) : s);
export function eventText(st: Pick<Status, 'people'>, e: LogEvent): Node[] {
export function eventText(st: Pick<Status, 'people'>, e: LogEvent, personId?: string): Node[] {
const scoped = personId !== undefined && e.person === personId;
const person = st.people.find((p) => p.id === e.person);
const who = person?.name ?? e.pname ?? e.person ?? '';
const dev = person?.devices.find((d) => d.id === e.device)?.name ?? e.dname ?? '';
@@ -88,33 +89,49 @@ export function eventText(st: Pick<Status, 'people'>, e: LogEvent): Node[] {
const w = _('You');
return s.startsWith(`${w} `) ? [E('span', { class: 'dl-you' }, w), ...say(s.slice(w.length), ...args)] : say(s, ...args);
};
const wd = b(dev ? `${who} · ${dev}` : who);
const wd = b(scoped ? dev || _('a device') : dev ? `${who} · ${dev}` : who);
const detail = plainDetail(e);
const devName = b(detail || dev || _('a device'));
const by = eventBy(e);
if (by === 'admin')
switch (e.type) {
case 'device_added':
return you(_('You added device %s for %s'), devName, b(who));
return scoped ? you(_('You added device %s'), devName) : you(_('You added device %s for %s'), devName, b(who));
case 'device_removed':
return you(_('You removed device %s from %s'), devName, b(who));
return scoped ? you(_('You removed device %s'), devName) : you(_('You removed device %s from %s'), devName, b(who));
case 'paused':
return you(_('You paused person %s'), b(who));
return scoped ? you(_('You paused access')) : you(_('You paused person %s'), b(who));
case 'resumed':
return you(_('You resumed person %s'), b(who));
return scoped ? you(_('You resumed access')) : you(_('You resumed person %s'), b(who));
case 'device_changed': {
const d = b(dev || _('a device'));
if (detail.startsWith('renamed from '))
return [...you(_('You renamed device %s of %s'), d, b(who)), m(` · ${fmt(_('was %s'), detail.slice(13))}`)];
if (detail === 'turned off') return you(_('You turned off device %s of %s'), d, b(who));
if (detail === 'turned on') return you(_('You turned on device %s of %s'), d, b(who));
return [
...(scoped ? you(_('You renamed device %s'), d) : you(_('You renamed device %s of %s'), d, b(who))),
m(` · ${fmt(_('was %s'), detail.slice(13))}`),
];
if (detail === 'turned off')
return scoped ? you(_('You turned off device %s'), d) : you(_('You turned off device %s of %s'), d, b(who));
if (detail === 'turned on')
return scoped ? you(_('You turned on device %s'), d) : you(_('You turned on device %s of %s'), d, b(who));
// Its own link options by name ("mtu, keepalive"), as person_changed lists a person's.
return [...you(_('You changed device %s of %s'), d, b(who)), ...(detail ? [m(` · ${deviceChangedText(detail)}`)] : [])];
return [
...(scoped ? you(_('You changed device %s'), d) : you(_('You changed device %s of %s'), d, b(who))),
...(detail ? [m(` · ${deviceChangedText(detail)}`)] : []),
];
}
case 'device_keys':
return [...you(_('You issued new keys for device %s of %s'), devName, b(who)), m(` · ${_('it needs its new configuration')}`)];
return [
...(scoped
? you(_('You issued new keys for device %s'), devName)
: you(_('You issued new keys for device %s of %s'), devName, b(who))),
m(` · ${_('it needs its new configuration')}`),
];
case 'link_changed':
return [...you(_('You issued a new link for person %s'), b(who)), m(` · ${_('the old link stopped working')}`)];
return [
...(scoped ? you(_('You issued a new personal link')) : you(_('You issued a new link for person %s'), b(who))),
m(` · ${_('the old link stopped working')}`),
];
}
switch (e.type) {
case 'connect':
@@ -136,35 +153,77 @@ export function eventText(st: Pick<Status, 'people'>, e: LogEvent): Node[] {
);
case 'device_added':
return by === 'portal'
? say(_('Person %s added device %s on their portal'), b(who), devName)
: say(_('Person %s added device %s'), b(who), devName);
? scoped
? say(_('Device %s added on the portal'), devName)
: say(_('Person %s added device %s on their portal'), b(who), devName)
: scoped
? say(_('Device %s added'), devName)
: say(_('Person %s added device %s'), b(who), devName);
case 'device_removed':
return by === 'portal'
? say(_('Person %s removed device %s on their portal'), b(who), devName)
: say(_('Person %s removed device %s'), b(who), devName);
? scoped
? say(_('Device %s removed on the portal'), devName)
: say(_('Person %s removed device %s on their portal'), b(who), devName)
: scoped
? say(_('Device %s removed'), devName)
: say(_('Person %s removed device %s'), b(who), devName);
case 'device_changed':
if (detail.startsWith('renamed from '))
return [
...(by === 'portal'
? scoped
? say(_('Device %s renamed on the portal'), b(dev || _('a device')))
: say(_('Person %s renamed device %s on their portal'), b(who), b(dev || _('a device')))
: say(_('Device %s renamed'), wd)),
m(` · ${fmt(_('was %s'), detail.slice(13))}`),
];
if (detail === 'turned off') return say(_('Device %s turned off'), wd);
if (detail === 'turned on') return say(_('Device %s turned on'), wd);
return [...say(_('Device %s changed'), wd), ...(detail ? [m(` · ${deviceChangedText(detail)}`)] : [])];
case 'device_keys':
return say(_('Person %s issued new keys for device %s on their portal'), b(who), devName);
return scoped
? say(_('New keys issued for device %s on the portal'), devName)
: say(_('Person %s issued new keys for device %s on their portal'), b(who), devName);
case 'person_added':
return you(_('You added person %s'), b(e.detail ?? who));
return scoped ? you(_('You added this person')) : you(_('You added person %s'), b(e.detail ?? who));
case 'person_removed':
return you(_('You removed person %s'), b(e.detail ?? who));
return scoped ? you(_('You removed this person')) : you(_('You removed person %s'), b(e.detail ?? who));
case 'person_changed':
// The detail lists changed fields by their option names (device_limit, expire_action).
return [...you(_('You changed person %s'), b(who)), ...(detail ? [m(` · ${changedText(detail)}`)] : [])];
return [
...(scoped ? you(_('You changed settings')) : you(_('You changed person %s'), b(who))),
...(detail ? [m(` · ${changedText(detail)}`)] : []),
];
case 'expiring': {
const n = daysOf(e.detail ?? '');
return n != null
? say(N_(n, 'Person %s’s access ends in %s day', 'Person %s’s access ends in %s days'), b(who), m(num(n)))
: say(_('Person %s’s access ends in a few days'), b(who));
? scoped
? say(N_(n, 'Access ends in %s day', 'Access ends in %s days'), m(num(n)))
: say(N_(n, 'Person %s’s access ends in %s day', 'Person %s’s access ends in %s days'), b(who), m(num(n)))
: scoped
? say(_('Access ends in a few days'))
: say(_('Person %s’s access ends in a few days'), b(who));
}
case 'expired_kept':
return say(_('Person %s’s end date passed (%s) · access kept'), b(who), m(routerDay(e.detail ?? '')));
return scoped
? say(_('End date passed (%s) · access kept'), m(routerDay(e.detail ?? '')))
: say(_('Person %s’s end date passed (%s) · access kept'), b(who), m(routerDay(e.detail ?? '')));
case 'paused':
return e.detail ? say(_('Person %s paused - %s'), b(who), m(reasonText(e.detail))) : say(_('Person %s paused'), b(who));
return e.detail
? scoped
? say(_('Access paused - %s'), m(reasonText(e.detail)))
: say(_('Person %s paused - %s'), b(who), m(reasonText(e.detail)))
: scoped
? say(_('Access paused'))
: say(_('Person %s paused'), b(who));
case 'resumed':
return e.detail && e.detail !== 'active'
? say(_('Person %s resumed - %s'), b(who), m(reasonText(e.detail)))
: say(_('Person %s resumed'), b(who));
? scoped
? say(_('Access resumed - %s'), m(reasonText(e.detail)))
: say(_('Person %s resumed - %s'), b(who), m(reasonText(e.detail)))
: scoped
? say(_('Access resumed'))
: say(_('Person %s resumed'), b(who));
case 'portal_blocked':
return say(
_('%s blocked %s for 15 min after too many wrong codes'),
@@ -172,7 +231,7 @@ export function eventText(st: Pick<Status, 'people'>, e: LogEvent): Node[] {
e.detail === 'all Cloudflare visitors' ? m(_('all Cloudflare visitors')) : mono(e.detail ?? ''),
);
case 'devices_removed':
return say(_('Person %s - all devices removed, end date reached'), b(who));
return scoped ? say(_('All devices removed, end date reached')) : say(_('Person %s - all devices removed, end date reached'), b(who));
case 'device_failing':
return [...say(_('Device %s has a connection problem'), wd), ...(e.detail ? [m(` · ${linkStatesText(e.detail)}`)] : [])];
case 'device_recovered':
@@ -196,7 +255,11 @@ function serverPill(st: Names, e: LogEvent): HTMLElement | '' {
}
/** An activity event as a row; `time` replaces the "5 min ago" (`now` is the router's clock). */
export function eventRow(st: Names & { now?: number }, e: LogEvent, opts: { server?: boolean; time?: string } = {}): HTMLElement {
export function eventRow(
st: Names & { now?: number },
e: LogEvent,
opts: { server?: boolean; time?: string; person?: string } = {},
): HTMLElement {
const sys = SYSTEM_EVENT[e.type];
const by = eventBy(e);
return E('div', { class: `dl-row${by === 'admin' ? ' dl-ev-by-admin' : sys ? ` dl-ev-by-system ${sys[1]}` : ''}` }, [
@@ -205,7 +268,7 @@ export function eventRow(st: Names & { now?: number }, e: LogEvent, opts: { serv
: sys
? E('span', { class: 'dl-ev-tile sys' }, icon(sys[0]))
: E('span', { class: `dl-ev-tile ev ${EVENT_TONE[e.type] ?? ''}` }, icon(eventIcon(st, e))),
E('span', { class: 'dl-row-main' }, eventText(st, e)),
E('span', { class: 'dl-row-main' }, eventText(st, e, opts.person)),
opts.server === false ? '' : serverPill(st, e),
E('span', { class: 'dl-faint dl-nowrap', title: new Date(e.ts * 1000).toLocaleString(locale()) }, opts.time ?? ago(e.ts, st.now)),
]);
+1 -1
View File
@@ -51,7 +51,7 @@ function moved(tab: '' | 'log') {
return () => ({
load: () => {
ui.menu?.flushCache();
location.replace(`${L.url('admin/network/dawnline/diagnostics')}${tab ? `?tab=${tab}` : ''}`);
location.replace(`${L.url('admin/services/dawnline/diagnostics')}${tab ? `?tab=${tab}` : ''}`);
return new Promise(() => {});
},
render: () => document.createElement('div'),
+1 -1
View File
@@ -65,7 +65,7 @@ export function activity(page: ComponentsPage): HTMLElement {
E('div', { class: 'dl-panel-head pad' }, [
E('h3', {}, _('Activity')),
E('span', { class: 'dl-spacer' }),
E('a', { href: `${L.url('admin/network/dawnline/diagnostics')}?tab=log` }, _('All in Log →')),
E('a', { href: `${L.url('admin/services/dawnline/diagnostics')}?tab=log` }, _('All in Log →')),
]),
h.length
? E('div', {}, h.slice(0, 8).map(row))
+1 -1
View File
@@ -160,7 +160,7 @@ export class ComponentsPage {
E('div', { class: 'dl-row-actions' }, [
E(
'a',
{ class: 'cbi-button cbi-button-neutral dl-icon-btn', href: `${L.url('admin/network/dawnline/settings')}?section=updates` },
{ class: 'cbi-button cbi-button-neutral dl-icon-btn', href: `${L.url('admin/services/dawnline/settings')}?section=updates` },
[icon('edit'), ' ', _('Settings')],
),
button([icon('refresh'), ' ', _('Check all')], () => this.op('check', _('Checking all components')), 'neutral', {
+7 -7
View File
@@ -34,7 +34,7 @@ interface Attention {
function attention(st: Status): Attention[] {
const out: Attention[] = [];
const link = (href: string, t: string) => E('a', { href }, t);
const diagnostics = () => link(L.url('admin/network/dawnline/diagnostics'), _('Open Diagnostics'));
const diagnostics = () => link(L.url('admin/services/dawnline/diagnostics'), _('Open Diagnostics'));
const today = todayOf(st.series);
// AmneziaWG itself can't run: the health notice says so once, not "Tunnel down" for every server.
const awg = !!st.awg_state && !st.awg_state.ok;
@@ -111,12 +111,12 @@ function attention(st: Status): Attention[] {
text: [
fmt(_('Internet through the LAN is off: %s'), st.like_home.error),
' ',
link(L.url('admin/network/dawnline/diagnostics'), _('Details')),
link(L.url('admin/services/dawnline/diagnostics'), _('Details')),
],
});
// Only while setting up: an admin who keeps the portal off has decided so.
if (!st.settings.portal_enabled && !st.people.length)
out.push({ tone: '', text: [_('The personal portal is off.'), ' ', link(L.url('admin/network/dawnline/settings'), _('Turn on'))] });
out.push({ tone: '', text: [_('The personal portal is off.'), ' ', link(L.url('admin/services/dawnline/settings'), _('Turn on'))] });
return out;
}
@@ -221,7 +221,7 @@ export class ServerOverview {
E(
'div',
{ class: 'dl-map-off' },
fill(_('Locations are off. %s.'), E('a', { href: L.url('admin/network/dawnline/settings') }, _('Turn them on in Settings'))),
fill(_('Locations are off. %s.'), E('a', { href: L.url('admin/services/dawnline/settings') }, _('Turn them on in Settings'))),
),
]);
const map = (this.map = new ConnectionMap(
@@ -268,7 +268,7 @@ export class ServerOverview {
E('div', { class: 'dl-panel-head pad' }, [
E('h3', {}, _('Needs attention')),
E('span', { class: 'dl-spacer' }),
E('a', { href: L.url('admin/network/dawnline/diagnostics') }, _('Health')),
E('a', { href: L.url('admin/services/dawnline/diagnostics') }, _('Health')),
]),
att.length
? att
@@ -292,7 +292,7 @@ export class ServerOverview {
E('div', { class: 'dl-panel-head pad' }, [
E('h3', {}, _('Activity')),
E('span', { class: 'dl-spacer' }),
E('a', { href: `${L.url('admin/network/dawnline/diagnostics')}?tab=log` }, _('View all')),
E('a', { href: `${L.url('admin/services/dawnline/diagnostics')}?tab=log` }, _('View all')),
]),
events.length
? events.map((e) => eventRow(st, e))
@@ -428,7 +428,7 @@ export class ServerOverview {
'a',
{
class: 'dl-onl-p sm more',
href: `${L.url('admin/network/dawnline/server')}?server=${encodeURIComponent(this.srvId)}&section=people&filter=online`,
href: `${L.url('admin/services/dawnline/server')}?server=${encodeURIComponent(this.srvId)}&section=people&filter=online`,
title: _('Everyone online'),
click: (ev: Event) => {
if (this.go) {
+2 -2
View File
@@ -281,7 +281,7 @@ export class PeoplePage {
{ class: 'alert-message warning' },
fill(
_('No server yet. %s before adding people.'),
E('a', { href: L.url('admin/network/dawnline/server') }, _('Run the setup wizard')),
E('a', { href: L.url('admin/services/dawnline/server') }, _('Run the setup wizard')),
),
),
E('div', { class: 'dl-toolbar' }, [
@@ -847,7 +847,7 @@ export class PeoplePage {
' ',
E(
'a',
{ class: 'cbi-button cbi-button-neutral', href: `${L.url('admin/network/dawnline/settings')}?section=portal` },
{ class: 'cbi-button cbi-button-neutral', href: `${L.url('admin/services/dawnline/settings')}?section=portal` },
_('Open Settings'),
),
' ',
+4 -4
View File
@@ -34,7 +34,7 @@ function mapCard(page: PersonPage): HTMLElement {
E(
'div',
{ class: 'dl-map-off' },
fill(_('Locations are off. %s.'), E('a', { href: L.url('admin/network/dawnline/settings') }, _('Turn them on in Settings'))),
fill(_('Locations are off. %s.'), E('a', { href: L.url('admin/services/dawnline/settings') }, _('Turn them on in Settings'))),
),
]);
const map = new ConnectionMap(
@@ -64,7 +64,7 @@ export function placesPart(page: PersonPage): HTMLElement | null {
E('span', { class: 'dl-sub' }, _('City-level, from the client IP')),
]),
E('span', { class: 'dl-spacer' }),
E('a', { class: 'cbi-button cbi-button-neutral', href: L.url('admin/network/dawnline/settings') }, _('Turn on')),
E('a', { class: 'cbi-button cbi-button-neutral', href: L.url('admin/services/dawnline/settings') }, _('Turn on')),
]);
if (page.mapOpen) return page.map && page.parts.places.contains(page.map.el) ? null : mapCard(page);
const since = st.now - 30 * 86400;
@@ -108,10 +108,10 @@ export function activityPart(page: PersonPage): HTMLElement {
const e = latest[i];
let n = 1;
while (e.type === 'roam' && latest[i + n]?.type === 'roam' && latest[i + n].device === e.device) n++;
const row = eventRow(st, e, { server: false });
const row = eventRow(st, e, { server: false, person: p.id });
if (n > 1) {
const main = row.querySelector('.dl-row-main') as HTMLElement;
dom.content(main, [...eventText(st, e).slice(0, 3), E('span', { class: 'dl-muted' }, plural(n, '%s time', '%s times'))]);
dom.content(main, [...eventText(st, e, p.id).slice(0, 3), E('span', { class: 'dl-muted' }, plural(n, '%s time', '%s times'))]);
main.title = latest
.slice(i, i + n)
.map((x) => x.detail ?? '')
+2 -2
View File
@@ -1,4 +1,4 @@
// Person page (admin/network/dawnline/person?id=…): devices as cards,
// Person page (admin/services/dawnline/person?id=…): devices as cards,
// locations, activity, and access & limits that apply immediately.
// The parts live in ./header, ./devices, ./limits, ./pickers, ./activity and
// ./dialogs; this class holds the state, the poller and the edits.
@@ -66,7 +66,7 @@ export class PersonPage {
return E('div', { class: 'dl-empty' }, [
E('h3', {}, _('Person not found')),
E('p', {}, _('They may have been removed.')),
E('a', { class: 'cbi-button', href: L.url('admin/network/dawnline/server') }, _('Back to Servers')),
E('a', { class: 'cbi-button', href: L.url('admin/services/dawnline/server') }, _('Back to Servers')),
]);
this.p = p;
for (const k of ['crumbs', 'head', 'devices', 'traffic', 'places', 'activity', 'limits'] as Part[]) this.parts[k] = E('div', {});
+2 -2
View File
@@ -48,7 +48,7 @@ const url = (server?: string, section?: string) => {
if (server) q.set('server', server);
if (section && section !== 'overview') q.set('section', section);
const s = q.toString();
return `${L.url('admin/network/dawnline/server')}${s ? `?${s}` : ''}`;
return `${L.url('admin/services/dawnline/server')}${s ? `?${s}` : ''}`;
};
export class ServerPage {
@@ -846,7 +846,7 @@ export class ServerPage {
'warn',
_('AmneziaWG’s kernel module doesn’t load on this firmware'),
_('Try another build in Components, or update OpenWrt. The server can’t start until it loads.'),
E('a', { class: 'cbi-button cbi-button-neutral', href: L.url('admin/network/dawnline/updates') }, _('Open Components')),
E('a', { class: 'cbi-button cbi-button-neutral', href: L.url('admin/services/dawnline/updates') }, _('Open Components')),
),
])
: '';
+2 -2
View File
@@ -134,9 +134,9 @@ export const MOVE_MS = 1600;
/** The shimmer sets off once the place it leaves has started to go gray (a share of the move). */
const LEAVE = 0.12;
/** The shimmer's length, a share of the arc: longer than the arc, so most of it is lit mid-move. */
export const BAND = 1.3;
const BAND = 1.3;
/** ± this around the shimmer's middle is fully lit; it fades out to ±BAND/2. */
export const FLAT = 0.32;
const FLAT = 0.32;
/** A move into stay `k` (from stay k − 1), or stay `k` itself, `ms` long from `start`. */
export interface Step {
+2 -2
View File
@@ -2,9 +2,9 @@
/** A server's People section (Servers page). */
export function peopleUrl(server?: string): string {
return `${L.url('admin/network/dawnline/server')}?${server ? `server=${encodeURIComponent(server)}&` : ''}section=people`;
return `${L.url('admin/services/dawnline/server')}?${server ? `server=${encodeURIComponent(server)}&` : ''}section=people`;
}
export function personUrl(id: string, device?: string): string {
return `${L.url('admin/network/dawnline/person')}?id=${encodeURIComponent(id)}${device ? `&device=${encodeURIComponent(device)}` : ''}`;
return `${L.url('admin/services/dawnline/person')}?id=${encodeURIComponent(id)}${device ? `&device=${encodeURIComponent(device)}` : ''}`;
}
+2 -2
View File
@@ -48,7 +48,7 @@ export function fixAction(c: HealthCheck, run: (fix: string) => void, refresh: (
// install:awg installs AmneziaWG itself (the build for this firmware), the rest come from the feeds.
if (fix.startsWith('install:')) return button(_('Install'), () => installFeature(fix.slice(8) as keyof Needs, refresh), kind);
if (fix === 'updates')
return E('a', { class: `cbi-button cbi-button-${kind}`, href: L.url('admin/network/dawnline/updates') }, fixLabel(fix));
return E('a', { class: `cbi-button cbi-button-${kind}`, href: L.url('admin/services/dawnline/updates') }, fixLabel(fix));
return button(fixLabel(fix), () => run(fix), kind);
}
@@ -89,7 +89,7 @@ export function healthNotices(checks: HealthCheck[], run: (fix: string) => void,
),
),
rest > 0
? E('a', { class: 'dl-row dl-notices-more', href: L.url('admin/network/dawnline/diagnostics') }, [
? E('a', { class: 'dl-row dl-notices-more', href: L.url('admin/services/dawnline/diagnostics') }, [
fmt(_('%s more in Diagnostics'), num(rest)),
E('span', { class: 'dl-spacer' }),
'→',
-10
View File
@@ -10,11 +10,6 @@ const days: Pair[] = [
];
describe('mirrored bars', () => {
it('splits the height between the two directions around the hairline', () => {
const m = mirror(days, 64);
expect(m.top + m.bottom + 3).toBe(64);
});
it('fits both peaks on one scale, the tighter one filling its half', () => {
const m = mirror(days, 64);
expect(120 * m.scale).toBeLessThanOrEqual(m.top);
@@ -22,11 +17,6 @@ describe('mirrored bars', () => {
expect(Math.max(120 * m.scale - m.top, 40 * m.scale - m.bottom)).toBeCloseTo(0);
});
it('keeps 55–80% of the height for downloads, however lopsided the days', () => {
expect(mirror([[0, 100]], 64).top).toBe(Math.round(61 * 0.8));
expect(mirror([[100, 1]], 64).top).toBe(Math.round(61 * 0.55));
});
it('draws a month without traffic', () => {
const m = mirror([[0, 0]], 34);
expect(Number.isFinite(m.scale)).toBe(true);
+3 -25
View File
@@ -11,22 +11,9 @@ const run = (x: number, t: number, frames = 1): number[] => {
};
describe('caret glide', () => {
it('is 90% of the way in about 134 ms (8–9 frames), a touch over, then rests exactly on its target', () => {
const xs = run(0, 100);
expect(xs[7]).toBeLessThan(90);
expect(xs[8]).toBeGreaterThanOrEqual(90);
const peak = Math.max(...xs);
expect(peak).toBeGreaterThan(101);
expect(peak).toBeLessThan(103);
expect(xs.at(-1)).toBe(100);
expect(xs.length).toBeLessThan(40);
});
it('goes the same way to the left', () => {
const xs = run(100, 0);
expect(xs[8]).toBeLessThanOrEqual(10);
expect(Math.min(...xs)).toBeGreaterThan(-3);
expect(xs.at(-1)).toBe(0);
it('settles exactly on its target in either direction', () => {
expect(run(0, 100).at(-1)).toBe(100);
expect(run(100, 0).at(-1)).toBe(0);
});
it('takes a late frame as up to 2.5 frames, and is simply there after a long gap', () => {
@@ -84,13 +71,4 @@ describe('caret places', () => {
expect(places(field({ value: long, start: 0, end: 22 }), mono)).toEqual({ caret: 216, start: 16, end: 216, range: true });
expect(places(field({ value: long, start: 0, end: 22, scroll: 20 }), mono)).toEqual({ caret: 216, start: 16, end: 216, range: true });
});
it('measures only the text before each end', () => {
const seen: string[] = [];
places(field({ value: 'iPad', start: 1, end: 3 }), (s) => {
seen.push(s);
return mono(s);
});
expect(seen).toEqual(['i', 'iPa']);
});
});
+27
View File
@@ -56,6 +56,33 @@ describe('events', () => {
expect(isProblem({ ts: 1, sys: { ts: 1, src: 'awg', level: 'down', msg: '' } })).toBe(true);
expect(isProblem({ ts: 1, ev: ev({ type: 'connect' }) })).toBe(false);
});
it('renders portal and unattributed renames, including saved names of removed devices', () => {
for (const by of ['portal', undefined] as const) {
const event = ev({ type: 'device_changed', by, person: 'p1', device: 'd1', detail: 'renamed from Мяточька ПК' });
expect(text(eventText({ people }, event))).toBe(
by === 'portal'
? 'Person Myata renamed device Phone on their portal · was Мяточька ПК'
: 'Device Myata · Phone renamed · was Мяточька ПК',
);
expect(text(eventText({ people: [] }, { ...event, pname: 'Myata', dname: 'Phone' }))).toBe(text(eventText({ people }, event)));
}
});
it('omits the person only in their own activity and preserves the actor', () => {
const st = { people };
const rename = ev({ type: 'device_changed', by: 'portal', person: 'p1', device: 'd1', detail: 'renamed from Old' });
expect(text(eventText(st, rename, 'p1'))).toBe('Device Phone renamed on the portal · was Old');
expect(text(eventText(st, { ...rename, by: 'admin' }, 'p1'))).toBe('You renamed device Phone · was Old');
expect(text(eventText(st, rename, 'another-person'))).toBe(text(eventText(st, rename)));
expect(text(eventText(st, ev({ type: 'disconnect', person: 'p1', device: 'd1' }), 'p1'))).toBe('Device Phone went offline');
expect(text(eventText(st, ev({ person: 'p1', device: 'd1', detail: '1.2.3.4' }), 'p1'))).toBe('Device Phone connected from 1.2.3.4');
expect(text(eventText(st, ev({ type: 'roam', person: 'p1', device: 'd1', detail: '1 → 2' }), 'p1').slice(0, 3))).toBe(
'Device Phone changed network ',
);
expect(text(eventText(st, ev({ type: 'expiring', person: 'p1', detail: '3 days' }), 'p1'))).toBe('Access ends in 3 days');
expect(text(eventText(st, ev({ type: 'device_added', by: 'portal', person: 'p1', detail: 'Tablet' }), 'p1'))).toBe(
'Device Tablet added on the portal',
);
});
it('says what happened', () => {
const st = { people };
expect(text(eventText(st, ev({ person: 'p1', device: 'd1', detail: '1.2.3.4', where: 'Berlin' })))).toBe(
+1 -12
View File
@@ -5,8 +5,6 @@ import {
date,
dayDiff,
daysLeft,
defaultName,
DEVICE_NAME_MAX,
deviceNameFits,
endsIn,
endsSoon,
@@ -14,7 +12,6 @@ import {
fmtDay,
kb,
shiftDay,
todayOf,
validDeviceName,
} from '../src/shared/format';
import { plural } from '../src/shared/i18n';
@@ -62,9 +59,7 @@ describe('router days', () => {
expect(endsIn(2)).toBe('ends tomorrow');
expect(endsIn(7)).toBe('ends in 7 days');
});
it('takes today from a series', () => {
expect(todayOf([{ day: '2026-10-15' }, { day: '2026-10-16' }])).toBe('2026-10-16');
});
it('shows a router day as that day in any time zone', () => {
expect(fmtDay('2026-10-01')).toBe('1 Oct 2026');
expect(date('2026-10-01')).toBe('1 Oct 2026');
@@ -84,7 +79,6 @@ describe('numbers', () => {
describe('device names', () => {
it('take letters of any language, digits, spaces and - _ . up to the limit', () => {
expect(DEVICE_NAME_MAX).toBe(20);
expect(validDeviceName('Kitchen iPad')).toBe(true);
expect(validDeviceName('my-pc_2.home')).toBe(true);
expect(validDeviceName('Мой ноутбук')).toBe(true);
@@ -120,9 +114,4 @@ describe('device names', () => {
expect(fitName('Living room TV ab xy', ' 2')).toBe('Living room TV ab 2');
expect(validDeviceName(fitName('Redmi Note 13 Pro+ 5G', ' 12'))).toBe(true);
});
it('names a device after its kind', () => {
expect(defaultName('phone')).toBe('Phone');
expect(defaultName('other')).toBe('Device');
});
});
+3 -11
View File
@@ -2,19 +2,11 @@ import { describe, expect, it } from 'vitest';
import { arc, cityPlaces, devicePlaces, separate, type MapData } from '../src/admin/map';
describe('arc (mapcn buildArcCoordinates)', () => {
it('runs from one point to the other in 64 steps', () => {
it('runs from one point to the other', () => {
const pts = arc([-0.1276, 51.5074], [-74.006, 40.7128]);
expect(pts).toHaveLength(65);
expect(pts[0]).toEqual([-0.1276, 51.5074]);
expect(pts[64][0]).toBeCloseTo(-74.006);
expect(pts[64][1]).toBeCloseTo(40.7128);
});
it('bends to the left of travel by a fifth of the distance', () => {
// Due east 10°: the control point sits 2° north of the middle, the curve's peak half of that.
const mid = arc([0, 0], [10, 0])[32];
expect(mid[0]).toBeCloseTo(5);
expect(mid[1]).toBeCloseTo(1);
expect(pts.at(-1)![0]).toBeCloseTo(-74.006);
expect(pts.at(-1)![1]).toBeCloseTo(40.7128);
});
it('takes the short way across the antimeridian', () => {
-9
View File
@@ -35,13 +35,4 @@ describe('motion', () => {
expect(s.at(s.duration)).toBe(1);
}
});
it('gives the bouncy spring its overshoot and the smooth one none', () => {
const peak = (s: typeof BOUNCY) => Math.max(...Array.from({ length: 200 }, (_, i) => s.at((s.duration * i) / 200)));
// skiper103: about 11% past the end, settled well inside a second.
expect(peak(BOUNCY)).toBeGreaterThan(1.08);
expect(peak(BOUNCY)).toBeLessThan(1.15);
expect(BOUNCY.duration).toBeLessThan(900);
expect(peak(SMOOTH)).toBeLessThanOrEqual(1);
});
});
+1 -27
View File
@@ -1,21 +1,5 @@
import { describe, expect, it } from 'vitest';
import {
BAND,
FLAT,
arrived,
bandMiddle,
moment,
msAt,
placeKey,
replayStays,
shares,
shimmerOpacity,
stays,
stretches,
ticks,
timeline,
visits,
} from '../src/admin/places/model';
import { moment, msAt, placeKey, replayStays, shares, stays, stretches, ticks, timeline, visits } from '../src/admin/places/model';
import type { GeoPoint, LogEvent } from '../src/shared/types';
const D = 'd_1';
@@ -148,16 +132,6 @@ describe('replay', () => {
const ms = msAt(st, steps, 38000);
expect(moment(st, steps, ms).t).toBeCloseTo(38000, -1);
});
it('runs the shimmer from before the place it leaves to past the next', () => {
expect(bandMiddle(0)).toBeCloseTo(-BAND / 2);
expect(bandMiddle(1)).toBeCloseTo(1 + BAND / 2);
expect(arrived(bandMiddle(0.3))).toBe(false);
expect(arrived(1 - FLAT)).toBe(true);
const ex = shimmerOpacity(0.5);
expect(ex[0]).toBe('interpolate');
expect(ex.slice(3)).toEqual([0, 1, FLAT, 1, BAND / 2, 0]);
});
});
describe('ticks', () => {
+2 -29
View File
@@ -7,42 +7,15 @@ const KEY = `vpn://${'A1b2C3d4'.repeat(180)}`;
const HUGE = 'A1b2C3d4'.repeat(425);
describe('qr', () => {
it('draws the plain look as black squares on white in one path', () => {
const svg = qrSvg(LINK);
expect(svg).toContain('fill="#fff"');
expect(svg).toContain('shape-rendering="crispEdges"');
expect(svg).not.toContain('evenodd');
});
it('draws the night look as light dots on black with eyes, marked on links only', () => {
it('omits the centre mark on dense codes', () => {
const link = qrSvg(LINK, 3, true, 'night');
expect(link).toContain('fill="#0a0a0a"');
expect(link).toContain('fill-rule="evenodd"');
expect(link).not.toContain('crispEdges');
// The mark's light tile on a short code, none on a dense one.
expect(link).toContain('fill="#f2f2f2"/><g transform');
expect(link).toContain('<g transform');
expect(denseQr(KEY)).toBe(true);
expect(qrSvg(KEY, 3, true, 'night')).not.toContain('<g transform');
});
it('draws the day look with the night shapes, dark on white', () => {
const night = qrSvg(LINK, 3, true, 'night');
const day = qrSvg(LINK, 3, true, 'day');
expect(day).toMatch(/<rect width="(\d+)" height="\1" fill="#ffffff"\/>/);
expect(day).toContain('fill-rule="evenodd"');
expect(day).not.toContain('crispEdges');
// The same dots and eyes as at night, in the other colours; the mark's tile turns dark.
expect(day.replace(/#ffffff/g, 'BG').replace(/#0a0a0a/g, 'FG')).toBe(night.replace(/#0a0a0a/g, 'BG').replace(/#f2f2f2/g, 'FG'));
});
it('gives a dense night code fuller dots', () => {
expect(qrSvg(LINK, 3, true, 'night')).toContain('a0.42 0.42');
expect(qrSvg(KEY, 3, true, 'night')).toContain('a0.48 0.48');
});
it('says a 3.4 KB text does not fit instead of throwing, and keeps it from the camera', () => {
expect(HUGE.length).toBe(3400);
expect(() => qrFits(HUGE)).not.toThrow();
expect(qrFits(HUGE)).toBe(false);
expect(scannable(HUGE)).toBe(false);
// It still fits a code, but too fine to read off a screen.
+10 -12
View File
@@ -2,19 +2,17 @@ import { describe, expect, it } from 'vitest';
import { labelFade } from '../src/portal/ui/seg';
describe('picker names on a pick', () => {
it('blurs the picked name in a beat after the pill, and folds a shown one whole', () => {
expect(labelFade({ width: 0, full: 90, opacity: 0 }, true)).toEqual({ duration: 280, delay: 70 });
expect(labelFade({ width: 90, full: 90, opacity: 1 }, false)).toEqual({ duration: 220, delay: 0 });
});
it('runs only what is left of a fade turned back half-way', () => {
it('shortens a fade interrupted part-way', () => {
// Picked again while it was folding away: it comes back from 40% at once.
const opening = labelFade({ width: 0, full: 90, opacity: 0 }, true);
const closing = labelFade({ width: 90, full: 90, opacity: 1 }, false);
const back = labelFade({ width: 36, full: 90, opacity: 0.4 }, true);
expect(back.duration).toBeCloseTo(168);
expect(back.delay).toBeCloseTo(42);
// Left while it was still coming in: it folds from the wider of its width and its opacity.
expect(labelFade({ width: 45, full: 90, opacity: 0.2 }, false).duration).toBeCloseTo(110);
expect(labelFade({ width: 9, full: 90, opacity: 0.7 }, false).duration).toBeCloseTo(154);
expect(back.duration).toBeGreaterThan(0);
expect(back.duration).toBeLessThan(opening.duration);
expect(back.delay).toBeLessThanOrEqual(opening.delay);
// Interrupted while opening: either width or opacity can keep the closing fade active.
expect(labelFade({ width: 45, full: 90, opacity: 0.2 }, false).duration).toBeLessThan(closing.duration);
expect(labelFade({ width: 9, full: 90, opacity: 0.7 }, false).duration).toBeLessThan(closing.duration);
});
it('leaves a folded name alone and a shown one picked again as it is', () => {
@@ -25,7 +23,7 @@ describe('picker names on a pick', () => {
it('keeps to its bounds when the readings are off (no width to measure, opacity past 1)', () => {
expect(labelFade({ width: 30, full: 0, opacity: 0 }, false).duration).toBe(0);
expect(labelFade({ width: 200, full: 90, opacity: 0 }, false).duration).toBe(220);
expect(labelFade({ width: 200, full: 90, opacity: 0 }, false)).toEqual(labelFade({ width: 90, full: 90, opacity: 0 }, false));
expect(labelFade({ width: 0, full: 90, opacity: 1.2 }, true).duration).toBe(0);
});
});
-7
View File
@@ -2,7 +2,6 @@ import { describe, expect, it } from 'vitest';
import {
addLink,
appsFor,
deviceNoun,
importPath,
importSteps,
inWebview,
@@ -53,12 +52,6 @@ describe('setup', () => {
expect(wantsAdd('')).toBe(false);
});
it('names the device being set up by its kind, not its name', () => {
expect(deviceNoun('phone')).toBe('phone');
expect(deviceNoun('computer')).toBe('computer');
expect(deviceNoun('other')).toBe('device');
});
it('knows whether the page is open on the device being set up', () => {
expect(sameDevice('phone', 'ios')).toBe(true);
expect(sameDevice('phone', 'mac')).toBe(false);
+1 -21
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { wayState, type WayState } from '../src/portal/way';
import { wayState } from '../src/portal/way';
import type { Device, SetupState } from '../src/shared/types';
/** When the sheet opened (router clock). */
@@ -73,24 +73,4 @@ describe('the set-up sheet’s way', () => {
expect(wayState(dev({ online: false, handshake: OPENED + 9, setup: null }), OPENED)).toBe('waiting');
expect(wayState(undefined, OPENED)).toBe('waiting');
});
it('follows a whole set-up: knocks, no data, imported again, connected', () => {
const seen: WayState[] = [];
const answers: Partial<Device>[] = [
{},
{ setup: setup('trying') },
{ setup: setup('trying') },
// The network let it through, but the phone holds an old configuration.
{ online: true, handshake: OPENED + 40 },
{ online: true, handshake: OPENED + 40, setup: setup('nodata', OPENED + 52) },
// Gone offline: plain waiting, no line of its own.
{ online: false, handshake: OPENED + 40 },
{ online: true, handshake: OPENED + 300, setup: setup('flowing', OPENED + 300) },
];
for (const a of answers) {
const st = wayState(dev(a), OPENED);
if (st !== seen[seen.length - 1]) seen.push(st);
}
expect(seen).toEqual(['waiting', 'trying', 'waiting', 'nodata', 'waiting', 'connected']);
});
});