Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18e3013047 | ||
|
|
b0d9982796 | ||
|
|
f2b5ba101b | ||
|
|
0fd22b917a |
No files matched your search
@@ -819,7 +819,7 @@ The ⋯ menu, the pick pills' popups and the page code card are one kind of thin
|
|||||||
- Card: `raised`, radius 28, padding 8, gap 8.
|
- Card: `raised`, radius 28, padding 8, gap 8.
|
||||||
- Top row (padding `8 6 6 10`, gap 12): a 32 px glass icon (blue on "this device", else grey), the name (16/22 500, one line), the status (13/18, one line, full wording in `title`), and the ⋯ knob.
|
- Top row (padding `8 6 6 10`, gap 12): a 32 px glass icon (blue on "this device", else grey), the name (16/22 500, one line), the status (13/18, one line, full wording in `title`), and the ⋯ knob.
|
||||||
- Bottom, one of three:
|
- Bottom, one of three:
|
||||||
- **Usage** (`field`, radius 20, padding `12 14 12 16`, min-height 66): "Last 7 days" 13/18 `text-2` over the total 17/24 500 tabular. Spark of 7 bars at the right: 6 px wide, gap 4, ≤ 34 px high, min 3, radius 3, `--bar`, today in accent. Hovering a bar puts that day's name and bytes in place of the label and total instantly, with no morph.
|
- **Usage** (`field`, radius 20, padding `12 14 12 16`, min-height 66): "Last 7 days" 13/18 `text-2` over the total 17/24 500 tabular. Spark of 7 bars at the right: 6 px wide, gap 4, ≤ 34 px high, min 3, radius 3, `--bar`, today in accent. A day under the pointer, tapped (it stays until a tap elsewhere) or picked with ← → once the bars have focus (*Reading the bars* below) puts its name and bytes in place of the label and total instantly, with no morph; a day with nothing adds "· not used".
|
||||||
- **Reconnect** (instead of the week): a `tint` block button with the refresh icon.
|
- **Reconnect** (instead of the week): a `tint` block button with the refresh icon.
|
||||||
- **Connect**: a `tint` block button with the QR icon.
|
- **Connect**: a `tint` block button with the QR icon.
|
||||||
- A status is one line, and Reconnect or Connect takes the week's place. The button is lower than the week (48 against 66), so a card alone in its row is lower too; when its bottom changes, the card glides to its new height (see *Motion → Repaint choreography*).
|
- A status is one line, and Reconnect or Connect takes the week's place. The button is lower than the week (48 against 66), so a card alone in its row is lower too; when its bottom changes, the card glides to its new height (see *Motion → Repaint choreography*).
|
||||||
@@ -869,11 +869,13 @@ A longer reason sits in `title` and, for a screen reader, in hidden text right a
|
|||||||
| Row | Head | Body |
|
| Row | Head | Body |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| **What it reaches** (shield, home or globe glass) | Title only | Two **reach tiles** (radius 16, `field`, padding `12 12 12 14`, glass 28, title 14/20 500, sub 12/16; a 20 px round mark at the top right: ok-soft check or knob minus, the tile dimmed when off). Then a sentence with the hostname pattern in mono, and **name chips** (32 high, radius 10, mono 13, the domain part in `text-3`, a copy icon 14). |
|
| **What it reaches** (shield, home or globe glass) | Title only | Two **reach tiles** (radius 16, `field`, padding `12 12 12 14`, glass 28, title 14/20 500, sub 12/16; a 20 px round mark at the top right: ok-soft check or knob minus, the tile dimmed when off). Then a sentence with the hostname pattern in mono, and **name chips** (32 high, radius 10, mono 13, the domain part in `text-3`, a copy icon 14). |
|
||||||
| **Data this month** (chart glass) | A 16 px **ring** (track `--bar`, arc accent, warn ≥ 90%, bad ≥ 100%) and "38.6 GB / 100 GB"; hidden while open | The **month**: one bar per day (flex, gap 3, 64 high, radius 2.5, min 3; days to come at 45% bar; today accent), an axis 11 px `text-3` with "Today" in accent under its bar (the month's ends hide when it comes close), the total line (`bad` when out), a 6 px **meter** (same tone thresholds), and a `.desc`. Hovering a bar puts that day's total in place of the total instantly. |
|
| **Data this month** (chart glass) | A 16 px **ring** (track `--bar`, arc accent, warn ≥ 90%, bad ≥ 100%) and "38.6 GB / 100 GB"; hidden while open | The **month**: one bar per day (flex, gap 3, 64 high, radius 2.5, min 3; days to come at 45% bar; today accent), an axis 11 px `text-3` with "Today" in accent under its bar (the month's ends hide when it comes close), the total line (`bad` when out), a 6 px **meter** (same tone thresholds), and a `.desc`. A picked day (*Reading the bars*) puts its down and up in place of the total and "21 Oct · +62%" (its date and how it compares with the month's other days; today "so far") in place of what is left, instantly. With a limit not reached, a line under the meter (12/16 `text-2`, warn when it fills within a week): the pace lately (the devices' last 7 days) and when the limit fills at it, or what a monthly one reaches by the reset (`shared/pace.ts`). |
|
||||||
| **Access until** (calendar glass) | "30 Nov" plus "42 days" in ok, warn when soon, or "ended" in bad | The **until block** (`field`, radius 16, padding `14 16`): the days left as a 36/40 600 number (warn when soon), "days left", the end date in `text-3`, and a **calendar** of the weeks to the end. 7 columns of 10 px cells with gap 5 and radius 3: past at text 5%, left at text 16%, today in accent, the last day ringed 1.5 px accent; warn colours when soon. Under it the **hours bar**: 8 px track, the allowed window in ok 70%, a 2 × 16 "now" marker (`text`, warn when outside, with a 2 px field ring), and axis 00/06/12/18/24 at 10 px. With nothing to open, the row is still. |
|
| **Access until** (calendar glass) | "30 Nov" plus "42 days" in ok, warn when soon, or "ended" in bad | The **until block** (`field`, radius 16, padding `14 16`): the days left as a 36/40 600 number (warn when soon), "days left", the end date in `text-3`, and a **calendar** of the weeks to the end. 7 columns of 10 px cells with gap 5 and radius 3: past at text 5%, left at text 16%, today in accent, the last day ringed 1.5 px accent; warn colours when soon. Under it the **hours bar**: 8 px track, the allowed window in ok 70%, a 2 × 16 "now" marker (`text`, warn when outside, with a 2 px field ring), and axis 00/06/12/18/24 at 10 px, then how long the window still runs ("3h 20m left") or, outside it in warn, when it opens (12/16 `text-2`). With nothing to open, the row is still. |
|
||||||
|
|
||||||
A repaint keeps the rows on the page and changes what they hold in place, the same row open (see *Motion → Repaint choreography*).
|
A repaint keeps the rows on the page and changes what they hold in place, the same row open (see *Motion → Repaint choreography*).
|
||||||
|
|
||||||
|
**Reading the bars** (`ui/bars.ts` `readBars`, `shared/scrub.ts`, the same rule as the admin's charts): the pointer picks the day under it; a tap picks one and it stays until a tap elsewhere (a tap on it again lets go), so a touch screen reads a day without it flickering back; with the bars focused (a 2 px accent 55% ring, radius 6) ← → Home End walk the days and Esc lets go, each day read out to a screen reader. The picked column takes the hover look (`.on`).
|
||||||
|
|
||||||
### Sheet · `ui/sheet.ts`
|
### Sheet · `ui/sheet.ts`
|
||||||
|
|
||||||
**Shape:** `raised`, radius 36, `--sheet-shadow`, `overflow: hidden`.
|
**Shape:** `raised`, radius 36, `--sheet-shadow`, `overflow: hidden`.
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ follows a modern design.
|
|||||||
sh -c "$(wget -qO- https://raw.githubusercontent.com/tickcount/luci-app-dawnline/main/install.sh)"
|
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.
|
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
|
3. **Invite** someone: <kbd>Add person</kbd>, then send them the link or the
|
||||||
invite card with its QR code. They do the rest.
|
invite card with its QR code. They do the rest.
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ Dawnline запускает сервер [AmneziaWG] на вашем роуте
|
|||||||
sh -c "$(wget -qO- https://raw.githubusercontent.com/tickcount/luci-app-dawnline/main/install.sh)"
|
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>, затем отправьте ему
|
3. **Пригласите** человека: <kbd>Добавить человека</kbd>, затем отправьте ему
|
||||||
ссылку или карточку приглашения с QR-кодом. Остальное он сделает сам.
|
ссылку или карточку приглашения с QR-кодом. Остальное он сделает сам.
|
||||||
|
|||||||
+33
-15
@@ -487,18 +487,19 @@ check_tools() {
|
|||||||
|
|
||||||
# ---------- downloads ----------
|
# ---------- downloads ----------
|
||||||
|
|
||||||
# fetch_once URL FILE [SECONDS]
|
# fetch_once URL FILE [SECONDS] [ACCEPT]
|
||||||
fetch_once() {
|
fetch_once() {
|
||||||
_fu="$1"
|
_fu="$1"
|
||||||
_fd="$2"
|
_fd="$2"
|
||||||
_ft="${3:-$DOWNLOAD_TIMEOUT}"
|
_ft="${3:-$DOWNLOAD_TIMEOUT}"
|
||||||
|
_fa="${4:-}"
|
||||||
rm -f "$_fd"
|
rm -f "$_fd"
|
||||||
case "$FETCHER" in
|
case "$FETCHER" in
|
||||||
curl)
|
curl)
|
||||||
run_logged download curl -fsSL --connect-timeout "$CONNECT_TIMEOUT" --max-time "$_ft" \
|
run_logged download curl -fsSL --connect-timeout "$CONNECT_TIMEOUT" --max-time "$_ft" \
|
||||||
--speed-limit 1024 --speed-time 30 -o "$_fd" "$_fu"
|
--speed-limit 1024 --speed-time 30 ${_fa:+-H "Accept: $_fa"} -o "$_fd" "$_fu"
|
||||||
;;
|
;;
|
||||||
*) run_logged download "$FETCHER" -q -T "$CONNECT_TIMEOUT" -O "$_fd" "$_fu" ;;
|
*) run_logged download "$FETCHER" -q -T "$CONNECT_TIMEOUT" ${_fa:+--header="Accept: $_fa"} -O "$_fd" "$_fu" ;;
|
||||||
esac
|
esac
|
||||||
_frc=$?
|
_frc=$?
|
||||||
[ "$_frc" -eq 0 ] && [ -s "$_fd" ] && return 0
|
[ "$_frc" -eq 0 ] && [ -s "$_fd" ] && return 0
|
||||||
@@ -531,16 +532,29 @@ asset_digest() {
|
|||||||
jsonfilter -i "$1" -e "@.assets[@.name='$2'].digest" 2>/dev/null | head -n 1 | sed -n 's/^sha256:\([0-9a-f]\{64\}\)$/\1/p'
|
jsonfilter -i "$1" -e "@.assets[@.name='$2'].digest" 2>/dev/null | head -n 1 | sed -n 's/^sha256:\([0-9a-f]\{64\}\)$/\1/p'
|
||||||
}
|
}
|
||||||
|
|
||||||
# download URL FILE LABEL [SHA256]: direct, then (only when the sha256 is
|
# A release file's URL in the GitHub API, from release JSON (empty if unknown).
|
||||||
# known) two mirrors, then direct again. A file whose sha256 doesn't match is
|
# Asked for application/octet-stream, it answers with the file itself.
|
||||||
# thrown away and the next source is tried; without a sha256 only GitHub
|
asset_api_url() {
|
||||||
# itself is used.
|
[ -s "$1" ] || return 0
|
||||||
|
jsonfilter -i "$1" -e "@.assets[@.name='$2'].url" 2>/dev/null | head -n 1 |
|
||||||
|
sed -n 's#^\(https://api\.github\.com/repos/[^/]*/[^/]*/releases/assets/[0-9][0-9]*\)$#\1#p'
|
||||||
|
}
|
||||||
|
|
||||||
|
# download URL FILE LABEL [SHA256] [API_URL]: without curl the API's URL
|
||||||
|
# first (github.com's redirect carries a Content-Security-Policy header that
|
||||||
|
# can outgrow uclient-fetch's 4 KB line buffer, and it stalls there), then
|
||||||
|
# direct, then (only when the sha256 is known) two mirrors, then direct again.
|
||||||
|
# A file whose sha256 doesn't match is thrown away and the next source is
|
||||||
|
# tried; without a sha256 only GitHub itself is used.
|
||||||
download() {
|
download() {
|
||||||
_du="$1"
|
_du="$1"
|
||||||
_dd="$2"
|
_dd="$2"
|
||||||
_dl="$3"
|
_dl="$3"
|
||||||
_dw="${4:-}"
|
_dw="${4:-}"
|
||||||
|
_da="${5:-}"
|
||||||
|
[ "$FETCHER" != curl ] || _da=""
|
||||||
set -- "$_du"
|
set -- "$_du"
|
||||||
|
[ -z "$_da" ] || set -- "$_da" "$_du"
|
||||||
if [ -n "$_dw" ]; then
|
if [ -n "$_dw" ]; then
|
||||||
for _m in $MIRRORS; do set -- "$@" "$_m$_du"; done
|
for _m in $MIRRORS; do set -- "$@" "$_m$_du"; done
|
||||||
fi
|
fi
|
||||||
@@ -555,7 +569,9 @@ download() {
|
|||||||
sleep 2
|
sleep 2
|
||||||
msg "Downloading $_dl via $(host_of "$_try") (attempt $_n/$_total)"
|
msg "Downloading $_dl via $(host_of "$_try") (attempt $_n/$_total)"
|
||||||
fi
|
fi
|
||||||
if fetch_once "$_try" "$_dd"; then
|
_acc=""
|
||||||
|
[ "$_try" != "$_da" ] || _acc="application/octet-stream"
|
||||||
|
if fetch_once "$_try" "$_dd" "" "$_acc"; then
|
||||||
if [ -n "$_dw" ] && [ "$(sha256sum "$_dd" 2>/dev/null | awk '{ print $1 }')" != "$_dw" ]; then
|
if [ -n "$_dw" ] && [ "$(sha256sum "$_dd" 2>/dev/null | awk '{ print $1 }')" != "$_dw" ]; then
|
||||||
warn "$(host_of "$_try") sent a file that doesn't match GitHub's sha256: discarded"
|
warn "$(host_of "$_try") sent a file that doesn't match GitHub's sha256: discarded"
|
||||||
rm -f "$_dd"
|
rm -f "$_dd"
|
||||||
@@ -1118,10 +1134,11 @@ confirm() {
|
|||||||
download_release_file() {
|
download_release_file() {
|
||||||
_name="$1"
|
_name="$1"
|
||||||
_sums="$TMP_DIR/sha256sums.txt"
|
_sums="$TMP_DIR/sha256sums.txt"
|
||||||
# The checksum: GitHub's own (API), else the release's sha256sums.txt straight from github.com.
|
# The checksum: GitHub's own (API), else the release's sha256sums.txt straight from GitHub.
|
||||||
_want="$(asset_digest "$TMP_DIR/release.json" "$_name")"
|
_want="$(asset_digest "$TMP_DIR/release.json" "$_name")"
|
||||||
if [ -z "$_want" ]; then
|
if [ -z "$_want" ]; then
|
||||||
[ -s "$_sums" ] || download "$ASSET_BASE/sha256sums.txt" "$_sums" sha256sums.txt || {
|
[ -s "$_sums" ] || download "$ASSET_BASE/sha256sums.txt" "$_sums" sha256sums.txt "" \
|
||||||
|
"$(asset_api_url "$TMP_DIR/release.json" sha256sums.txt)" || {
|
||||||
err "Download failed: sha256sums.txt (does release $VERSION exist?)"
|
err "Download failed: sha256sums.txt (does release $VERSION exist?)"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@@ -1131,7 +1148,7 @@ download_release_file() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
download "$ASSET_BASE/$_name" "$TMP_DIR/$_name" "$_name" "$_want" || {
|
download "$ASSET_BASE/$_name" "$TMP_DIR/$_name" "$_name" "$_want" "$(asset_api_url "$TMP_DIR/release.json" "$_name")" || {
|
||||||
err "Download failed: $_name"
|
err "Download failed: $_name"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@@ -1158,7 +1175,8 @@ download_awg() {
|
|||||||
_f="$TMP_DIR/$_p$_pf"
|
_f="$TMP_DIR/$_p$_pf"
|
||||||
# Verified when GitHub publishes the file's sha256 (then mirrors may serve it).
|
# Verified when GitHub publishes the file's sha256 (then mirrors may serve it).
|
||||||
_want="$(asset_digest "$TMP_DIR/awg-$_s.json" "$_p$_pf")"
|
_want="$(asset_digest "$TMP_DIR/awg-$_s.json" "$_p$_pf")"
|
||||||
if download "https://github.com/$_repo/releases/download/v$OWRT_RELEASE/$_p$_pf" "$_f" "$_p ($_repo)" "$_want" &&
|
if download "https://github.com/$_repo/releases/download/v$OWRT_RELEASE/$_p$_pf" "$_f" "$_p ($_repo)" "$_want" \
|
||||||
|
"$(asset_api_url "$TMP_DIR/awg-$_s.json" "$_p$_pf")" &&
|
||||||
verify_archive "$_f"; then
|
verify_archive "$_f"; then
|
||||||
_files="$_files $_f"
|
_files="$_files $_f"
|
||||||
else
|
else
|
||||||
@@ -1425,7 +1443,7 @@ on_pipe() {
|
|||||||
lan_url() {
|
lan_url() {
|
||||||
_ip="$(uci -q get network.lan.ipaddr 2>/dev/null | cut -d/ -f1 | awk '{ print $1 }')"
|
_ip="$(uci -q get network.lan.ipaddr 2>/dev/null | cut -d/ -f1 | awk '{ print $1 }')"
|
||||||
[ -n "$_ip" ] || _ip="192.168.1.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() {
|
main() {
|
||||||
@@ -1495,9 +1513,9 @@ main() {
|
|||||||
msg "Log: $LOG_FILE"
|
msg "Log: $LOG_FILE"
|
||||||
msg "Recovery snapshot: $SNAPSHOT_DIR"
|
msg "Recovery snapshot: $SNAPSHOT_DIR"
|
||||||
if [ "$MODE" = install ]; then
|
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
|
else
|
||||||
msg "Open LuCI → Network → Dawnline:"
|
msg "Open LuCI → Services → Dawnline:"
|
||||||
fi
|
fi
|
||||||
msg " $(lan_url)"
|
msg " $(lan_url)"
|
||||||
awg_netifd_restart
|
awg_netifd_restart
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-dawnline
|
PKG_NAME:=luci-app-dawnline
|
||||||
PKG_VERSION:=0.16.0
|
PKG_VERSION:=0.17.0
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
PKG_LICENSE:=MIT
|
PKG_LICENSE:=MIT
|
||||||
# po/<lang>/dawnline.po becomes luci-i18n-dawnline-<lang> (luci.mk), released
|
# po/<lang>/dawnline.po becomes luci-i18n-dawnline-<lang> (luci.mk), released
|
||||||
|
|||||||
@@ -126,6 +126,10 @@ msgstr[2] "%s устройств AmneziaWG перестанут подключа
|
|||||||
msgid "%s MB free: settings may stop saving. Remove old backups (Settings → Backups) or shorten the history."
|
msgid "%s MB free: settings may stop saving. Remove old backups (Settings → Backups) or shorten the history."
|
||||||
msgstr "Свободно %s МБ: настройки могут перестать сохраняться. Удалите старые резервные копии («Настройки» → «Резервные копии») или сократите историю."
|
msgstr "Свободно %s МБ: настройки могут перестать сохраняться. Удалите старые резервные копии («Настройки» → «Резервные копии») или сократите историю."
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "%s a day lately"
|
||||||
|
msgstr "%s в день за последние дни"
|
||||||
|
|
||||||
#: web/src/admin/access.ts
|
#: web/src/admin/access.ts
|
||||||
#: web/src/admin/device.ts
|
#: web/src/admin/device.ts
|
||||||
msgid "%s added"
|
msgid "%s added"
|
||||||
@@ -263,6 +267,13 @@ msgstr "Сервер %s не может использовать сетевой
|
|||||||
msgid "%s check failed"
|
msgid "%s check failed"
|
||||||
msgstr "%s: ошибка проверки"
|
msgstr "%s: ошибка проверки"
|
||||||
|
|
||||||
|
#: web/src/admin/pages/overview.ts
|
||||||
|
msgid "%s city"
|
||||||
|
msgid_plural "%s cities"
|
||||||
|
msgstr[0] "%s город"
|
||||||
|
msgstr[1] "%s города"
|
||||||
|
msgstr[2] "%s городов"
|
||||||
|
|
||||||
#: web/src/admin/device.ts
|
#: web/src/admin/device.ts
|
||||||
msgid "%s copied"
|
msgid "%s copied"
|
||||||
msgstr "Скопировано: %s"
|
msgstr "Скопировано: %s"
|
||||||
@@ -696,6 +707,10 @@ msgstr "осталось %s"
|
|||||||
msgid "%s may not contain # or a line break."
|
msgid "%s may not contain # or a line break."
|
||||||
msgstr "%s не может содержать # или перенос строки."
|
msgstr "%s не может содержать # или перенос строки."
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "%s min %s s ago"
|
||||||
|
msgstr "%s мин %s с назад"
|
||||||
|
|
||||||
#: web/src/shared/format.ts
|
#: web/src/shared/format.ts
|
||||||
msgid "%s min ago"
|
msgid "%s min ago"
|
||||||
msgstr "%s мин назад"
|
msgstr "%s мин назад"
|
||||||
@@ -912,6 +927,10 @@ msgstr "%s: доступ возобновлён"
|
|||||||
msgid "%s s"
|
msgid "%s s"
|
||||||
msgstr "%s с"
|
msgstr "%s с"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "%s s ago"
|
||||||
|
msgstr "%s с назад"
|
||||||
|
|
||||||
#: web/src/admin/pages/settings/logs.ts
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
msgid "%s since %s"
|
msgid "%s since %s"
|
||||||
msgstr "%s с %s"
|
msgstr "%s с %s"
|
||||||
@@ -1107,6 +1126,10 @@ msgstr[0] "Ещё %s пункт в «Что нового»"
|
|||||||
msgstr[1] "Ещё %s пункта в «Что нового»"
|
msgstr[1] "Ещё %s пункта в «Что нового»"
|
||||||
msgstr[2] "Ещё %s пунктов в «Что нового»"
|
msgstr[2] "Ещё %s пунктов в «Что нового»"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "+%s%% vs average"
|
||||||
|
msgstr "+%s%% к среднему"
|
||||||
|
|
||||||
#: web/src/admin/pages/person/limits.ts
|
#: web/src/admin/pages/person/limits.ts
|
||||||
msgid "+1 month"
|
msgid "+1 month"
|
||||||
msgstr "+1 месяц"
|
msgstr "+1 месяц"
|
||||||
@@ -1140,6 +1163,10 @@ msgstr "1 год"
|
|||||||
msgid "15 min"
|
msgid "15 min"
|
||||||
msgstr "15 мин"
|
msgstr "15 мин"
|
||||||
|
|
||||||
|
#: web/src/admin/pages/overview.ts
|
||||||
|
msgid "2 min"
|
||||||
|
msgstr "2 мин"
|
||||||
|
|
||||||
#: web/src/admin/map.ts
|
#: web/src/admin/map.ts
|
||||||
msgid "24h"
|
msgid "24h"
|
||||||
msgstr "24 ч"
|
msgstr "24 ч"
|
||||||
@@ -1239,6 +1266,13 @@ msgstr "Срок доступа"
|
|||||||
msgid "Access ends %s"
|
msgid "Access ends %s"
|
||||||
msgstr "Окончание доступа: %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
|
#: web/src/admin/netcheck.ts
|
||||||
msgid "Access ends in %s day (%s)."
|
msgid "Access ends in %s day (%s)."
|
||||||
msgid_plural "Access ends in %s days (%s)."
|
msgid_plural "Access ends in %s days (%s)."
|
||||||
@@ -1246,6 +1280,10 @@ msgstr[0] "Доступ закончится через %s день (%s)."
|
|||||||
msgstr[1] "Доступ закончится через %s дня (%s)."
|
msgstr[1] "Доступ закончится через %s дня (%s)."
|
||||||
msgstr[2] "Доступ закончится через %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
|
#: web/src/admin/netcheck.ts
|
||||||
msgid "Access ends today (%s)."
|
msgid "Access ends today (%s)."
|
||||||
msgstr "Доступ закончится сегодня (%s)."
|
msgstr "Доступ закончится сегодня (%s)."
|
||||||
@@ -1254,6 +1292,22 @@ msgstr "Доступ закончится сегодня (%s)."
|
|||||||
msgid "Access must be lan, internet or both."
|
msgid "Access must be lan, internet or both."
|
||||||
msgstr "Доступ должен быть lan, internet или 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/libexec/dawnline/agent
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/watchdog.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/watchdog.uc
|
||||||
@@ -1441,6 +1495,10 @@ msgstr "Все проверки пройдены."
|
|||||||
msgid "All components"
|
msgid "All components"
|
||||||
msgstr "Все компоненты"
|
msgstr "Все компоненты"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "All devices removed, end date reached"
|
||||||
|
msgstr "Все устройства удалены: срок доступа закончился"
|
||||||
|
|
||||||
#: web/src/admin/pages/overview.ts
|
#: web/src/admin/pages/overview.ts
|
||||||
msgid "All good. Nothing needs you right now."
|
msgid "All good. Nothing needs you right now."
|
||||||
msgstr "Всё в порядке. Сейчас ничего не требует вашего внимания."
|
msgstr "Всё в порядке. Сейчас ничего не требует вашего внимания."
|
||||||
@@ -2205,10 +2263,6 @@ msgstr "Часы не настроены"
|
|||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr "Закрыть"
|
msgstr "Закрыть"
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "Collecting… 1 point a minute"
|
|
||||||
msgstr "Сбор данных… 1 точка в минуту"
|
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
#: web/src/admin/widgets/tiles.ts
|
||||||
msgid "Collecting… 1 point a second"
|
msgid "Collecting… 1 point a second"
|
||||||
msgstr "Сбор данных… 1 точка в секунду"
|
msgstr "Сбор данных… 1 точка в секунду"
|
||||||
@@ -2526,6 +2580,10 @@ msgstr "Dawnline обновлён до %s"
|
|||||||
msgid "Dawnline was updated to %s: reload the page."
|
msgid "Dawnline was updated to %s: reload the page."
|
||||||
msgstr "Dawnline обновлён до версии %s: перезагрузите страницу."
|
msgstr "Dawnline обновлён до версии %s: перезагрузите страницу."
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/tiles.ts
|
||||||
|
msgid "Days this device was used"
|
||||||
|
msgstr "Дни с трафиком на устройстве"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc
|
||||||
msgid "Default device limit must be 1-32."
|
msgid "Default device limit must be 1-32."
|
||||||
msgstr "Лимит устройств по умолчанию: от 1 до 32."
|
msgstr "Лимит устройств по умолчанию: от 1 до 32."
|
||||||
@@ -2579,6 +2637,18 @@ msgstr "Сведения"
|
|||||||
msgid "Device"
|
msgid "Device"
|
||||||
msgstr "Устройство"
|
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
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Device %s changed network %s"
|
msgid "Device %s changed network %s"
|
||||||
msgstr "Устройство %s сменило сеть %s"
|
msgstr "Устройство %s сменило сеть %s"
|
||||||
@@ -2643,6 +2713,30 @@ msgstr "Устройство %s (%s): публичный ключ некорре
|
|||||||
msgid "Device %s of %s: the public key is the server's own."
|
msgid "Device %s of %s: the public key is the server's own."
|
||||||
msgstr "Устройство %s (%s): публичный ключ совпадает с ключом сервера."
|
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
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Device %s went offline"
|
msgid "Device %s went offline"
|
||||||
msgstr "Устройство %s отключилось"
|
msgstr "Устройство %s отключилось"
|
||||||
@@ -2935,6 +3029,10 @@ msgstr "Дата окончания"
|
|||||||
msgid "End date must be YYYY-MM-DD."
|
msgid "End date must be YYYY-MM-DD."
|
||||||
msgstr "Дата окончания должна быть в формате ГГГГ-ММ-ДД."
|
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
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
||||||
msgid "End dates and quotas use the router clock."
|
msgid "End dates and quotas use the router clock."
|
||||||
msgstr "Даты окончания и лимиты трафика считаются по часам роутера."
|
msgstr "Даты окончания и лимиты трафика считаются по часам роутера."
|
||||||
@@ -3835,6 +3933,7 @@ msgid "Last 30 days"
|
|||||||
msgstr "За 30 дней"
|
msgstr "За 30 дней"
|
||||||
|
|
||||||
#: web/src/admin/device.ts
|
#: web/src/admin/device.ts
|
||||||
|
#: web/src/admin/widgets/spark.ts
|
||||||
msgid "Last 7 days"
|
msgid "Last 7 days"
|
||||||
msgstr "За 7 дней"
|
msgstr "За 7 дней"
|
||||||
|
|
||||||
@@ -4099,6 +4198,10 @@ msgstr "Метод не поддерживается."
|
|||||||
msgid "Missing: %s."
|
msgid "Missing: %s."
|
||||||
msgstr "Не хватает: %s."
|
msgstr "Не хватает: %s."
|
||||||
|
|
||||||
|
#: web/src/shared/format.ts
|
||||||
|
msgid "Mobile"
|
||||||
|
msgstr "Мобильный"
|
||||||
|
|
||||||
#: web/src/admin/pages/person/limits.ts
|
#: web/src/admin/pages/person/limits.ts
|
||||||
msgid "Monthly"
|
msgid "Monthly"
|
||||||
msgstr "В месяц"
|
msgstr "В месяц"
|
||||||
@@ -4278,6 +4381,10 @@ msgstr "Ключи обновлены %s"
|
|||||||
msgid "New keys generated"
|
msgid "New keys generated"
|
||||||
msgstr "Новые ключи созданы"
|
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
|
#: web/src/admin/pages/person/header.ts
|
||||||
msgid "New link"
|
msgid "New link"
|
||||||
msgstr "Новая ссылка"
|
msgstr "Новая ссылка"
|
||||||
@@ -4618,6 +4725,10 @@ msgstr "Не настроено."
|
|||||||
msgid "Not set: the certificate is picked automatically."
|
msgid "Not set: the certificate is picked automatically."
|
||||||
msgstr "Не заданы: сертификат выбирается автоматически."
|
msgstr "Не заданы: сертификат выбирается автоматически."
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "Not used"
|
||||||
|
msgstr "Без трафика"
|
||||||
|
|
||||||
#: web/src/admin/pages/diagnostics/health.ts
|
#: web/src/admin/pages/diagnostics/health.ts
|
||||||
msgid "Not working"
|
msgid "Not working"
|
||||||
msgstr "Не работает"
|
msgstr "Не работает"
|
||||||
@@ -5071,6 +5182,10 @@ msgstr "%s: удалено устройство %s"
|
|||||||
msgid "Person %s removed device %s on their portal"
|
msgid "Person %s removed device %s on their portal"
|
||||||
msgstr "%s: удалено устройство %s через портал"
|
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
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Person %s resumed"
|
msgid "Person %s resumed"
|
||||||
msgstr "%s: доступ возобновлён"
|
msgstr "%s: доступ возобновлён"
|
||||||
@@ -6088,6 +6203,10 @@ msgstr "Скорость"
|
|||||||
msgid "Speed now"
|
msgid "Speed now"
|
||||||
msgstr "Скорость сейчас"
|
msgstr "Скорость сейчас"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/tiles.ts
|
||||||
|
msgid "Speed over the last 2 minutes"
|
||||||
|
msgstr "Скорость за последние 2 минуты"
|
||||||
|
|
||||||
#: web/src/admin/disguise.ts
|
#: web/src/admin/disguise.ts
|
||||||
msgid "Standard (old)"
|
msgid "Standard (old)"
|
||||||
msgstr "Стандартная (старая)"
|
msgstr "Стандартная (старая)"
|
||||||
@@ -6299,6 +6418,10 @@ msgstr "Резервная копия (%s) будет удалена с роут
|
|||||||
msgid "The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds."
|
msgid "The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds."
|
||||||
msgstr "Снова установится сборка, сохранённая на роутере. Все туннели AmneziaWG перезапустятся на несколько секунд."
|
msgstr "Снова установится сборка, сохранённая на роутере. Все туннели AmneziaWG перезапустятся на несколько секунд."
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "The busiest of the %s days"
|
||||||
|
msgstr "Самый загруженный из %s дней"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/backup.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/backup.uc
|
||||||
msgid "The configuration in this file cannot be read."
|
msgid "The configuration in this file cannot be read."
|
||||||
msgstr "Не удаётся прочитать конфигурацию из этого файла."
|
msgstr "Не удаётся прочитать конфигурацию из этого файла."
|
||||||
@@ -6680,8 +6803,7 @@ msgstr "Чтобы оставить старую маскировку части
|
|||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
#: web/src/admin/places/model.ts
|
#: web/src/admin/places/model.ts
|
||||||
#: web/src/admin/widgets/spark.ts
|
#: web/src/admin/widgets/readouts.ts
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "Today"
|
msgid "Today"
|
||||||
msgstr "Сегодня"
|
msgstr "Сегодня"
|
||||||
|
|
||||||
@@ -6718,6 +6840,10 @@ msgstr "История трафика"
|
|||||||
msgid "Traffic history reset"
|
msgid "Traffic history reset"
|
||||||
msgstr "История трафика сброшена"
|
msgstr "История трафика сброшена"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/tiles.ts
|
||||||
|
msgid "Traffic, last 30 days"
|
||||||
|
msgstr "Трафик за последние 30 дней"
|
||||||
|
|
||||||
#: web/src/admin/pages/components/hero.ts
|
#: web/src/admin/pages/components/hero.ts
|
||||||
msgid "Translation"
|
msgid "Translation"
|
||||||
msgstr "Перевод"
|
msgstr "Перевод"
|
||||||
@@ -7129,6 +7255,13 @@ msgstr "Порт занят: %s. Выберите другой."
|
|||||||
msgid "Used for HTTPS links"
|
msgid "Used for HTTPS links"
|
||||||
msgstr "Для ссылок HTTPS"
|
msgstr "Для ссылок HTTPS"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "Used on %s of %s day"
|
||||||
|
msgid_plural "Used on %s of %s days"
|
||||||
|
msgstr[0] "С трафиком %s из %s дня"
|
||||||
|
msgstr[1] "С трафиком %s из %s дней"
|
||||||
|
msgstr[2] "С трафиком %s из %s дней"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
||||||
msgid "Using a self-signed certificate: browsers will show a warning."
|
msgid "Using a self-signed certificate: browsers will show a warning."
|
||||||
msgstr "Используется самоподписанный сертификат: браузеры покажут предупреждение."
|
msgstr "Используется самоподписанный сертификат: браузеры покажут предупреждение."
|
||||||
@@ -7318,7 +7451,7 @@ msgstr "По неверной ссылке откроется просто «Not
|
|||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
#: web/src/admin/places/model.ts
|
#: web/src/admin/places/model.ts
|
||||||
#: web/src/admin/widgets/spark.ts
|
#: web/src/admin/widgets/readouts.ts
|
||||||
msgid "Yesterday"
|
msgid "Yesterday"
|
||||||
msgstr "Вчера"
|
msgstr "Вчера"
|
||||||
|
|
||||||
@@ -7334,6 +7467,10 @@ msgstr "Вы"
|
|||||||
msgid "You added circle %s"
|
msgid "You added circle %s"
|
||||||
msgstr "Вы добавили круг %s"
|
msgstr "Вы добавили круг %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You added device %s"
|
||||||
|
msgstr "Вы добавили устройство %s"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You added device %s for %s"
|
msgid "You added device %s for %s"
|
||||||
msgstr "Вы добавили устройство %s (%s)"
|
msgstr "Вы добавили устройство %s (%s)"
|
||||||
@@ -7342,10 +7479,18 @@ msgstr "Вы добавили устройство %s (%s)"
|
|||||||
msgid "You added person %s"
|
msgid "You added person %s"
|
||||||
msgstr "Вы добавили человека %s"
|
msgstr "Вы добавили человека %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You added this person"
|
||||||
|
msgstr "Вы добавили этого человека"
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "You changed circle %s"
|
msgid "You changed circle %s"
|
||||||
msgstr "Вы изменили круг %s"
|
msgstr "Вы изменили круг %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You changed device %s"
|
||||||
|
msgstr "Вы изменили устройство %s"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You changed device %s of %s"
|
msgid "You changed device %s of %s"
|
||||||
msgstr "Вы изменили устройство %s (%s)"
|
msgstr "Вы изменили устройство %s (%s)"
|
||||||
@@ -7358,6 +7503,10 @@ msgstr "Вы изменили настройки: %s"
|
|||||||
msgid "You changed server %s"
|
msgid "You changed server %s"
|
||||||
msgstr "Вы изменили сервер %s"
|
msgstr "Вы изменили сервер %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You changed settings"
|
||||||
|
msgstr "Вы изменили настройки"
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "You changed the personal portal"
|
msgid "You changed the personal portal"
|
||||||
msgstr "Вы изменили настройки личного портала"
|
msgstr "Вы изменили настройки личного портала"
|
||||||
@@ -7386,10 +7535,22 @@ msgstr "Вы импортировали настройки из файла"
|
|||||||
msgid "You issued a new link for person %s"
|
msgid "You issued a new link for person %s"
|
||||||
msgstr "Вы выпустили новую личную ссылку: %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
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You issued new keys for device %s of %s"
|
msgid "You issued new keys for device %s of %s"
|
||||||
msgstr "Вы выпустили новые ключи для устройства %s (%s)"
|
msgstr "Вы выпустили новые ключи для устройства %s (%s)"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You paused access"
|
||||||
|
msgstr "Вы приостановили доступ"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You paused person %s"
|
msgid "You paused person %s"
|
||||||
msgstr "Вы приостановили доступ: %s"
|
msgstr "Вы приостановили доступ: %s"
|
||||||
@@ -7398,6 +7559,10 @@ msgstr "Вы приостановили доступ: %s"
|
|||||||
msgid "You removed circle %s"
|
msgid "You removed circle %s"
|
||||||
msgstr "Вы удалили круг %s"
|
msgstr "Вы удалили круг %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You removed device %s"
|
||||||
|
msgstr "Вы удалили устройство %s"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You removed device %s from %s"
|
msgid "You removed device %s from %s"
|
||||||
msgstr "Вы удалили устройство %s (%s)"
|
msgstr "Вы удалили устройство %s (%s)"
|
||||||
@@ -7410,6 +7575,14 @@ msgstr "Вы удалили человека %s"
|
|||||||
msgid "You removed server %s"
|
msgid "You removed server %s"
|
||||||
msgstr "Вы удалили сервер %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
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You renamed device %s of %s"
|
msgid "You renamed device %s of %s"
|
||||||
msgstr "Вы переименовали устройство %s (%s)"
|
msgstr "Вы переименовали устройство %s (%s)"
|
||||||
@@ -7430,10 +7603,18 @@ msgstr "Вы восстановили резервную копию из фай
|
|||||||
msgid "You restored backup %s"
|
msgid "You restored backup %s"
|
||||||
msgstr "Вы восстановили резервную копию %s"
|
msgstr "Вы восстановили резервную копию %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You resumed access"
|
||||||
|
msgstr "Вы возобновили доступ"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You resumed person %s"
|
msgid "You resumed person %s"
|
||||||
msgstr "Вы возобновили доступ: %s"
|
msgstr "Вы возобновили доступ: %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You turned off device %s"
|
||||||
|
msgstr "Вы выключили устройство %s"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You turned off device %s of %s"
|
msgid "You turned off device %s of %s"
|
||||||
msgstr "Вы выключили устройство %s (%s)"
|
msgstr "Вы выключили устройство %s (%s)"
|
||||||
@@ -7450,6 +7631,10 @@ msgstr "Вы выключили личный портал"
|
|||||||
msgid "You turned off the watchdog"
|
msgid "You turned off the watchdog"
|
||||||
msgstr "Вы выключили автовосстановление"
|
msgstr "Вы выключили автовосстановление"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You turned on device %s"
|
||||||
|
msgstr "Вы включили устройство %s"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You turned on device %s of %s"
|
msgid "You turned on device %s of %s"
|
||||||
msgstr "Вы включили устройство %s (%s)"
|
msgstr "Вы включили устройство %s (%s)"
|
||||||
@@ -7514,6 +7699,14 @@ msgstr "без имени"
|
|||||||
msgid "a new build needs a manual switch in Components"
|
msgid "a new build needs a manual switch in Components"
|
||||||
msgstr ": новую сборку нужно включить вручную в «Компонентах»"
|
msgstr ": новую сборку нужно включить вручную в «Компонентах»"
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "about %s by the reset on %s"
|
||||||
|
msgstr "около %s к сбросу %s"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "about average"
|
||||||
|
msgstr "около среднего"
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "access"
|
msgid "access"
|
||||||
msgstr "доступ"
|
msgstr "доступ"
|
||||||
@@ -7818,6 +8011,13 @@ msgstr ": ошибка (%s)"
|
|||||||
msgid "from the portal"
|
msgid "from the portal"
|
||||||
msgstr "через портал"
|
msgstr "через портал"
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "full in about %s day, %s"
|
||||||
|
msgid_plural "full in about %s days, %s"
|
||||||
|
msgstr[0] "закончится примерно через %s день, %s"
|
||||||
|
msgstr[1] "закончится примерно через %s дня, %s"
|
||||||
|
msgstr[2] "закончится примерно через %s дней, %s"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
||||||
msgid "has an invalid interface name \"%s\""
|
msgid "has an invalid interface name \"%s\""
|
||||||
msgstr ": недопустимое имя интерфейса «%s»"
|
msgstr ": недопустимое имя интерфейса «%s»"
|
||||||
@@ -7966,10 +8166,6 @@ msgstr ": модуль ядра не установлен, туннели не
|
|||||||
msgid "kernel module isn't loaded"
|
msgid "kernel module isn't loaded"
|
||||||
msgstr ": модуль ядра не загружен"
|
msgstr ": модуль ядра не загружен"
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "last 15 min"
|
|
||||||
msgstr "за 15 мин"
|
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
#: web/src/admin/widgets/tiles.ts
|
||||||
msgid "last 2 min"
|
msgid "last 2 min"
|
||||||
msgstr "за 2 мин"
|
msgstr "за 2 мин"
|
||||||
@@ -8104,6 +8300,7 @@ msgstr "не настроено"
|
|||||||
|
|
||||||
#: web/src/admin/map.ts
|
#: web/src/admin/map.ts
|
||||||
#: web/src/admin/places/render.ts
|
#: web/src/admin/places/render.ts
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
msgid "now"
|
msgid "now"
|
||||||
msgstr "сейчас"
|
msgstr "сейчас"
|
||||||
|
|
||||||
@@ -8163,10 +8360,6 @@ msgstr "приостановить доступ"
|
|||||||
msgid "paused by admin"
|
msgid "paused by admin"
|
||||||
msgstr "приостановлено администратором"
|
msgstr "приостановлено администратором"
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "peak %s"
|
|
||||||
msgstr "пик %s"
|
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "port %s"
|
msgid "port %s"
|
||||||
msgstr "порт %s"
|
msgstr "порт %s"
|
||||||
@@ -8311,6 +8504,10 @@ msgstr "настраиваем заново"
|
|||||||
msgid "sha256 matches the release (%s…)"
|
msgid "sha256 matches the release (%s…)"
|
||||||
msgstr "sha256 совпадает с релизом (%s…)"
|
msgstr "sha256 совпадает с релизом (%s…)"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "so far"
|
||||||
|
msgstr "пока"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/bin/dawnline
|
#: package/luci-app-dawnline/root/usr/bin/dawnline
|
||||||
msgid "started"
|
msgid "started"
|
||||||
msgstr ": запущен"
|
msgstr ": запущен"
|
||||||
@@ -8488,3 +8685,7 @@ msgstr "«%s» - не IP-адрес. Несколько адресов разд
|
|||||||
#: web/src/admin/pages/components/hero.ts
|
#: web/src/admin/pages/components/hero.ts
|
||||||
msgid "← Newer"
|
msgid "← Newer"
|
||||||
msgstr "← Новее"
|
msgstr "← Новее"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "−%s%% vs average"
|
||||||
|
msgstr "−%s%% к среднему"
|
||||||
@@ -117,6 +117,10 @@ msgstr[1] ""
|
|||||||
msgid "%s MB free: settings may stop saving. Remove old backups (Settings → Backups) or shorten the history."
|
msgid "%s MB free: settings may stop saving. Remove old backups (Settings → Backups) or shorten the history."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "%s a day lately"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/access.ts
|
#: web/src/admin/access.ts
|
||||||
#: web/src/admin/device.ts
|
#: web/src/admin/device.ts
|
||||||
msgid "%s added"
|
msgid "%s added"
|
||||||
@@ -250,6 +254,12 @@ msgstr ""
|
|||||||
msgid "%s check failed"
|
msgid "%s check failed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/pages/overview.ts
|
||||||
|
msgid "%s city"
|
||||||
|
msgid_plural "%s cities"
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
#: web/src/admin/device.ts
|
#: web/src/admin/device.ts
|
||||||
msgid "%s copied"
|
msgid "%s copied"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -665,6 +675,10 @@ msgstr ""
|
|||||||
msgid "%s may not contain # or a line break."
|
msgid "%s may not contain # or a line break."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "%s min %s s ago"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/shared/format.ts
|
#: web/src/shared/format.ts
|
||||||
msgid "%s min ago"
|
msgid "%s min ago"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -869,6 +883,10 @@ msgstr ""
|
|||||||
msgid "%s s"
|
msgid "%s s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "%s s ago"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/settings/logs.ts
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
msgid "%s since %s"
|
msgid "%s since %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1055,6 +1073,10 @@ msgid_plural "+%s more in What’s new"
|
|||||||
msgstr[0] ""
|
msgstr[0] ""
|
||||||
msgstr[1] ""
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "+%s%% vs average"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/person/limits.ts
|
#: web/src/admin/pages/person/limits.ts
|
||||||
msgid "+1 month"
|
msgid "+1 month"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1088,6 +1110,10 @@ msgstr ""
|
|||||||
msgid "15 min"
|
msgid "15 min"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/pages/overview.ts
|
||||||
|
msgid "2 min"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/map.ts
|
#: web/src/admin/map.ts
|
||||||
msgid "24h"
|
msgid "24h"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1187,12 +1213,22 @@ msgstr ""
|
|||||||
msgid "Access ends %s"
|
msgid "Access ends %s"
|
||||||
msgstr ""
|
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
|
#: web/src/admin/netcheck.ts
|
||||||
msgid "Access ends in %s day (%s)."
|
msgid "Access ends in %s day (%s)."
|
||||||
msgid_plural "Access ends in %s days (%s)."
|
msgid_plural "Access ends in %s days (%s)."
|
||||||
msgstr[0] ""
|
msgstr[0] ""
|
||||||
msgstr[1] ""
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Access ends in a few days"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/netcheck.ts
|
#: web/src/admin/netcheck.ts
|
||||||
msgid "Access ends today (%s)."
|
msgid "Access ends today (%s)."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1201,6 +1237,22 @@ msgstr ""
|
|||||||
msgid "Access must be lan, internet or both."
|
msgid "Access must be lan, internet or both."
|
||||||
msgstr ""
|
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/libexec/dawnline/agent
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/watchdog.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/watchdog.uc
|
||||||
@@ -1387,6 +1439,10 @@ msgstr ""
|
|||||||
msgid "All components"
|
msgid "All components"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "All devices removed, end date reached"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/overview.ts
|
#: web/src/admin/pages/overview.ts
|
||||||
msgid "All good. Nothing needs you right now."
|
msgid "All good. Nothing needs you right now."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -2149,10 +2205,6 @@ msgstr ""
|
|||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "Collecting… 1 point a minute"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
#: web/src/admin/widgets/tiles.ts
|
||||||
msgid "Collecting… 1 point a second"
|
msgid "Collecting… 1 point a second"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -2470,6 +2522,10 @@ msgstr ""
|
|||||||
msgid "Dawnline was updated to %s: reload the page."
|
msgid "Dawnline was updated to %s: reload the page."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/tiles.ts
|
||||||
|
msgid "Days this device was used"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc
|
||||||
msgid "Default device limit must be 1-32."
|
msgid "Default device limit must be 1-32."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -2523,6 +2579,18 @@ msgstr ""
|
|||||||
msgid "Device"
|
msgid "Device"
|
||||||
msgstr ""
|
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
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Device %s changed network %s"
|
msgid "Device %s changed network %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -2587,6 +2655,30 @@ msgstr ""
|
|||||||
msgid "Device %s of %s: the public key is the server's own."
|
msgid "Device %s of %s: the public key is the server's own."
|
||||||
msgstr ""
|
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
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Device %s went offline"
|
msgid "Device %s went offline"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -2879,6 +2971,10 @@ msgstr ""
|
|||||||
msgid "End date must be YYYY-MM-DD."
|
msgid "End date must be YYYY-MM-DD."
|
||||||
msgstr ""
|
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
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
||||||
msgid "End dates and quotas use the router clock."
|
msgid "End dates and quotas use the router clock."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -3779,6 +3875,7 @@ msgid "Last 30 days"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/device.ts
|
#: web/src/admin/device.ts
|
||||||
|
#: web/src/admin/widgets/spark.ts
|
||||||
msgid "Last 7 days"
|
msgid "Last 7 days"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -4043,6 +4140,10 @@ msgstr ""
|
|||||||
msgid "Missing: %s."
|
msgid "Missing: %s."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/shared/format.ts
|
||||||
|
msgid "Mobile"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/person/limits.ts
|
#: web/src/admin/pages/person/limits.ts
|
||||||
msgid "Monthly"
|
msgid "Monthly"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -4222,6 +4323,10 @@ msgstr ""
|
|||||||
msgid "New keys generated"
|
msgid "New keys generated"
|
||||||
msgstr ""
|
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
|
#: web/src/admin/pages/person/header.ts
|
||||||
msgid "New link"
|
msgid "New link"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -4561,6 +4666,10 @@ msgstr ""
|
|||||||
msgid "Not set: the certificate is picked automatically."
|
msgid "Not set: the certificate is picked automatically."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "Not used"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/diagnostics/health.ts
|
#: web/src/admin/pages/diagnostics/health.ts
|
||||||
msgid "Not working"
|
msgid "Not working"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -5013,6 +5122,10 @@ msgstr ""
|
|||||||
msgid "Person %s removed device %s on their portal"
|
msgid "Person %s removed device %s on their portal"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Person %s renamed device %s on their portal"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Person %s resumed"
|
msgid "Person %s resumed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -6026,6 +6139,10 @@ msgstr ""
|
|||||||
msgid "Speed now"
|
msgid "Speed now"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/tiles.ts
|
||||||
|
msgid "Speed over the last 2 minutes"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/disguise.ts
|
#: web/src/admin/disguise.ts
|
||||||
msgid "Standard (old)"
|
msgid "Standard (old)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -6236,6 +6353,10 @@ msgstr ""
|
|||||||
msgid "The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds."
|
msgid "The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "The busiest of the %s days"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/backup.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/backup.uc
|
||||||
msgid "The configuration in this file cannot be read."
|
msgid "The configuration in this file cannot be read."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -6614,8 +6735,7 @@ msgstr ""
|
|||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
#: web/src/admin/places/model.ts
|
#: web/src/admin/places/model.ts
|
||||||
#: web/src/admin/widgets/spark.ts
|
#: web/src/admin/widgets/readouts.ts
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "Today"
|
msgid "Today"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -6652,6 +6772,10 @@ msgstr ""
|
|||||||
msgid "Traffic history reset"
|
msgid "Traffic history reset"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/tiles.ts
|
||||||
|
msgid "Traffic, last 30 days"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/components/hero.ts
|
#: web/src/admin/pages/components/hero.ts
|
||||||
msgid "Translation"
|
msgid "Translation"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7062,6 +7186,12 @@ msgstr ""
|
|||||||
msgid "Used for HTTPS links"
|
msgid "Used for HTTPS links"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "Used on %s of %s day"
|
||||||
|
msgid_plural "Used on %s of %s days"
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
||||||
msgid "Using a self-signed certificate: browsers will show a warning."
|
msgid "Using a self-signed certificate: browsers will show a warning."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7250,7 +7380,7 @@ msgstr ""
|
|||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
#: web/src/admin/places/model.ts
|
#: web/src/admin/places/model.ts
|
||||||
#: web/src/admin/widgets/spark.ts
|
#: web/src/admin/widgets/readouts.ts
|
||||||
msgid "Yesterday"
|
msgid "Yesterday"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -7266,6 +7396,10 @@ msgstr ""
|
|||||||
msgid "You added circle %s"
|
msgid "You added circle %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You added device %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You added device %s for %s"
|
msgid "You added device %s for %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7274,10 +7408,18 @@ msgstr ""
|
|||||||
msgid "You added person %s"
|
msgid "You added person %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You added this person"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "You changed circle %s"
|
msgid "You changed circle %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You changed device %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You changed device %s of %s"
|
msgid "You changed device %s of %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7290,6 +7432,10 @@ msgstr ""
|
|||||||
msgid "You changed server %s"
|
msgid "You changed server %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You changed settings"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "You changed the personal portal"
|
msgid "You changed the personal portal"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7318,10 +7464,22 @@ msgstr ""
|
|||||||
msgid "You issued a new link for person %s"
|
msgid "You issued a new link for person %s"
|
||||||
msgstr ""
|
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
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You issued new keys for device %s of %s"
|
msgid "You issued new keys for device %s of %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You paused access"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You paused person %s"
|
msgid "You paused person %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7330,6 +7488,10 @@ msgstr ""
|
|||||||
msgid "You removed circle %s"
|
msgid "You removed circle %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You removed device %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You removed device %s from %s"
|
msgid "You removed device %s from %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7342,6 +7504,14 @@ msgstr ""
|
|||||||
msgid "You removed server %s"
|
msgid "You removed server %s"
|
||||||
msgstr ""
|
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
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You renamed device %s of %s"
|
msgid "You renamed device %s of %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7362,10 +7532,18 @@ msgstr ""
|
|||||||
msgid "You restored backup %s"
|
msgid "You restored backup %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You resumed access"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You resumed person %s"
|
msgid "You resumed person %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You turned off device %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You turned off device %s of %s"
|
msgid "You turned off device %s of %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7382,6 +7560,10 @@ msgstr ""
|
|||||||
msgid "You turned off the watchdog"
|
msgid "You turned off the watchdog"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You turned on device %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You turned on device %s of %s"
|
msgid "You turned on device %s of %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7446,6 +7628,14 @@ msgstr ""
|
|||||||
msgid "a new build needs a manual switch in Components"
|
msgid "a new build needs a manual switch in Components"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "about %s by the reset on %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "about average"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "access"
|
msgid "access"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7749,6 +7939,12 @@ msgstr ""
|
|||||||
msgid "from the portal"
|
msgid "from the portal"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "full in about %s day, %s"
|
||||||
|
msgid_plural "full in about %s days, %s"
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
||||||
msgid "has an invalid interface name \"%s\""
|
msgid "has an invalid interface name \"%s\""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7897,10 +8093,6 @@ msgstr ""
|
|||||||
msgid "kernel module isn't loaded"
|
msgid "kernel module isn't loaded"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "last 15 min"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
#: web/src/admin/widgets/tiles.ts
|
||||||
msgid "last 2 min"
|
msgid "last 2 min"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -8035,6 +8227,7 @@ msgstr ""
|
|||||||
|
|
||||||
#: web/src/admin/map.ts
|
#: web/src/admin/map.ts
|
||||||
#: web/src/admin/places/render.ts
|
#: web/src/admin/places/render.ts
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
msgid "now"
|
msgid "now"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -8093,10 +8286,6 @@ msgstr ""
|
|||||||
msgid "paused by admin"
|
msgid "paused by admin"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "peak %s"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "port %s"
|
msgid "port %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -8241,6 +8430,10 @@ msgstr ""
|
|||||||
msgid "sha256 matches the release (%s…)"
|
msgid "sha256 matches the release (%s…)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "so far"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/bin/dawnline
|
#: package/luci-app-dawnline/root/usr/bin/dawnline
|
||||||
msgid "started"
|
msgid "started"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -8416,3 +8609,7 @@ msgstr ""
|
|||||||
#: web/src/admin/pages/components/hero.ts
|
#: web/src/admin/pages/components/hero.ts
|
||||||
msgid "← Newer"
|
msgid "← Newer"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "−%s%% vs average"
|
||||||
|
msgstr ""
|
||||||
@@ -77,4 +77,8 @@ reload_service() {
|
|||||||
|
|
||||||
service_triggers() {
|
service_triggers() {
|
||||||
procd_add_reload_trigger dawnline
|
procd_add_reload_trigger dawnline
|
||||||
|
# The portal's uhttpd reads its certificate once: an issued or renewed one needs a
|
||||||
|
# reload (procd restarts the portal alone, its cert file having changed).
|
||||||
|
procd_add_raw_trigger acme.issue 5000 /etc/init.d/dawnline reload
|
||||||
|
procd_add_raw_trigger acme.renew 5000 /etc/init.d/dawnline reload
|
||||||
}
|
}
|
||||||
@@ -360,7 +360,7 @@ let LOCK = null;
|
|||||||
for (let i = 0; i < 10 && !LOCK; i++) {
|
for (let i = 0; i < 10 && !LOCK; i++) {
|
||||||
LOCK = upd.try_lock();
|
LOCK = upd.try_lock();
|
||||||
if (!LOCK)
|
if (!LOCK)
|
||||||
system('usleep 100000 2>/dev/null || sleep 1');
|
sleep(100);
|
||||||
}
|
}
|
||||||
if (!LOCK)
|
if (!LOCK)
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"admin/network/dawnline": {
|
"admin/services/dawnline": {
|
||||||
"title": "Dawnline",
|
"title": "Dawnline",
|
||||||
"order": 65,
|
"order": 65,
|
||||||
"action": {
|
"action": {
|
||||||
"type": "alias",
|
"type": "alias",
|
||||||
"path": "admin/network/dawnline/server"
|
"path": "admin/services/dawnline/server"
|
||||||
},
|
},
|
||||||
"depends": {
|
"depends": {
|
||||||
"acl": [
|
"acl": [
|
||||||
@@ -15,31 +15,31 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/overview": {
|
"admin/services/dawnline/overview": {
|
||||||
"action": {
|
"action": {
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"path": "dawnline/server"
|
"path": "dawnline/server"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/people": {
|
"admin/services/dawnline/people": {
|
||||||
"action": {
|
"action": {
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"path": "dawnline/people"
|
"path": "dawnline/people"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/activity": {
|
"admin/services/dawnline/activity": {
|
||||||
"action": {
|
"action": {
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"path": "dawnline/activity"
|
"path": "dawnline/activity"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/person": {
|
"admin/services/dawnline/person": {
|
||||||
"action": {
|
"action": {
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"path": "dawnline/person"
|
"path": "dawnline/person"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/server": {
|
"admin/services/dawnline/server": {
|
||||||
"title": "Servers",
|
"title": "Servers",
|
||||||
"order": 10,
|
"order": 10,
|
||||||
"action": {
|
"action": {
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
"path": "dawnline/server"
|
"path": "dawnline/server"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/diagnostics": {
|
"admin/services/dawnline/diagnostics": {
|
||||||
"title": "Diagnostics",
|
"title": "Diagnostics",
|
||||||
"order": 40,
|
"order": 40,
|
||||||
"action": {
|
"action": {
|
||||||
@@ -55,13 +55,13 @@
|
|||||||
"path": "dawnline/diagnostics"
|
"path": "dawnline/diagnostics"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/health": {
|
"admin/services/dawnline/health": {
|
||||||
"action": {
|
"action": {
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"path": "dawnline/health"
|
"path": "dawnline/health"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/settings": {
|
"admin/services/dawnline/settings": {
|
||||||
"title": "Settings",
|
"title": "Settings",
|
||||||
"order": 60,
|
"order": 60,
|
||||||
"action": {
|
"action": {
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
"path": "dawnline/settings"
|
"path": "dawnline/settings"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/updates": {
|
"admin/services/dawnline/updates": {
|
||||||
"title": "Components",
|
"title": "Components",
|
||||||
"order": 70,
|
"order": 70,
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -79,14 +79,17 @@ function cached(key, ttl, fn) {
|
|||||||
/* ---------- releases ---------- */
|
/* ---------- releases ---------- */
|
||||||
|
|
||||||
function slim(x) {
|
function slim(x) {
|
||||||
let digests = {};
|
let digests = {}, ids = {};
|
||||||
for (let a in x.assets ?? [])
|
for (let a in x.assets ?? []) {
|
||||||
if (match(a.digest ?? '', /^sha256:[0-9a-f]{64}$/))
|
if (match(a.digest ?? '', /^sha256:[0-9a-f]{64}$/))
|
||||||
digests[a.name] = substr(a.digest, 7);
|
digests[a.name] = substr(a.digest, 7);
|
||||||
|
if (type(a.id) == 'int' && a.id > 0)
|
||||||
|
ids[a.name] = a.id;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
tag: x.tag_name, name: x.name ?? x.tag_name, published: x.published_at ?? null,
|
tag: x.tag_name, name: x.name ?? x.tag_name, published: x.published_at ?? null,
|
||||||
prerelease: !!x.prerelease, url: x.html_url ?? null, body: substr(x.body ?? '', 0, 12000),
|
prerelease: !!x.prerelease, url: x.html_url ?? null, body: substr(x.body ?? '', 0, 12000),
|
||||||
assets: map(x.assets ?? [], (a) => a.name), digests,
|
assets: map(x.assets ?? [], (a) => a.name), digests, ids,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,6 +197,25 @@ export function sha256(path) {
|
|||||||
return match(run(`sha256sum ${q(path)}`).out, /^([0-9a-f]{64})/)?.[1];
|
return match(run(`sha256sum ${q(path)}`).out, /^([0-9a-f]{64})/)?.[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** A release file's URL on github.com in parts: { repo, tag, name }, or null for any other URL. */
|
||||||
|
export function release_file(url) {
|
||||||
|
let m = match(url ?? '', /^https:\/\/github\.com\/([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)\/releases\/download\/([^\/?#]+)\/([^\/?#]+)$/);
|
||||||
|
return m ? { repo: m[1], tag: m[2], name: m[3] } : null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The same file through the API (api.github.com), when its release is known; else null. */
|
||||||
|
function asset_api_url(url) {
|
||||||
|
let f = release_file(url);
|
||||||
|
if (!f)
|
||||||
|
return null;
|
||||||
|
let id = null;
|
||||||
|
try {
|
||||||
|
id = release(f.repo, f.tag)?.ids?.[f.name];
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
return id ? `https://api.github.com/repos/${f.repo}/releases/assets/${id}` : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download to a file. o: { sha256, mirrors, log }. Direct first; mirrors
|
* Download to a file. o: { sha256, mirrors, log }. Direct first; mirrors
|
||||||
* only when the sha256 is known (from the API) and mirrors are allowed. A
|
* only when the sha256 is known (from the API) and mirrors are allowed. A
|
||||||
@@ -203,24 +225,32 @@ export function sha256(path) {
|
|||||||
export function download(url, dest, o) {
|
export function download(url, dest, o) {
|
||||||
o ??= {};
|
o ??= {};
|
||||||
let want = o.sha256 ? lc(o.sha256) : null;
|
let want = o.sha256 ? lc(o.sha256) : null;
|
||||||
let tries = [ url ];
|
let curl = have_curl();
|
||||||
|
let tries = [];
|
||||||
|
// Without curl a release file comes through the API first: github.com's redirect to it carries a
|
||||||
|
// Content-Security-Policy header that can outgrow uclient-fetch's 4 KB line buffer, and it stalls there.
|
||||||
|
let api = curl ? null : asset_api_url(url);
|
||||||
|
if (api)
|
||||||
|
push(tries, { u: api, accept: 'application/octet-stream' });
|
||||||
|
push(tries, { u: url });
|
||||||
|
let direct = length(tries);
|
||||||
if (want && o.mirrors && match(url, /^https:\/\/(github\.com|raw\.githubusercontent\.com)\//))
|
if (want && o.mirrors && match(url, /^https:\/\/(github\.com|raw\.githubusercontent\.com)\//))
|
||||||
for (let m in MIRRORS)
|
for (let m in MIRRORS)
|
||||||
push(tries, m + url);
|
push(tries, { u: m + url, mirror: true });
|
||||||
for (let i, u in tries) {
|
for (let i, t in tries) {
|
||||||
let host = replace(u, /^https:\/\/([^\/]+)\/.*$/, '$1');
|
let host = replace(t.u, /^https:\/\/([^\/]+)\/.*$/, '$1');
|
||||||
if (i > 0)
|
if (t.mirror)
|
||||||
o.log?.(sprintf(_('Trying mirror %s'), host));
|
o.log?.(sprintf(_('Trying mirror %s'), host));
|
||||||
let r = have_curl()
|
let r = curl
|
||||||
? run(`curl -fsSL --connect-timeout 15 --max-time 300 --retry 1 -o ${q(dest)} ${q(u)}`)
|
? run(`curl -fsSL --connect-timeout 15 --max-time 300 --retry 1 -o ${q(dest)} ${q(t.u)}`)
|
||||||
: run(`uclient-fetch -q -T 30 -O ${q(dest)} ${q(u)}`);
|
: run(`uclient-fetch -q -T 30 ${t.accept ? `--header=${q('Accept: ' + t.accept)} ` : ''}-O ${q(dest)} ${q(t.u)}`);
|
||||||
if (r.code == 0 && (stat(dest)?.size ?? 0) > 0) {
|
if (r.code == 0 && (stat(dest)?.size ?? 0) > 0) {
|
||||||
if (!want || sha256(dest) == want)
|
if (!want || sha256(dest) == want)
|
||||||
return u;
|
return t.u;
|
||||||
o.log?.(sprintf(_("Warning: %s sent a file that does not match GitHub's sha256, discarded"), host));
|
o.log?.(sprintf(_("Warning: %s sent a file that does not match GitHub's sha256, discarded"), host));
|
||||||
}
|
}
|
||||||
system(`rm -f ${q(dest)}`);
|
system(`rm -f ${q(dest)}`);
|
||||||
if (i == 0 && length(tries) > 1)
|
if (i == direct - 1 && length(tries) > direct)
|
||||||
o.log?.(_('GitHub did not answer, trying mirrors'));
|
o.log?.(_('GitHub did not answer, trying mirrors'));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// Dawnline — the live meter (the Overview's Speed now): each server's
|
// Dawnline — the live meter (Speed now on the Overview, the People list and a
|
||||||
// throughput, one point a second over the last two minutes.
|
// person's page): each server's throughput and that of each device moving
|
||||||
|
// traffic, one point a second over the last two minutes.
|
||||||
//
|
//
|
||||||
// The meter RPC (dawnline.rpc.status) calls want() and read(); the agent's
|
// The meter RPC (dawnline.rpc.status) calls want() and read(); the agent's
|
||||||
// watcher makes a point from every read it already does (sample(), point())
|
// watcher makes a point from every read it already does (sample(), point())
|
||||||
@@ -8,8 +9,8 @@
|
|||||||
// while WANT is younger than WANT_FOR seconds: the first second of a look,
|
// while WANT is younger than WANT_FOR seconds: the first second of a look,
|
||||||
// then with each new point. When WANT goes stale it removes FILE: with nobody
|
// then with each new point. When WANT goes stale it removes FILE: with nobody
|
||||||
// looking the watcher pays a little arithmetic and one stat() a second, and
|
// looking the watcher pays a little arithmetic and one stat() a second, and
|
||||||
// writes nothing. FILE holds server ids and byte rates only, no keys, names
|
// writes nothing. FILE holds server and device ids and byte rates only, no
|
||||||
// or personal codes. Who is online and the per-minute rates are not here
|
// keys, names or personal codes. Who is online and the per-minute rates are not here
|
||||||
// (dawnline.live, the agent's tick).
|
// (dawnline.live, the agent's tick).
|
||||||
//
|
//
|
||||||
// Bytes are the peers' counters (dawnline.awg.dump): tx includes the
|
// Bytes are the peers' counters (dawnline.awg.dump): tx includes the
|
||||||
@@ -95,26 +96,31 @@ function delta(a, b) {
|
|||||||
/**
|
/**
|
||||||
* The point between samples `a` and `b`, null when they are not a second or
|
* The point between samples `a` and `b`, null when they are not a second or
|
||||||
* so apart (the first sample, a stalled watcher): { ts, servers: { server
|
* so apart (the first sample, a stalled watcher): { ts, servers: { server
|
||||||
* id: [ rx, tx ] } }, bytes per second of its devices together (rx what came
|
* id: [ rx, tx ] }, dev: { device id: [ rx, tx ] } }, bytes per second of
|
||||||
* from them, tx what went to them, as a server's per-minute `rate`), for
|
* each server's devices together (rx what came from them, tx what went to
|
||||||
* every server whose tunnel `b` read ([ 0, 0 ] when nothing moved). A device
|
* them, as a server's per-minute `rate`), for every server whose tunnel `b`
|
||||||
* is counted from its second sample on, on the server it was on in both.
|
* read ([ 0, 0 ] when nothing moved), and of each device that moved
|
||||||
|
* something (one left out moved nothing, while its server was read). A
|
||||||
|
* device is counted from its second sample on, on the server it was on in both.
|
||||||
*/
|
*/
|
||||||
export function point(a, b) {
|
export function point(a, b) {
|
||||||
let dt = b.t - a.t;
|
let dt = b.t - a.t;
|
||||||
if (!(dt > 0.2 && dt < 5))
|
if (!(dt > 0.2 && dt < 5))
|
||||||
return null;
|
return null;
|
||||||
let sum = {};
|
let sum = {}, dev = {};
|
||||||
for (let sid in b.servers)
|
for (let sid in b.servers)
|
||||||
sum[sid] = [ 0, 0 ];
|
sum[sid] = [ 0, 0 ];
|
||||||
for (let id, v in b.dev) {
|
for (let id, v in b.dev) {
|
||||||
let o = a.dev[id];
|
let o = a.dev[id];
|
||||||
if (!o || o[2] != v[2])
|
if (!o || o[2] != v[2])
|
||||||
continue;
|
continue;
|
||||||
sum[v[2]][0] += delta(o[0], v[0]);
|
let rx = delta(o[0], v[0]), tx = delta(o[1], v[1]);
|
||||||
sum[v[2]][1] += delta(o[1], v[1]);
|
sum[v[2]][0] += rx;
|
||||||
|
sum[v[2]][1] += tx;
|
||||||
|
if (rx || tx)
|
||||||
|
dev[id] = [ int(rx / dt), int(tx / dt) ];
|
||||||
}
|
}
|
||||||
let p = { ts: b.ts, servers: {} };
|
let p = { ts: b.ts, servers: {}, dev };
|
||||||
for (let sid, v in sum)
|
for (let sid, v in sum)
|
||||||
p.servers[sid] = [ int(v[0] / dt), int(v[1] / dt) ];
|
p.servers[sid] = [ int(v[0] / dt), int(v[1] / dt) ];
|
||||||
return p;
|
return p;
|
||||||
|
|||||||
@@ -216,6 +216,13 @@ function table(m, sets, ctx) {
|
|||||||
if (length(ifs))
|
if (length(ifs))
|
||||||
// Home names (and no LAN DNS at all): the plain resolver, whatever address was asked.
|
// Home names (and no LAN DNS at all): the plain resolver, whatever address was asked.
|
||||||
push(t, ` iifname { ${join(', ', ifs)} } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 ${to_resolver}`);
|
push(t, ` iifname { ${join(', ', ifs)} } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 ${to_resolver}`);
|
||||||
|
push(t, ' }');
|
||||||
|
// After the LAN's own DNS interceptors (transparent proxies redirect port 53
|
||||||
|
// at dstnat - 1): only the first NAT of a connection counts, so a DNAT here
|
||||||
|
// first would hand the query to the plain resolver behind their back. When
|
||||||
|
// none of them takes the tunnel, this sends it to the LAN's DNS.
|
||||||
|
push(t, ' chain dns_lan {');
|
||||||
|
push(t, ' type nat hook prerouting priority dstnat + 5; policy accept;');
|
||||||
for (let id, srv in m.servers)
|
for (let id, srv in m.servers)
|
||||||
for (let tn in core.tunnels(srv)) {
|
for (let tn in core.tunnels(srv)) {
|
||||||
// Everyone else: the LAN's DNS, through the netns (from the LAN side) when internet goes that way.
|
// Everyone else: the LAN's DNS, through the netns (from the LAN side) when internet goes that way.
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ function releases(a) {
|
|||||||
let page = +(a.page ?? 1);
|
let page = +(a.page ?? 1);
|
||||||
if (page != int(page) || page < 1 || page > 50)
|
if (page != int(page) || page < 1 || page > 50)
|
||||||
die(_('Unknown page.'));
|
die(_('Unknown page.'));
|
||||||
return { releases: map(gh.releases(REPO, page), (x) => ({ ...x, body: null, digests: null })), page };
|
return { releases: map(gh.releases(REPO, page), (x) => ({ ...x, body: null, digests: null, ids: null })), page };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Release notes for What's new: Dawnline by tag, or an AmneziaWG build's release. */
|
/** Release notes for What's new: Dawnline by tag, or an AmneziaWG build's release. */
|
||||||
@@ -94,7 +94,7 @@ function notes(a) {
|
|||||||
r = gh.release(rp, `v${tag}`);
|
r = gh.release(rp, `v${tag}`);
|
||||||
if (!r)
|
if (!r)
|
||||||
die(sprintf(_('No release %s in %s.'), tag, rp));
|
die(sprintf(_('No release %s in %s.'), tag, rp));
|
||||||
return { ...r, digests: null, repo: rp };
|
return { ...r, digests: null, ids: null, repo: rp };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** What changed between the installed Dawnline and a release (points for the Components tab). */
|
/** What changed between the installed Dawnline and a release (points for the Components tab). */
|
||||||
@@ -111,8 +111,10 @@ function changes(a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start an update job. Returns the new job once its worker has written it,
|
* Start an update job. Returns the new job once its worker has written it
|
||||||
* else null (the caller follows updates_status); never an older job.
|
* (a quick check may be over by then), else null (the caller follows
|
||||||
|
* updates_status); never an older job. Waits two seconds at most: LuCI gives
|
||||||
|
* up on a call after twenty.
|
||||||
*/
|
*/
|
||||||
function run(a) {
|
function run(a) {
|
||||||
let what = a.what ?? 'check';
|
let what = a.what ?? 'check';
|
||||||
@@ -126,16 +128,17 @@ function run(a) {
|
|||||||
if (upd.busy())
|
if (upd.busy())
|
||||||
die(_('Another component action is already running'));
|
die(_('Another component action is already running'));
|
||||||
ensure_dir(RUN_DIR);
|
ensure_dir(RUN_DIR);
|
||||||
let t0 = time();
|
let t0 = time(), prev = read_json(upd.JOB_FILE, null)?.id;
|
||||||
let args = substr(what, 0, 5) == 'check' ? `check ${substr(what, 6)}` : `install ${what}`;
|
let args = substr(what, 0, 5) == 'check' ? `check ${substr(what, 6)}` : `install ${what}`;
|
||||||
// The job speaks the admin's language (use() let only a plain language code through).
|
// The job speaks the admin's language (use() let only a plain language code through).
|
||||||
let lang = i18n.current();
|
let lang = i18n.current();
|
||||||
system(`${lang ? `DAWNLINE_LANG=${lang} ` : ''}start-stop-daemon -S -b -x /usr/libexec/dawnline/updater -- ${args}`);
|
system(`${lang ? `DAWNLINE_LANG=${lang} ` : ''}start-stop-daemon -S -b -x /usr/libexec/dawnline/updater -- ${args}`);
|
||||||
for (let i = 0; i < 20; i++) {
|
for (let i = 0; i < 20; i++) {
|
||||||
let j = read_json(upd.JOB_FILE, null);
|
let j = read_json(upd.JOB_FILE, null);
|
||||||
if (j?.state == 'running' && j.started >= t0)
|
if (j && j.id != prev && j.started >= t0)
|
||||||
return { started: true, job: j };
|
return { started: true, job: j };
|
||||||
system('usleep 100000 2>/dev/null || sleep 1');
|
// ucode's own sleep: OpenWrt's BusyBox has no usleep.
|
||||||
|
sleep(100);
|
||||||
}
|
}
|
||||||
return { started: true, job: null };
|
return { started: true, job: null };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export function check(ctx) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The sha256 a release publishes for a file: GitHub's own (API), else the
|
* The sha256 a release publishes for a file: GitHub's own (API), else the
|
||||||
* release's sha256sums.txt fetched straight from github.com (never a mirror).
|
* release's sha256sums.txt fetched straight from GitHub (never a mirror).
|
||||||
*/
|
*/
|
||||||
function want_sha(ctx, tag, asset, dir) {
|
function want_sha(ctx, tag, asset, dir) {
|
||||||
let want = gh.asset_sha256(REPO, tag, asset);
|
let want = gh.asset_sha256(REPO, tag, asset);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs';
|
import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs';
|
||||||
import { _ } from 'dawnline.i18n';
|
import { _ } from 'dawnline.i18n';
|
||||||
|
|
||||||
export const VERSION = '0.16.0';
|
export const VERSION = '0.17.0';
|
||||||
/** GitHub repository with Dawnline releases (updates and the installer). */
|
/** GitHub repository with Dawnline releases (updates and the installer). */
|
||||||
export const REPO = 'tickcount/luci-app-dawnline';
|
export const REPO = 'tickcount/luci-app-dawnline';
|
||||||
export const RUN_DIR = '/var/run/dawnline';
|
export const RUN_DIR = '/var/run/dawnline';
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ for (const [real, shown] of args.names)
|
|||||||
args.mask.push([real, shown], [real.toLowerCase(), shown.toLowerCase()], [real.toUpperCase(), shown.toUpperCase()]);
|
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 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';
|
const USER = process.env.LUCI_USER || 'root';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -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)"
|
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
|
EOF
|
||||||
if [ -n "$PREV" ]; then
|
if [ -n "$PREV" ]; then
|
||||||
printf '\n**Full Changelog**: https://github.com/%s/compare/%s...%s\n' "$REPO" "$PREV" "$TAG"
|
printf '\n**Full Changelog**: https://github.com/%s/compare/%s...%s\n' "$REPO" "$PREV" "$TAG"
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ table inet dawnline {
|
|||||||
chain dns {
|
chain dns {
|
||||||
type nat hook prerouting priority dstnat - 5; policy accept;
|
type nat hook prerouting priority dstnat - 5; policy accept;
|
||||||
iifname { "awghome", "awgwork" } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 dnat ip to 169.254.77.2:53
|
iifname { "awghome", "awgwork" } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 dnat ip to 169.254.77.2:53
|
||||||
|
}
|
||||||
|
chain dns_lan {
|
||||||
|
type nat hook prerouting priority dstnat + 5; policy accept;
|
||||||
iifname "awghome" ip daddr 10.9.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.1.250:53
|
iifname "awghome" ip daddr 10.9.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.1.250:53
|
||||||
iifname "awgwork" ip daddr 10.9.1.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.1.1:53
|
iifname "awgwork" ip daddr 10.9.1.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.1.1:53
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// dawnline.github: which URLs are a release's files (those can come through
|
||||||
|
// the API instead of github.com's redirect) and the points of a commit message.
|
||||||
|
import * as gh from 'dawnline.github';
|
||||||
|
|
||||||
|
test('release_file', () => {
|
||||||
|
eq(gh.release_file('https://github.com/tickcount/luci-app-dawnline/releases/download/v0.16.0/sha256sums.txt'),
|
||||||
|
{ repo: 'tickcount/luci-app-dawnline', tag: 'v0.16.0', name: 'sha256sums.txt' }, 'a Dawnline release file');
|
||||||
|
eq(gh.release_file('https://github.com/Slava-Shchipunov/awg-openwrt/releases/download/v24.10.4/kmod-amneziawg_v24.10.4_aarch64_cortex-a53_mediatek_filogic.ipk'),
|
||||||
|
{ repo: 'Slava-Shchipunov/awg-openwrt', tag: 'v24.10.4', name: 'kmod-amneziawg_v24.10.4_aarch64_cortex-a53_mediatek_filogic.ipk' },
|
||||||
|
'an AmneziaWG build');
|
||||||
|
eq(gh.release_file('https://ghfast.top/https://github.com/tickcount/luci-app-dawnline/releases/download/v0.16.0/a.ipk'), null, 'a mirror');
|
||||||
|
eq(gh.release_file('https://raw.githubusercontent.com/tickcount/luci-app-dawnline/main/install.sh'), null, 'not a release file');
|
||||||
|
eq(gh.release_file('https://github.com/tickcount/luci-app-dawnline/releases/latest'), null, 'the latest redirect');
|
||||||
|
eq(gh.release_file('https://github.com/a/b/releases/download/v1/x.ipk?raw=1'), null, 'a query');
|
||||||
|
eq(gh.release_file('https://github.com/a/b/releases/download/v1/sub/x.ipk'), null, 'a deeper path');
|
||||||
|
eq(gh.release_file(null), null, 'nothing');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('points', () => {
|
||||||
|
eq(gh.points('Dawnline 0.16.0\n\n- Check no longer times out\n- Downloads without curl\n go through the API'),
|
||||||
|
[ 'Check no longer times out', 'Downloads without curl go through the API' ], 'a release commit, a wrapped point');
|
||||||
|
eq(gh.points('Fix the portal'), [ 'Fix the portal' ], 'another commit: its title');
|
||||||
|
eq(gh.points('Dawnline 0.16.0'), [], 'a bare release title');
|
||||||
|
eq(gh.points('Merge branch x\n\n- y'), [], 'a merge');
|
||||||
|
});
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
// dawnline.meter: the point between two samples (each server's bytes per
|
// dawnline.meter: the point between two samples (each server's and each
|
||||||
// second), the sample taken from a dump, the two minutes kept, and the file
|
// moving device's bytes per second), the sample taken from a dump, the two minutes kept, and the file
|
||||||
// the watcher writes and the RPC reads (in RUN_DIR, removed after).
|
// the watcher writes and the RPC reads (in RUN_DIR, removed after).
|
||||||
import * as meter from 'dawnline.meter';
|
import * as meter from 'dawnline.meter';
|
||||||
import { stat, unlink } from 'fs';
|
import { stat, unlink } from 'fs';
|
||||||
@@ -14,13 +14,15 @@ test('point', () => {
|
|||||||
// d_2 sent nothing; d_3's peer was added again (counters from zero); d_4 is new; d_5 moved to s_1.
|
// d_2 sent nothing; d_3's peer was added again (counters from zero); d_4 is new; d_5 moved to s_1.
|
||||||
dev: { d_1: [ 3000, 12000, 's_1' ], d_2: [ 500, 500, 's_1' ], d_3: [ 100, 300, 's_1' ], d_4: [ 10, 10, 's_1' ], d_5: [ 50, 50, 's_1' ] },
|
dev: { d_1: [ 3000, 12000, 's_1' ], d_2: [ 500, 500, 's_1' ], d_3: [ 100, 300, 's_1' ], d_4: [ 10, 10, 's_1' ], d_5: [ 50, 50, 's_1' ] },
|
||||||
};
|
};
|
||||||
eq(meter.point(a, b), { ts: 5001, servers: { s_1: [ 2000, 10000 ], s_2: [ 0, 0 ] } },
|
eq(meter.point(a, b), { ts: 5001, servers: { s_1: [ 2000, 10000 ], s_2: [ 0, 0 ] }, dev: { d_1: [ 2000, 10000 ] } },
|
||||||
'bytes per second of each server\'s devices together; a server read with nothing moving is 0');
|
'bytes per second of each server\'s devices together; a server read with nothing moving is 0; only devices that moved');
|
||||||
|
eq(meter.point(a, { ...b, t: 102.0 }).dev, { d_1: [ 1000, 5000 ] }, 'a device over two seconds');
|
||||||
eq(meter.point(a, { ...b, t: 102.0 }).servers.s_1, [ 1000, 5000 ], 'over two seconds');
|
eq(meter.point(a, { ...b, t: 102.0 }).servers.s_1, [ 1000, 5000 ], 'over two seconds');
|
||||||
eq(meter.point(a, { ...b, t: 100.0 }), null, 'no time passed');
|
eq(meter.point(a, { ...b, t: 100.0 }), null, 'no time passed');
|
||||||
eq(meter.point(a, { ...b, t: 110.0 }), null, 'the watcher stalled');
|
eq(meter.point(a, { ...b, t: 110.0 }), null, 'the watcher stalled');
|
||||||
eq(meter.point(a, { ...b, servers: [ 's_2' ], dev: { d_5: [ 50, 50, 's_2' ] } }).servers, { s_2: [ 50, 50 ] }, 'only servers read in the newer sample');
|
eq(meter.point(a, { ...b, servers: [ 's_2' ], dev: { d_5: [ 50, 50, 's_2' ] } }).servers, { s_2: [ 50, 50 ] }, 'only servers read in the newer sample');
|
||||||
eq(meter.point({ ...a, dev: {} }, b).servers, { s_1: [ 0, 0 ], s_2: [ 0, 0 ] }, 'a first look at every device: nothing yet');
|
eq(meter.point({ ...a, dev: {} }, b).servers, { s_1: [ 0, 0 ], s_2: [ 0, 0 ] }, 'a first look at every device: nothing yet');
|
||||||
|
eq(meter.point({ ...a, dev: {} }, b).dev, {}, 'and no device either');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sample', () => {
|
test('sample', () => {
|
||||||
@@ -37,7 +39,7 @@ test('sample', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('keep', () => {
|
test('keep', () => {
|
||||||
let pt = (ts) => ({ ts: ts, servers: { s_1: [ ts, 0 ] } });
|
let pt = (ts) => ({ ts: ts, servers: { s_1: [ ts, 0 ] }, dev: { d_1: [ ts, 0 ] } });
|
||||||
let ring = [];
|
let ring = [];
|
||||||
for (let ts = 1000; ts < 1000 + meter.POINTS + 5; ts++)
|
for (let ts = 1000; ts < 1000 + meter.POINTS + 5; ts++)
|
||||||
meter.keep(ring, pt(ts));
|
meter.keep(ring, pt(ts));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// dawnline.nft: the access table rendered for a model with two servers (one
|
// dawnline.nft: the access table rendered for a model with two servers (one
|
||||||
// sending everyone like a home device, one direct) and the router read as a
|
// sending everyone like a home device, one direct) and the router read as a
|
||||||
// fixed context: exactly what 0.13.0 renders (fixtures/nft-table.txt, made by
|
// fixed context: what 0.13.0 rendered (fixtures/nft-table.txt, made by
|
||||||
// that version from this model).
|
// that version from this model).
|
||||||
import { readfile } from 'fs';
|
import { readfile } from 'fs';
|
||||||
import * as nft from 'dawnline.nft';
|
import * as nft from 'dawnline.nft';
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "dawnline-web",
|
"name": "dawnline-web",
|
||||||
"version": "0.16.0",
|
"version": "0.17.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "dawnline-web",
|
"name": "dawnline-web",
|
||||||
"version": "0.16.0",
|
"version": "0.17.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"qrcode-generator": "2.0.4"
|
"qrcode-generator": "2.0.4"
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dawnline-web",
|
"name": "dawnline-web",
|
||||||
"version": "0.16.0",
|
"version": "0.17.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -82,10 +82,14 @@ export interface EndpointProbe {
|
|||||||
here6?: boolean;
|
here6?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** One second of the live meter: each server whose tunnel was read, [rx, tx] in bytes/s (rx = from devices, as Server.rate). */
|
/**
|
||||||
|
* One second of the live meter: each server whose tunnel was read, [rx, tx] in bytes/s (rx = from devices, as
|
||||||
|
* Server.rate), and each device that moved something (one left out moved nothing; an older agent sends none).
|
||||||
|
*/
|
||||||
export interface MeterPoint {
|
export interface MeterPoint {
|
||||||
ts: number;
|
ts: number;
|
||||||
servers: Record<string, Pair>;
|
servers: Record<string, Pair>;
|
||||||
|
dev?: Record<string, Pair>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -448,7 +448,7 @@ function overviewTile(srv: Server): HTMLElement {
|
|||||||
return E('div', { class: 'dl-bento-tile dl-disg' }, [
|
return E('div', { class: 'dl-bento-tile dl-disg' }, [
|
||||||
E('div', { class: 'dl-bento-head' }, [
|
E('div', { class: 'dl-bento-head' }, [
|
||||||
E('span', { class: 'dl-metric-label' }, _('Disguise')),
|
E('span', { class: 'dl-metric-label' }, _('Disguise')),
|
||||||
E('a', { href: `${L.url('admin/network/dawnline/server')}?server=${encodeURIComponent(srv.id)}§ion=awg` }, _('Change')),
|
E('a', { href: `${L.url('admin/services/dawnline/server')}?server=${encodeURIComponent(srv.id)}§ion=awg` }, _('Change')),
|
||||||
]),
|
]),
|
||||||
E('div', { class: 'dl-disg-id' }, [
|
E('div', { class: 'dl-disg-id' }, [
|
||||||
E('span', { class: `dl-disg-ic${m?.id === 'off' ? ' off' : ''}` }, icon(m?.ic ?? 'shield')),
|
E('span', { class: `dl-disg-ic${m?.id === 'off' ? ' off' : ''}` }, icon(m?.ic ?? 'shield')),
|
||||||
|
|||||||
+30
-16
@@ -17,7 +17,20 @@ import { isOn, sw } from './ui/controls';
|
|||||||
import { qrCode } from './ui/qr';
|
import { qrCode } from './ui/qr';
|
||||||
import { deviceNameHelp, type Help } from './netcheck';
|
import { deviceNameHelp, type Help } from './netcheck';
|
||||||
import { deviceStatus } from './ui/badges';
|
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 { guardDeviceName } from '../shared/name-guard';
|
||||||
import { fill, fmt, locale, num } from '../shared/i18n';
|
import { fill, fmt, locale, num } from '../shared/i18n';
|
||||||
import { icon } from '../shared/icons';
|
import { icon } from '../shared/icons';
|
||||||
@@ -222,8 +235,7 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) {
|
|||||||
E('span', { class: 'dl-sub' }, `${p.name} · ${kindLabel(d.kind)}`),
|
E('span', { class: 'dl-sub' }, `${p.name} · ${kindLabel(d.kind)}`),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
const days = d.spark.map(([rx, tx]) => rx + tx);
|
const week = d.spark.reduce((a, [rx, tx]) => a + rx + tx, 0);
|
||||||
const week = days.reduce((a, b) => a + b, 0);
|
|
||||||
dom.content(
|
dom.content(
|
||||||
stats,
|
stats,
|
||||||
E('div', { class: 'dl-dstats' }, [
|
E('div', { class: 'dl-dstats' }, [
|
||||||
@@ -240,7 +252,7 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) {
|
|||||||
E('div', { class: 'dl-dstats-cell' }, [
|
E('div', { class: 'dl-dstats-cell' }, [
|
||||||
E('span', { class: 'dl-metric-label' }, _('Last 7 days')),
|
E('span', { class: 'dl-metric-label' }, _('Last 7 days')),
|
||||||
E('b', {}, bytes(week)),
|
E('b', {}, bytes(week)),
|
||||||
spark(days, 120, 22, today),
|
spark(d.spark, 120, 22, today),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
@@ -421,7 +433,7 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) {
|
|||||||
},
|
},
|
||||||
_('Clear'),
|
_('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,
|
log,
|
||||||
@@ -610,44 +622,46 @@ export function addDevice(person: Person, o: DeviceOpts) {
|
|||||||
while (taken.some((t) => t.toLowerCase() === name.toLowerCase())) name = fitName(base, ` ${++n}`);
|
while (taken.some((t) => t.toLowerCase() === name.toLowerCase())) name = fitName(base, ` ${++n}`);
|
||||||
return name;
|
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', {
|
const nameInput = E('input', {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
class: 'cbi-input-text',
|
class: 'cbi-input-text',
|
||||||
placeholder: suggest(kind),
|
placeholder: suggest(kindOf(pick)),
|
||||||
}) as HTMLInputElement;
|
}) as HTMLInputElement;
|
||||||
const said = nameGuard(nameInput, () => nameRow.refresh());
|
const said = nameGuard(nameInput, () => nameRow.refresh());
|
||||||
const nameRow = liveField(_('Name'), nameInput, () =>
|
const nameRow = liveField(_('Name'), nameInput, () =>
|
||||||
said(
|
said(
|
||||||
nameInput.value.trim()
|
nameInput.value.trim()
|
||||||
? deviceNameHelp(nameInput.value, taken, _('Shown in the portal and in the app.'))
|
? 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(
|
const kinds = E(
|
||||||
'div',
|
'div',
|
||||||
{ class: 'dl-kinds', role: 'radiogroup', 'aria-label': _('Type') },
|
{ class: 'dl-kinds', role: 'radiogroup', 'aria-label': _('Type') },
|
||||||
KINDS.map((k) =>
|
PICKS.map((k) =>
|
||||||
E(
|
E(
|
||||||
'button',
|
'button',
|
||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
role: 'radio',
|
role: 'radio',
|
||||||
class: k === kind ? 'on' : '',
|
class: k === pick ? 'on' : '',
|
||||||
'aria-checked': k === kind ? 'true' : 'false',
|
'aria-checked': k === pick ? 'true' : 'false',
|
||||||
'data-kind': k,
|
'data-kind': k,
|
||||||
click: () => {
|
click: () => {
|
||||||
kind = k;
|
pick = k;
|
||||||
kinds.querySelectorAll('button').forEach((c) => {
|
kinds.querySelectorAll('button').forEach((c) => {
|
||||||
const on = (c as HTMLElement).dataset.kind === k;
|
const on = (c as HTMLElement).dataset.kind === k;
|
||||||
c.classList.toggle('on', on);
|
c.classList.toggle('on', on);
|
||||||
c.setAttribute('aria-checked', on ? 'true' : 'false');
|
c.setAttribute('aria-checked', on ? 'true' : 'false');
|
||||||
});
|
});
|
||||||
nameInput.placeholder = suggest(k);
|
nameInput.placeholder = suggest(kindOf(k));
|
||||||
nameRow.refresh();
|
nameRow.refresh();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[icon(k), E('span', {}, kindLabel(k))],
|
[icon(k), E('span', {}, pickLabel(k))],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -704,8 +718,8 @@ export function addDevice(person: Person, o: DeviceOpts) {
|
|||||||
notify(h.text, 'warning');
|
notify(h.text, 'warning');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const name = nameInput.value.trim() || suggest(kind);
|
const name = nameInput.value.trim() || suggest(kindOf(pick));
|
||||||
const r = await attempt(() => api.deviceCreate(person.id, name, kind, isOn(bypass)));
|
const r = await attempt(() => api.deviceCreate(person.id, name, kindOf(pick), isOn(bypass)));
|
||||||
if (!r) return;
|
if (!r) return;
|
||||||
closeModal();
|
closeModal();
|
||||||
notify(fmt(_('%s added'), name), 'success', 3000);
|
notify(fmt(_('%s added'), name), 'success', 3000);
|
||||||
|
|||||||
@@ -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. */
|
/** 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);
|
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 person = st.people.find((p) => p.id === e.person);
|
||||||
const who = person?.name ?? e.pname ?? e.person ?? '';
|
const who = person?.name ?? e.pname ?? e.person ?? '';
|
||||||
const dev = person?.devices.find((d) => d.id === e.device)?.name ?? e.dname ?? '';
|
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');
|
const w = _('You');
|
||||||
return s.startsWith(`${w} `) ? [E('span', { class: 'dl-you' }, w), ...say(s.slice(w.length), ...args)] : say(s, ...args);
|
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 detail = plainDetail(e);
|
||||||
const devName = b(detail || dev || _('a device'));
|
const devName = b(detail || dev || _('a device'));
|
||||||
const by = eventBy(e);
|
const by = eventBy(e);
|
||||||
if (by === 'admin')
|
if (by === 'admin')
|
||||||
switch (e.type) {
|
switch (e.type) {
|
||||||
case 'device_added':
|
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':
|
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':
|
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':
|
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': {
|
case 'device_changed': {
|
||||||
const d = b(dev || _('a device'));
|
const d = b(dev || _('a device'));
|
||||||
if (detail.startsWith('renamed from '))
|
if (detail.startsWith('renamed from '))
|
||||||
return [...you(_('You renamed device %s of %s'), d, b(who)), m(` · ${fmt(_('was %s'), detail.slice(13))}`)];
|
return [
|
||||||
if (detail === 'turned off') return you(_('You turned off device %s of %s'), d, b(who));
|
...(scoped ? you(_('You renamed device %s'), d) : you(_('You renamed device %s of %s'), d, b(who))),
|
||||||
if (detail === 'turned on') return you(_('You turned on 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.
|
// 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':
|
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':
|
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) {
|
switch (e.type) {
|
||||||
case 'connect':
|
case 'connect':
|
||||||
@@ -136,35 +153,77 @@ export function eventText(st: Pick<Status, 'people'>, e: LogEvent): Node[] {
|
|||||||
);
|
);
|
||||||
case 'device_added':
|
case 'device_added':
|
||||||
return by === 'portal'
|
return by === 'portal'
|
||||||
? say(_('Person %s added device %s on their portal'), b(who), devName)
|
? scoped
|
||||||
: say(_('Person %s added device %s'), b(who), devName);
|
? 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':
|
case 'device_removed':
|
||||||
return by === 'portal'
|
return by === 'portal'
|
||||||
? say(_('Person %s removed device %s on their portal'), b(who), devName)
|
? scoped
|
||||||
: say(_('Person %s removed device %s'), b(who), devName);
|
? 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':
|
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':
|
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':
|
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':
|
case 'person_changed':
|
||||||
// The detail lists changed fields by their option names (device_limit, expire_action).
|
// 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': {
|
case 'expiring': {
|
||||||
const n = daysOf(e.detail ?? '');
|
const n = daysOf(e.detail ?? '');
|
||||||
return n != null
|
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)))
|
? scoped
|
||||||
: say(_('Person %s’s access ends in a few days'), b(who));
|
? 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':
|
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':
|
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':
|
case 'resumed':
|
||||||
return e.detail && e.detail !== 'active'
|
return e.detail && e.detail !== 'active'
|
||||||
? say(_('Person %s resumed - %s'), b(who), m(reasonText(e.detail)))
|
? scoped
|
||||||
: say(_('Person %s resumed'), b(who));
|
? 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':
|
case 'portal_blocked':
|
||||||
return say(
|
return say(
|
||||||
_('%s blocked %s for 15 min after too many wrong codes'),
|
_('%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 ?? ''),
|
e.detail === 'all Cloudflare visitors' ? m(_('all Cloudflare visitors')) : mono(e.detail ?? ''),
|
||||||
);
|
);
|
||||||
case 'devices_removed':
|
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':
|
case 'device_failing':
|
||||||
return [...say(_('Device %s has a connection problem'), wd), ...(e.detail ? [m(` · ${linkStatesText(e.detail)}`)] : [])];
|
return [...say(_('Device %s has a connection problem'), wd), ...(e.detail ? [m(` · ${linkStatesText(e.detail)}`)] : [])];
|
||||||
case 'device_recovered':
|
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). */
|
/** 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 sys = SYSTEM_EVENT[e.type];
|
||||||
const by = eventBy(e);
|
const by = eventBy(e);
|
||||||
return E('div', { class: `dl-row${by === 'admin' ? ' dl-ev-by-admin' : sys ? ` dl-ev-by-system ${sys[1]}` : ''}` }, [
|
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
|
: sys
|
||||||
? E('span', { class: 'dl-ev-tile sys' }, icon(sys[0]))
|
? 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-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),
|
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)),
|
E('span', { class: 'dl-faint dl-nowrap', title: new Date(e.ts * 1000).toLocaleString(locale()) }, opts.time ?? ago(e.ts, st.now)),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ function moved(tab: '' | 'log') {
|
|||||||
return () => ({
|
return () => ({
|
||||||
load: () => {
|
load: () => {
|
||||||
ui.menu?.flushCache();
|
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(() => {});
|
return new Promise(() => {});
|
||||||
},
|
},
|
||||||
render: () => document.createElement('div'),
|
render: () => document.createElement('div'),
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export function activity(page: ComponentsPage): HTMLElement {
|
|||||||
E('div', { class: 'dl-panel-head pad' }, [
|
E('div', { class: 'dl-panel-head pad' }, [
|
||||||
E('h3', {}, _('Activity')),
|
E('h3', {}, _('Activity')),
|
||||||
E('span', { class: 'dl-spacer' }),
|
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
|
h.length
|
||||||
? E('div', {}, h.slice(0, 8).map(row))
|
? E('div', {}, h.slice(0, 8).map(row))
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ export class ComponentsPage {
|
|||||||
E('div', { class: 'dl-row-actions' }, [
|
E('div', { class: 'dl-row-actions' }, [
|
||||||
E(
|
E(
|
||||||
'a',
|
'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')],
|
[icon('edit'), ' ', _('Settings')],
|
||||||
),
|
),
|
||||||
button([icon('refresh'), ' ', _('Check all')], () => this.op('check', _('Checking all components')), 'neutral', {
|
button([icon('refresh'), ' ', _('Check all')], () => this.op('check', _('Checking all components')), 'neutral', {
|
||||||
|
|||||||
@@ -2,11 +2,10 @@
|
|||||||
// online, traffic, disguise, the connection map, activity and what needs
|
// online, traffic, disguise, the connection map, activity and what needs
|
||||||
// attention — all limited to the people on that server.
|
// attention — all limited to the people on that server.
|
||||||
|
|
||||||
import type { Device, Person, Status } from '../../shared/types';
|
import type { Device, GeoPoint, Person, Status } from '../../shared/types';
|
||||||
import { E } from '../e';
|
import { E } from '../e';
|
||||||
import { api } from '../api';
|
import { api } from '../api';
|
||||||
import { svg } from '../ui/layout';
|
import { attachTip, refreshTip } from '../ui/tooltip';
|
||||||
import { attachTip } from '../ui/tooltip';
|
|
||||||
import { icon } from '../../shared/icons';
|
import { icon } from '../../shared/icons';
|
||||||
import { ago, bits, bytes, date, daysLeft, duration, endsIn, endsSoon, initials, todayOf } from '../../shared/format';
|
import { ago, bits, bytes, date, daysLeft, duration, endsIn, endsSoon, initials, todayOf } from '../../shared/format';
|
||||||
import { fill, fmt, plural } from '../../shared/i18n';
|
import { fill, fmt, plural } from '../../shared/i18n';
|
||||||
@@ -17,6 +16,7 @@ import { scoped } from '../state/scope';
|
|||||||
import { focusInside, repaint } from '../state/poller';
|
import { focusInside, repaint } from '../state/poller';
|
||||||
import type { LiveMeter } from '../state/meter';
|
import type { LiveMeter } from '../state/meter';
|
||||||
import { daysTile, LiveSpeedTile } from '../widgets/tiles';
|
import { daysTile, LiveSpeedTile } from '../widgets/tiles';
|
||||||
|
import { SpeedLines } from '../widgets/lines';
|
||||||
import { coreOf } from '../cores';
|
import { coreOf } from '../cores';
|
||||||
import { healthNotices, runFix } from '../widgets/health';
|
import { healthNotices, runFix } from '../widgets/health';
|
||||||
import { attempt } from '../ui/toast';
|
import { attempt } from '../ui/toast';
|
||||||
@@ -34,7 +34,7 @@ interface Attention {
|
|||||||
function attention(st: Status): Attention[] {
|
function attention(st: Status): Attention[] {
|
||||||
const out: Attention[] = [];
|
const out: Attention[] = [];
|
||||||
const link = (href: string, t: string) => E('a', { href }, t);
|
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);
|
const today = todayOf(st.series);
|
||||||
// AmneziaWG itself can't run: the health notice says so once, not "Tunnel down" for every server.
|
// 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;
|
const awg = !!st.awg_state && !st.awg_state.ok;
|
||||||
@@ -111,12 +111,12 @@ function attention(st: Status): Attention[] {
|
|||||||
text: [
|
text: [
|
||||||
fmt(_('Internet through the LAN is off: %s'), st.like_home.error),
|
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.
|
// Only while setting up: an admin who keeps the portal off has decided so.
|
||||||
if (!st.settings.portal_enabled && !st.people.length)
|
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;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ export class ServerOverview {
|
|||||||
E(
|
E(
|
||||||
'div',
|
'div',
|
||||||
{ class: 'dl-map-off' },
|
{ 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(
|
const map = (this.map = new ConnectionMap(
|
||||||
@@ -268,7 +268,7 @@ export class ServerOverview {
|
|||||||
E('div', { class: 'dl-panel-head pad' }, [
|
E('div', { class: 'dl-panel-head pad' }, [
|
||||||
E('h3', {}, _('Needs attention')),
|
E('h3', {}, _('Needs attention')),
|
||||||
E('span', { class: 'dl-spacer' }),
|
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.length
|
||||||
? att
|
? att
|
||||||
@@ -292,7 +292,7 @@ export class ServerOverview {
|
|||||||
E('div', { class: 'dl-panel-head pad' }, [
|
E('div', { class: 'dl-panel-head pad' }, [
|
||||||
E('h3', {}, _('Activity')),
|
E('h3', {}, _('Activity')),
|
||||||
E('span', { class: 'dl-spacer' }),
|
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.length
|
||||||
? events.map((e) => eventRow(st, e))
|
? events.map((e) => eventRow(st, e))
|
||||||
@@ -316,7 +316,11 @@ export class ServerOverview {
|
|||||||
const [rx, tx] = d.spark[d.spark.length - 1] ?? [0, 0];
|
const [rx, tx] = d.spark[d.spark.length - 1] ?? [0, 0];
|
||||||
return rx + tx;
|
return rx + tx;
|
||||||
};
|
};
|
||||||
const cityOf = (d: Device) => st.geo.points.find((g) => g.device === d.id && g.city)?.city;
|
// The address it is connected from now, else the newest one (the points come oldest first).
|
||||||
|
const cityOf = (d: Device) => {
|
||||||
|
const pts = st.geo.points.filter((g) => g.device === d.id && g.city);
|
||||||
|
return (pts.find((g) => g.online) ?? pts.reduce<GeoPoint | undefined>((a, g) => (a && a.ts >= g.ts ? a : g), undefined))?.city;
|
||||||
|
};
|
||||||
const home = (d: Device) => /^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(d.endpoint ?? '');
|
const home = (d: Device) => /^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(d.endpoint ?? '');
|
||||||
// Where a device is: its city, or "LAN" when it connects from the home network (the hover
|
// Where a device is: its city, or "LAN" when it connects from the home network (the hover
|
||||||
// card adds its address there).
|
// card adds its address there).
|
||||||
@@ -331,20 +335,22 @@ export class ServerOverview {
|
|||||||
const card = ({ p, devs }: { p: Person; devs: Device[] }): Node[] => {
|
const card = ({ p, devs }: { p: Person; devs: Device[] }): Node[] => {
|
||||||
const starts = devs.map(connectedAt).filter(Boolean);
|
const starts = devs.map(connectedAt).filter(Boolean);
|
||||||
const since = starts.length ? Math.min(...starts) : 0;
|
const since = starts.length ? Math.min(...starts) : 0;
|
||||||
const pts = (p.rate ?? []).slice(-15);
|
// The live meter's last 2 minutes of their devices while it has them (the card is drawn again each
|
||||||
|
// second it shows, paintSpeed), else their last 15 minutes.
|
||||||
|
const ls = this.meter.speed(
|
||||||
|
p.server,
|
||||||
|
Date.now(),
|
||||||
|
p.devices.map((d) => d.id),
|
||||||
|
);
|
||||||
|
const live = ls.pts.length > 1;
|
||||||
|
const pts = live ? ls.pts : (p.rate ?? []).slice(-15);
|
||||||
|
const xs = live ? ls.xs : pts.map((_x, i) => (pts.length > 1 ? i / (pts.length - 1) : 1));
|
||||||
const last = pts[pts.length - 1];
|
const last = pts[pts.length - 1];
|
||||||
const fresh = last && st.now - last[0] < 180 ? last : null;
|
const fresh = live ? ([0, ls.rx, ls.tx] as const) : last && st.now - last[0] < 180 ? last : null;
|
||||||
const W = 200,
|
// The card's speed box is 228 px inside (280, less the card's and the box's padding).
|
||||||
H = 30,
|
const lines = pts.length > 1 ? new SpeedLines(30, true, 228) : null;
|
||||||
max = Math.max(1, ...pts.map((x) => Math.max(x[1], x[2])));
|
lines?.set(pts, xs);
|
||||||
const line = (k: 1 | 2) => pts.map((x, i) => `${pts.length > 1 ? (i / (pts.length - 1)) * W : W},${H - 2 - (x[k] / max) * (H - 6)}`);
|
const chart = lines?.el ?? '';
|
||||||
const chart =
|
|
||||||
pts.length > 1
|
|
||||||
? svg(
|
|
||||||
`<svg viewBox="0 0 ${W} ${H}" preserveAspectRatio="none" class="dl-hc-chart" aria-hidden="true">` +
|
|
||||||
`<path d="M${line(2).join(' L')} L${W},${H} L0,${H}Z" class="area"/><path d="M${line(2).join(' L')}" class="dn"/><path d="M${line(1).join(' L')}" class="up"/></svg>`,
|
|
||||||
)
|
|
||||||
: '';
|
|
||||||
const idle = !fresh || (fresh[1] < 64 && fresh[2] < 64);
|
const idle = !fresh || (fresh[1] < 64 && fresh[2] < 64);
|
||||||
const reach = p.access === 'both' ? ['home', 'globe'] : p.access === 'lan' ? ['home'] : ['globe'];
|
const reach = p.access === 'both' ? ['home', 'globe'] : p.access === 'lan' ? ['home'] : ['globe'];
|
||||||
return [
|
return [
|
||||||
@@ -371,7 +377,7 @@ export class ServerOverview {
|
|||||||
E('span', {}, [E('span', { class: 'dl-dn' }, '↓'), ` ${bits(fresh![2])}`]),
|
E('span', {}, [E('span', { class: 'dl-dn' }, '↓'), ` ${bits(fresh![2])}`]),
|
||||||
E('span', {}, [E('span', { class: 'dl-up' }, '↑'), ` ${bits(fresh![1])}`]),
|
E('span', {}, [E('span', { class: 'dl-up' }, '↑'), ` ${bits(fresh![1])}`]),
|
||||||
E('span', { class: 'dl-spacer' }),
|
E('span', { class: 'dl-spacer' }),
|
||||||
E('span', { class: 'dl-faint' }, _('15 min')),
|
E('span', { class: 'dl-faint' }, live ? _('2 min') : _('15 min')),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
chart,
|
chart,
|
||||||
@@ -395,17 +401,32 @@ export class ServerOverview {
|
|||||||
const person = (x: { p: Person; devs: Device[] }) => {
|
const person = (x: { p: Person; devs: Device[] }) => {
|
||||||
const { p, devs } = x;
|
const { p, devs } = x;
|
||||||
const badge = E('span', { class: 'dl-onl-dev' }, devs.length > 1 ? String(devs.length) : icon(devs[0].kind));
|
const badge = E('span', { class: 'dl-onl-dev' }, devs.length > 1 ? String(devs.length) : icon(devs[0].kind));
|
||||||
|
// Every place their devices are, once, the busiest device's first: "Krasnodar · Moscow", or
|
||||||
|
// "Krasnodar +1" when two do not fit under the avatar, "3 cities" from three on (the card names each).
|
||||||
|
const places = [...new Set(devs.map((d) => where(d)).filter(Boolean))];
|
||||||
|
const full = places.length > 2 ? plural(places.length, '%s city', '%s cities') : places.join(' · ');
|
||||||
|
const place = E('span', {}, full ? [' · ', full] : '');
|
||||||
|
const meta = big
|
||||||
|
? E('span', { class: 'dl-onl-meta' }, [
|
||||||
|
...devs.slice(0, 3).map((d) => icon(d.kind)),
|
||||||
|
devs.length > 3 ? `+${devs.length - 3}` : '',
|
||||||
|
place,
|
||||||
|
])
|
||||||
|
: '';
|
||||||
const el = E('a', { class: `dl-onl-p${big ? '' : ' sm'}`, href: personUrl(p.id), 'aria-label': fmt(_('%s, online'), p.name) }, [
|
const el = E('a', { class: `dl-onl-p${big ? '' : ' sm'}`, href: personUrl(p.id), 'aria-label': fmt(_('%s, online'), p.name) }, [
|
||||||
E('span', { class: 'dl-onl-av' }, [initials(p.name), badge]),
|
E('span', { class: 'dl-onl-av' }, [initials(p.name), badge]),
|
||||||
big ? E('span', { class: 'dl-onl-name' }, p.name) : '',
|
big ? E('span', { class: 'dl-onl-name' }, p.name) : '',
|
||||||
big
|
meta,
|
||||||
? E('span', { class: 'dl-onl-meta' }, [
|
|
||||||
...devs.slice(0, 3).map((d) => icon(d.kind)),
|
|
||||||
devs.length > 3 ? `+${devs.length - 3}` : '',
|
|
||||||
where(devs[0]) ? E('span', {}, [' · ', where(devs[0])]) : '',
|
|
||||||
])
|
|
||||||
: '',
|
|
||||||
]);
|
]);
|
||||||
|
if (meta && places.length === 2) {
|
||||||
|
// Measured where it stands (the person is a fixed width, so swapping the words never resizes what is observed).
|
||||||
|
const fit = new ResizeObserver(() => {
|
||||||
|
if (!el.isConnected) return fit.disconnect();
|
||||||
|
place.textContent = ` · ${full}`;
|
||||||
|
if (meta.scrollWidth > meta.clientWidth) place.textContent = ` · ${places[0]} +1`;
|
||||||
|
});
|
||||||
|
fit.observe(el);
|
||||||
|
}
|
||||||
attachTip(el, () => card(x));
|
attachTip(el, () => card(x));
|
||||||
return el;
|
return el;
|
||||||
};
|
};
|
||||||
@@ -428,7 +449,7 @@ export class ServerOverview {
|
|||||||
'a',
|
'a',
|
||||||
{
|
{
|
||||||
class: 'dl-onl-p sm more',
|
class: 'dl-onl-p sm more',
|
||||||
href: `${L.url('admin/network/dawnline/server')}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,
|
href: `${L.url('admin/services/dawnline/server')}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,
|
||||||
title: _('Everyone online'),
|
title: _('Everyone online'),
|
||||||
click: (ev: Event) => {
|
click: (ev: Event) => {
|
||||||
if (this.go) {
|
if (this.go) {
|
||||||
@@ -465,6 +486,8 @@ export class ServerOverview {
|
|||||||
if (!this.st) return;
|
if (!this.st) return;
|
||||||
const srv = this.st.servers[0];
|
const srv = this.st.servers[0];
|
||||||
this.speed.update(this.meter.speed(this.srvId, Date.now()), this.st.totals.today, srv ? !srv.enabled : false);
|
this.speed.update(this.meter.speed(this.srvId, Date.now()), this.st.totals.today, srv ? !srv.enabled : false);
|
||||||
|
// A person's card under the pointer follows the same second.
|
||||||
|
refreshTip();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The last 30 days, today on the right, with the peak. */
|
/** The last 30 days, today on the right, with the peak. */
|
||||||
|
|||||||
@@ -10,13 +10,16 @@ import { cancelButton, closeModal, confirmDialog, modal } from '../ui/modal';
|
|||||||
import { copyText } from '../ui/files';
|
import { copyText } from '../ui/files';
|
||||||
import { dropdown, type MenuItem } from '../ui/menu';
|
import { dropdown, type MenuItem } from '../ui/menu';
|
||||||
import { attempt, notify } from '../ui/toast';
|
import { attempt, notify } from '../ui/toast';
|
||||||
import { attachTip } from '../ui/tooltip';
|
import { pointTip } from '../ui/glide';
|
||||||
|
import { limitMeter, splitMeter } from '../widgets/meter';
|
||||||
|
import { paceOf, paceWords, weekAhead } from '../../shared/pace';
|
||||||
import { accessBadge } from '../ui/badges';
|
import { accessBadge } from '../ui/badges';
|
||||||
import { addDevice, openDevice, type DeviceOpts } from '../device';
|
import { addDevice, openDevice, type DeviceOpts } from '../device';
|
||||||
import { copyPersonLink, inviteCard } from '../invite';
|
import { copyPersonLink, inviteCard } from '../invite';
|
||||||
import { personUrl } from '../urls';
|
import { personUrl } from '../urls';
|
||||||
import { scoped } from '../state/scope';
|
import { scoped } from '../state/scope';
|
||||||
import { createPoller, focusInside, type Poller } from '../state/poller';
|
import { createPoller, focusInside, type Poller } from '../state/poller';
|
||||||
|
import type { LiveMeter, Rate } from '../state/meter';
|
||||||
import { onNavigate } from '../ui/nav';
|
import { onNavigate } from '../ui/nav';
|
||||||
import { accessPicker } from '../widgets/access-picker';
|
import { accessPicker } from '../widgets/access-picker';
|
||||||
import { firstBad, liveField } from '../ui/layout';
|
import { firstBad, liveField } from '../ui/layout';
|
||||||
@@ -122,6 +125,11 @@ export class PeoplePage {
|
|||||||
serverId: string | null = null;
|
serverId: string | null = null;
|
||||||
el: HTMLElement | null = null;
|
el: HTMLElement | null = null;
|
||||||
poller?: Poller<Status>;
|
poller?: Poller<Status>;
|
||||||
|
/** Each online person's speed in their card, put in place each second from the meter (a server's People list). */
|
||||||
|
private speedEls = new Map<string, { p: Person; down: HTMLElement; up: HTMLElement }>();
|
||||||
|
|
||||||
|
/** `meter`: the Servers page's live meter, which it polls while this list shows (none on its own page). */
|
||||||
|
constructor(private meter?: LiveMeter) {}
|
||||||
|
|
||||||
async load(): Promise<Status> {
|
async load(): Promise<Status> {
|
||||||
return api.status(30);
|
return api.status(30);
|
||||||
@@ -281,7 +289,7 @@ export class PeoplePage {
|
|||||||
{ class: 'alert-message warning' },
|
{ class: 'alert-message warning' },
|
||||||
fill(
|
fill(
|
||||||
_('No server yet. %s before adding people.'),
|
_('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' }, [
|
E('div', { class: 'dl-toolbar' }, [
|
||||||
@@ -601,49 +609,60 @@ export class PeoplePage {
|
|||||||
const used = p.quota_used || p.month[0] + p.month[1];
|
const used = p.quota_used || p.month[0] + p.month[1];
|
||||||
const pct = p.quota_limit ? Math.min(100, (p.quota_used / p.quota_limit) * 100) : 0;
|
const pct = p.quota_limit ? Math.min(100, (p.quota_used / p.quota_limit) * 100) : 0;
|
||||||
const today = p.devices.reduce((a, d) => a + (d.spark[d.spark.length - 1] ?? [0, 0]).reduce((x, y) => x + y), 0);
|
const today = p.devices.reduce((a, d) => a + (d.spark[d.spark.length - 1] ?? [0, 0]).reduce((x, y) => x + y), 0);
|
||||||
const r = p.rate?.[p.rate.length - 1];
|
const r = p.online ? this.speedOf(p) : null;
|
||||||
const live = p.online && r && this.st.now - r[0] < 180;
|
const live = !!r;
|
||||||
|
|
||||||
const bar = E('div', { class: `dl-usebar${pct >= 100 ? ' bad' : pct >= 90 ? ' warn' : ''}` });
|
// The pace lately: their devices' days added up (each device's last 7, today last).
|
||||||
|
const week = Array.from({ length: 7 }, (_x, k) => p.devices.reduce((a, d) => a + (d.spark[k]?.[0] ?? 0) + (d.spark[k]?.[1] ?? 0), 0));
|
||||||
|
const pace = paceOf(week);
|
||||||
|
const paceText = paceWords(used, p.quota_limit, pace, p.quota_period === 'month', this.today);
|
||||||
|
let bar: HTMLElement;
|
||||||
if (p.quota_limit) {
|
if (p.quota_limit) {
|
||||||
const fill = E('i', { class: 'fill' });
|
bar = limitMeter(pct, weekAhead(p.quota_used, p.quota_limit, pace));
|
||||||
fill.style.width = `${pct}%`;
|
// Above where the fill ends: the value's own place.
|
||||||
bar.appendChild(fill);
|
pointTip(
|
||||||
attachTip(bar, () => [
|
bar,
|
||||||
E('div', { class: 'dl-tip-title' }, fmt(_('%s%% used'), num(pct, 1))),
|
() => [
|
||||||
E(
|
E('div', { class: 'dl-glide-head' }, [
|
||||||
'div',
|
E('b', {}, fmt(_('%s%% used'), num(pct, 1))),
|
||||||
{ class: 'dl-muted' },
|
E(
|
||||||
`${fmt(_('%s of %s'), bytes(p.quota_used), bytes(p.quota_limit))} · ${fmt(_('%s left'), bytes(Math.max(0, p.quota_limit - p.quota_used)))}`,
|
'span',
|
||||||
),
|
{ class: 'dl-faint' },
|
||||||
E(
|
p.quota_period === 'total'
|
||||||
'div',
|
? _('In total')
|
||||||
{ class: 'dl-faint' },
|
: [_('This month'), p.bonus_gb ? fmt(_('includes +%s GB extra'), num(p.bonus_gb)) : ''].filter(Boolean).join(' · '),
|
||||||
p.quota_period === 'total'
|
),
|
||||||
? _('In total')
|
]),
|
||||||
: [_('This month'), p.bonus_gb ? fmt(_('includes +%s GB extra'), num(p.bonus_gb)) : ''].filter(Boolean).join(' · '),
|
E(
|
||||||
),
|
'div',
|
||||||
]);
|
{ class: 'dl-muted' },
|
||||||
|
`${fmt(_('%s of %s'), bytes(p.quota_used), bytes(p.quota_limit))} · ${fmt(_('%s left'), bytes(Math.max(0, p.quota_limit - p.quota_used)))}`,
|
||||||
|
),
|
||||||
|
pct < 100 && paceText ? E('div', { class: 'dl-glide-note' }, paceText) : '',
|
||||||
|
],
|
||||||
|
() => {
|
||||||
|
const r = bar.getBoundingClientRect();
|
||||||
|
return [r.left + (r.width * pct) / 100, r.top];
|
||||||
|
},
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
const devs = p.devices
|
const devs = p.devices
|
||||||
.map((d) => ({ d, v: d.month[0] + d.month[1] }))
|
.map((d) => ({ d, v: d.month[0] + d.month[1] }))
|
||||||
.filter((x) => x.v > 0)
|
.filter((x) => x.v > 0)
|
||||||
.sort((a, b) => b.v - a.v);
|
.sort((a, b) => b.v - a.v);
|
||||||
devs.forEach((x, i) => {
|
bar = splitMeter(devs.map((x) => x.v));
|
||||||
const seg = E('i', { class: `c${Math.min(i, 4)}` });
|
|
||||||
seg.style.flexGrow = String(x.v);
|
|
||||||
bar.appendChild(seg);
|
|
||||||
});
|
|
||||||
if (devs.length)
|
if (devs.length)
|
||||||
attachTip(bar, () => [
|
pointTip(bar, () => [
|
||||||
E('div', { class: 'dl-tip-title' }, _('This month by device')),
|
E('div', { class: 'dl-glide-head' }, [E('b', {}, _('This month by device')), E('span', { class: 'dl-faint' }, bytes(used))]),
|
||||||
...devs.map((x, i) =>
|
...devs.map((x, i) =>
|
||||||
E('div', { class: 'dl-tip-row' }, [
|
E('div', { class: 'dl-tip-row' }, [
|
||||||
E('span', { class: `dl-swatch c${Math.min(i, 4)}` }),
|
E('span', { class: `dl-swatch c${Math.min(i, 4)}` }),
|
||||||
E('span', {}, x.d.name),
|
E('span', {}, x.d.name),
|
||||||
|
E('span', { class: 'dl-faint' }, `${num(Math.round((x.v / Math.max(1, used)) * 100))}%`),
|
||||||
E('b', {}, bytes(x.v)),
|
E('b', {}, bytes(x.v)),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
|
paceText ? E('div', { class: 'dl-glide-note' }, paceText) : '',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -668,15 +687,42 @@ export class PeoplePage {
|
|||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
bar,
|
bar,
|
||||||
live
|
r
|
||||||
? E('div', { class: 'dl-use-live', title: _('Right now') }, [
|
? this.speedRow(p, r)
|
||||||
`↓ ${bits(r![2])}`,
|
|
||||||
E('span', { class: 'dl-faint' }, `↑ ${bits(r![1])}`),
|
|
||||||
])
|
|
||||||
: E('div', { class: 'dl-faint dl-pside-foot' }, today ? `${fmt(_('today %s'), bytes(today))} · ${limitText}` : limitText),
|
: E('div', { class: 'dl-faint dl-pside-foot' }, today ? `${fmt(_('today %s'), bytes(today))} · ${limitText}` : limitText),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Their speed now ([ts, rx, tx]): the live meter's while it has points, else their newest minute while it is recent. */
|
||||||
|
private speedOf(p: Person): Rate | null {
|
||||||
|
const s = this.meter?.speed(
|
||||||
|
p.server,
|
||||||
|
Date.now(),
|
||||||
|
p.devices.map((d) => d.id),
|
||||||
|
);
|
||||||
|
if (s?.pts.length) return [0, s.rx, s.tx];
|
||||||
|
const r = p.rate?.[p.rate.length - 1];
|
||||||
|
return r && this.st.now - r[0] < 180 ? r : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private speedRow(p: Person, r: Rate): HTMLElement {
|
||||||
|
const down = E('span', {}, `↓ ${bits(r[2])}`);
|
||||||
|
const up = E('span', { class: 'dl-faint' }, `↑ ${bits(r[1])}`);
|
||||||
|
this.speedEls.set(p.id, { p, down, up });
|
||||||
|
return E('div', { class: 'dl-use-live', title: _('Right now') }, [down, up]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Each second's meter answer: the speeds in the cards on screen (whether someone is online waits for the status). */
|
||||||
|
paintSpeed() {
|
||||||
|
for (const { p, down, up } of this.speedEls.values()) {
|
||||||
|
if (!down.isConnected) continue;
|
||||||
|
const r = this.speedOf(p);
|
||||||
|
if (!r) continue;
|
||||||
|
down.textContent = `↓ ${bits(r[2])}`;
|
||||||
|
up.textContent = `↑ ${bits(r[1])}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async togglePause(p: Person) {
|
async togglePause(p: Person) {
|
||||||
if (await attempt(() => api.personPause(p.id, !p.paused), fmt(p.paused ? _('%s resumed') : _('%s paused'), p.name)))
|
if (await attempt(() => api.personPause(p.id, !p.paused), fmt(p.paused ? _('%s resumed') : _('%s paused'), p.name)))
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
@@ -847,7 +893,7 @@ export class PeoplePage {
|
|||||||
' ',
|
' ',
|
||||||
E(
|
E(
|
||||||
'a',
|
'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'),
|
_('Open Settings'),
|
||||||
),
|
),
|
||||||
' ',
|
' ',
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ function mapCard(page: PersonPage): HTMLElement {
|
|||||||
E(
|
E(
|
||||||
'div',
|
'div',
|
||||||
{ class: 'dl-map-off' },
|
{ 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(
|
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-sub' }, _('City-level, from the client IP')),
|
||||||
]),
|
]),
|
||||||
E('span', { class: 'dl-spacer' }),
|
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);
|
if (page.mapOpen) return page.map && page.parts.places.contains(page.map.el) ? null : mapCard(page);
|
||||||
const since = st.now - 30 * 86400;
|
const since = st.now - 30 * 86400;
|
||||||
@@ -108,10 +108,10 @@ export function activityPart(page: PersonPage): HTMLElement {
|
|||||||
const e = latest[i];
|
const e = latest[i];
|
||||||
let n = 1;
|
let n = 1;
|
||||||
while (e.type === 'roam' && latest[i + n]?.type === 'roam' && latest[i + n].device === e.device) n++;
|
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) {
|
if (n > 1) {
|
||||||
const main = row.querySelector('.dl-row-main') as HTMLElement;
|
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
|
main.title = latest
|
||||||
.slice(i, i + n)
|
.slice(i, i + n)
|
||||||
.map((x) => x.detail ?? '')
|
.map((x) => x.detail ?? '')
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { icon } from '../../../shared/icons';
|
|||||||
import { ago, bytes, date, initials, isoDay } from '../../../shared/format';
|
import { ago, bytes, date, initials, isoDay } from '../../../shared/format';
|
||||||
import { fmt } from '../../../shared/i18n';
|
import { fmt } from '../../../shared/i18n';
|
||||||
import { copyPersonLink } from '../../invite';
|
import { copyPersonLink } from '../../invite';
|
||||||
import { daysTile, speedTile } from '../../widgets/tiles';
|
import { daysTile } from '../../widgets/tiles';
|
||||||
import { editNote, invite, moveToServer, newLink, remove, rename } from './dialogs';
|
import { editNote, invite, moveToServer, newLink, remove, rename } from './dialogs';
|
||||||
import type { PersonPage } from './index';
|
import type { PersonPage } from './index';
|
||||||
|
|
||||||
@@ -66,13 +66,12 @@ export function headPart(page: PersonPage): HTMLElement {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Speed now and the last 30 days, the same tiles as the server Overview; speed only while a device is online. */
|
/** Speed now (live) and the last 30 days, the same tiles as the server Overview; speed only while a device is online. */
|
||||||
export function trafficPart(page: PersonPage): HTMLElement {
|
export function trafficPart(page: PersonPage): HTMLElement {
|
||||||
const p = page.p;
|
const p = page.p;
|
||||||
// Today on the router: the last day of the series.
|
if (p.online) page.paintSpeed();
|
||||||
const todayUse = page.series[page.series.length - 1];
|
|
||||||
return E('div', { class: `dl-person-live${p.online ? '' : ' solo'}` }, [
|
return E('div', { class: `dl-person-live${p.online ? '' : ' solo'}` }, [
|
||||||
p.online ? speedTile(p.rate ?? [], page.st.now, todayUse ? [todayUse.rx, todayUse.tx] : [0, 0]) : '',
|
p.online ? page.speed.el : '',
|
||||||
daysTile(page.series, fmt(_('%s this month'), bytes(p.month[0] + p.month[1]))),
|
daysTile(page.series, fmt(_('%s this month'), bytes(p.month[0] + p.month[1]))),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -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.
|
// locations, activity, and access & limits that apply immediately.
|
||||||
// The parts live in ./header, ./devices, ./limits, ./pickers, ./activity and
|
// The parts live in ./header, ./devices, ./limits, ./pickers, ./activity and
|
||||||
// ./dialogs; this class holds the state, the poller and the edits.
|
// ./dialogs; this class holds the state, the poller and the edits.
|
||||||
@@ -13,6 +13,9 @@ import { peopleUrl } from '../../urls';
|
|||||||
import { addDevice, openDevice, type DeviceOpts } from '../../device';
|
import { addDevice, openDevice, type DeviceOpts } from '../../device';
|
||||||
import { coreFor, type Core } from '../../cores';
|
import { coreFor, type Core } from '../../cores';
|
||||||
import { createPoller, repaint, type Poller } from '../../state/poller';
|
import { createPoller, repaint, type Poller } from '../../state/poller';
|
||||||
|
import { LiveMeter, type MeterAnswer } from '../../state/meter';
|
||||||
|
import { pollMeter } from '../../state/meterpoll';
|
||||||
|
import { LiveSpeedTile } from '../../widgets/tiles';
|
||||||
import { headPart, trafficPart } from './header';
|
import { headPart, trafficPart } from './header';
|
||||||
import { devicesPart } from './devices';
|
import { devicesPart } from './devices';
|
||||||
import { limitsPart } from './limits';
|
import { limitsPart } from './limits';
|
||||||
@@ -40,6 +43,10 @@ export class PersonPage {
|
|||||||
/** The same per device. */
|
/** The same per device. */
|
||||||
devSeries: Record<string, DayUsage[]> = {};
|
devSeries: Record<string, DayUsage[]> = {};
|
||||||
poller?: Poller<Loaded>;
|
poller?: Poller<Loaded>;
|
||||||
|
/** Speed now, live (the meter's last 2 minutes of their devices): one tile for the page's life, and its poller. */
|
||||||
|
meter = new LiveMeter();
|
||||||
|
speed = new LiveSpeedTile();
|
||||||
|
meterPoller?: Poller<MeterAnswer>;
|
||||||
/** Status every 15 s; the log and the traffic history every fourth time (and after a change). */
|
/** Status every 15 s; the log and the traffic history every fourth time (and after a change). */
|
||||||
private ticks = 0;
|
private ticks = 0;
|
||||||
private fullNext = false;
|
private fullNext = false;
|
||||||
@@ -66,7 +73,7 @@ export class PersonPage {
|
|||||||
return E('div', { class: 'dl-empty' }, [
|
return E('div', { class: 'dl-empty' }, [
|
||||||
E('h3', {}, _('Person not found')),
|
E('h3', {}, _('Person not found')),
|
||||||
E('p', {}, _('They may have been removed.')),
|
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;
|
this.p = p;
|
||||||
for (const k of ['crumbs', 'head', 'devices', 'traffic', 'places', 'activity', 'limits'] as Part[]) this.parts[k] = E('div', {});
|
for (const k of ['crumbs', 'head', 'devices', 'traffic', 'places', 'activity', 'limits'] as Part[]) this.parts[k] = E('div', {});
|
||||||
@@ -96,9 +103,30 @@ export class PersonPage {
|
|||||||
active: () => root.isConnected,
|
active: () => root.isConnected,
|
||||||
apply: (data, quiet) => this.apply(data, quiet),
|
apply: (data, quiet) => this.apply(data, quiet),
|
||||||
});
|
});
|
||||||
|
// One meter call a second while a device of theirs is online on a running server.
|
||||||
|
this.meterPoller?.stop();
|
||||||
|
this.meterPoller = pollMeter(
|
||||||
|
this.meter,
|
||||||
|
() => root.isConnected && this.p.online > 0 && !!this.st.servers.find((x) => x.id === this.p.server)?.enabled,
|
||||||
|
() => this.paintSpeed(),
|
||||||
|
);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The speed tile from the meter as it stands, with today's traffic. */
|
||||||
|
paintSpeed() {
|
||||||
|
const day = this.series[this.series.length - 1];
|
||||||
|
this.speed.update(
|
||||||
|
this.meter.speed(
|
||||||
|
this.p.server,
|
||||||
|
Date.now(),
|
||||||
|
this.p.devices.map((d) => d.id),
|
||||||
|
),
|
||||||
|
day ? [day.rx, day.tx] : [0, 0],
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private take(d: Loaded) {
|
private take(d: Loaded) {
|
||||||
this.st = d.st;
|
this.st = d.st;
|
||||||
if (d.ev) this.events = d.ev;
|
if (d.ev) this.events = d.ev;
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import { button } from '../../ui/button';
|
|||||||
import { cancelButton, closeModal, modal } from '../../ui/modal';
|
import { cancelButton, closeModal, modal } from '../../ui/modal';
|
||||||
import { liveField } from '../../ui/layout';
|
import { liveField } from '../../ui/layout';
|
||||||
import { quotaHelp } from '../../netcheck';
|
import { quotaHelp } from '../../netcheck';
|
||||||
import { attachTip } from '../../ui/tooltip';
|
import { pointTip } from '../../ui/glide';
|
||||||
|
import { limitMeter } from '../../widgets/meter';
|
||||||
|
import { paceOf, paceWords, weekAhead } from '../../../shared/pace';
|
||||||
import { icon } from '../../../shared/icons';
|
import { icon } from '../../../shared/icons';
|
||||||
import { accessLabel, bytes, date, daysLeft, endsSoon, shiftDay } from '../../../shared/format';
|
import { accessLabel, bytes, date, daysLeft, endsSoon, shiftDay } from '../../../shared/format';
|
||||||
import { fmt, num, plural } from '../../../shared/i18n';
|
import { fmt, num, plural } from '../../../shared/i18n';
|
||||||
@@ -128,21 +130,31 @@ function dataTile(page: PersonPage): HTMLElement {
|
|||||||
const p = page.p;
|
const p = page.p;
|
||||||
const used = p.quota_used || p.month[0] + p.month[1];
|
const used = p.quota_used || p.month[0] + p.month[1];
|
||||||
const pct = p.quota_limit ? Math.min(100, (p.quota_used / p.quota_limit) * 100) : 0;
|
const pct = p.quota_limit ? Math.min(100, (p.quota_used / p.quota_limit) * 100) : 0;
|
||||||
const bar = E('div', { class: `dl-meter${pct >= 100 ? ' bad' : pct >= 90 ? ' warn' : ''}` }, [
|
// The pace lately (the person's days) and where a week at it takes them, dashed past the fill.
|
||||||
E('i'),
|
const pace = paceOf(page.series.map((d) => d.rx + d.tx));
|
||||||
p.quota_limit ? E('span', { class: 'mark', title: _('Alert at 90%') }) : '',
|
const bar = limitMeter(pct, p.quota_limit ? weekAhead(p.quota_used, p.quota_limit, pace) : 0, p.quota_limit ? 0.9 : undefined);
|
||||||
]);
|
if (p.quota_limit) {
|
||||||
(bar.firstChild as HTMLElement).style.width = `${pct}%`;
|
const paceText = paceWords(p.quota_used, p.quota_limit, pace, p.quota_period === 'month', page.today);
|
||||||
if (p.quota_limit)
|
pointTip(
|
||||||
attachTip(bar, () => [
|
bar,
|
||||||
E('div', { class: 'dl-tip-title' }, fmt(_('%s%% used'), num(pct, 1))),
|
() => [
|
||||||
E(
|
E('div', { class: 'dl-glide-head' }, [
|
||||||
'div',
|
E('b', {}, fmt(_('%s%% used'), num(pct, 1))),
|
||||||
{ class: 'dl-muted' },
|
E('span', { class: 'dl-faint' }, _('Alert at 90%')),
|
||||||
`${fmt(_('%s of %s'), bytes(p.quota_used), bytes(p.quota_limit))} · ${fmt(_('%s left'), bytes(Math.max(0, p.quota_limit - p.quota_used)))}`,
|
]),
|
||||||
),
|
E(
|
||||||
E('div', { class: 'dl-faint' }, _('Alert at 90%')),
|
'div',
|
||||||
]);
|
{ class: 'dl-muted' },
|
||||||
|
`${fmt(_('%s of %s'), bytes(p.quota_used), bytes(p.quota_limit))} · ${fmt(_('%s left'), bytes(Math.max(0, p.quota_limit - p.quota_used)))}`,
|
||||||
|
),
|
||||||
|
pct < 100 && paceText ? E('div', { class: 'dl-glide-note' }, paceText) : '',
|
||||||
|
],
|
||||||
|
() => {
|
||||||
|
const r = bar.getBoundingClientRect();
|
||||||
|
return [r.left + (r.width * pct) / 100, r.top];
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
const period = seg(
|
const period = seg(
|
||||||
[
|
[
|
||||||
['month', _('Monthly')],
|
['month', _('Monthly')],
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { coreOf } from '../cores';
|
|||||||
import { installAwg } from '../pkgs';
|
import { installAwg } from '../pkgs';
|
||||||
import { createPoller, focusInside, repaint, type Poller } from '../state/poller';
|
import { createPoller, focusInside, repaint, type Poller } from '../state/poller';
|
||||||
import { LiveMeter, type MeterAnswer } from '../state/meter';
|
import { LiveMeter, type MeterAnswer } from '../state/meter';
|
||||||
|
import { pollMeter } from '../state/meterpoll';
|
||||||
import { ServerOverview } from './overview';
|
import { ServerOverview } from './overview';
|
||||||
import { PeoplePage } from './people';
|
import { PeoplePage } from './people';
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ const url = (server?: string, section?: string) => {
|
|||||||
if (server) q.set('server', server);
|
if (server) q.set('server', server);
|
||||||
if (section && section !== 'overview') q.set('section', section);
|
if (section && section !== 'overview') q.set('section', section);
|
||||||
const s = q.toString();
|
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 {
|
export class ServerPage {
|
||||||
@@ -65,7 +66,7 @@ export class ServerPage {
|
|||||||
secEl = E('div', {});
|
secEl = E('div', {});
|
||||||
bodyEl = E('div', { class: 'dl-srvbody' });
|
bodyEl = E('div', { class: 'dl-srvbody' });
|
||||||
poller?: Poller<Status>;
|
poller?: Poller<Status>;
|
||||||
/** The live meter's last 2 minutes, every server's (the Overviews' Speed now), and its poller. */
|
/** The live meter's last 2 minutes, every server's (Speed now on the Overviews and People lists), and its poller. */
|
||||||
meter = new LiveMeter();
|
meter = new LiveMeter();
|
||||||
meterPoller?: Poller<MeterAnswer>;
|
meterPoller?: Poller<MeterAnswer>;
|
||||||
|
|
||||||
@@ -104,23 +105,16 @@ export class ServerPage {
|
|||||||
this.ov[this.current().id]?.update(n, quiet);
|
this.ov[this.current().id]?.update(n, quiet);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// Speed now, live: one meter call a second while the Overview of a running server is on screen
|
// Speed now, live, while the Overview of a running server or its People list is on screen.
|
||||||
// (the router keeps the last two minutes and writes them out while someone asks). A failed call is said in the tile, not in a
|
|
||||||
// second "not answering" toast beside the status poller's.
|
|
||||||
this.meterPoller?.stop();
|
this.meterPoller?.stop();
|
||||||
this.meterPoller = createPoller<MeterAnswer>({
|
this.meterPoller = pollMeter(
|
||||||
fetch: () =>
|
this.meter,
|
||||||
api.meter(this.meter.since(Date.now())).then(
|
() => (this.section === 'overview' || this.section === 'people') && this.root.isConnected && this.current().enabled,
|
||||||
(meter) => ({ meter }),
|
() => {
|
||||||
(e) => ({ error: errorText(e) }),
|
|
||||||
),
|
|
||||||
every: 1,
|
|
||||||
active: () => this.section === 'overview' && this.root.isConnected && this.current().enabled,
|
|
||||||
apply: (r) => {
|
|
||||||
this.meter.take(r, Date.now());
|
|
||||||
this.ov[this.current().id]?.paintSpeed();
|
this.ov[this.current().id]?.paintSpeed();
|
||||||
|
this.pp[this.current().id]?.paintSpeed();
|
||||||
},
|
},
|
||||||
});
|
);
|
||||||
return this.root;
|
return this.root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +214,7 @@ export class ServerPage {
|
|||||||
pp.filter = filter as PeoplePage['filter'];
|
pp.filter = filter as PeoplePage['filter'];
|
||||||
if (pp.el) pp.decorate();
|
if (pp.el) pp.decorate();
|
||||||
} else if (filter) {
|
} else if (filter) {
|
||||||
const page = (this.pp[this.current().id] = new PeoplePage());
|
const page = (this.pp[this.current().id] = new PeoplePage(this.meter));
|
||||||
page.filter = filter as PeoplePage['filter'];
|
page.filter = filter as PeoplePage['filter'];
|
||||||
}
|
}
|
||||||
this.showSection(k);
|
this.showSection(k);
|
||||||
@@ -261,7 +255,7 @@ export class ServerPage {
|
|||||||
return pp.el;
|
return pp.el;
|
||||||
}
|
}
|
||||||
const holder = E('div', {}, E('p', { class: 'dl-muted' }, _('Loading people…')));
|
const holder = E('div', {}, E('p', { class: 'dl-muted' }, _('Loading people…')));
|
||||||
const page = (this.pp[srv.id] ??= new PeoplePage());
|
const page = (this.pp[srv.id] ??= new PeoplePage(this.meter));
|
||||||
page
|
page
|
||||||
.embed(st, srv.id)
|
.embed(st, srv.id)
|
||||||
.then((node) => {
|
.then((node) => {
|
||||||
@@ -846,7 +840,7 @@ export class ServerPage {
|
|||||||
'warn',
|
'warn',
|
||||||
_('AmneziaWG’s kernel module doesn’t load on this firmware'),
|
_('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.'),
|
_('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')),
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
: '';
|
: '';
|
||||||
|
|||||||
@@ -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). */
|
/** The shimmer sets off once the place it leaves has started to go gray (a share of the move). */
|
||||||
const LEAVE = 0.12;
|
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. */
|
/** 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. */
|
/** ± 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`. */
|
/** A move into stay `k` (from stay k − 1), or stay `k` itself, `ms` long from `start`. */
|
||||||
export interface Step {
|
export interface Step {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
// The live meter as the Servers page keeps it (rpc meter, polled once a
|
// The live meter as a page keeps it (rpc meter, polled once a second while a
|
||||||
// second while an Overview is on screen): the answers merged into the last two
|
// speed is on screen): the answers merged into the last two minutes, and one
|
||||||
// minutes, and one server's part of them for its Speed now tile. No DOM and no
|
// server's part of them, or one person's devices on it, for Speed now. No DOM
|
||||||
// RPC here: the poller is the page's (pages/server.ts), the tile widgets/tiles.
|
// and no RPC here: the poller is the page's (pages/server.ts, pages/person),
|
||||||
|
// the tile widgets/tiles.
|
||||||
|
|
||||||
import type { Meter, MeterPoint } from '../api';
|
import type { Meter, MeterPoint } from '../api';
|
||||||
|
|
||||||
@@ -84,12 +85,26 @@ export class LiveMeter {
|
|||||||
this.error = '';
|
this.error = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Server `id`'s points at page time `ms` (none once they are not live), placed against the meter's newest point. */
|
/**
|
||||||
speed(id: string, ms: number): LiveSpeed {
|
* Server `id`'s points at page time `ms` (none once they are not live), placed against the meter's newest point;
|
||||||
|
* with `devices`, only theirs added up (a person's speed).
|
||||||
|
*/
|
||||||
|
speed(id: string, ms: number, devices?: string[]): LiveSpeed {
|
||||||
const error = this.failed >= LOST_AFTER ? this.error : null;
|
const error = this.failed >= LOST_AFTER ? this.error : null;
|
||||||
const live = this.live(ms) ? this.points : [];
|
const live = this.live(ms) ? this.points : [];
|
||||||
|
const sum = (p: MeterPoint): Rate => {
|
||||||
|
if (!devices) return [p.ts, p.servers[id][0], p.servers[id][1]];
|
||||||
|
const r: Rate = [p.ts, 0, 0];
|
||||||
|
for (const d of devices) {
|
||||||
|
const v = p.dev?.[d];
|
||||||
|
if (!v) continue;
|
||||||
|
r[1] += v[0];
|
||||||
|
r[2] += v[1];
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
};
|
||||||
// A second its tunnel was not read has no point of its own.
|
// A second its tunnel was not read has no point of its own.
|
||||||
const pts = live.flatMap((p): Rate[] => (p.servers[id] ? [[p.ts, p.servers[id][0], p.servers[id][1]]] : []));
|
const pts = live.flatMap((p): Rate[] => (p.servers[id] ? [sum(p)] : []));
|
||||||
const end = live.length ? live[live.length - 1].ts : 0;
|
const end = live.length ? live[live.length - 1].ts : 0;
|
||||||
const span = this.keep - 1;
|
const span = this.keep - 1;
|
||||||
const last = pts[pts.length - 1];
|
const last = pts[pts.length - 1];
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// The live meter's poller: one meter call a second while a speed is on screen
|
||||||
|
// (the router keeps the last two minutes and writes them out while someone
|
||||||
|
// asks). A failed call is said in the tile, not in a second "not answering"
|
||||||
|
// toast beside the page's status poller.
|
||||||
|
|
||||||
|
import { api } from '../api';
|
||||||
|
import { errorText } from '../ui/toast';
|
||||||
|
import { createPoller, type Poller } from './poller';
|
||||||
|
import type { LiveMeter, MeterAnswer } from './meter';
|
||||||
|
|
||||||
|
export function pollMeter(meter: LiveMeter, active: () => boolean, paint: () => void): Poller<MeterAnswer> {
|
||||||
|
return createPoller<MeterAnswer>({
|
||||||
|
fetch: () =>
|
||||||
|
api.meter(meter.since(Date.now())).then(
|
||||||
|
(m) => ({ meter: m }),
|
||||||
|
(e) => ({ error: errorText(e) }),
|
||||||
|
),
|
||||||
|
every: 1,
|
||||||
|
active,
|
||||||
|
apply: (r) => {
|
||||||
|
meter.take(r, Date.now());
|
||||||
|
paint();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -21,7 +21,9 @@
|
|||||||
--dl-info-wash: var(--info-a15, color-mix(in srgb, var(--dl-info) 15%, transparent));
|
--dl-info-wash: var(--info-a15, color-mix(in srgb, var(--dl-info) 15%, transparent));
|
||||||
--dl-track: var(--foreground-a10, color-mix(in srgb, var(--dl-fg) 10%, transparent));
|
--dl-track: var(--foreground-a10, color-mix(in srgb, var(--dl-fg) 10%, transparent));
|
||||||
--dl-chart-1: var(--chart-blue, #3a83f7);
|
--dl-chart-1: var(--chart-blue, #3a83f7);
|
||||||
--dl-chart-2: var(--chart-green, var(--dl-ok));
|
/* The connection map's arcs (map.ts LIVE and RECENT, mapcn's): every chart draws live and past in them. */
|
||||||
|
--dl-live: #3b82f6;
|
||||||
|
--dl-recent: #8a8a8a;
|
||||||
--dl-ring: var(--ring, #3a83f7);
|
--dl-ring: var(--ring, #3a83f7);
|
||||||
--dl-primary: var(--primary, var(--dl-fg));
|
--dl-primary: var(--primary, var(--dl-fg));
|
||||||
--dl-primary-fg: var(--primary-foreground, var(--dl-elevated));
|
--dl-primary-fg: var(--primary-foreground, var(--dl-elevated));
|
||||||
@@ -78,14 +80,6 @@
|
|||||||
.dl-grid2 { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 0 16px; }
|
.dl-grid2 { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 0 16px; }
|
||||||
@media (max-width: 960px) { .dl-grid2 { grid-template-columns: minmax(0, 1fr); } }
|
@media (max-width: 960px) { .dl-grid2 { grid-template-columns: minmax(0, 1fr); } }
|
||||||
|
|
||||||
/* chart */
|
|
||||||
.dl-chart { display: block; width: 100%; height: 120px; }
|
|
||||||
.dl-bar-down { fill: var(--dl-chart-1); }
|
|
||||||
.dl-bar-up { fill: var(--dl-chart-2); opacity: .8; }
|
|
||||||
.dl-legend { display: flex; gap: 16px; font-size: 12px; color: var(--dl-fg-muted); margin-top: 8px; }
|
|
||||||
.dl-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 999px; margin-right: 6px; vertical-align: 0; }
|
|
||||||
.dl-legend .down { background: var(--dl-chart-1); } .dl-legend .up { background: var(--dl-chart-2); }
|
|
||||||
|
|
||||||
/* activity */
|
/* activity */
|
||||||
.dl-events { list-style: none; margin: 0; padding: 0; }
|
.dl-events { list-style: none; margin: 0; padding: 0; }
|
||||||
.dl-events li { display: flex; gap: 12px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--dl-line); font-size: 14px; line-height: 20px; min-width: 0; }
|
.dl-events li { display: flex; gap: 12px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--dl-line); font-size: 14px; line-height: 20px; min-width: 0; }
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
/* Charts (ui/plot.ts, widgets/lines.ts, days.ts, meter.ts). The speed lines, markers, ticks and meters speak the
|
||||||
|
connection map's language: live is its blue and solid, the past its grey, lines 2 px with round ends, what is
|
||||||
|
secondary dashed like an arc, a soft zone under a line, ringed markers with a halo while live, the replay's tick
|
||||||
|
for a picked moment. Days of traffic are stacked bars in the colours of the tiles' ↓ and ↑ numbers. Reading a
|
||||||
|
chart (shared/scrub.ts) and its tooltip (ui/glide.ts). */
|
||||||
|
|
||||||
|
.dl-plot { position: relative; width: 100%; min-width: 0; }
|
||||||
|
.dl-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; display: block; }
|
||||||
|
.dl-plot .ln { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
|
||||||
|
.dl-plot .ln.live { stroke: var(--dl-live); }
|
||||||
|
.dl-plot .ln.past { stroke: var(--dl-recent); }
|
||||||
|
.dl-plot .ln.thin { stroke-width: 1.5; }
|
||||||
|
.dl-plot .dash { stroke-dasharray: 4 4; }
|
||||||
|
.dl-plot .live.z0 { stop-color: var(--dl-live); stop-opacity: .2; }
|
||||||
|
.dl-plot .live.z1 { stop-color: var(--dl-live); stop-opacity: 0; }
|
||||||
|
.dl-plot .mk { fill: color-mix(in srgb, var(--dl-recent) 22%, var(--dl-elevated)); stroke: var(--dl-recent); stroke-width: 2; }
|
||||||
|
.dl-plot .mk.live { fill: color-mix(in srgb, var(--dl-live) 22%, var(--dl-elevated)); stroke: var(--dl-live); }
|
||||||
|
.dl-plot .mk.on { fill: var(--dl-fg); stroke: var(--dl-card); }
|
||||||
|
.dl-plot .halo { fill: var(--dl-live); transform-box: fill-box; transform-origin: center; animation: dl-halo 2s ease-out infinite; pointer-events: none; }
|
||||||
|
@keyframes dl-halo { 0% { transform: scale(1); opacity: .35; } 100% { transform: scale(3.2); opacity: 0; } }
|
||||||
|
.dl-plot .tick-ring { stroke: var(--dl-card); stroke-width: 6; stroke-linecap: round; }
|
||||||
|
.dl-plot .tick { stroke: var(--dl-fg); stroke-width: 2; stroke-linecap: round; }
|
||||||
|
.dl-plot .band { fill: var(--dl-fg); opacity: .06; }
|
||||||
|
.dl-plot .none { fill: var(--dl-recent); opacity: .5; }
|
||||||
|
/* Stacked days: download at the base, upload on top, the colours of the ↓ and ↑ numbers (.dl-dn, .dl-up). */
|
||||||
|
.dl-plot .dn { fill: var(--dl-accent); opacity: .9; }
|
||||||
|
.dl-plot .up { fill: var(--dl-ok); opacity: .9; }
|
||||||
|
.dl-plot .dim { opacity: .35; }
|
||||||
|
.dl-plot .on { opacity: 1; }
|
||||||
|
.dl-plot rect.none { fill: var(--dl-track); opacity: 1; }
|
||||||
|
.dl-days-key { display: inline-flex; gap: 14px; font-variant-numeric: tabular-nums; }
|
||||||
|
.dl-days-key > span { display: inline-flex; align-items: center; gap: 6px; }
|
||||||
|
.dl-days-key i { width: 8px; height: 8px; border-radius: 2px; }
|
||||||
|
.dl-days-key i.dn { background: var(--dl-accent); }
|
||||||
|
.dl-days-key i.up { background: var(--dl-ok); }
|
||||||
|
/* A device's strip: the places strip's track and segments. */
|
||||||
|
.dl-plot .track { fill: var(--dl-track); }
|
||||||
|
.dl-plot .seg { fill: var(--dl-recent); }
|
||||||
|
.dl-plot .seg.live { fill: var(--dl-live); }
|
||||||
|
.dl-dstrip { flex: 1; }
|
||||||
|
|
||||||
|
/* Reading a chart: it takes focus, the pointer is a crosshair, the picked point's words are the accent. */
|
||||||
|
.scrub { outline: none; cursor: crosshair; border-radius: 6px; }
|
||||||
|
.scrub:focus-visible { box-shadow: 0 0 0 2px var(--dl-ring); }
|
||||||
|
.dl-picked .dl-metric-label, .dl-sub.dl-picked, .dl-picked > .dl-sub { color: var(--dl-accent); font-variant-numeric: tabular-nums; }
|
||||||
|
.dl-speed-cols.dl-picked .dl-speed-val { color: color-mix(in oklab, var(--dl-accent) 55%, var(--dl-fg)); }
|
||||||
|
.offscreen { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
||||||
|
|
||||||
|
/* The chart tooltip: anchored above a point, gliding to the next; a map chip's blur. */
|
||||||
|
.dl-glide { left: 0; top: 0; display: flex; flex-direction: column; gap: 6px; min-width: 150px; padding: 10px 12px; border-radius: 12px; pointer-events: none;
|
||||||
|
background: color-mix(in srgb, var(--dl-elevated) 88%, transparent); backdrop-filter: blur(8px); }
|
||||||
|
.dl-glide.glides { transition: transform .18s cubic-bezier(.23, 1, .32, 1); }
|
||||||
|
.dl-glide-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
|
||||||
|
.dl-glide-head b { font-weight: 500; }
|
||||||
|
.dl-glide-big { font-size: 18px; line-height: 22px; font-weight: 500; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
|
||||||
|
.dl-glide-note { font-size: 11.5px; color: var(--dl-fg-muted); white-space: normal; max-width: 240px; }
|
||||||
|
.dl-glide-note.bad { color: var(--dl-bad); }
|
||||||
|
.dl-glide-split { display: flex; gap: 2px; height: 6px; width: 150px; }
|
||||||
|
.dl-glide-split i { display: block; border-radius: 3px; min-width: 3px; }
|
||||||
|
.dl-glide-split .dn { background: var(--dl-accent); }
|
||||||
|
.dl-glide-split .up { background: var(--dl-ok); }
|
||||||
|
.dl-glide .dl-tip-row .dl-swatch { width: 8px; height: 8px; border-radius: 50%; }
|
||||||
|
|
||||||
|
/* The meter: a places strip's track and fill; the week ahead dashed; the alert the replay's tick. */
|
||||||
|
.dl-smeter { position: relative; height: 6px; border-radius: 3px; background: var(--dl-track); margin: 4px 0; outline: none; }
|
||||||
|
.dl-smeter > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--dl-live); }
|
||||||
|
.dl-smeter.warn > i { background: var(--dl-warn); }
|
||||||
|
.dl-smeter.bad > i { background: var(--dl-bad); }
|
||||||
|
.dl-smeter > b { position: absolute; top: 2px; height: 2px; margin-left: 4px; opacity: .85; color: var(--dl-live);
|
||||||
|
background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 8px); }
|
||||||
|
.dl-smeter.warn > b { color: var(--dl-warn); }
|
||||||
|
.dl-smeter .mark { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--dl-fg); box-shadow: 0 0 0 2px var(--dl-card); }
|
||||||
|
.dl-smeter.parts { display: flex; gap: 2px; background: none; }
|
||||||
|
.dl-smeter.parts > i { position: static; flex: 1 1 0; min-width: 3px; }
|
||||||
|
.dl-smeter:focus-visible { box-shadow: 0 0 0 2px var(--dl-ring); }
|
||||||
|
|
||||||
|
/* Speed now, waiting: the dashed track where the line will stand; while collecting, a shimmer runs along it
|
||||||
|
(the map's replay along an arc). */
|
||||||
|
.dl-speed-wait i { display: block; height: 2px; order: 2; position: relative; opacity: .6;
|
||||||
|
background: repeating-linear-gradient(90deg, var(--dl-recent) 0 4px, transparent 4px 8px); }
|
||||||
|
.dl-speed-wait i.run { opacity: 1;
|
||||||
|
background: linear-gradient(90deg, transparent, var(--dl-live), transparent) no-repeat -40% 0 / 40% 100%, repeating-linear-gradient(90deg, color-mix(in srgb, var(--dl-recent) 60%, transparent) 0 4px, transparent 4px 8px);
|
||||||
|
-webkit-mask: repeating-linear-gradient(90deg, #000 0 4px, transparent 4px 8px); mask: repeating-linear-gradient(90deg, #000 0 4px, transparent 4px 8px);
|
||||||
|
animation: dl-run 1.6s linear infinite; }
|
||||||
|
@keyframes dl-run { to { background-position: 140% 0, 0 0; } }
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.dl-plot .halo { animation: none; opacity: 0; }
|
||||||
|
.dl-speed-wait i.run { animation: none; }
|
||||||
|
}
|
||||||
@@ -26,6 +26,7 @@ import drawer from './drawer.css';
|
|||||||
import settings from './settings.css';
|
import settings from './settings.css';
|
||||||
import components from './components.css';
|
import components from './components.css';
|
||||||
import access from './access.css';
|
import access from './access.css';
|
||||||
|
import charts from './charts.css';
|
||||||
|
|
||||||
const CSS = [
|
const CSS = [
|
||||||
base,
|
base,
|
||||||
@@ -43,6 +44,7 @@ const CSS = [
|
|||||||
settings,
|
settings,
|
||||||
components,
|
components,
|
||||||
access,
|
access,
|
||||||
|
charts,
|
||||||
].join('\n');
|
].join('\n');
|
||||||
|
|
||||||
/** A <style> element for the view root (see the note at the top). */
|
/** A <style> element for the view root (see the note at the top). */
|
||||||
|
|||||||
@@ -230,29 +230,9 @@
|
|||||||
.dl-pop-actions { display: flex; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--dl-line); }
|
.dl-pop-actions { display: flex; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--dl-line); }
|
||||||
.dl-pop-actions .cbi-button { flex: 1; height: 28px !important; font-size: 12px !important; justify-content: center; }
|
.dl-pop-actions .cbi-button { flex: 1; height: 28px !important; font-size: 12px !important; justify-content: center; }
|
||||||
|
|
||||||
/* charts */
|
/* tooltips (charts: charts.css) */
|
||||||
.dl-chartbox { position: relative; }
|
|
||||||
.dl-bars { display: flex; align-items: flex-end; gap: 4px; border-bottom: 1px solid var(--dl-line); }
|
|
||||||
.dl-bar { flex: 1; height: 100%; display: flex; flex-direction: column-reverse; gap: 1px; cursor: default; min-width: 3px; }
|
|
||||||
.dl-bar i { display: block; border-radius: 3px 3px 0 0; }
|
|
||||||
.dl-bar i.down { background: var(--dl-chart-1); }
|
|
||||||
.dl-bar i.up { background: var(--dl-chart-2); opacity: .75; border-radius: 3px 3px 0 0; }
|
|
||||||
.dl-bar:hover i { filter: brightness(1.25); }
|
|
||||||
.dl-bar.empty { background: linear-gradient(to top, var(--dl-line) 2px, transparent 2px); }
|
|
||||||
.dl-tip { position: absolute; top: -8px; transform: translate(-50%, -100%); padding: 8px 10px; border-radius: 10px; font-size: 12px; line-height: 18px; white-space: nowrap;
|
.dl-tip { position: absolute; top: -8px; transform: translate(-50%, -100%); padding: 8px 10px; border-radius: 10px; font-size: 12px; line-height: 18px; white-space: nowrap;
|
||||||
background: var(--dl-elevated); border: 1px solid var(--dl-line); box-shadow: var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4)); pointer-events: none; z-index: 3; }
|
background: var(--dl-elevated); border: 1px solid var(--dl-line); box-shadow: var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4)); pointer-events: none; z-index: 3; }
|
||||||
.dl-tip-title { font-weight: 500; }
|
.dl-tip-title { font-weight: 500; }
|
||||||
.dl-tip-float { position: fixed; z-index: 2000; color: var(--dl-fg); }
|
.dl-tip-float { position: fixed; z-index: 2000; color: var(--dl-fg); }
|
||||||
.dl-meter, .dl-slots { cursor: default; }
|
.dl-slots { cursor: default; }
|
||||||
.dl-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--dl-fg-faint); margin-top: 6px; }
|
|
||||||
.dl-legend i.down { background: var(--dl-chart-1); } .dl-legend i.up { background: var(--dl-chart-2); }
|
|
||||||
.dl-spark { display: flex; align-items: flex-end; flex: 0 0 auto; --dl-gap: 2px; }
|
|
||||||
.dl-spark i { flex: 1; display: block; border-radius: 2px 2px 0 0; background: var(--dl-chart-1); opacity: .85; }
|
|
||||||
.dl-spark i.zero { opacity: .22; }
|
|
||||||
.dl-spark > span:hover i:not(.zero) { opacity: 1; filter: brightness(1.25); }
|
|
||||||
/* A day's column in the daily charts (spark, a device card's bars, the last 30 days): the chart's full height and
|
|
||||||
half the gap on either side, so its tooltip answers above a short bar and between two bars. The outer columns
|
|
||||||
keep no outer half, so the bars stand where a plain gap would put them. */
|
|
||||||
.dl-spark > span, .dl-dbars > span, .dl-bento-bars > span { flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; padding: 0 calc(var(--dl-gap) / 2); }
|
|
||||||
.dl-spark > span:first-child, .dl-dbars > span:first-child, .dl-bento-bars > span:first-child { padding-left: 0; }
|
|
||||||
.dl-spark > span:last-child, .dl-dbars > span:last-child, .dl-bento-bars > span:last-child { padding-right: 0; }
|
|
||||||
@@ -25,11 +25,6 @@
|
|||||||
.dl-dcard-trend { display: flex; align-items: flex-end; gap: 12px; min-width: 0; }
|
.dl-dcard-trend { display: flex; align-items: flex-end; gap: 12px; min-width: 0; }
|
||||||
.dl-dcard-trend > .dl-stack { flex: none; }
|
.dl-dcard-trend > .dl-stack { flex: none; }
|
||||||
.dl-dcard-trend b { font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; }
|
.dl-dcard-trend b { font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; }
|
||||||
.dl-dbars { flex: 1; min-width: 0; height: 32px; display: flex; align-items: flex-end; --dl-gap: 2px; }
|
|
||||||
.dl-dbars i { flex: 1; min-width: 0; border-radius: 2px; background: var(--dl-chart-1); opacity: .55; }
|
|
||||||
.dl-dbars i.zero { background: var(--dl-track); opacity: 1; }
|
|
||||||
.dl-dbars i.hi { opacity: 1; }
|
|
||||||
.dl-dbars > span:hover i { opacity: 1; filter: brightness(1.2); }
|
|
||||||
.dl-datechip { position: relative; display: inline-flex; }
|
.dl-datechip { position: relative; display: inline-flex; }
|
||||||
.dl-date-hidden { position: absolute !important; left: 0; bottom: 0; width: 1px !important; min-width: 0 !important; height: 1px !important; opacity: 0; pointer-events: none; border: 0 !important; padding: 0 !important; margin: 0 !important; }
|
.dl-date-hidden { position: absolute !important; left: 0; bottom: 0; width: 1px !important; min-width: 0 !important; height: 1px !important; opacity: 0; pointer-events: none; border: 0 !important; padding: 0 !important; margin: 0 !important; }
|
||||||
.dl-chipbtn .dl-icon { width: 13px; height: 13px; }
|
.dl-chipbtn .dl-icon { width: 13px; height: 13px; }
|
||||||
@@ -85,10 +80,6 @@
|
|||||||
.dl-hc-reach { display: inline-flex; gap: 4px; }
|
.dl-hc-reach { display: inline-flex; gap: 4px; }
|
||||||
.dl-hc-speed { border-radius: 12px; background: var(--dl-soft); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
|
.dl-hc-speed { border-radius: 12px; background: var(--dl-soft); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
|
||||||
.dl-hc-speed-row { display: flex; align-items: baseline; gap: 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
|
.dl-hc-speed-row { display: flex; align-items: baseline; gap: 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
|
||||||
.dl-hc-chart { display: block; width: 100%; height: 30px; }
|
|
||||||
.dl-hc-chart .area { fill: color-mix(in srgb, var(--dl-chart-1) 16%, transparent); }
|
|
||||||
.dl-hc-chart .dn { fill: none; stroke: var(--dl-chart-1); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
|
|
||||||
.dl-hc-chart .up { fill: none; stroke: var(--dl-ok); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
|
|
||||||
.dl-hc-devs { display: flex; flex-wrap: wrap; gap: 6px; }
|
.dl-hc-devs { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||||
.dl-hc-dev { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; background: var(--dl-soft); font-size: 11.5px; }
|
.dl-hc-dev { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; background: var(--dl-soft); font-size: 11.5px; }
|
||||||
.dl-hc-dev .dl-icon-wrap { display: inline-flex; } .dl-hc-dev .dl-icon { width: 12px; height: 12px; color: var(--dl-fg-muted); }
|
.dl-hc-dev .dl-icon-wrap { display: inline-flex; } .dl-hc-dev .dl-icon { width: 12px; height: 12px; color: var(--dl-fg-muted); }
|
||||||
@@ -143,15 +134,7 @@
|
|||||||
.dl-dn { color: var(--dl-accent); } .dl-up { color: var(--dl-ok); }
|
.dl-dn { color: var(--dl-accent); } .dl-up { color: var(--dl-ok); }
|
||||||
.dl-bento-method { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 500; }
|
.dl-bento-method { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 500; }
|
||||||
.dl-bento-method .dl-icon { width: 20px; height: 20px; color: var(--dl-accent); }
|
.dl-bento-method .dl-icon { width: 20px; height: 20px; color: var(--dl-accent); }
|
||||||
.dl-meter { display: inline-flex; gap: 3px; }
|
|
||||||
.dl-meter i { width: 16px; height: 4px; border-radius: 2px; background: var(--dl-line); }
|
|
||||||
.dl-meter i.on { background: var(--dl-accent); }
|
|
||||||
.dl-bento-total { font-size: 16px; font-weight: 500; margin-left: 8px; }
|
.dl-bento-total { font-size: 16px; font-weight: 500; margin-left: 8px; }
|
||||||
.dl-bento-bars { display: flex; align-items: flex-end; height: 54px; --dl-gap: 3px; }
|
|
||||||
.dl-bento-bars i { flex: 1; min-width: 0; border-radius: 3px 3px 0 0; background: var(--dl-soft-hover); transition: background .15s; }
|
|
||||||
.dl-bento-bars i.future { height: 4px; background: var(--dl-soft); }
|
|
||||||
.dl-bento-bars > span:hover i:not(.hi) { background: var(--dl-fg-faint); }
|
|
||||||
.dl-bento-bars i.hi { background: var(--dl-accent); }
|
|
||||||
@media (max-width: 700px) { .dl-addrbar { flex-wrap: wrap; } }
|
@media (max-width: 700px) { .dl-addrbar { flex-wrap: wrap; } }
|
||||||
@media (max-width: 900px) { .dl-bento { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .dl-bento-tile.online { grid-column: span 2; } }
|
@media (max-width: 900px) { .dl-bento { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .dl-bento-tile.online { grid-column: span 2; } }
|
||||||
@media (max-width: 560px) { .dl-bento { grid-template-columns: minmax(0, 1fr); } .dl-bento-tile.online, .dl-bento-tile.month { grid-column: auto; } }
|
@media (max-width: 560px) { .dl-bento { grid-template-columns: minmax(0, 1fr); } .dl-bento-tile.online, .dl-bento-tile.month { grid-column: auto; } }
|
||||||
@@ -170,17 +153,12 @@
|
|||||||
.dl-speed-val { font-size: 20px; line-height: 26px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
.dl-speed-val { font-size: 20px; line-height: 26px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||||
.dl-speed-today { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--dl-fg-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
|
.dl-speed-today { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--dl-fg-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
|
||||||
.dl-speed-today b { font-weight: 500; color: var(--dl-fg); }
|
.dl-speed-today b { font-weight: 500; color: var(--dl-fg); }
|
||||||
.dl-speed-chart { display: block; width: 100%; height: 44px; }
|
|
||||||
.dl-speed-chart .area { fill: color-mix(in srgb, var(--dl-accent) 16%, transparent); }
|
|
||||||
.dl-speed-chart .line { fill: none; stroke: var(--dl-accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
|
|
||||||
.dl-speed-chart .line.up { stroke: var(--dl-ok); stroke-width: 1.2; opacity: .85; }
|
|
||||||
.dl-speed-wait { height: 44px; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; font-size: 11px; color: var(--dl-fg-faint); }
|
.dl-speed-wait { height: 44px; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; font-size: 11px; color: var(--dl-fg-faint); }
|
||||||
.dl-speed-wait i { display: block; height: 1px; background: var(--dl-line); order: 2; }
|
|
||||||
.dl-speed-val.off { color: var(--dl-fg-faint); }
|
.dl-speed-val.off { color: var(--dl-fg-faint); }
|
||||||
.dl-fld { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; }
|
.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-label { font-size: 13px; font-weight: 500; color: var(--dl-fg); }
|
||||||
.dl-fld .cbi-input-text { width: 100%; box-sizing: border-box; }
|
.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;
|
.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; }
|
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; }
|
.dl-kinds button .dl-icon { width: 20px; height: 20px; }
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
.dl-plist > .dl-card.dl-filtered { display: none; }
|
.dl-plist > .dl-card.dl-filtered { display: none; }
|
||||||
/* Stopped (paused, ended, over a limit): the card fades, its strip and actions stay bright. */
|
/* Stopped (paused, ended, over a limit): the card fades, its strip and actions stay bright. */
|
||||||
.dl-plist > .dl-card.dl-off :is(.dl-card-name, .dl-avatar, .dl-access, .dl-slotbar, .dl-chips, .dl-pill-ic, .dl-use-num, .dl-pside-foot, .dl-pside-state) { opacity: .45; }
|
.dl-plist > .dl-card.dl-off :is(.dl-card-name, .dl-avatar, .dl-access, .dl-slotbar, .dl-chips, .dl-pill-ic, .dl-use-num, .dl-pside-foot, .dl-pside-state) { opacity: .45; }
|
||||||
.dl-plist > .dl-card.dl-off .dl-usebar i { background: var(--dl-fg-faint); }
|
.dl-plist > .dl-card.dl-off .dl-smeter > i { background: var(--dl-fg-faint); }
|
||||||
.dl-plist > .dl-card.dl-off .dl-chip-tag { background: var(--dl-soft); color: var(--dl-fg-muted); }
|
.dl-plist > .dl-card.dl-off .dl-chip-tag { background: var(--dl-soft); color: var(--dl-fg-muted); }
|
||||||
/* Why, across the card's bottom edge, with the action that lifts it */
|
/* Why, across the card's bottom edge, with the action that lifts it */
|
||||||
.dl-pcard:has(> .dl-pstrip) { row-gap: 14px; }
|
.dl-pcard:has(> .dl-pstrip) { row-gap: 14px; }
|
||||||
|
|||||||
@@ -70,11 +70,6 @@
|
|||||||
.dl-slots i.over { background: color-mix(in srgb, var(--dl-warn) 80%, transparent); }
|
.dl-slots i.over { background: color-mix(in srgb, var(--dl-warn) 80%, transparent); }
|
||||||
.dl-date { display: flex; align-items: center; gap: 8px; flex: 1 1 150px; min-width: 0; box-sizing: border-box; height: 34px; padding: 0 10px; border: 1px solid var(--input, var(--dl-line)); border-radius: 8px; color: var(--dl-fg-faint); }
|
.dl-date { display: flex; align-items: center; gap: 8px; flex: 1 1 150px; min-width: 0; box-sizing: border-box; height: 34px; padding: 0 10px; border: 1px solid var(--input, var(--dl-line)); border-radius: 8px; color: var(--dl-fg-faint); }
|
||||||
.dl-date input { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; height: 32px !important; color: var(--dl-fg); flex: 1; min-width: 0 !important; width: 100% !important; }
|
.dl-date input { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; height: 32px !important; color: var(--dl-fg); flex: 1; min-width: 0 !important; width: 100% !important; }
|
||||||
.dl-meter { position: relative; height: 6px; border-radius: 999px; background: var(--dl-track); }
|
|
||||||
.dl-meter > i { display: block; height: 100%; border-radius: 999px; background: var(--dl-accent); }
|
|
||||||
.dl-meter.warn > i { background: var(--dl-warn); } .dl-meter.bad > i { background: var(--dl-bad); }
|
|
||||||
.dl-meter .mark { position: absolute; left: 90%; top: -3px; width: 1px; height: 12px; background: var(--dl-warn); }
|
|
||||||
.dl-meter.sm { height: 4px; }
|
|
||||||
.dl-chips-row { display: flex; flex-wrap: wrap; gap: 4px; }
|
.dl-chips-row { display: flex; flex-wrap: wrap; gap: 4px; }
|
||||||
.dl-chipbtn { all: unset; cursor: pointer; height: 26px; padding: 0 10px; border-radius: 999px; background: var(--dl-soft); font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; }
|
.dl-chipbtn { all: unset; cursor: pointer; height: 26px; padding: 0 10px; border-radius: 999px; background: var(--dl-soft); font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; }
|
||||||
.dl-chipbtn:hover { background: var(--dl-soft-hover); } .dl-chipbtn.on { background: var(--dl-primary); color: var(--dl-primary-fg); }
|
.dl-chipbtn:hover { background: var(--dl-soft-hover); } .dl-chipbtn.on { background: var(--dl-primary); color: var(--dl-primary-fg); }
|
||||||
@@ -111,15 +106,11 @@
|
|||||||
.dl-use-num { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
|
.dl-use-num { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
|
||||||
.dl-use-num b { font-size: 15px; font-weight: 500; }
|
.dl-use-num b { font-size: 15px; font-weight: 500; }
|
||||||
.dl-use-live { display: flex; align-items: center; gap: 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
|
.dl-use-live { display: flex; align-items: center; gap: 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
|
||||||
.dl-usebar { display: flex; gap: 2px; height: 6px; border-radius: 999px; overflow: hidden; background: var(--dl-track); }
|
.dl-smeter .c0, .dl-swatch.c0 { background: var(--dl-chart-1); }
|
||||||
.dl-usebar i { display: block; height: 100%; min-width: 3px; flex: 0 1 0; }
|
.dl-smeter .c1, .dl-swatch.c1 { background: #8b7cf6; }
|
||||||
.dl-usebar i.fill { flex: none; min-width: 0; border-radius: 999px; background: var(--dl-accent); }
|
.dl-smeter .c2, .dl-swatch.c2 { background: #2fb889; }
|
||||||
.dl-usebar.warn i.fill { background: var(--dl-warn); } .dl-usebar.bad i.fill { background: var(--dl-bad); }
|
.dl-smeter .c3, .dl-swatch.c3 { background: #d9a03f; }
|
||||||
.dl-usebar .c0, .dl-swatch.c0 { background: var(--dl-chart-1); }
|
.dl-smeter .c4, .dl-swatch.c4 { background: var(--dl-fg-faint); }
|
||||||
.dl-usebar .c1, .dl-swatch.c1 { background: #8b7cf6; }
|
|
||||||
.dl-usebar .c2, .dl-swatch.c2 { background: #2fb889; }
|
|
||||||
.dl-usebar .c3, .dl-swatch.c3 { background: #d9a03f; }
|
|
||||||
.dl-usebar .c4, .dl-swatch.c4 { background: var(--dl-fg-faint); }
|
|
||||||
.dl-tip-row { display: flex; align-items: center; gap: 8px; min-width: 160px; }
|
.dl-tip-row { display: flex; align-items: center; gap: 8px; min-width: 160px; }
|
||||||
.dl-tip-row b { margin-left: auto; font-weight: 500; }
|
.dl-tip-row b { margin-left: auto; font-weight: 500; }
|
||||||
.dl-swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
|
.dl-swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
// The chart tooltip: one card anchored above a point of a chart (not under the
|
||||||
|
// pointer, see tooltip.ts for that), gliding from one point to the next while a
|
||||||
|
// chart is read (shared/scrub.ts). Its numbers swap at once; only the card moves.
|
||||||
|
// It hides when the page navigates, on scrolling, and when its owner lets go.
|
||||||
|
|
||||||
|
import { E } from '../e';
|
||||||
|
import { onNavigate } from './nav';
|
||||||
|
|
||||||
|
let card: HTMLElement | null = null;
|
||||||
|
let owner: object | null = null;
|
||||||
|
const still = () => matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||||
|
|
||||||
|
/** Show `kids` above page point (x, y) for `who`; the same owner's next point glides there. */
|
||||||
|
export function showGlide(who: object, x: number, y: number, kids: (Node | string)[]): void {
|
||||||
|
card ??= document.body.appendChild(E('div', { class: 'dl-tip dl-tip-float dl-root dl-glide' }));
|
||||||
|
card.replaceChildren(...kids.map((k) => (typeof k === 'string' ? document.createTextNode(k) : k)));
|
||||||
|
card.style.display = '';
|
||||||
|
// Kept inside the window: measured with its new content, before it moves.
|
||||||
|
const w = card.offsetWidth;
|
||||||
|
const cx = Math.min(innerWidth - 8 - w / 2, Math.max(8 + w / 2, x));
|
||||||
|
card.classList.toggle('glides', owner === who && !still());
|
||||||
|
card.style.transform = `translate(${cx}px, ${y - 10}px) translate(-50%, -100%)`;
|
||||||
|
card.classList.add('on');
|
||||||
|
owner = who;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Hide the card (only if `who` owns it, when given). */
|
||||||
|
export function hideGlide(who?: object): void {
|
||||||
|
if (!card || (who && who !== owner)) return;
|
||||||
|
card.classList.remove('on', 'glides');
|
||||||
|
card.style.display = 'none';
|
||||||
|
owner = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A tooltip for a piece that is one value (a meter): above `anchor` (the piece's
|
||||||
|
* top centre by default) while the pointer is on it, after a tap (until a tap
|
||||||
|
* elsewhere), or while it has focus.
|
||||||
|
*/
|
||||||
|
export function pointTip(el: HTMLElement, content: () => (Node | string)[], anchor?: () => [number, number]): void {
|
||||||
|
const at = (): [number, number] => {
|
||||||
|
if (anchor) return anchor();
|
||||||
|
const r = el.getBoundingClientRect();
|
||||||
|
return [r.left + r.width / 2, r.top];
|
||||||
|
};
|
||||||
|
let shown = false;
|
||||||
|
const show = () => {
|
||||||
|
shown = true;
|
||||||
|
const [x, y] = at();
|
||||||
|
showGlide(el, x, y, content());
|
||||||
|
document.addEventListener('pointerdown', away, true);
|
||||||
|
};
|
||||||
|
const hide = () => {
|
||||||
|
shown = false;
|
||||||
|
hideGlide(el);
|
||||||
|
document.removeEventListener('pointerdown', away, true);
|
||||||
|
};
|
||||||
|
const away = (ev: PointerEvent) => !el.contains(ev.target as Node) && hide();
|
||||||
|
el.tabIndex = 0;
|
||||||
|
el.addEventListener('pointerenter', (ev) => ev.pointerType === 'mouse' && show());
|
||||||
|
el.addEventListener('pointerleave', (ev) => ev.pointerType === 'mouse' && hide());
|
||||||
|
el.addEventListener('pointerup', (ev) => ev.pointerType !== 'mouse' && (shown ? hide() : show()));
|
||||||
|
el.addEventListener('focus', show);
|
||||||
|
el.addEventListener('blur', hide);
|
||||||
|
}
|
||||||
|
|
||||||
|
onNavigate(() => hideGlide());
|
||||||
|
window.addEventListener('scroll', () => owner && hideGlide(), { capture: true, passive: true });
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
// Charts drawn in the connection map's language (map.ts, styles/map.css): an SVG
|
||||||
|
// sized to its box in real pixels (so the arcs' dashes and the markers stay true
|
||||||
|
// at any width), and the map's marks: the person marker (a ringed circle, a halo
|
||||||
|
// while live), the replay's tick for a picked moment, the soft accuracy zone
|
||||||
|
// under a line. Colours and strokes are CSS (styles/charts.css), so a theme
|
||||||
|
// switch needs no redraw. What a chart draws is the subclass's.
|
||||||
|
|
||||||
|
let ids = 0;
|
||||||
|
|
||||||
|
export abstract class Plot {
|
||||||
|
readonly el: HTMLElement;
|
||||||
|
protected svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
||||||
|
/** The box in CSS pixels; 0 until it is laid out. */
|
||||||
|
protected W = 0;
|
||||||
|
protected H = 0;
|
||||||
|
/** Unique within the page, for the gradients a chart defines. */
|
||||||
|
protected id = `dl-plot${++ids}`;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `width`: a box whose size is known up front (a tooltip's chart, built anew
|
||||||
|
* each time it shows) is drawn at once, without waiting to be laid out.
|
||||||
|
*/
|
||||||
|
constructor(cls: string, height: number, width?: number) {
|
||||||
|
this.el = document.createElement('div');
|
||||||
|
this.el.className = `dl-plot ${cls}`;
|
||||||
|
this.el.style.height = `${height}px`;
|
||||||
|
this.svg.setAttribute('aria-hidden', 'true');
|
||||||
|
this.el.appendChild(this.svg);
|
||||||
|
if (width) {
|
||||||
|
this.el.style.width = `${width}px`;
|
||||||
|
this.W = width;
|
||||||
|
this.H = height;
|
||||||
|
this.svg.setAttribute('viewBox', `0 0 ${width} ${height}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const ro = new ResizeObserver(() => {
|
||||||
|
// A chart a repaint replaced lets go of its observer.
|
||||||
|
if (!this.el.isConnected && this.W) return ro.disconnect();
|
||||||
|
const r = this.el.getBoundingClientRect();
|
||||||
|
const w = Math.round(r.width),
|
||||||
|
h = Math.round(r.height);
|
||||||
|
if (!w || (w === this.W && h === this.H)) return;
|
||||||
|
this.W = w;
|
||||||
|
this.H = h;
|
||||||
|
this.svg.setAttribute('viewBox', `0 0 ${w} ${h}`);
|
||||||
|
this.draw();
|
||||||
|
});
|
||||||
|
ro.observe(this.el);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Draw what the chart holds now (nothing before it has a size). */
|
||||||
|
abstract draw(): void;
|
||||||
|
|
||||||
|
protected put(markup: string): void {
|
||||||
|
this.svg.innerHTML = markup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Page x of a point at x inside the box, and page y of a y inside it. */
|
||||||
|
protected page(x: number, y: number): [number, number] {
|
||||||
|
const r = this.el.getBoundingClientRect();
|
||||||
|
return [r.left + x, r.top + y];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const f = (n: number) => n.toFixed(1);
|
||||||
|
|
||||||
|
/** A marker: the map's person circle, live blue or the recent grey; `halo`: it breathes. */
|
||||||
|
export const marker = (x: number, y: number, live: boolean, r = 4, halo = false): string =>
|
||||||
|
(halo && live ? `<circle class="halo" cx="${f(x)}" cy="${f(y)}" r="${r}"/>` : '') +
|
||||||
|
`<circle class="mk${live ? ' live' : ''}" cx="${f(x)}" cy="${f(y)}" r="${r}"/>`;
|
||||||
|
|
||||||
|
/** The picked point on a chart: a marker in the text colour with a ring of the card. */
|
||||||
|
export const picked = (x: number, y: number, r = 4.5): string => `<circle class="mk on" cx="${f(x)}" cy="${f(y)}" r="${r}"/>`;
|
||||||
|
|
||||||
|
/** The replay's tick: 2 px in the text colour, a ring of the card around it. */
|
||||||
|
export const tick = (x: number, y0: number, y1: number): string =>
|
||||||
|
`<line class="tick-ring" x1="${f(x)}" x2="${f(x)}" y1="${y0}" y2="${y1}"/><line class="tick" x1="${f(x)}" x2="${f(x)}" y1="${y0}" y2="${y1}"/>`;
|
||||||
|
|
||||||
|
/** A vertical soft zone (the accuracy circle's fill fading to nothing), as a gradient `id` of class `cls`. */
|
||||||
|
export const zone = (id: string, cls: string): string =>
|
||||||
|
`<linearGradient id="${id}" x1="0" x2="0" y1="0" y2="1"><stop class="${cls} z0" offset="0"/><stop class="${cls} z1" offset="1"/></linearGradient>`;
|
||||||
|
|
||||||
|
/** A smooth path through points that never overshoots them (monotone cubic): a quiet stretch stays flat, never dips. */
|
||||||
|
export function smooth(p: [number, number][]): string {
|
||||||
|
const n = p.length;
|
||||||
|
if (n < 2) return n ? `M${f(p[0][0])},${f(p[0][1])}` : '';
|
||||||
|
const d: number[] = [];
|
||||||
|
for (let i = 0; i < n - 1; i++) d.push((p[i + 1][1] - p[i][1]) / Math.max(1e-6, p[i + 1][0] - p[i][0]));
|
||||||
|
const m = [d[0], ...d.slice(1).map((v, i) => (d[i] * v <= 0 ? 0 : (d[i] + v) / 2)), d[n - 2]];
|
||||||
|
// Fritsch–Carlson: tangents scaled down where they would overshoot.
|
||||||
|
for (let i = 0; i < n - 1; i++) {
|
||||||
|
if (d[i] === 0) {
|
||||||
|
m[i] = m[i + 1] = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const a = m[i] / d[i],
|
||||||
|
b = m[i + 1] / d[i],
|
||||||
|
s = a * a + b * b;
|
||||||
|
if (s > 9) {
|
||||||
|
const t = 3 / Math.sqrt(s);
|
||||||
|
m[i] = t * a * d[i];
|
||||||
|
m[i + 1] = t * b * d[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let out = `M${f(p[0][0])},${f(p[0][1])}`;
|
||||||
|
for (let i = 0; i < n - 1; i++) {
|
||||||
|
const h = (p[i + 1][0] - p[i][0]) / 3;
|
||||||
|
out += ` C${f(p[i][0] + h)},${f(p[i][1] + m[i] * h)} ${f(p[i + 1][0] - h)},${f(p[i + 1][1] - m[i + 1] * h)} ${f(p[i + 1][0])},${f(p[i + 1][1])}`;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
@@ -9,11 +9,17 @@ import { onNavigate } from './nav';
|
|||||||
|
|
||||||
let floating: HTMLElement | null = null;
|
let floating: HTMLElement | null = null;
|
||||||
let anchor: HTMLElement | null = null;
|
let anchor: HTMLElement | null = null;
|
||||||
|
/** What the shown tooltip is drawn from. */
|
||||||
|
let drawn: (() => (Node | string)[]) | null = null;
|
||||||
let watch = 0;
|
let watch = 0;
|
||||||
|
|
||||||
|
const draw = (content: () => (Node | string)[]) =>
|
||||||
|
floating!.replaceChildren(...content().map((c) => (typeof c === 'string' ? document.createTextNode(c) : c)));
|
||||||
|
|
||||||
function hideTip() {
|
function hideTip() {
|
||||||
if (floating) floating.style.display = 'none';
|
if (floating) floating.style.display = 'none';
|
||||||
anchor = null;
|
anchor = null;
|
||||||
|
drawn = null;
|
||||||
clearInterval(watch);
|
clearInterval(watch);
|
||||||
watch = 0;
|
watch = 0;
|
||||||
}
|
}
|
||||||
@@ -21,7 +27,8 @@ function hideTip() {
|
|||||||
export function attachTip(el: HTMLElement, content: () => (Node | string)[]) {
|
export function attachTip(el: HTMLElement, content: () => (Node | string)[]) {
|
||||||
const show = (ev: MouseEvent) => {
|
const show = (ev: MouseEvent) => {
|
||||||
floating ??= document.body.appendChild(E('div', { class: 'dl-tip dl-tip-float dl-root' }));
|
floating ??= document.body.appendChild(E('div', { class: 'dl-tip dl-tip-float dl-root' }));
|
||||||
floating.replaceChildren(...content().map((c) => (typeof c === 'string' ? document.createTextNode(c) : c)));
|
draw(content);
|
||||||
|
drawn = content;
|
||||||
floating.style.display = '';
|
floating.style.display = '';
|
||||||
floating.style.left = `${ev.clientX}px`;
|
floating.style.left = `${ev.clientX}px`;
|
||||||
floating.style.top = `${ev.clientY - 10}px`;
|
floating.style.top = `${ev.clientY - 10}px`;
|
||||||
@@ -43,6 +50,11 @@ export function attachTip(el: HTMLElement, content: () => (Node | string)[]) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Draw the shown tooltip again where it stands (live numbers in it); nothing when none shows. */
|
||||||
|
export function refreshTip() {
|
||||||
|
if (drawn && anchor?.isConnected) draw(drawn);
|
||||||
|
}
|
||||||
|
|
||||||
onNavigate(hideTip);
|
onNavigate(hideTip);
|
||||||
window.addEventListener('scroll', () => anchor && hideTip(), { capture: true, passive: true });
|
window.addEventListener('scroll', () => anchor && hideTip(), { capture: true, passive: true });
|
||||||
document.addEventListener(
|
document.addEventListener(
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ export async function runOperation(what: string | null, o: OpOptions, follow?: U
|
|||||||
prevId = before?.job?.id;
|
prevId = before?.job?.id;
|
||||||
since = before?.now ?? 0;
|
since = before?.now ?? 0;
|
||||||
const r = await api.updatesRun(what!);
|
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;
|
job = r.job;
|
||||||
known(r.job);
|
known(r.job);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
/** A server's People section (Servers page). */
|
/** A server's People section (Servers page). */
|
||||||
export function peopleUrl(server?: string): string {
|
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 {
|
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)}` : ''}`;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
// Days as charts: stacked rounded bars (download at the base, upload on top, in
|
||||||
|
// the colours of the tiles' ↓ and ↑ numbers), and the strip of the device
|
||||||
|
// panel's places (a track with a segment for each day used, today the map's live
|
||||||
|
// blue). The picked day (shared/scrub.ts) stays bright over a soft band while the
|
||||||
|
// others dim, or gets the replay's tick on a strip. Days are [rx, tx] oldest
|
||||||
|
// first, today last.
|
||||||
|
|
||||||
|
import type { Pair } from '../../shared/types';
|
||||||
|
import type { Readable } from '../../shared/scrub';
|
||||||
|
import { Plot, tick } from '../ui/plot';
|
||||||
|
|
||||||
|
const f = (n: number) => n.toFixed(1);
|
||||||
|
|
||||||
|
/** A chart with a column per day: which column a pointer is over, where a column's top stands. */
|
||||||
|
abstract class DayPlot extends Plot implements Readable {
|
||||||
|
protected hov = -1;
|
||||||
|
/** Each day's top (box y) in the last paint, for the tooltip's anchor. */
|
||||||
|
protected tops: number[] = [];
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
cls: string,
|
||||||
|
height: number,
|
||||||
|
protected days: Pair[],
|
||||||
|
) {
|
||||||
|
super(cls, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
mark(i: number): void {
|
||||||
|
this.hov = i;
|
||||||
|
this.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected cx(i: number): number {
|
||||||
|
return ((i + 0.5) * this.W) / this.days.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The day under a pointer: each column's share of the width, the gaps included. */
|
||||||
|
indexAt(clientX: number): number {
|
||||||
|
const i = Math.floor(((clientX - this.el.getBoundingClientRect().left) / Math.max(1, this.W)) * this.days.length);
|
||||||
|
return i >= 0 && i < this.days.length ? i : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
anchor(i: number): [number, number] {
|
||||||
|
return this.page(this.cx(i), this.tops[i] ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The picked day's soft band, under everything. */
|
||||||
|
protected band(): string {
|
||||||
|
if (this.hov < 0) return '';
|
||||||
|
const w = this.W / this.days.length;
|
||||||
|
return `<rect class="band" x="${f(this.cx(this.hov) - w / 2)}" y="0" width="${f(w)}" height="${this.H}" rx="4"/>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Days as stacked rounded bars, one a day on one scale: the download at the base
|
||||||
|
* and the upload on top, in the colours of the tile's ↓ and ↑ numbers, so a
|
||||||
|
* bar's height is the day's total and its colours the split. The picked day
|
||||||
|
* stays bright over a soft band while the others dim. `maxW`: the widest a bar
|
||||||
|
* gets (px).
|
||||||
|
*/
|
||||||
|
export class DayStack extends DayPlot {
|
||||||
|
constructor(
|
||||||
|
days: Pair[],
|
||||||
|
height: number,
|
||||||
|
private maxW = 14,
|
||||||
|
) {
|
||||||
|
super('dl-stack-bars', height, days);
|
||||||
|
}
|
||||||
|
|
||||||
|
draw(): void {
|
||||||
|
const { W, H, days } = this;
|
||||||
|
if (!W) return;
|
||||||
|
const max = Math.max(1, ...days.map((d) => d[0] + d[1]));
|
||||||
|
const w = Math.min(this.maxW, Math.max(3, (W / days.length) * 0.62));
|
||||||
|
const r = Math.min(2.5, w / 2);
|
||||||
|
let s = this.band();
|
||||||
|
days.forEach(([rx, tx], i) => {
|
||||||
|
const x = this.cx(i) - w / 2;
|
||||||
|
const cls = i === this.hov ? ' on' : this.hov >= 0 ? ' dim' : '';
|
||||||
|
const down = (tx / max) * H,
|
||||||
|
up = (rx / max) * H;
|
||||||
|
// A gap of 1 px between the parts when both show.
|
||||||
|
const gap = down >= 1 && up >= 1 ? 1 : 0;
|
||||||
|
this.tops[i] = H - down - up - gap;
|
||||||
|
if (!rx && !tx) {
|
||||||
|
s += `<rect class="none" x="${f(x)}" y="${H - 2}" width="${f(w)}" height="2" rx="1"/>`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (down)
|
||||||
|
s += `<rect class="dn${cls}" x="${f(x)}" y="${f(H - Math.max(2, down))}" width="${f(w)}" height="${f(Math.max(2, down))}" rx="${r}"/>`;
|
||||||
|
if (up) s += `<rect class="up${cls}" x="${f(x)}" y="${f(this.tops[i])}" width="${f(w)}" height="${f(Math.max(2, up))}" rx="${r}"/>`;
|
||||||
|
});
|
||||||
|
this.put(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Which days a device was used, as the device panel's places strip: a 6 px track,
|
||||||
|
* a segment on each day used (stronger the more), today live blue; the picked
|
||||||
|
* day gets the replay's tick.
|
||||||
|
*/
|
||||||
|
export class DayStrip extends DayPlot {
|
||||||
|
constructor(days: Pair[], height: number) {
|
||||||
|
super('dl-dstrip', height, days);
|
||||||
|
}
|
||||||
|
|
||||||
|
draw(): void {
|
||||||
|
const { W, H, days } = this;
|
||||||
|
if (!W) return;
|
||||||
|
const n = days.length;
|
||||||
|
const vals = days.map((d) => d[0] + d[1]);
|
||||||
|
const max = Math.max(1, ...vals);
|
||||||
|
const y0 = H / 2 - 3,
|
||||||
|
w = W / n;
|
||||||
|
let s = `<rect class="track" x="0" y="${f(y0)}" width="${W}" height="6" rx="3"/>`;
|
||||||
|
vals.forEach((v, i) => {
|
||||||
|
this.tops[i] = y0 - 4;
|
||||||
|
if (!v) return;
|
||||||
|
const live = i === n - 1;
|
||||||
|
s += `<rect class="seg${live ? ' live' : ''}" x="${f(i * w + 0.5)}" y="${f(y0)}" width="${f(Math.max(2, w - 1))}" height="6" rx="2"${
|
||||||
|
live ? '' : ` opacity="${(0.35 + 0.65 * Math.sqrt(v / max)).toFixed(2)}"`
|
||||||
|
}/>`;
|
||||||
|
});
|
||||||
|
if (this.hov >= 0) s += tick(this.cx(this.hov), y0 - 4, y0 + 10);
|
||||||
|
this.put(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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.
|
// 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.startsWith('install:')) return button(_('Install'), () => installFeature(fix.slice(8) as keyof Needs, refresh), kind);
|
||||||
if (fix === 'updates')
|
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);
|
return button(fixLabel(fix), () => run(fix), kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ export function healthNotices(checks: HealthCheck[], run: (fix: string) => void,
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
rest > 0
|
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)),
|
fmt(_('%s more in Diagnostics'), num(rest)),
|
||||||
E('span', { class: 'dl-spacer' }),
|
E('span', { class: 'dl-spacer' }),
|
||||||
'→',
|
'→',
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
// The speed chart (Speed now, an online person's hover card): download as the
|
||||||
|
// map's live line over its zone, upload as a recent grey dashed line on the same
|
||||||
|
// scale, the newest second a live marker that breathes. Read point by point
|
||||||
|
// (shared/scrub.ts): the picked second gets the replay's tick and a marker on each
|
||||||
|
// line. Waiting, an unreadable meter and a server that is off are the tile's.
|
||||||
|
|
||||||
|
import type { Rate } from '../state/meter';
|
||||||
|
import type { Readable } from '../../shared/scrub';
|
||||||
|
import { Plot, marker, picked, smooth, tick, zone } from '../ui/plot';
|
||||||
|
|
||||||
|
/** Room at the ends for the markers. */
|
||||||
|
const PAD = 5;
|
||||||
|
|
||||||
|
export class SpeedLines extends Plot implements Readable {
|
||||||
|
private pts: Rate[] = [];
|
||||||
|
private xs: number[] = [];
|
||||||
|
private hov = -1;
|
||||||
|
|
||||||
|
/** `small`: the hover card's, with smaller marks, at a known `width`. */
|
||||||
|
constructor(
|
||||||
|
height: number,
|
||||||
|
private small = false,
|
||||||
|
width?: number,
|
||||||
|
) {
|
||||||
|
super('dl-lines', height, width);
|
||||||
|
}
|
||||||
|
|
||||||
|
get points(): Rate[] {
|
||||||
|
return this.pts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The points ([ts, rx, tx], oldest first) and where each sits across (0–1, the newest at 1). */
|
||||||
|
set(pts: Rate[], xs: number[]): void {
|
||||||
|
this.pts = pts;
|
||||||
|
this.xs = xs;
|
||||||
|
this.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
mark(i: number): void {
|
||||||
|
this.hov = i;
|
||||||
|
this.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private x(i: number): number {
|
||||||
|
return PAD + this.xs[i] * (this.W - 2 * PAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
indexAt(clientX: number): number {
|
||||||
|
if (this.pts.length < 2 || !this.W) return -1;
|
||||||
|
const f = (clientX - this.el.getBoundingClientRect().left - PAD) / (this.W - 2 * PAD);
|
||||||
|
// Left of the first point (the meter still filling its two minutes) is nothing.
|
||||||
|
if (f < this.xs[0] - 0.02) return -1;
|
||||||
|
let best = 0;
|
||||||
|
this.xs.forEach((x, i) => {
|
||||||
|
if (Math.abs(x - f) < Math.abs(this.xs[best] - f)) best = i;
|
||||||
|
});
|
||||||
|
return best;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw(): void {
|
||||||
|
const { W, H, pts } = this;
|
||||||
|
const n = pts.length;
|
||||||
|
if (!W || n < 2) return this.put('');
|
||||||
|
const max = Math.max(1, ...pts.map((p) => Math.max(p[1], p[2])));
|
||||||
|
const y = (v: number) => H - 3 - (v / max) * (H - 3 - PAD);
|
||||||
|
const dn = pts.map((p, i): [number, number] => [this.x(i), y(p[2])]);
|
||||||
|
const up = pts.map((p, i): [number, number] => [this.x(i), y(p[1])]);
|
||||||
|
const d = smooth(dn);
|
||||||
|
const r = this.small ? 3 : 3.5;
|
||||||
|
let s = `<defs>${zone(`${this.id}z`, 'live')}</defs>`;
|
||||||
|
s += `<path class="area" fill="url(#${this.id}z)" d="${d} L${dn[n - 1][0]},${H} L${dn[0][0]},${H}Z"/>`;
|
||||||
|
s += `<path class="ln past dash thin" d="${smooth(up)}"/><path class="ln live" d="${d}"/>`;
|
||||||
|
const h = this.hov >= 0 && this.hov < n ? this.hov : -1;
|
||||||
|
if (h >= 0) {
|
||||||
|
s += tick(dn[h][0], 1, H - 1) + marker(up[h][0], up[h][1], false, r) + picked(dn[h][0], dn[h][1], r + 0.5);
|
||||||
|
}
|
||||||
|
// The newest second, breathing while nothing is picked.
|
||||||
|
if (h !== n - 1) s += marker(dn[n - 1][0], dn[n - 1][1], true, r, h < 0);
|
||||||
|
this.put(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
// A usage meter in the connection map's language (the device panel's places
|
||||||
|
// strip): a 6 px track and a rounded fill, live blue, orange when nearly full,
|
||||||
|
// red when full. Past the fill, dashed like an arc, where a week at the recent
|
||||||
|
// pace takes it (shared/pace.ts). The alert level is the replay's tick. Without a
|
||||||
|
// limit, the month split by device: a rounded segment each (c0–c4, the swatch
|
||||||
|
// colours), a gap between. Tooltips are the caller's (ui/glide.ts pointTip).
|
||||||
|
|
||||||
|
type MeterTone = 'live' | 'warn' | 'bad';
|
||||||
|
|
||||||
|
/** The tone for a share used: full at 100%, nearly full from 90%. */
|
||||||
|
const toneOf = (pct: number): MeterTone => (pct >= 100 ? 'bad' : pct >= 90 ? 'warn' : 'live');
|
||||||
|
|
||||||
|
/** `pct` used of the limit; `ahead`: where a week at this pace takes it (both 0–100); `mark`: the alert (0–1). */
|
||||||
|
export function limitMeter(pct: number, ahead = 0, mark?: number): HTMLElement {
|
||||||
|
const el = document.createElement('div');
|
||||||
|
el.className = `dl-smeter ${toneOf(pct)}`;
|
||||||
|
const fill = el.appendChild(document.createElement('i'));
|
||||||
|
fill.style.width = `${pct}%`;
|
||||||
|
if (ahead > pct) {
|
||||||
|
const dash = el.appendChild(document.createElement('b'));
|
||||||
|
dash.style.left = `${pct}%`;
|
||||||
|
dash.style.width = `${ahead - pct}%`;
|
||||||
|
}
|
||||||
|
if (mark != null) {
|
||||||
|
const m = el.appendChild(document.createElement('span'));
|
||||||
|
m.className = 'mark';
|
||||||
|
m.style.left = `${mark * 100}%`;
|
||||||
|
}
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The month split by device, largest first (values in bytes; colours c0–c4 in that order). */
|
||||||
|
export function splitMeter(values: number[]): HTMLElement {
|
||||||
|
const el = document.createElement('div');
|
||||||
|
el.className = 'dl-smeter parts';
|
||||||
|
values.forEach((v, i) => {
|
||||||
|
const seg = el.appendChild(document.createElement('i'));
|
||||||
|
seg.className = `c${Math.min(i, 4)}`;
|
||||||
|
seg.style.flexGrow = String(v);
|
||||||
|
});
|
||||||
|
return el;
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
// What a picked point says: a day of traffic in a chart's tooltip (ui/glide.ts:
|
||||||
|
// its name, its total against the average, the down/up split as a strip, the
|
||||||
|
// busiest of the span), and when a second of the live speed was, for the tile's
|
||||||
|
// head. Content only; anchoring and gliding are the tooltip's, sums shared/pace.ts.
|
||||||
|
|
||||||
|
import { E } from '../e';
|
||||||
|
import { addDays, bytes, parseDay } from '../../shared/format';
|
||||||
|
import { fmt, locale, num } from '../../shared/i18n';
|
||||||
|
import { vsAverage } from '../../shared/pace';
|
||||||
|
|
||||||
|
/** "Today", "Yesterday", "Sat 31 Oct", on the router's calendar (`today`). */
|
||||||
|
export function dayName(day: string, today: string): string {
|
||||||
|
if (day === today) return _('Today');
|
||||||
|
if (day === addDays(today, -1)) return _('Yesterday');
|
||||||
|
return parseDay(day).toLocaleDateString(locale(), { weekday: 'short', day: 'numeric', month: 'short' });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A day against the average of the others: "+62% vs average", "about average"; today is "so far". */
|
||||||
|
function againstAverage(totals: number[], i: number): string {
|
||||||
|
if (i === totals.length - 1) return _('so far');
|
||||||
|
const p = vsAverage(totals, i);
|
||||||
|
if (Math.abs(p) < 5) return _('about average');
|
||||||
|
return p > 0 ? fmt(_('+%s%% vs average'), num(p)) : fmt(_('−%s%% vs average'), num(-p));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Down and up as one strip: download the live blue, upload the past grey. */
|
||||||
|
function split(tx: number, rx: number): HTMLElement {
|
||||||
|
const dn = E('i', { class: 'dn' }),
|
||||||
|
up = E('i', { class: 'up' });
|
||||||
|
dn.style.flexGrow = String(tx);
|
||||||
|
up.style.flexGrow = String(rx);
|
||||||
|
return E('div', { class: 'dl-glide-split' }, rx || tx ? [dn, up] : []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** "↓ 8.3 GB ↑ 1.1 GB". */
|
||||||
|
export const downUp = (tx: number, rx: number) => [
|
||||||
|
E('span', { class: 'dl-dn' }, '↓'),
|
||||||
|
` ${bytes(tx)} `,
|
||||||
|
E('span', { class: 'dl-up' }, '↑'),
|
||||||
|
` ${bytes(rx)}`,
|
||||||
|
];
|
||||||
|
|
||||||
|
/** Day i of `days` ([rx, tx], today last): its name and how it compares, its total, the split. */
|
||||||
|
export function dayTip(days: { day: string; rx: number; tx: number }[], i: number, today: string): (Node | string)[] {
|
||||||
|
const totals = days.map((d) => d.rx + d.tx);
|
||||||
|
const d = days[i];
|
||||||
|
return [
|
||||||
|
E('div', { class: 'dl-glide-head' }, [E('b', {}, dayName(d.day, today)), E('span', { class: 'dl-faint' }, againstAverage(totals, i))]),
|
||||||
|
E('div', { class: 'dl-glide-big' }, bytes(totals[i])),
|
||||||
|
split(d.tx, d.rx),
|
||||||
|
E('div', { class: 'dl-muted dl-mono' }, downUp(d.tx, d.rx)),
|
||||||
|
totals[i] > 0 && totals[i] === Math.max(...totals)
|
||||||
|
? E('div', { class: 'dl-glide-note' }, fmt(_('The busiest of the %s days'), num(days.length)))
|
||||||
|
: '',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A device's day: its name, what it moved or that it was not used, and on how many days of the span it was. */
|
||||||
|
export function deviceDayTip(days: { day: string; rx: number; tx: number }[], i: number, today: string): (Node | string)[] {
|
||||||
|
const d = days[i],
|
||||||
|
v = d.rx + d.tx;
|
||||||
|
const used = days.filter((x) => x.rx + x.tx > 0).length;
|
||||||
|
return [
|
||||||
|
E('div', { class: 'dl-glide-head' }, [
|
||||||
|
E('b', {}, dayName(d.day, today)),
|
||||||
|
E('span', { class: 'dl-faint' }, v ? bytes(v) : _('Not used')),
|
||||||
|
]),
|
||||||
|
v ? split(d.tx, d.rx) : '',
|
||||||
|
E(
|
||||||
|
'div',
|
||||||
|
{ class: 'dl-glide-note' },
|
||||||
|
fmt(N_(days.length, 'Used on %s of %s day', 'Used on %s of %s days'), num(used), num(days.length)),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** When a second was against the newest: "now", "12 s ago", "1 min 40 s ago". */
|
||||||
|
export function secondsAgo(s: number): string {
|
||||||
|
if (s < 1) return _('now');
|
||||||
|
return s < 60 ? fmt(_('%s s ago'), num(s)) : fmt(_('%s min %s s ago'), num(Math.floor(s / 60)), num(s % 60));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A second's time on the clock, with seconds. */
|
||||||
|
export const timeOf = (ts: number) =>
|
||||||
|
new Date(ts * 1000).toLocaleTimeString(locale(), { hour: '2-digit', minute: '2-digit', second: '2-digit' });
|
||||||
@@ -1,36 +1,28 @@
|
|||||||
// Tiny daily sparkline (oldest first, the last bar is today) with per-day tooltips.
|
// A device's last 7 days as small stacked bars (oldest first, the last is
|
||||||
|
// today; download at the base, upload on top), read day by day with the
|
||||||
|
// tooltip above the picked one.
|
||||||
|
|
||||||
import { E } from '../e';
|
import type { Pair } from '../../shared/types';
|
||||||
import { addDays, bytes, isoDay, parseDay } from '../../shared/format';
|
import { addDays, bytes, isoDay } from '../../shared/format';
|
||||||
import { attachTip } from '../ui/tooltip';
|
import { scrub } from '../../shared/scrub';
|
||||||
import { locale } from '../../shared/i18n';
|
import { hideGlide, showGlide } from '../ui/glide';
|
||||||
|
import { DayStack } from './days';
|
||||||
|
import { dayName, deviceDayTip } from './readouts';
|
||||||
|
|
||||||
/** `today` is the router's day (YYYY-MM-DD), so the labels follow its calendar. */
|
/** `days` are [rx, tx]; `today` is the router's day (YYYY-MM-DD), so the names follow its calendar. */
|
||||||
export function spark(values: number[], width = 120, height = 26, today = isoDay(new Date())): HTMLElement {
|
export function spark(days: Pair[], width = 120, height = 22, today = isoDay(new Date())): HTMLElement {
|
||||||
const max = Math.max(1, ...values);
|
const chart = new DayStack(days, height, 10);
|
||||||
const el = E('div', { class: 'dl-spark' });
|
chart.el.style.width = `${width}px`;
|
||||||
el.style.width = `${width}px`;
|
const dated = days.map(([rx, tx], i) => ({ day: addDays(today, i - (days.length - 1)), rx, tx }));
|
||||||
el.style.height = `${height}px`;
|
scrub(chart.el, chart, {
|
||||||
values.forEach((v, i) => {
|
count: () => days.length,
|
||||||
const b = E('i');
|
pick: (i) => {
|
||||||
b.style.height = `${Math.max(6, (v / max) * 100)}%`;
|
if (i < 0) return hideGlide(chart.el);
|
||||||
if (!v) b.classList.add('zero');
|
const [x, y] = chart.anchor(i);
|
||||||
// The day's column carries the tooltip: it answers above a short bar and between two bars.
|
showGlide(chart.el, x, y, deviceDayTip(dated, i, today));
|
||||||
const col = E('span', {}, [b]);
|
},
|
||||||
const back = values.length - 1 - i;
|
label: _('Last 7 days'),
|
||||||
attachTip(col, () => [
|
say: (i) => `${dayName(dated[i].day, today)}: ${bytes(dated[i].rx + dated[i].tx)}`,
|
||||||
E(
|
|
||||||
'div',
|
|
||||||
{ class: 'dl-tip-title' },
|
|
||||||
back === 0
|
|
||||||
? _('Today')
|
|
||||||
: back === 1
|
|
||||||
? _('Yesterday')
|
|
||||||
: parseDay(addDays(today, -back)).toLocaleDateString(locale(), { weekday: 'short', day: 'numeric', month: 'short' }),
|
|
||||||
),
|
|
||||||
E('div', { class: 'dl-muted' }, bytes(v)),
|
|
||||||
]);
|
|
||||||
el.appendChild(col);
|
|
||||||
});
|
});
|
||||||
return el;
|
return chart.el;
|
||||||
}
|
}
|
||||||
+135
-135
@@ -1,33 +1,22 @@
|
|||||||
// Bento tiles shared by the server Overview and the person page: speed now
|
// Bento tiles shared by the server Overview and the person page: speed now
|
||||||
// (from the minute samples, or live on the Overview) and the last 30 days.
|
// (live, from the meter) and the last 30 days, plus
|
||||||
|
// a device card's 30 days. The charts are in the connection map's language
|
||||||
|
// (widgets/lines.ts, days.ts) and read point by point (shared/scrub.ts): the
|
||||||
|
// speed in the tile's own head, a day in a tooltip above it (ui/glide.ts).
|
||||||
|
|
||||||
import type { DayUsage } from '../../shared/types';
|
import type { DayUsage } from '../../shared/types';
|
||||||
import type { LiveSpeed, Rate } from '../state/meter';
|
import type { LiveSpeed } from '../state/meter';
|
||||||
import { E } from '../e';
|
import { E } from '../e';
|
||||||
import { bits, bytes, parseDay } from '../../shared/format';
|
import { bits, bytes, parseDay } from '../../shared/format';
|
||||||
import { fill, fmt, locale } from '../../shared/i18n';
|
import { fill, fmt, locale } from '../../shared/i18n';
|
||||||
import { attachTip } from '../ui/tooltip';
|
import { scrub, type Scrub } from '../../shared/scrub';
|
||||||
import { svg } from '../ui/layout';
|
import { hideGlide, showGlide } from '../ui/glide';
|
||||||
|
import { SpeedLines } from './lines';
|
||||||
|
import { DayStack, DayStrip } from './days';
|
||||||
|
import { dayTip, deviceDayTip, downUp, secondsAgo, timeOf } from './readouts';
|
||||||
|
|
||||||
const dayLabel = (day: string) => parseDay(day).toLocaleDateString(locale(), { day: 'numeric', month: 'short' });
|
const dayLabel = (day: string) => parseDay(day).toLocaleDateString(locale(), { day: 'numeric', month: 'short' });
|
||||||
|
|
||||||
/** The speed chart's box (its viewBox; CSS stretches it to the tile). */
|
|
||||||
const W = 200,
|
|
||||||
H = 40;
|
|
||||||
|
|
||||||
/** The speed chart's lines through `pts` at `xs` (0–1 across): download filled, upload over it. */
|
|
||||||
function chartPaths(pts: Rate[], xs: number[]): { area: string; down: string; up: string } {
|
|
||||||
const max = Math.max(1, ...pts.map((p) => Math.max(p[1], p[2])));
|
|
||||||
const line = (k: 1 | 2) => pts.map((p, i) => `${xs[i] * W},${H - 2 - (p[k] / max) * (H - 6)}`);
|
|
||||||
const dl = line(2),
|
|
||||||
ul = line(1);
|
|
||||||
return {
|
|
||||||
area: `M${dl.join(' L')} L${xs[xs.length - 1] * W},${H} L${xs[0] * W},${H}Z`,
|
|
||||||
down: `M${dl.join(' L')}`,
|
|
||||||
up: `M${ul.join(' L')}`,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** One of the two speeds: its arrow and label, then the value. */
|
/** One of the two speeds: its arrow and label, then the value. */
|
||||||
const speedCol = (label: string, ic: string, cls: string, val: HTMLElement) =>
|
const speedCol = (label: string, ic: string, cls: string, val: HTMLElement) =>
|
||||||
E('div', { class: 'dl-speed-col' }, [E('span', { class: 'dl-sub' }, [E('span', { class: cls }, ic), ` ${label}`]), val]);
|
E('div', { class: 'dl-speed-col' }, [E('span', { class: 'dl-sub' }, [E('span', { class: cls }, ic), ` ${label}`]), val]);
|
||||||
@@ -35,76 +24,84 @@ const speedCol = (label: string, ic: string, cls: string, val: HTMLElement) =>
|
|||||||
/** Today's traffic under the chart (`today` is [rx, tx]). */
|
/** Today's traffic under the chart (`today` is [rx, tx]). */
|
||||||
const todayParts = ([rx, tx]: [number, number]) => [
|
const todayParts = ([rx, tx]: [number, number]) => [
|
||||||
E('span', {}, fill(_('Today %s'), E('b', {}, bytes(rx + tx)))),
|
E('span', {}, fill(_('Today %s'), E('b', {}, bytes(rx + tx)))),
|
||||||
E('span', {}, [E('span', { class: 'dl-dn' }, '↓'), ` ${bytes(tx)} `, E('span', { class: 'dl-up' }, '↑'), ` ${bytes(rx)}`]),
|
E('span', {}, downUp(tx, rx)),
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throughput over the last 15 minutes plus today's total. `off`: the server is
|
* A speed tile's head, numbers and chart, read in place: the picked point's
|
||||||
* turned off, so there is no speed to show (dashes, not zeros) and no chart.
|
* speeds take the numbers' place and the span says when it was ("14:32:07 · 12 s
|
||||||
|
* ago"); letting go puts the newest back. Shared by both speed tiles.
|
||||||
*/
|
*/
|
||||||
export function speedTile(rate: Rate[], now: number, today: [number, number], off = false): HTMLElement {
|
class SpeedHead {
|
||||||
const pts = rate.slice(-15);
|
readonly span: HTMLElement;
|
||||||
const last = pts[pts.length - 1];
|
private down = E('span', { class: 'dl-speed-val' });
|
||||||
const fresh = last && now - last[0] < 180;
|
private up = E('span', { class: 'dl-speed-val' });
|
||||||
const down = fresh ? last[2] : 0,
|
readonly cols = E('div', { class: 'dl-speed-cols' }, [
|
||||||
up = fresh ? last[1] : 0;
|
speedCol(_('Download', 'speed'), '↓', 'dl-dn', this.down),
|
||||||
let chart: HTMLElement;
|
speedCol(_('Upload', 'speed'), '↑', 'dl-up', this.up),
|
||||||
if (pts.length > 1 && !off) {
|
|
||||||
const d = chartPaths(
|
|
||||||
pts,
|
|
||||||
pts.map((_x, i) => i / (pts.length - 1)),
|
|
||||||
);
|
|
||||||
chart = svg(
|
|
||||||
`<svg viewBox="0 0 ${W} ${H}" preserveAspectRatio="none" class="dl-speed-chart" aria-hidden="true">` +
|
|
||||||
`<path d="${d.area}" class="area"/><path d="${d.down}" class="line"/><path d="${d.up}" class="line up"/></svg>`,
|
|
||||||
);
|
|
||||||
attachTip(chart, () => {
|
|
||||||
const p = pts[pts.length - 1];
|
|
||||||
return [
|
|
||||||
E('div', { class: 'dl-tip-title' }, new Date(p[0] * 1000).toLocaleTimeString(locale(), { hour: '2-digit', minute: '2-digit' })),
|
|
||||||
E('div', {}, `↓ ${bits(p[2])} · ↑ ${bits(p[1])}`),
|
|
||||||
];
|
|
||||||
});
|
|
||||||
} else chart = E('div', { class: 'dl-speed-wait' }, [E('i'), off ? '' : E('span', {}, _('Collecting… 1 point a minute'))]);
|
|
||||||
const val = (v: number) => (off ? E('span', { class: 'dl-speed-val off' }, '—') : E('span', { class: 'dl-speed-val' }, bits(v)));
|
|
||||||
return E('div', { class: 'dl-bento-tile' }, [
|
|
||||||
E('div', { class: 'dl-bento-head' }, [
|
|
||||||
E('span', { class: 'dl-metric-label' }, _('Speed now')),
|
|
||||||
off ? '' : E('span', { class: 'dl-sub' }, _('last 15 min')),
|
|
||||||
]),
|
|
||||||
E('div', { class: 'dl-speed-cols' }, [
|
|
||||||
speedCol(_('Download', 'speed'), '↓', 'dl-dn', val(down)),
|
|
||||||
speedCol(_('Upload', 'speed'), '↑', 'dl-up', val(up)),
|
|
||||||
]),
|
|
||||||
chart,
|
|
||||||
E('div', { class: 'dl-speed-today' }, todayParts(today)),
|
|
||||||
]);
|
]);
|
||||||
|
readonly chart: SpeedLines;
|
||||||
|
readonly read: Scrub;
|
||||||
|
/** What the numbers say when nothing is picked: [rx, tx], or null for dashes. */
|
||||||
|
private now: [number, number] | null = null;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private spanText: string,
|
||||||
|
label: string,
|
||||||
|
) {
|
||||||
|
this.span = E('span', { class: 'dl-sub' }, spanText);
|
||||||
|
this.chart = new SpeedLines(44);
|
||||||
|
this.read = scrub(this.chart.el, this.chart, {
|
||||||
|
count: () => this.chart.points.length,
|
||||||
|
pick: () => this.paint(),
|
||||||
|
label,
|
||||||
|
say: (i) => {
|
||||||
|
const p = this.chart.points[i];
|
||||||
|
return `${timeOf(p[0])}: ↓ ${bits(p[2])}, ↑ ${bits(p[1])}`;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The numbers when nothing is picked (null: dashes, the server is off or the meter unreadable). */
|
||||||
|
set(now: [number, number] | null): void {
|
||||||
|
this.now = now;
|
||||||
|
this.paint();
|
||||||
|
}
|
||||||
|
|
||||||
|
private paint(): void {
|
||||||
|
const pts = this.chart.points;
|
||||||
|
const i = this.read.current();
|
||||||
|
const p = i >= 0 ? pts[i] : null;
|
||||||
|
const newest = pts.length ? pts[pts.length - 1][0] : 0;
|
||||||
|
this.span.textContent = p ? `${timeOf(p[0])} · ${secondsAgo(newest - p[0])}` : this.spanText;
|
||||||
|
this.span.classList.toggle('dl-picked', !!p);
|
||||||
|
this.cols.classList.toggle('dl-picked', !!p);
|
||||||
|
const v = p ? ([p[1], p[2]] as [number, number]) : this.now;
|
||||||
|
for (const [el, x] of [
|
||||||
|
[this.down, v?.[1]],
|
||||||
|
[this.up, v?.[0]],
|
||||||
|
] as const) {
|
||||||
|
el.className = `dl-speed-val${v ? '' : ' off'}`;
|
||||||
|
el.textContent = v ? bits(x!) : '—';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Speed now, live (the server Overview): speedTile's tile, its chart the last
|
* Speed now, live (the server Overview, a person's page): its chart the last
|
||||||
* 2 minutes one point a second (state/meter.ts). Built once; update() puts each
|
* 2 minutes one point a second (state/meter.ts). Built once; update() puts each
|
||||||
* second's numbers and lines in place. No tooltip: the numbers above the chart
|
* second's numbers and line in place. A second picked on the chart stays under a
|
||||||
* are its newest point already.
|
* still pointer as the line moves on, so its "ago" keeps counting.
|
||||||
*/
|
*/
|
||||||
export class LiveSpeedTile {
|
export class LiveSpeedTile {
|
||||||
private span = E('span', { class: 'dl-sub' }, _('last 2 min'));
|
private head = new SpeedHead(_('last 2 min'), _('Speed over the last 2 minutes'));
|
||||||
private down = E('span', { class: 'dl-speed-val' });
|
|
||||||
private up = E('span', { class: 'dl-speed-val' });
|
|
||||||
private chart = svg(
|
|
||||||
`<svg viewBox="0 0 ${W} ${H}" preserveAspectRatio="none" class="dl-speed-chart" aria-hidden="true">` +
|
|
||||||
`<path class="area"/><path class="line"/><path class="line up"/></svg>`,
|
|
||||||
);
|
|
||||||
private wait = E('div', { class: 'dl-speed-wait' });
|
private wait = E('div', { class: 'dl-speed-wait' });
|
||||||
/** The chart or the waiting line, whichever is in the tile. */
|
/** The chart or the waiting line, whichever is in the tile. */
|
||||||
private shown = this.wait;
|
private shown = this.wait;
|
||||||
private today = E('div', { class: 'dl-speed-today' });
|
private today = E('div', { class: 'dl-speed-today' });
|
||||||
readonly el = E('div', { class: 'dl-bento-tile' }, [
|
readonly el = E('div', { class: 'dl-bento-tile' }, [
|
||||||
E('div', { class: 'dl-bento-head' }, [E('span', { class: 'dl-metric-label' }, _('Speed now')), this.span]),
|
E('div', { class: 'dl-bento-head' }, [E('span', { class: 'dl-metric-label' }, _('Speed now')), this.head.span]),
|
||||||
E('div', { class: 'dl-speed-cols' }, [
|
this.head.cols,
|
||||||
speedCol(_('Download', 'speed'), '↓', 'dl-dn', this.down),
|
|
||||||
speedCol(_('Upload', 'speed'), '↑', 'dl-up', this.up),
|
|
||||||
]),
|
|
||||||
this.wait,
|
this.wait,
|
||||||
this.today,
|
this.today,
|
||||||
]);
|
]);
|
||||||
@@ -112,70 +109,82 @@ export class LiveSpeedTile {
|
|||||||
/**
|
/**
|
||||||
* This second's speed and today's traffic ([rx, tx]). `off`: the server is
|
* This second's speed and today's traffic ([rx, tx]). `off`: the server is
|
||||||
* turned off (dashes, no chart); a meter that cannot be read says why in
|
* turned off (dashes, no chart); a meter that cannot be read says why in
|
||||||
* the chart's place, with dashes for the speeds.
|
* the chart's place, with dashes for the speeds. While collecting, a shimmer
|
||||||
|
* runs along the dashed track.
|
||||||
*/
|
*/
|
||||||
update(s: LiveSpeed, today: [number, number], off: boolean): void {
|
update(s: LiveSpeed, today: [number, number], off: boolean): void {
|
||||||
const none = off || !!s.error;
|
const none = off || !!s.error;
|
||||||
this.span.style.display = off ? 'none' : '';
|
this.head.span.style.display = off ? 'none' : '';
|
||||||
for (const [el, v] of [
|
|
||||||
[this.down, s.tx],
|
|
||||||
[this.up, s.rx],
|
|
||||||
] as const) {
|
|
||||||
el.className = `dl-speed-val${none ? ' off' : ''}`;
|
|
||||||
el.textContent = none ? '—' : bits(v);
|
|
||||||
}
|
|
||||||
const lines = !none && s.pts.length > 1;
|
const lines = !none && s.pts.length > 1;
|
||||||
if (lines) {
|
if (lines) this.head.chart.set(s.pts, s.xs);
|
||||||
const p = chartPaths(s.pts, s.xs);
|
else {
|
||||||
const [area, down, up] = this.chart.querySelectorAll('path');
|
const words =
|
||||||
area.setAttribute('d', p.area);
|
|
||||||
down.setAttribute('d', p.down);
|
|
||||||
up.setAttribute('d', p.up);
|
|
||||||
} else
|
|
||||||
dom.content(this.wait, [
|
|
||||||
E('i'),
|
|
||||||
off || (s.early && !s.error)
|
off || (s.early && !s.error)
|
||||||
? ''
|
? ''
|
||||||
: E('span', {}, s.error ? fmt(_("Couldn't read the live speed: %s"), s.error) : _('Collecting… 1 point a second')),
|
: s.error
|
||||||
]);
|
? fmt(_("Couldn't read the live speed: %s"), s.error)
|
||||||
const want = lines ? this.chart : this.wait;
|
: _('Collecting… 1 point a second');
|
||||||
|
dom.content(this.wait, [E('i', { class: !none && !s.early ? 'run' : '' }), words ? E('span', {}, words) : '']);
|
||||||
|
}
|
||||||
|
const want = lines ? this.head.chart.el : this.wait;
|
||||||
if (want !== this.shown) {
|
if (want !== this.shown) {
|
||||||
this.shown.replaceWith(want);
|
this.shown.replaceWith(want);
|
||||||
this.shown = want;
|
this.shown = want;
|
||||||
}
|
}
|
||||||
|
this.head.set(none ? null : [s.rx, s.tx]);
|
||||||
|
if (lines) this.head.read.refresh();
|
||||||
dom.content(this.today, todayParts(today));
|
dom.content(this.today, todayParts(today));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Daily traffic for the last 30 days, today on the right. */
|
/**
|
||||||
|
* A chart of days read with the tooltip above the picked day: the pointer, a tap
|
||||||
|
* or the arrow keys pick one; the tooltip glides from day to day.
|
||||||
|
*/
|
||||||
|
function readDays(chart: DayStack | DayStrip, days: DayUsage[], label: string, tip: (i: number) => (Node | string)[]): void {
|
||||||
|
scrub(chart.el, chart, {
|
||||||
|
count: () => days.length,
|
||||||
|
pick: (i) => {
|
||||||
|
if (i < 0) return hideGlide(chart.el);
|
||||||
|
const [x, y] = chart.anchor(i);
|
||||||
|
showGlide(chart.el, x, y, tip(i));
|
||||||
|
},
|
||||||
|
label,
|
||||||
|
say: (i) => `${dayLabel(days[i].day)}: ${bytes(days[i].rx + days[i].tx)}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Daily traffic for the last 30 days, today on the right: a stacked bar a day,
|
||||||
|
* download at the base and upload on top; the head's legend is the 30 days'
|
||||||
|
* down and up in the same colours.
|
||||||
|
*/
|
||||||
export function daysTile(series: DayUsage[], note: string): HTMLElement {
|
export function daysTile(series: DayUsage[], note: string): HTMLElement {
|
||||||
const days = series.slice(-30);
|
const days = series.slice(-30);
|
||||||
const vals = days.map((d) => d.rx + d.tx);
|
const total = days.reduce((a, d) => a + d.rx + d.tx, 0);
|
||||||
const max = Math.max(1, ...vals);
|
const down = days.reduce((a, d) => a + d.tx, 0),
|
||||||
const total = vals.reduce((a, v) => a + v, 0);
|
up = days.reduce((a, d) => a + d.rx, 0);
|
||||||
const peakI = vals.reduce((a, v, i) => (v > vals[a] ? i : a), 0);
|
const today = days.length ? days[days.length - 1].day : '';
|
||||||
const bars = E(
|
let chart: HTMLElement;
|
||||||
'div',
|
if (days.length) {
|
||||||
{ class: 'dl-bento-bars' },
|
const bars = new DayStack(
|
||||||
days.map((d, i) => {
|
days.map((d) => [d.rx, d.tx]),
|
||||||
const v = vals[i];
|
64,
|
||||||
const bar = E('i', { class: i === days.length - 1 ? 'hi' : '', style: `height:${Math.max(4, (v / max) * 100)}%` });
|
);
|
||||||
// The day's column carries the tooltip: it answers above a short bar and between two bars.
|
readDays(bars, days, _('Traffic, last 30 days'), (i) => dayTip(days, i, today));
|
||||||
const col = E('span', {}, [bar]);
|
chart = bars.el;
|
||||||
attachTip(col, () => [
|
} else chart = E('p', { class: 'dl-muted' }, _('No traffic yet.'));
|
||||||
E('div', { class: 'dl-tip-title' }, i === days.length - 1 ? `${_('Today')} · ${dayLabel(d.day)}` : dayLabel(d.day)),
|
|
||||||
E('div', {}, bytes(v)),
|
|
||||||
E('div', { class: 'dl-muted dl-mono' }, `↓ ${bytes(d.tx)} ↑ ${bytes(d.rx)}`),
|
|
||||||
]);
|
|
||||||
return col;
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
return E('div', { class: 'dl-bento-tile month' }, [
|
return E('div', { class: 'dl-bento-tile month' }, [
|
||||||
E('div', { class: 'dl-bento-head' }, [
|
E('div', { class: 'dl-bento-head' }, [
|
||||||
E('span', {}, [E('span', { class: 'dl-metric-label' }, _('Last 30 days')), E('b', { class: 'dl-bento-total' }, bytes(total))]),
|
E('span', {}, [E('span', { class: 'dl-metric-label' }, _('Last 30 days')), E('b', { class: 'dl-bento-total' }, bytes(total))]),
|
||||||
vals[peakI] > 0 ? E('span', { class: 'dl-sub' }, `${fmt(_('peak %s'), bytes(vals[peakI]))} · ${dayLabel(days[peakI].day)}`) : '',
|
total > 0
|
||||||
|
? E('span', { class: 'dl-sub dl-days-key' }, [
|
||||||
|
E('span', {}, [E('i', { class: 'dn' }), `↓ ${bytes(down)}`]),
|
||||||
|
E('span', {}, [E('i', { class: 'up' }), `↑ ${bytes(up)}`]),
|
||||||
|
])
|
||||||
|
: '',
|
||||||
]),
|
]),
|
||||||
days.length ? bars : E('p', { class: 'dl-muted' }, _('No traffic yet.')),
|
chart,
|
||||||
E('div', { class: 'dl-bento-head' }, [
|
E('div', { class: 'dl-bento-head' }, [
|
||||||
E('span', { class: 'dl-sub' }, days.length ? dayLabel(days[0].day) : ''),
|
E('span', { class: 'dl-sub' }, days.length ? dayLabel(days[0].day) : ''),
|
||||||
E('span', { class: 'dl-sub' }, note),
|
E('span', { class: 'dl-sub' }, note),
|
||||||
@@ -184,23 +193,14 @@ export function daysTile(series: DayUsage[], note: string): HTMLElement {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Daily traffic of one device over the last 30 days, today on the right (person page device cards). */
|
/** Which of the last 30 days one device was used, today on the right (person page device cards). */
|
||||||
export function dayBars(series: DayUsage[]): HTMLElement {
|
export function dayBars(series: DayUsage[]): HTMLElement {
|
||||||
const days = series.slice(-30);
|
const days = series.slice(-30);
|
||||||
const vals = days.map((x) => x.rx + x.tx);
|
const strip = new DayStrip(
|
||||||
const max = Math.max(1, ...vals);
|
days.map((d) => [d.rx, d.tx]),
|
||||||
return E(
|
18,
|
||||||
'div',
|
|
||||||
{ class: 'dl-dbars' },
|
|
||||||
days.map((x, i) => {
|
|
||||||
const bar = E('i', { class: `${vals[i] ? '' : 'zero'}${i === days.length - 1 ? ' hi' : ''}` });
|
|
||||||
bar.style.height = `${Math.max(8, (vals[i] / max) * 100)}%`;
|
|
||||||
const col = E('span', {}, [bar]);
|
|
||||||
attachTip(col, () => [
|
|
||||||
E('div', { class: 'dl-tip-title' }, i === days.length - 1 ? `${_('Today')} · ${dayLabel(x.day)}` : dayLabel(x.day)),
|
|
||||||
E('div', {}, bytes(vals[i])),
|
|
||||||
]);
|
|
||||||
return col;
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
const today = days.length ? days[days.length - 1].day : '';
|
||||||
|
readDays(strip, days, _('Days this device was used'), (i) => deviceDayTip(days, i, today));
|
||||||
|
return strip.el;
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
// to add it there.
|
// to add it there.
|
||||||
|
|
||||||
import type { ClientConfig, Kind } from '../../shared/types';
|
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 { guardDeviceName } from '../../shared/name-guard';
|
||||||
import { shake } from '../../shared/shake';
|
import { shake } from '../../shared/shake';
|
||||||
import { fmt, num, plural } from '../../shared/i18n';
|
import { fmt, num, plural } from '../../shared/i18n';
|
||||||
@@ -77,15 +77,8 @@ function guessName(kind: Kind): string {
|
|||||||
return defaultName(kind);
|
return defaultName(kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Mobile is a tablet when this page is open on one (see KindPick).
|
||||||
* Phones and tablets are one choice. The device is still kept as a phone or a
|
const kindOf = (p: KindPick): Kind => (p !== 'mobile' ? p : guessKind() === 'tablet' ? 'tablet' : 'phone');
|
||||||
* 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');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What they chose so far, kept outside the view: Back from "Open on the device"
|
* 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).
|
* typed (unset while the name is still the guess).
|
||||||
*/
|
*/
|
||||||
interface Draft {
|
interface Draft {
|
||||||
pick?: Pick;
|
pick?: KindPick;
|
||||||
bypass: boolean;
|
bypass: boolean;
|
||||||
name?: string;
|
name?: string;
|
||||||
}
|
}
|
||||||
@@ -142,11 +135,11 @@ function vAdd(draft: Draft): View {
|
|||||||
const st = state()!;
|
const st = state()!;
|
||||||
const p = st.person;
|
const p = st.person;
|
||||||
// The kinds this router takes, as the four choices.
|
// 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];
|
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 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);
|
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").
|
// 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);
|
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);
|
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).
|
// 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;
|
pick = draft.pick = k;
|
||||||
tiles.forEach((t, i) => {
|
tiles.forEach((t, i) => {
|
||||||
const on = picks[i] === k;
|
const on = picks[i] === k;
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ msgstr ""
|
|||||||
msgid "%s (router time)"
|
msgid "%s (router time)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "%s a day lately"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc
|
||||||
msgid "%s already has %d device. Remove one first to lower the limit to %d."
|
msgid "%s already has %d device. Remove one first to lower the limit to %d."
|
||||||
msgid_plural "%s already has %d devices. Remove one first to lower the limit to %d."
|
msgid_plural "%s already has %d devices. Remove one first to lower the limit to %d."
|
||||||
@@ -161,6 +165,10 @@ msgstr ""
|
|||||||
msgid "%s your time"
|
msgid "%s your time"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/portal/page/devices.ts
|
||||||
|
msgid "%s, last 7 days"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
||||||
msgid "%s: <%s> is not a tag AmneziaWG apps accept: use <b 0x…> with an even number of hex digits, <r N>, <rc N> or <rd N> with N from 1 to 1000, or <t>."
|
msgid "%s: <%s> is not a tag AmneziaWG apps accept: use <b 0x…> with an even number of hex digits, <r N>, <rc N> or <rd N> with N from 1 to 1000, or <t>."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -808,7 +816,7 @@ msgstr ""
|
|||||||
msgid "Method not allowed."
|
msgid "Method not allowed."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/portal/flows/add.ts
|
#: web/src/shared/format.ts
|
||||||
msgid "Mobile"
|
msgid "Mobile"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -1412,6 +1420,10 @@ msgstr ""
|
|||||||
msgid "Your access is paused."
|
msgid "Your access is paused."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/portal/page/access.ts
|
||||||
|
msgid "Your data this month"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/portal/page/devices.ts
|
#: web/src/portal/page/devices.ts
|
||||||
msgid "Your devices"
|
msgid "Your devices"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1436,6 +1448,14 @@ msgstr ""
|
|||||||
msgid "Your network may be blocking the connection."
|
msgid "Your network may be blocking the connection."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "about %s by the reset on %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/portal/page/access.ts
|
||||||
|
msgid "about average"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/shared/format.ts
|
#: web/src/shared/format.ts
|
||||||
msgid "bit/s"
|
msgid "bit/s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1482,6 +1502,12 @@ msgstr ""
|
|||||||
msgid "ends tomorrow"
|
msgid "ends tomorrow"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "full in about %s day, %s"
|
||||||
|
msgid_plural "full in about %s days, %s"
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
#: web/src/shared/format.ts
|
#: web/src/shared/format.ts
|
||||||
msgid "just now"
|
msgid "just now"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1502,6 +1528,14 @@ msgstr ""
|
|||||||
msgid "no limit"
|
msgid "no limit"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/portal/page/devices.ts
|
||||||
|
msgid "not used"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/portal/page/access.ts
|
||||||
|
msgid "opens in %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/portal/setup.ts
|
#: web/src/portal/setup.ts
|
||||||
msgid "phone"
|
msgid "phone"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1520,6 +1554,10 @@ msgctxt "on the"
|
|||||||
msgid "router"
|
msgid "router"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/portal/page/access.ts
|
||||||
|
msgid "so far"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/portal/setup.ts
|
#: web/src/portal/setup.ts
|
||||||
msgid "tablet"
|
msgid "tablet"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ msgstr "%s (на Android: %s)"
|
|||||||
msgid "%s (router time)"
|
msgid "%s (router time)"
|
||||||
msgstr "%s (по времени роутера)"
|
msgstr "%s (по времени роутера)"
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "%s a day lately"
|
||||||
|
msgstr "%s в день за последние дни"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc
|
||||||
msgid "%s already has %d device. Remove one first to lower the limit to %d."
|
msgid "%s already has %d device. Remove one first to lower the limit to %d."
|
||||||
msgid_plural "%s already has %d devices. Remove one first to lower the limit to %d."
|
msgid_plural "%s already has %d devices. Remove one first to lower the limit to %d."
|
||||||
@@ -166,6 +170,10 @@ msgstr "%s в этом месяце"
|
|||||||
msgid "%s your time"
|
msgid "%s your time"
|
||||||
msgstr "%s по вашему времени"
|
msgstr "%s по вашему времени"
|
||||||
|
|
||||||
|
#: web/src/portal/page/devices.ts
|
||||||
|
msgid "%s, last 7 days"
|
||||||
|
msgstr "%s, последние 7 дней"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
||||||
msgid "%s: <%s> is not a tag AmneziaWG apps accept: use <b 0x…> with an even number of hex digits, <r N>, <rc N> or <rd N> with N from 1 to 1000, or <t>."
|
msgid "%s: <%s> is not a tag AmneziaWG apps accept: use <b 0x…> with an even number of hex digits, <r N>, <rc N> or <rd N> with N from 1 to 1000, or <t>."
|
||||||
msgstr "%s: тег <%s> не примут приложения AmneziaWG: используйте <b 0x…> с чётным числом шестнадцатеричных цифр, <r N>, <rc N> или <rd N> с N от 1 до 1000 либо <t>."
|
msgstr "%s: тег <%s> не примут приложения AmneziaWG: используйте <b 0x…> с чётным числом шестнадцатеричных цифр, <r N>, <rc N> или <rd N> с N от 1 до 1000 либо <t>."
|
||||||
@@ -813,7 +821,7 @@ msgstr "Мбит/с"
|
|||||||
msgid "Method not allowed."
|
msgid "Method not allowed."
|
||||||
msgstr "Метод не поддерживается."
|
msgstr "Метод не поддерживается."
|
||||||
|
|
||||||
#: web/src/portal/flows/add.ts
|
#: web/src/shared/format.ts
|
||||||
msgid "Mobile"
|
msgid "Mobile"
|
||||||
msgstr "Мобильный"
|
msgstr "Мобильный"
|
||||||
|
|
||||||
@@ -1419,6 +1427,10 @@ msgstr "Ваш доступ закончился."
|
|||||||
msgid "Your access is paused."
|
msgid "Your access is paused."
|
||||||
msgstr "Ваш доступ на паузе."
|
msgstr "Ваш доступ на паузе."
|
||||||
|
|
||||||
|
#: web/src/portal/page/access.ts
|
||||||
|
msgid "Your data this month"
|
||||||
|
msgstr "Ваш трафик за месяц"
|
||||||
|
|
||||||
#: web/src/portal/page/devices.ts
|
#: web/src/portal/page/devices.ts
|
||||||
msgid "Your devices"
|
msgid "Your devices"
|
||||||
msgstr "Ваши устройства"
|
msgstr "Ваши устройства"
|
||||||
@@ -1443,6 +1455,14 @@ msgstr "Ваша локальная сеть остаётся доступной
|
|||||||
msgid "Your network may be blocking the connection."
|
msgid "Your network may be blocking the connection."
|
||||||
msgstr "Возможно, ваша сеть блокирует подключение."
|
msgstr "Возможно, ваша сеть блокирует подключение."
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "about %s by the reset on %s"
|
||||||
|
msgstr "около %s к сбросу %s"
|
||||||
|
|
||||||
|
#: web/src/portal/page/access.ts
|
||||||
|
msgid "about average"
|
||||||
|
msgstr "около среднего"
|
||||||
|
|
||||||
#: web/src/shared/format.ts
|
#: web/src/shared/format.ts
|
||||||
msgid "bit/s"
|
msgid "bit/s"
|
||||||
msgstr "бит/с"
|
msgstr "бит/с"
|
||||||
@@ -1491,6 +1511,13 @@ msgstr "закончится сегодня"
|
|||||||
msgid "ends tomorrow"
|
msgid "ends tomorrow"
|
||||||
msgstr "закончится завтра"
|
msgstr "закончится завтра"
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "full in about %s day, %s"
|
||||||
|
msgid_plural "full in about %s days, %s"
|
||||||
|
msgstr[0] "закончится примерно через %s день, %s"
|
||||||
|
msgstr[1] "закончится примерно через %s дня, %s"
|
||||||
|
msgstr[2] "закончится примерно через %s дней, %s"
|
||||||
|
|
||||||
#: web/src/shared/format.ts
|
#: web/src/shared/format.ts
|
||||||
msgid "just now"
|
msgid "just now"
|
||||||
msgstr "только что"
|
msgstr "только что"
|
||||||
@@ -1511,6 +1538,14 @@ msgstr "никогда"
|
|||||||
msgid "no limit"
|
msgid "no limit"
|
||||||
msgstr "без лимита"
|
msgstr "без лимита"
|
||||||
|
|
||||||
|
#: web/src/portal/page/devices.ts
|
||||||
|
msgid "not used"
|
||||||
|
msgstr "без трафика"
|
||||||
|
|
||||||
|
#: web/src/portal/page/access.ts
|
||||||
|
msgid "opens in %s"
|
||||||
|
msgstr "откроется через %s"
|
||||||
|
|
||||||
#: web/src/portal/setup.ts
|
#: web/src/portal/setup.ts
|
||||||
msgid "phone"
|
msgid "phone"
|
||||||
msgstr "телефон"
|
msgstr "телефон"
|
||||||
@@ -1529,6 +1564,10 @@ msgctxt "on the"
|
|||||||
msgid "router"
|
msgid "router"
|
||||||
msgstr "роутере"
|
msgstr "роутере"
|
||||||
|
|
||||||
|
#: web/src/portal/page/access.ts
|
||||||
|
msgid "so far"
|
||||||
|
msgstr "пока"
|
||||||
|
|
||||||
#: web/src/portal/setup.ts
|
#: web/src/portal/setup.ts
|
||||||
msgid "tablet"
|
msgid "tablet"
|
||||||
msgstr "планшет"
|
msgstr "планшет"
|
||||||
|
|||||||
@@ -6,14 +6,15 @@
|
|||||||
// keeps the rows on the page and changes what they hold in place.
|
// keeps the rows on the page and changes what they hold in place.
|
||||||
|
|
||||||
import type { Pair, Person } from '../../shared/types';
|
import type { Pair, Person } from '../../shared/types';
|
||||||
import { accessLabel, byDeviceState, bytes, date, daysLeft, endsSoon, parseDay } from '../../shared/format';
|
import { accessLabel, byDeviceState, bytes, date, daysLeft, duration, endsSoon, parseDay } from '../../shared/format';
|
||||||
|
import { paceOf, paceWords, vsAverage } from '../../shared/pace';
|
||||||
import { fill, fmt, locale, num, plural } from '../../shared/i18n';
|
import { fill, fmt, locale, num, plural } from '../../shared/i18n';
|
||||||
import { h, ic, markup } from '../dom';
|
import { h, ic, markup } from '../dom';
|
||||||
import { calendar, clockOf, hoursFor, minuteAt, monthOf, stretches } from '../days';
|
import { calendar, clockOf, hoursFor, minuteAt, monthOf, stretches } from '../days';
|
||||||
import { SMOOTH, play } from '../motion';
|
import { SMOOTH, play } from '../motion';
|
||||||
import { now, today, type State } from '../state';
|
import { now, today, type State } from '../state';
|
||||||
import { accordion, regrow, type Accordion } from '../ui/accordion';
|
import { accordion, regrow, type Accordion } from '../ui/accordion';
|
||||||
import { bars, upDown } from '../ui/bars';
|
import { bars, readBars, upDown } from '../ui/bars';
|
||||||
import { copy } from '../ui/feedback';
|
import { copy } from '../ui/feedback';
|
||||||
import { glass } from '../ui/glass';
|
import { glass } from '../ui/glass';
|
||||||
import { morphChanged, morphInto, setText, textOf, textsOf } from '../ui/morph';
|
import { morphChanged, morphInto, setText, textOf, textsOf } from '../ui/morph';
|
||||||
@@ -107,17 +108,21 @@ function month(p: Person, used: number, pct: number): HTMLElement {
|
|||||||
const read = upDown('m');
|
const read = upDown('m');
|
||||||
const left = p.quota_limit ? fmt(_('%s left'), bytes(Math.max(0, p.quota_limit - used))) : _('No limit');
|
const left = p.quota_limit ? fmt(_('%s left'), bytes(Math.max(0, p.quota_limit - used))) : _('No limit');
|
||||||
const side = h('span', { class: 'num', 'data-t': 'm-left' }, left);
|
const side = h('span', { class: 'num', 'data-t': 'm-left' }, left);
|
||||||
const say = (v: Pair, d?: number) => {
|
const totals = series.map(([rx, tx]) => rx + tx);
|
||||||
read.set(v);
|
// A picked day says its date and how it compares with the month's other days ("21 Oct · +62%").
|
||||||
setText(side, d ? short(d) : left);
|
const against = (i: number) => {
|
||||||
side.classList.toggle('bad-t', !d && p.state === 'quota');
|
if (i === totals.length - 1) return _('so far');
|
||||||
|
const v = vsAverage(totals, i);
|
||||||
|
return Math.abs(v) < 5 ? _('about average') : v > 0 ? `+${num(v)}%` : `−${num(-v)}%`;
|
||||||
};
|
};
|
||||||
say(p.month);
|
const say = (i: number) => {
|
||||||
|
read.set(i >= 0 ? series[i] : p.month);
|
||||||
|
setText(side, i >= 0 ? `${short(i + 1)} · ${against(i)}` : left);
|
||||||
|
side.classList.toggle('bad-t', i < 0 && p.state === 'quota');
|
||||||
|
};
|
||||||
|
say(-1);
|
||||||
const chart = bars(series, 'bars-month', 64, days - day);
|
const chart = bars(series, 'bars-month', 64, days - day);
|
||||||
chart.cols.forEach((col, i) => {
|
readBars(chart, _('Your data this month'), say);
|
||||||
col.addEventListener('pointerenter', () => say(series[i], i + 1));
|
|
||||||
col.addEventListener('pointerleave', () => say(p.month));
|
|
||||||
});
|
|
||||||
// "Today" under its bar; the month's ends step aside when it comes close.
|
// "Today" under its bar; the month's ends step aside when it comes close.
|
||||||
const td = h('span', { class: 'td' }, _('Today'));
|
const td = h('span', { class: 'td' }, _('Today'));
|
||||||
td.style.left = pc(day - 0.5, days);
|
td.style.left = pc(day - 0.5, days);
|
||||||
@@ -128,7 +133,22 @@ function month(p: Person, used: number, pct: number): HTMLElement {
|
|||||||
td,
|
td,
|
||||||
h('span', { class: day >= days - 3 ? 'hide' : '' }, short(days)),
|
h('span', { class: day >= days - 3 ? 'hide' : '' }, short(days)),
|
||||||
);
|
);
|
||||||
return h('div', { class: 'month' }, chart.el, axis, h('div', { class: 'month-read' }, read.el, side), p.quota_limit ? meter(pct) : null);
|
// With a limit not yet reached: the pace lately (the devices' last 7 days, so the month's first days have one
|
||||||
|
// too) and when the limit fills at it, orange within a week.
|
||||||
|
const pace = paceOf(
|
||||||
|
Array.from({ length: 7 }, (_x, k) => p.devices.reduce((a, d) => a + (d.spark[k]?.[0] ?? 0) + (d.spark[k]?.[1] ?? 0), 0)),
|
||||||
|
);
|
||||||
|
const words = p.quota_limit && used < p.quota_limit ? paceWords(used, p.quota_limit, pace, p.quota_period === 'month', today()) : '';
|
||||||
|
const soon = pace > 0 && (p.quota_limit - used) / pace <= 7;
|
||||||
|
return h(
|
||||||
|
'div',
|
||||||
|
{ class: 'month' },
|
||||||
|
chart.el,
|
||||||
|
axis,
|
||||||
|
h('div', { class: 'month-read' }, read.el, side),
|
||||||
|
p.quota_limit ? meter(pct) : null,
|
||||||
|
words ? h('div', { class: `month-pace${soon ? ' warn-t' : ''}` }, words) : null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The days left as a number over a calendar of the weeks to the end (the last day ringed). */
|
/** The days left as a number over a calendar of the weeks to the end (the last day ringed). */
|
||||||
@@ -190,6 +210,10 @@ function hoursBar(hours: string, tzOffset: number | undefined): HTMLElement | nu
|
|||||||
const mark = h('span', { class: `hours-now${inside ? '' : ' out'}`, title: fmt(_('Now, %s'), clockOf(at)) });
|
const mark = h('span', { class: `hours-now${inside ? '' : ' out'}`, title: fmt(_('Now, %s'), clockOf(at)) });
|
||||||
mark.style.left = pc(at, 1440);
|
mark.style.left = pc(at, 1440);
|
||||||
bar.appendChild(mark);
|
bar.appendChild(mark);
|
||||||
|
// How long the window still runs, or until it opens (a stretch may run past midnight: the next starts are a day on).
|
||||||
|
const end = segs.find(([a, b]) => at >= a && at < b)?.[1];
|
||||||
|
const next = Math.min(...segs.map(([a]) => (a > at ? a : a + 1440)));
|
||||||
|
const runs = inside ? fmt(_('%s left'), duration((end! - at) * 60)) : fmt(_('opens in %s'), duration((next - at) * 60));
|
||||||
return h(
|
return h(
|
||||||
'div',
|
'div',
|
||||||
{ class: 'hours' },
|
{ class: 'hours' },
|
||||||
@@ -205,6 +229,7 @@ function hoursBar(hours: string, tzOffset: number | undefined): HTMLElement | nu
|
|||||||
{ class: 'hours-axis' },
|
{ class: 'hours-axis' },
|
||||||
['00', '06', '12', '18', '24'].map((x) => h('span', {}, x)),
|
['00', '06', '12', '18', '24'].map((x) => h('span', {}, x)),
|
||||||
),
|
),
|
||||||
|
h('div', { class: `hours-left${inside ? '' : ' warn-t'}` }, runs),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { fmt, locale, num, plural } from '../../shared/i18n';
|
|||||||
import { h, ic } from '../dom';
|
import { h, ic } from '../dom';
|
||||||
import { BOUNCY, EASE_IN, EASE_OUT, SMOOTH, calm, play } from '../motion';
|
import { BOUNCY, EASE_IN, EASE_OUT, SMOOTH, calm, play } from '../motion';
|
||||||
import { now, today, type RepaintOpts, type State } from '../state';
|
import { now, today, type RepaintOpts, type State } from '../state';
|
||||||
import { bars, sumDays, upDown } from '../ui/bars';
|
import { bars, readBars, sumDays, upDown } from '../ui/bars';
|
||||||
import { copy } from '../ui/feedback';
|
import { copy } from '../ui/feedback';
|
||||||
import { glass } from '../ui/glass';
|
import { glass } from '../ui/glass';
|
||||||
import { openMenu, type MenuItem } from '../ui/menu';
|
import { openMenu, type MenuItem } from '../ui/menu';
|
||||||
@@ -129,17 +129,17 @@ function usage(d: Device): HTMLElement {
|
|||||||
const val = upDown(d.id);
|
const val = upDown(d.id);
|
||||||
val.set(week);
|
val.set(week);
|
||||||
const chart = bars(d.spark, 'bars-week', 34);
|
const chart = bars(d.spark, 'bars-week', 34);
|
||||||
chart.cols.forEach((col, i) => {
|
// What the pointer, a tap or the keys pick changes at once: no morph while it moves. A day with nothing says so.
|
||||||
const back = d.spark.length - 1 - i;
|
readBars(chart, fmt(_('%s, last 7 days'), d.name), (i) => {
|
||||||
// What the pointer reads off the bars changes at once: no morph while it moves.
|
if (i < 0) {
|
||||||
col.addEventListener('pointerenter', () => {
|
|
||||||
setText(lbl, dayName(back));
|
|
||||||
val.set(d.spark[i]);
|
|
||||||
});
|
|
||||||
col.addEventListener('pointerleave', () => {
|
|
||||||
setText(lbl, _('Last 7 days'));
|
setText(lbl, _('Last 7 days'));
|
||||||
val.set(week);
|
val.set(week);
|
||||||
});
|
return;
|
||||||
|
}
|
||||||
|
const [rx, tx] = d.spark[i];
|
||||||
|
const name = dayName(d.spark.length - 1 - i);
|
||||||
|
setText(lbl, rx || tx ? name : `${name} · ${_('not used')}`);
|
||||||
|
val.set(d.spark[i]);
|
||||||
});
|
});
|
||||||
return h('div', { class: 'dev-use' }, h('div', { class: 'use-txt' }, lbl, h('span', { class: 'use-val' }, val.el)), chart.el);
|
return h('div', { class: 'dev-use' }, h('div', { class: 'use-txt' }, lbl, h('span', { class: 'use-val' }, val.el)), chart.el);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,6 +158,11 @@
|
|||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
letter-spacing: -0.02em;
|
letter-spacing: -0.02em;
|
||||||
}
|
}
|
||||||
|
.month-pace {
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 16px;
|
||||||
|
color: var(--text-2);
|
||||||
|
}
|
||||||
.meter {
|
.meter {
|
||||||
height: 6px;
|
height: 6px;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
@@ -312,6 +317,15 @@
|
|||||||
.hours-now.out {
|
.hours-now.out {
|
||||||
background: var(--warn);
|
background: var(--warn);
|
||||||
}
|
}
|
||||||
|
.hours-left {
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 16px;
|
||||||
|
color: var(--text-2);
|
||||||
|
}
|
||||||
|
.month-pace.warn-t,
|
||||||
|
.hours-left.warn-t {
|
||||||
|
color: var(--warn);
|
||||||
|
}
|
||||||
.hours-axis {
|
.hours-axis {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|||||||
@@ -65,15 +65,24 @@
|
|||||||
.bars .today .up {
|
.bars .today .up {
|
||||||
background: color-mix(in srgb, var(--accent) 45%, transparent);
|
background: color-mix(in srgb, var(--accent) 45%, transparent);
|
||||||
}
|
}
|
||||||
.bars .col:not(.future):hover .dn {
|
/* A day under the pointer, or picked by a tap or the keys (.on, ui/bars.ts readBars). */
|
||||||
|
.bars .col:not(.future):is(:hover, .on) .dn {
|
||||||
background: var(--text-2);
|
background: var(--text-2);
|
||||||
}
|
}
|
||||||
.bars .col:not(.future):hover .up {
|
.bars .col:not(.future):is(:hover, .on) .up {
|
||||||
background: color-mix(in srgb, var(--text-2) 50%, transparent);
|
background: color-mix(in srgb, var(--text-2) 50%, transparent);
|
||||||
}
|
}
|
||||||
.bars .today:hover .dn {
|
.bars .today:is(:hover, .on) .dn {
|
||||||
background: color-mix(in srgb, var(--accent) 75%, var(--text));
|
background: color-mix(in srgb, var(--accent) 75%, var(--text));
|
||||||
}
|
}
|
||||||
|
/* Read with the keys: focus shows as a ring around the bars; the pointer keeps its arrow. */
|
||||||
|
.bars.scrub {
|
||||||
|
outline: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
.bars.scrub:focus-visible {
|
||||||
|
box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent);
|
||||||
|
}
|
||||||
.bars .future i {
|
.bars .future i {
|
||||||
height: 3px;
|
height: 3px;
|
||||||
background: color-mix(in srgb, var(--bar) 45%, transparent);
|
background: color-mix(in srgb, var(--bar) 45%, transparent);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import type { Pair } from '../../shared/types';
|
import type { Pair } from '../../shared/types';
|
||||||
import { bytes } from '../../shared/format';
|
import { bytes } from '../../shared/format';
|
||||||
|
import { scrub } from '../../shared/scrub';
|
||||||
import { h, ic } from '../dom';
|
import { h, ic } from '../dom';
|
||||||
import { setText } from './morph';
|
import { setText } from './morph';
|
||||||
|
|
||||||
@@ -57,6 +58,27 @@ export function bars(days: Pair[], cls: string, height: number, future = 0): Bar
|
|||||||
return { el, cols };
|
return { el, cols };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read the bars a day at a time (shared/scrub.ts): the pointer, a tap that stays
|
||||||
|
* until a tap elsewhere, ← → with the chart focused. The picked column looks as
|
||||||
|
* under the pointer (.on); `pick` gets its index, -1 when let go.
|
||||||
|
*/
|
||||||
|
export function readBars(b: Bars, label: string, pick: (i: number) => void): void {
|
||||||
|
b.el.removeAttribute('aria-hidden');
|
||||||
|
scrub(
|
||||||
|
b.el,
|
||||||
|
{
|
||||||
|
indexAt: (x) =>
|
||||||
|
b.cols.findIndex((c) => {
|
||||||
|
const r = c.getBoundingClientRect();
|
||||||
|
return x >= r.left && x < r.right;
|
||||||
|
}),
|
||||||
|
mark: (i) => b.cols.forEach((c, k) => c.classList.toggle('on', k === i)),
|
||||||
|
},
|
||||||
|
{ count: () => b.cols.length, pick, label },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export interface UpDown {
|
export interface UpDown {
|
||||||
el: HTMLElement;
|
el: HTMLElement;
|
||||||
/** Show these, at once (a repaint morphs them by their keys). */
|
/** Show these, at once (a repaint morphs them by their keys). */
|
||||||
|
|||||||
@@ -222,13 +222,23 @@ export function defaultName(k: Kind): string {
|
|||||||
return k === 'other' ? _('Device') : kindLabel(k);
|
return k === 'other' ? _('Device') : kindLabel(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** In picker order. */
|
|
||||||
export const KINDS: Kind[] = ['computer', 'phone', 'tablet', 'router', 'other'];
|
|
||||||
|
|
||||||
export function kindLabel(k: Kind): string {
|
export function kindLabel(k: Kind): string {
|
||||||
return { computer: _('PC'), phone: _('Phone'), tablet: _('Tablet'), router: _('Router'), other: _('Other') }[k];
|
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 {
|
export function stateLabel(s: PersonState): string {
|
||||||
return {
|
return {
|
||||||
active: _('Active'),
|
active: _('Active'),
|
||||||
|
|||||||
@@ -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"/>',
|
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"/>',
|
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"/>',
|
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"/>',
|
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:
|
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"/>',
|
'<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"/>',
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
// How fast someone uses data lately, and where that leads against their limit,
|
||||||
|
// on the router's calendar; and that in one line of words, which the admin's
|
||||||
|
// meter tooltips and the portal's data row show.
|
||||||
|
|
||||||
|
import { addDays, addMonthsClamped, bytes, dayDiff, parseDay } from './format';
|
||||||
|
import { fmt, locale, num } from './i18n';
|
||||||
|
|
||||||
|
/** Days the pace looks back over. */
|
||||||
|
const SPAN = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bytes a day lately: the average of the complete days before today (today is
|
||||||
|
* still running), the last 7 at most. `days` are totals, oldest first, today last.
|
||||||
|
*/
|
||||||
|
export function paceOf(days: number[]): number {
|
||||||
|
const done = days.slice(Math.max(0, days.length - 1 - SPAN), -1);
|
||||||
|
return done.length ? done.reduce((a, v) => a + v, 0) / done.length : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A day against the average of the complete days (today left out): +62 is 62% over it. */
|
||||||
|
export function vsAverage(days: number[], i: number): number {
|
||||||
|
const done = days.slice(0, -1);
|
||||||
|
const avg = done.reduce((a, v) => a + v, 0) / Math.max(1, done.length);
|
||||||
|
return avg > 0 ? Math.round(((days[i] - avg) / avg) * 100) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Forecast =
|
||||||
|
/** At this pace the limit fills in `days`, on `on`. */
|
||||||
|
| { kind: 'fills'; days: number; on: string }
|
||||||
|
/** A monthly limit that holds until the reset on `on`, with about `reach` used by then. */
|
||||||
|
| { kind: 'holds'; on: string; reach: number }
|
||||||
|
/** Nothing to say: no limit, already full, or no use lately. */
|
||||||
|
| { kind: 'none' };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where the pace leads: when the limit fills, or (monthly) what is used by the
|
||||||
|
* reset on the 1st when that comes first. `today` is the router's day.
|
||||||
|
*/
|
||||||
|
export function forecast(used: number, limit: number, pace: number, monthly: boolean, today: string): Forecast {
|
||||||
|
if (!limit || used >= limit || pace <= 0) return { kind: 'none' };
|
||||||
|
const days = Math.ceil((limit - used) / pace);
|
||||||
|
const reset = addMonthsClamped(`${today.slice(0, 8)}01`, 1);
|
||||||
|
const on = addDays(today, days);
|
||||||
|
if (monthly && dayDiff(on, reset) >= 0) return { kind: 'holds', on: reset, reach: used + pace * dayDiff(reset, today) };
|
||||||
|
return { kind: 'fills', days, on };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Where a week at this pace takes them, as a share of the limit (0..100). */
|
||||||
|
export function weekAhead(used: number, limit: number, pace: number): number {
|
||||||
|
return limit ? Math.min(100, ((used + SPAN * pace) / limit) * 100) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The pace in words: "2.1 GB a day lately · full in about 2 days, 4 Nov", or for a
|
||||||
|
* monthly limit the reset comes first: "… · about 36 GB by the reset on 1 Dec".
|
||||||
|
* Empty when there was no use lately.
|
||||||
|
*/
|
||||||
|
export function paceWords(used: number, limit: number, pace: number, monthly: boolean, today: string): string {
|
||||||
|
if (pace <= 0) return '';
|
||||||
|
const base = fmt(_('%s a day lately'), bytes(pace));
|
||||||
|
const f = forecast(used, limit, pace, monthly, today);
|
||||||
|
const on = (d: string) => parseDay(d).toLocaleDateString(locale(), { day: 'numeric', month: 'short' });
|
||||||
|
if (f.kind === 'fills')
|
||||||
|
return `${base} · ${fmt(N_(f.days, 'full in about %s day, %s', 'full in about %s days, %s'), num(f.days), on(f.on))}`;
|
||||||
|
if (f.kind === 'holds') return `${base} · ${fmt(_('about %s by the reset on %s'), bytes(f.reach), on(f.on))}`;
|
||||||
|
return base;
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
// Reading a chart point by point, the same way in the admin UI and the portal:
|
||||||
|
// the pointer picks the point under it, a tap keeps one until a tap elsewhere,
|
||||||
|
// and with the chart focused ← → Home End walk the points (Esc lets go). The
|
||||||
|
// chart marks the picked point; what its numbers are and where they show (the
|
||||||
|
// tile's own head, a tooltip) is the caller's. No drawing and no text here.
|
||||||
|
|
||||||
|
/** A chart that can be read: the point under a pointer, and marking one (-1: none). */
|
||||||
|
export interface Readable {
|
||||||
|
indexAt(clientX: number): number;
|
||||||
|
mark(i: number): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScrubOpts {
|
||||||
|
/** How many points; the last is the newest, where the keys start. */
|
||||||
|
count: () => number;
|
||||||
|
/** Point i was picked (-1: let go). */
|
||||||
|
pick: (i: number) => void;
|
||||||
|
/** The chart's name for assistive technology. */
|
||||||
|
label: string;
|
||||||
|
/** A point in words, read out as the keys move. */
|
||||||
|
say?: (i: number) => string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Scrub {
|
||||||
|
/** The points moved under a still pointer (a live chart's new second): pick what is under it now. */
|
||||||
|
refresh(): void;
|
||||||
|
/** The picked point, or -1. */
|
||||||
|
current(): number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Wire `host` (the chart's element, or its box) for reading. */
|
||||||
|
export function scrub(host: HTMLElement, chart: Readable, o: ScrubOpts): Scrub {
|
||||||
|
let cur = -1;
|
||||||
|
/** Where a mouse rests over the chart (null: it is not over it), so a moving chart can re-pick under it. */
|
||||||
|
let restX: number | null = null;
|
||||||
|
const words = document.createElement('span');
|
||||||
|
words.className = 'offscreen';
|
||||||
|
words.setAttribute('aria-live', 'polite');
|
||||||
|
host.append(words);
|
||||||
|
host.classList.add('scrub');
|
||||||
|
host.tabIndex = 0;
|
||||||
|
host.setAttribute('role', 'group');
|
||||||
|
host.setAttribute('aria-label', o.label);
|
||||||
|
|
||||||
|
const pick = (i: number, force = false) => {
|
||||||
|
if (i === cur && !force) return;
|
||||||
|
const was = cur;
|
||||||
|
cur = i;
|
||||||
|
chart.mark(i);
|
||||||
|
o.pick(i);
|
||||||
|
if (i >= 0 && i !== was && o.say) words.textContent = o.say(i);
|
||||||
|
// A tap's pick lasts until a tap elsewhere, a scroll or leaving the page section.
|
||||||
|
if (i >= 0 && restX == null) document.addEventListener('pointerdown', away, true);
|
||||||
|
else document.removeEventListener('pointerdown', away, true);
|
||||||
|
};
|
||||||
|
const away = (ev: PointerEvent) => {
|
||||||
|
if (!host.contains(ev.target as Node)) pick(-1);
|
||||||
|
};
|
||||||
|
|
||||||
|
host.addEventListener('pointermove', (ev) => {
|
||||||
|
if (ev.pointerType !== 'mouse') return;
|
||||||
|
restX = ev.clientX;
|
||||||
|
pick(chart.indexAt(ev.clientX));
|
||||||
|
});
|
||||||
|
host.addEventListener('pointerleave', (ev) => {
|
||||||
|
if (ev.pointerType !== 'mouse') return;
|
||||||
|
restX = null;
|
||||||
|
pick(-1);
|
||||||
|
});
|
||||||
|
// No hover on a touch screen: a tap picks, a tap on the same point lets go.
|
||||||
|
host.addEventListener('pointerup', (ev) => {
|
||||||
|
if (ev.pointerType === 'mouse') return;
|
||||||
|
const i = chart.indexAt(ev.clientX);
|
||||||
|
pick(i === cur ? -1 : i);
|
||||||
|
});
|
||||||
|
host.addEventListener('keydown', (ev) => {
|
||||||
|
const n = o.count();
|
||||||
|
if (!n) return;
|
||||||
|
const from = cur < 0 ? n : cur;
|
||||||
|
const to =
|
||||||
|
ev.key === 'ArrowLeft'
|
||||||
|
? Math.max(0, from - 1)
|
||||||
|
: ev.key === 'ArrowRight'
|
||||||
|
? Math.min(n - 1, cur < 0 ? n - 1 : from + 1)
|
||||||
|
: ev.key === 'Home'
|
||||||
|
? 0
|
||||||
|
: ev.key === 'End'
|
||||||
|
? n - 1
|
||||||
|
: ev.key === 'Escape'
|
||||||
|
? -1
|
||||||
|
: null;
|
||||||
|
if (to == null) return;
|
||||||
|
ev.preventDefault();
|
||||||
|
restX = null;
|
||||||
|
pick(to);
|
||||||
|
});
|
||||||
|
host.addEventListener('blur', () => restX == null && pick(-1));
|
||||||
|
|
||||||
|
return {
|
||||||
|
refresh() {
|
||||||
|
if (restX != null) pick(chart.indexAt(restX), true);
|
||||||
|
else if (cur >= 0) pick(Math.min(cur, o.count() - 1), true);
|
||||||
|
},
|
||||||
|
current: () => cur,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -10,11 +10,6 @@ const days: Pair[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
describe('mirrored bars', () => {
|
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', () => {
|
it('fits both peaks on one scale, the tighter one filling its half', () => {
|
||||||
const m = mirror(days, 64);
|
const m = mirror(days, 64);
|
||||||
expect(120 * m.scale).toBeLessThanOrEqual(m.top);
|
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);
|
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', () => {
|
it('draws a month without traffic', () => {
|
||||||
const m = mirror([[0, 0]], 34);
|
const m = mirror([[0, 0]], 34);
|
||||||
expect(Number.isFinite(m.scale)).toBe(true);
|
expect(Number.isFinite(m.scale)).toBe(true);
|
||||||
|
|||||||
+3
-25
@@ -11,22 +11,9 @@ const run = (x: number, t: number, frames = 1): number[] => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
describe('caret glide', () => {
|
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', () => {
|
it('settles exactly on its target in either direction', () => {
|
||||||
const xs = run(0, 100);
|
expect(run(0, 100).at(-1)).toBe(100);
|
||||||
expect(xs[7]).toBeLessThan(90);
|
expect(run(100, 0).at(-1)).toBe(0);
|
||||||
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('takes a late frame as up to 2.5 frames, and is simply there after a long gap', () => {
|
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 }), 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 });
|
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']);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
@@ -56,6 +56,33 @@ describe('events', () => {
|
|||||||
expect(isProblem({ ts: 1, sys: { ts: 1, src: 'awg', level: 'down', msg: '' } })).toBe(true);
|
expect(isProblem({ ts: 1, sys: { ts: 1, src: 'awg', level: 'down', msg: '' } })).toBe(true);
|
||||||
expect(isProblem({ ts: 1, ev: ev({ type: 'connect' }) })).toBe(false);
|
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', () => {
|
it('says what happened', () => {
|
||||||
const st = { people };
|
const st = { people };
|
||||||
expect(text(eventText(st, ev({ person: 'p1', device: 'd1', detail: '1.2.3.4', where: 'Berlin' })))).toBe(
|
expect(text(eventText(st, ev({ person: 'p1', device: 'd1', detail: '1.2.3.4', where: 'Berlin' })))).toBe(
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import {
|
|||||||
date,
|
date,
|
||||||
dayDiff,
|
dayDiff,
|
||||||
daysLeft,
|
daysLeft,
|
||||||
defaultName,
|
|
||||||
DEVICE_NAME_MAX,
|
|
||||||
deviceNameFits,
|
deviceNameFits,
|
||||||
endsIn,
|
endsIn,
|
||||||
endsSoon,
|
endsSoon,
|
||||||
@@ -14,7 +12,6 @@ import {
|
|||||||
fmtDay,
|
fmtDay,
|
||||||
kb,
|
kb,
|
||||||
shiftDay,
|
shiftDay,
|
||||||
todayOf,
|
|
||||||
validDeviceName,
|
validDeviceName,
|
||||||
} from '../src/shared/format';
|
} from '../src/shared/format';
|
||||||
import { plural } from '../src/shared/i18n';
|
import { plural } from '../src/shared/i18n';
|
||||||
@@ -62,9 +59,7 @@ describe('router days', () => {
|
|||||||
expect(endsIn(2)).toBe('ends tomorrow');
|
expect(endsIn(2)).toBe('ends tomorrow');
|
||||||
expect(endsIn(7)).toBe('ends in 7 days');
|
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', () => {
|
it('shows a router day as that day in any time zone', () => {
|
||||||
expect(fmtDay('2026-10-01')).toBe('1 Oct 2026');
|
expect(fmtDay('2026-10-01')).toBe('1 Oct 2026');
|
||||||
expect(date('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', () => {
|
describe('device names', () => {
|
||||||
it('take letters of any language, digits, spaces and - _ . up to the limit', () => {
|
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('Kitchen iPad')).toBe(true);
|
||||||
expect(validDeviceName('my-pc_2.home')).toBe(true);
|
expect(validDeviceName('my-pc_2.home')).toBe(true);
|
||||||
expect(validDeviceName('Мой ноутбук')).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(fitName('Living room TV ab xy', ' 2')).toBe('Living room TV ab 2');
|
||||||
expect(validDeviceName(fitName('Redmi Note 13 Pro+ 5G', ' 12'))).toBe(true);
|
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
@@ -2,19 +2,11 @@ import { describe, expect, it } from 'vitest';
|
|||||||
import { arc, cityPlaces, devicePlaces, separate, type MapData } from '../src/admin/map';
|
import { arc, cityPlaces, devicePlaces, separate, type MapData } from '../src/admin/map';
|
||||||
|
|
||||||
describe('arc (mapcn buildArcCoordinates)', () => {
|
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]);
|
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[0]).toEqual([-0.1276, 51.5074]);
|
||||||
expect(pts[64][0]).toBeCloseTo(-74.006);
|
expect(pts.at(-1)![0]).toBeCloseTo(-74.006);
|
||||||
expect(pts[64][1]).toBeCloseTo(40.7128);
|
expect(pts.at(-1)![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);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('takes the short way across the antimeridian', () => {
|
it('takes the short way across the antimeridian', () => {
|
||||||
|
|||||||
@@ -114,3 +114,25 @@ describe('live meter', () => {
|
|||||||
expect(m.speed('a', 4000).error).toBeNull();
|
expect(m.speed('a', 4000).error).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('live meter, a person', () => {
|
||||||
|
it('adds up their devices; a device left out of a second moved nothing', () => {
|
||||||
|
const m = new LiveMeter();
|
||||||
|
const pts: MeterPoint[] = [
|
||||||
|
{ ts: 1001, servers: { a: [30, 60] }, dev: { d1: [10, 20], d2: [20, 40] } },
|
||||||
|
{ ts: 1002, servers: { a: [5, 5] }, dev: { d3: [5, 5] } },
|
||||||
|
// Server a was not read this second: no point for anyone on it.
|
||||||
|
{ ts: 1003, servers: {} },
|
||||||
|
{ ts: 1004, servers: { a: [7, 9] }, dev: { d1: [7, 9] } },
|
||||||
|
];
|
||||||
|
m.take({ meter: meter(pts) }, 0);
|
||||||
|
const s = m.speed('a', 0, ['d1', 'd2']);
|
||||||
|
expect(s.pts).toEqual([
|
||||||
|
[1001, 30, 60],
|
||||||
|
[1002, 0, 0],
|
||||||
|
[1004, 7, 9],
|
||||||
|
]);
|
||||||
|
expect(s).toMatchObject({ rx: 7, tx: 9 });
|
||||||
|
expect(m.speed('a', 0, []).pts.map((p) => p[1])).toEqual([0, 0, 0]);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -35,13 +35,4 @@ describe('motion', () => {
|
|||||||
expect(s.at(s.duration)).toBe(1);
|
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);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { forecast, paceOf, vsAverage, weekAhead } from '../src/shared/pace';
|
||||||
|
|
||||||
|
const GB = 1024 ** 3;
|
||||||
|
|
||||||
|
describe('pace', () => {
|
||||||
|
it('averages the complete days before today, the last 7 at most', () => {
|
||||||
|
// Ten days, today (999) left out: the 7 before it are 1..7.
|
||||||
|
expect(paceOf([50, 50, 1, 2, 3, 4, 5, 6, 7, 999])).toBe(4);
|
||||||
|
expect(paceOf([3, 5, 100])).toBe(4);
|
||||||
|
expect(paceOf([100])).toBe(0);
|
||||||
|
expect(paceOf([])).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('compares a day with the average, today left out', () => {
|
||||||
|
expect(vsAverage([10, 10, 10, 20, 0], 3)).toBe(60);
|
||||||
|
expect(vsAverage([10, 30, 5], 0)).toBe(-50);
|
||||||
|
expect(vsAverage([0, 0, 5], 2)).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('says when a limit fills at this pace', () => {
|
||||||
|
expect(forecast(46 * GB, 50 * GB, 2 * GB, false, '2026-11-02')).toEqual({ kind: 'fills', days: 2, on: '2026-11-04' });
|
||||||
|
// A monthly limit filling before the 1st is the same.
|
||||||
|
expect(forecast(40 * GB, 50 * GB, 1 * GB, true, '2026-11-15')).toEqual({ kind: 'fills', days: 10, on: '2026-11-25' });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('says what a monthly limit reaches by the reset when that comes first', () => {
|
||||||
|
const f = forecast(12 * GB, 100 * GB, 1 * GB, true, '2026-11-02');
|
||||||
|
expect(f).toEqual({ kind: 'holds', on: '2026-12-01', reach: 41 * GB });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has nothing to say without a limit, when full or idle', () => {
|
||||||
|
expect(forecast(5, 0, 1, true, '2026-11-02').kind).toBe('none');
|
||||||
|
expect(forecast(10, 10, 1, true, '2026-11-02').kind).toBe('none');
|
||||||
|
expect(forecast(1, 10, 0, true, '2026-11-02').kind).toBe('none');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('takes a week ahead, capped at the limit', () => {
|
||||||
|
expect(weekAhead(10, 100, 1)).toBe(17);
|
||||||
|
expect(weekAhead(90, 100, 5)).toBe(100);
|
||||||
|
expect(weekAhead(5, 0, 1)).toBe(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,21 +1,5 @@
|
|||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
import {
|
import { moment, msAt, placeKey, replayStays, shares, stays, stretches, ticks, timeline, visits } from '../src/admin/places/model';
|
||||||
BAND,
|
|
||||||
FLAT,
|
|
||||||
arrived,
|
|
||||||
bandMiddle,
|
|
||||||
moment,
|
|
||||||
msAt,
|
|
||||||
placeKey,
|
|
||||||
replayStays,
|
|
||||||
shares,
|
|
||||||
shimmerOpacity,
|
|
||||||
stays,
|
|
||||||
stretches,
|
|
||||||
ticks,
|
|
||||||
timeline,
|
|
||||||
visits,
|
|
||||||
} from '../src/admin/places/model';
|
|
||||||
import type { GeoPoint, LogEvent } from '../src/shared/types';
|
import type { GeoPoint, LogEvent } from '../src/shared/types';
|
||||||
|
|
||||||
const D = 'd_1';
|
const D = 'd_1';
|
||||||
@@ -148,16 +132,6 @@ describe('replay', () => {
|
|||||||
const ms = msAt(st, steps, 38000);
|
const ms = msAt(st, steps, 38000);
|
||||||
expect(moment(st, steps, ms).t).toBeCloseTo(38000, -1);
|
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', () => {
|
describe('ticks', () => {
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { smooth } from '../src/admin/ui/plot';
|
||||||
|
|
||||||
|
/** Every y a path's points and control points reach. */
|
||||||
|
const ys = (d: string) => [...d.matchAll(/(-?[\d.]+),(-?[\d.]+)/g)].map((m) => Number(m[2]));
|
||||||
|
|
||||||
|
describe('smooth line', () => {
|
||||||
|
it('never overshoots its points, so a quiet stretch stays flat', () => {
|
||||||
|
const pts: [number, number][] = [
|
||||||
|
[0, 40],
|
||||||
|
[10, 40],
|
||||||
|
[20, 2],
|
||||||
|
[30, 40],
|
||||||
|
[40, 40],
|
||||||
|
];
|
||||||
|
const y = ys(smooth(pts));
|
||||||
|
expect(Math.min(...y)).toBeGreaterThanOrEqual(2);
|
||||||
|
expect(Math.max(...y)).toBeLessThanOrEqual(40);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('draws one point as a move and nothing as nothing', () => {
|
||||||
|
expect(smooth([[3, 4]])).toBe('M3.0,4.0');
|
||||||
|
expect(smooth([])).toBe('');
|
||||||
|
});
|
||||||
|
});
|
||||||
+2
-29
@@ -7,42 +7,15 @@ const KEY = `vpn://${'A1b2C3d4'.repeat(180)}`;
|
|||||||
const HUGE = 'A1b2C3d4'.repeat(425);
|
const HUGE = 'A1b2C3d4'.repeat(425);
|
||||||
|
|
||||||
describe('qr', () => {
|
describe('qr', () => {
|
||||||
it('draws the plain look as black squares on white in one path', () => {
|
it('omits the centre mark on dense codes', () => {
|
||||||
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', () => {
|
|
||||||
const link = qrSvg(LINK, 3, true, 'night');
|
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.
|
// 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(denseQr(KEY)).toBe(true);
|
||||||
expect(qrSvg(KEY, 3, true, 'night')).not.toContain('<g transform');
|
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', () => {
|
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(qrFits(HUGE)).toBe(false);
|
||||||
expect(scannable(HUGE)).toBe(false);
|
expect(scannable(HUGE)).toBe(false);
|
||||||
// It still fits a code, but too fine to read off a screen.
|
// It still fits a code, but too fine to read off a screen.
|
||||||
|
|||||||
+10
-12
@@ -2,19 +2,17 @@ import { describe, expect, it } from 'vitest';
|
|||||||
import { labelFade } from '../src/portal/ui/seg';
|
import { labelFade } from '../src/portal/ui/seg';
|
||||||
|
|
||||||
describe('picker names on a pick', () => {
|
describe('picker names on a pick', () => {
|
||||||
it('blurs the picked name in a beat after the pill, and folds a shown one whole', () => {
|
it('shortens a fade interrupted part-way', () => {
|
||||||
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', () => {
|
|
||||||
// Picked again while it was folding away: it comes back from 40% at once.
|
// 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);
|
const back = labelFade({ width: 36, full: 90, opacity: 0.4 }, true);
|
||||||
expect(back.duration).toBeCloseTo(168);
|
expect(back.duration).toBeGreaterThan(0);
|
||||||
expect(back.delay).toBeCloseTo(42);
|
expect(back.duration).toBeLessThan(opening.duration);
|
||||||
// Left while it was still coming in: it folds from the wider of its width and its opacity.
|
expect(back.delay).toBeLessThanOrEqual(opening.delay);
|
||||||
expect(labelFade({ width: 45, full: 90, opacity: 0.2 }, false).duration).toBeCloseTo(110);
|
// Interrupted while opening: either width or opacity can keep the closing fade active.
|
||||||
expect(labelFade({ width: 9, full: 90, opacity: 0.7 }, false).duration).toBeCloseTo(154);
|
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', () => {
|
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)', () => {
|
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: 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);
|
expect(labelFade({ width: 0, full: 90, opacity: 1.2 }, true).duration).toBe(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -2,7 +2,6 @@ import { describe, expect, it } from 'vitest';
|
|||||||
import {
|
import {
|
||||||
addLink,
|
addLink,
|
||||||
appsFor,
|
appsFor,
|
||||||
deviceNoun,
|
|
||||||
importPath,
|
importPath,
|
||||||
importSteps,
|
importSteps,
|
||||||
inWebview,
|
inWebview,
|
||||||
@@ -53,12 +52,6 @@ describe('setup', () => {
|
|||||||
expect(wantsAdd('')).toBe(false);
|
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', () => {
|
it('knows whether the page is open on the device being set up', () => {
|
||||||
expect(sameDevice('phone', 'ios')).toBe(true);
|
expect(sameDevice('phone', 'ios')).toBe(true);
|
||||||
expect(sameDevice('phone', 'mac')).toBe(false);
|
expect(sameDevice('phone', 'mac')).toBe(false);
|
||||||
|
|||||||
+1
-21
@@ -1,5 +1,5 @@
|
|||||||
import { describe, expect, it } from 'vitest';
|
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';
|
import type { Device, SetupState } from '../src/shared/types';
|
||||||
|
|
||||||
/** When the sheet opened (router clock). */
|
/** 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(dev({ online: false, handshake: OPENED + 9, setup: null }), OPENED)).toBe('waiting');
|
||||||
expect(wayState(undefined, 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']);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
"installCommand": "npm ci",
|
"installCommand": "npm ci",
|
||||||
"buildCommand": "npm run build:demo",
|
"buildCommand": "npm run build:demo",
|
||||||
"outputDirectory": "dist/demo",
|
"outputDirectory": "dist/demo",
|
||||||
"ignoreCommand": "[ \"$VERCEL_GIT_COMMIT_REF\" != main ] || git diff --quiet HEAD^ HEAD -- .",
|
"ignoreCommand": "[ \"$VERCEL_GIT_COMMIT_REF\" != main ] || git diff --quiet \"$VERCEL_GIT_PREVIOUS_SHA\" HEAD -- .",
|
||||||
"headers": [
|
"headers": [
|
||||||
{
|
{
|
||||||
"source": "/(.*)",
|
"source": "/(.*)",
|
||||||
|
|||||||
Reference in new issue
Block a user