From e21fbe28f12b3df62e1e61fea15fe1b189ab5a94 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 27 Jul 2023 23:18:45 +0200 Subject: expose thermal info via /thermal --- src/app.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app.py b/src/app.py index 3964a38..274ff7b 100755 --- a/src/app.py +++ b/src/app.py @@ -585,6 +585,7 @@ def cgi_one_value(params, name, default=None): class Request(Enum): STATUS = 'status' TOP = 'top' + THERMAL = 'thermal' REBOOT = 'reboot' POWEROFF = 'poweroff' @@ -610,6 +611,8 @@ class Request(Enum): return Status().complete() if self is Request.TOP: return Top().complete() + if self is Request.THERMAL: + return ThermalInfo().complete() if self in [Request.REBOOT, Request.POWEROFF] and self.disable_power: return Response(None, HTTPStatus.FORBIDDEN) -- cgit v1.2.3 From e249b08a095ecd1bba5726951b12dfff21206689 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 27 Jul 2023 23:23:43 +0200 Subject: test: check thermal info --- test/test.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/test.sh b/test/test.sh index aaf80fd..c6366f7 100755 --- a/test/test.sh +++ b/test/test.sh @@ -141,10 +141,11 @@ run_curl_tests() { run_curl_test '/index.html' '' 'var status_refresh_interval_seconds' # /status returns a JSON with a number of fields: - run_curl_test '/status' '"hostname":' '"system":' '"user":' - - # /top is a `top` output: + run_curl_test '/status' '"hostname":' '"thermal":' '"system":' '"user":' + # /top is `top` output: run_curl_test '/top' 'load average:' + # /thermal is also an endpoint: + run_curl_test '/thermal' } cgi_check_header() { @@ -187,9 +188,11 @@ run_cgi_tests() { # Check that app.py still works as a CGI script. # /status returns a JSON with a number of fields: - run_cgi_test 'status' '"hostname":' '"system":' '"user":' - # /top is a `top` output: + run_cgi_test 'status' '"hostname":' '"thermal":' '"system":' '"user":' + # /top is `top` output: run_cgi_test 'top' 'load average:' + # /thermal is also an endpoint: + run_cgi_test 'thermal' } main() { -- cgit v1.2.3 From e9efe2de0cf7d3ceba46456360fc11b285aa8de5 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 28 Jul 2023 00:15:37 +0200 Subject: html: tweak styling --- html/index.html | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/html/index.html b/html/index.html index 8c4ebf1..b4baec0 100644 --- a/html/index.html +++ b/html/index.html @@ -10,13 +10,13 @@
-
+

-

refreshed every - seconds

-
+
@@ -210,16 +210,14 @@ function set_thermal(data) { let type = info['type']; let temp = info['temp'].toFixed(2) + '°C'; let row = $('') - .append($('', {'class': 'py-0'}) - .append($('', {'class': 'text-reset'}).text(type))) - .append($('', {'class': 'py-0 text-right'}) - .append($('', {'class': 'text-reset'}).html(temp))); + .append($('', {'class': 'pr-1'}).text(type)) + .append($('', {'class': 'pl-1 text-right'}).html(temp)); body.append(row); }); $('#thermal').empty(); $('#thermal').append($('
', {'class': 'table-responsive'}) - .append($('', {'class': 'table table-borderless table-sm text-nowrap mb-0'}) + .append($('
', {'class': 'text-nowrap', 'style': 'width: 100%;'}) .append(body))); } -- cgit v1.2.3 From e1b8d53e17ce5e2d6768d82b4c1575e313cebbb0 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 28 Jul 2023 00:32:55 +0200 Subject: update example screenshot --- doc/example.png | Bin 691707 -> 396709 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/doc/example.png b/doc/example.png index 8cf23fe..caec72a 100644 Binary files a/doc/example.png and b/doc/example.png differ -- cgit v1.2.3