From b973c8f133528f58d720dcc5e5f528e4fd203db0 Mon Sep 17 00:00:00 2001 From: "aiyion.prime" 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 d9210479..861c13a4 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('', pcdata(key), pcdata(format or 'id')) end @@ -122,6 +132,17 @@
<%| nodeinfo.network.mesh_vpn.provider %> <%- end %> + <% if nodeinfo.network.mesh_vpn.bandwidth_limit.enabled then -%> +
<%:Bandwidth limit%>
+
+ <% if nodeinfo.network.mesh_vpn.bandwidth_limit.egress then -%> + ▲ <%| formatBits(nodeinfo.network.mesh_vpn.bandwidth_limit.egress*1000) %>/s <%:upstream%>
+ <%- end %> + <% if nodeinfo.network.mesh_vpn.bandwidth_limit.ingress then -%> + ▼ <%| formatBits(nodeinfo.network.mesh_vpn.bandwidth_limit.ingress*1000) %>/s <%:downstream%> + <%- end %> +
+ <%- end %> <%- end %>
<%:Site%>
<%| site.site_name() %>
<% 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 31ee99d5..e86b174b 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 00000000..642f9aaf --- /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 cac28222..5a8008fd 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 06f8e4e7..b5a1b85e 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": "Время работы",