From 4af78f635ee6a51f63ca2fa17b5f8f35821b7ebe Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 18 Nov 2021 19:50:47 +0100 Subject: [PATCH 1/2] Show how much storage space is used by shared files Requires at least https://hg.prosody.im/prosody-modules/rev/883ad8b0a7c0 --- snikket_web/admin.py | 5 +++++ snikket_web/templates/admin_system.html | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/snikket_web/admin.py b/snikket_web/admin.py index 39fea15..4b04126 100644 --- a/snikket_web/admin.py +++ b/snikket_web/admin.py @@ -682,6 +682,11 @@ async def system() -> typing.Union[str, quart.Response]: except KeyError: pass + try: + metrics["prosody_uploads"] = prosody_metrics["uploads"] + except KeyError: + pass + for k in list(metrics.keys()): if metrics[k] is None: # so that defaulting in jinja works diff --git a/snikket_web/templates/admin_system.html b/snikket_web/templates/admin_system.html index c2360fb..00bcd35 100644 --- a/snikket_web/templates/admin_system.html +++ b/snikket_web/templates/admin_system.html @@ -68,6 +68,14 @@ {% trans %}unknown{% endtrans %} {%- endif -%} +
{% trans %}Storage used by shared files{% endtrans %}
+
+ {%- if metrics.prosody_uploads -%} + {{ metrics.prosody_uploads | format_bytes }} + {%- else -%} + {% trans %}unknown{% endtrans %} + {%- endif -%} +
{% trans %}Connected devices{% endtrans %}
{%- if metrics.prosody_devices | default(None) is not none -%} From 52d8047546023b08cf4dc312d87e9ad844e30c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Mon, 10 Jan 2022 16:56:31 +0100 Subject: [PATCH 2/2] Correctly detect presence of storage metric If there have been no uploads yet, the metric will be zero, so the if condition would fail the test, so it would render as "unknown". --- snikket_web/templates/admin_system.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snikket_web/templates/admin_system.html b/snikket_web/templates/admin_system.html index 00bcd35..fe547de 100644 --- a/snikket_web/templates/admin_system.html +++ b/snikket_web/templates/admin_system.html @@ -70,7 +70,7 @@
{% trans %}Storage used by shared files{% endtrans %}
- {%- if metrics.prosody_uploads -%} + {%- if metrics.prosody_uploads | default(None) is not none -%} {{ metrics.prosody_uploads | format_bytes }} {%- else -%} {% trans %}unknown{% endtrans %}