From b973c8f133528f58d720dcc5e5f528e4fd203db0 Mon Sep 17 00:00:00 2001 From: "aiyion.prime" <git@aiyionpri.me> Date: Fri, 7 May 2021 13:39:49 +0200 Subject: [PATCH] gluon-status-page: show bandwidth limits --- .../gluon/status-page/view/status-page.html | 21 +++++++++++++++++++ package/gluon-status-page/i18n/de.po | 9 ++++++++ package/gluon-status-page/i18n/fr.README | 10 +++++++++ .../i18n/gluon-status-page.pot | 9 ++++++++ package/gluon-status-page/i18n/ru.README | 1 + 5 files changed, 50 insertions(+) create mode 100644 package/gluon-status-page/i18n/fr.README diff --git a/package/gluon-status-page/files/lib/gluon/status-page/view/status-page.html b/package/gluon-status-page/files/lib/gluon/status-page/view/status-page.html index d9210479f..861c13a43 100644 --- a/package/gluon-status-page/files/lib/gluon/status-page/view/status-page.html +++ b/package/gluon-status-page/files/lib/gluon/status-page/view/status-page.html @@ -64,6 +64,16 @@ return v and translate('enabled') or translate('disabled') end + local function formatBits(bits) + local units = {[0]='', 'k', 'M', 'G'} + + local pow = math.floor(math.log(math.max(math.abs(bits), 1)) / math.log(1000)) + local known_pow = math.min(pow, #units) + + local significand = bits/(1000^known_pow) + return string.format('%g %sbit', significand, units[known_pow]) + end + local function statistics(key, format) return string.format('<span data-statistics="%s" data-format="%s"></span>', pcdata(key), pcdata(format or 'id')) end @@ -122,6 +132,17 @@ <br /><%| nodeinfo.network.mesh_vpn.provider %> <%- end %> </dd> + <% if nodeinfo.network.mesh_vpn.bandwidth_limit.enabled then -%> + <dt><%:Bandwidth limit%></dt> + <dd> + <% if nodeinfo.network.mesh_vpn.bandwidth_limit.egress then -%> + â–² <%| formatBits(nodeinfo.network.mesh_vpn.bandwidth_limit.egress*1000) %>/s <%:upstream%><br /> + <%- end %> + <% if nodeinfo.network.mesh_vpn.bandwidth_limit.ingress then -%> + â–¼ <%| formatBits(nodeinfo.network.mesh_vpn.bandwidth_limit.ingress*1000) %>/s <%:downstream%> + <%- end %> + </dd> + <%- end %> <%- end %> <dt><%:Site%></dt><dd><%| site.site_name() %></dd> <% if nodeinfo.system.domain_code then -%> diff --git a/package/gluon-status-page/i18n/de.po b/package/gluon-status-page/i18n/de.po index 31ee99d5f..e86b174be 100644 --- a/package/gluon-status-page/i18n/de.po +++ b/package/gluon-status-page/i18n/de.po @@ -28,6 +28,9 @@ msgstr "1 Tag" msgid "Automatic updates" msgstr "Automatische Updates" +msgid "Bandwidth limit" +msgstr "Bandbreitenlimit" + msgid "Channel" msgstr "Kanal" @@ -43,6 +46,9 @@ msgstr "Entfernung" msgid "Domain" msgstr "Domäne" +msgid "downstream" +msgstr "Downstream" + msgid "Error" msgstr "Fehler" @@ -124,6 +130,9 @@ msgstr "" msgid "Transmitted" msgstr "Gesendet" +msgid "upstream" +msgstr "Upstream" + msgid "Uptime" msgstr "Laufzeit" diff --git a/package/gluon-status-page/i18n/fr.README b/package/gluon-status-page/i18n/fr.README new file mode 100644 index 000000000..642f9aaf3 --- /dev/null +++ b/package/gluon-status-page/i18n/fr.README @@ -0,0 +1,10 @@ +Draft for french translation, taken from gluon-config-mode-mesh-vpn + +msgid "" +msgstr "" + +msgid "downstream" +msgstr "débit déscendant" + +msgid "upstream" +msgstr "débit ascendant" diff --git a/package/gluon-status-page/i18n/gluon-status-page.pot b/package/gluon-status-page/i18n/gluon-status-page.pot index cac28222f..5a8008fdf 100644 --- a/package/gluon-status-page/i18n/gluon-status-page.pot +++ b/package/gluon-status-page/i18n/gluon-status-page.pot @@ -19,6 +19,9 @@ msgstr "" msgid "Automatic updates" msgstr "" +msgid "Bandwidth limit" +msgstr "" + msgid "Channel" msgstr "" @@ -34,6 +37,9 @@ msgstr "" msgid "Domain" msgstr "" +msgid "downstream" +msgstr "" + msgid "Error" msgstr "" @@ -115,6 +121,9 @@ msgstr "" msgid "Transmitted" msgstr "" +msgid "upstream" +msgstr "" + msgid "Uptime" msgstr "" diff --git a/package/gluon-status-page/i18n/ru.README b/package/gluon-status-page/i18n/ru.README index 06f8e4e7d..b5a1b85e5 100644 --- a/package/gluon-status-page/i18n/ru.README +++ b/package/gluon-status-page/i18n/ru.README @@ -10,6 +10,7 @@ if we ever add Russion to gluon-web, the following strings can be reused: "Primary MAC": "ОÑновной MAC", "IP Address": "IP ÐдреÑ", "Automatic updates": "ÐвтоматичеÑкие обновлениÑ", +"Bandwidth limit": "Ограничение пропуÑкной ÑпоÑобноÑти", "Overview": "Обзор", "used": "иÑпользуетÑÑ", "Uptime": "Ð’Ñ€ÐµÐ¼Ñ Ñ€Ð°Ð±Ð¾Ñ‚Ñ‹", -- GitLab