From 978c5d5ec5a72212f5a32aa48ae467cc352c9d08 Mon Sep 17 00:00:00 2001
From: David Huss <dh@atoav.com>
Date: Tue, 5 Nov 2024 18:11:48 +0100
Subject: [PATCH] Hide uptime when off

---
 static/modules/system.js | 7 +++++--
 static/style.css         | 4 ++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/static/modules/system.js b/static/modules/system.js
index e4cb098..3e6bf88 100644
--- a/static/modules/system.js
+++ b/static/modules/system.js
@@ -98,11 +98,14 @@ class System {
                 let now = new Date();
                 let t = now - power_up;
                 console.log(t);
+                let seconds =  Math.round(t/1000, 0);
                 let minutes = Math.round(t/1000/60, 0);
-                if (minutes < 240) {
+                if (minutes < 1) {
+                    uptime_display.innerHTML = `on for ${seconds} s`;
+                } else if (minutes < 240) {
                     uptime_display.innerHTML = `on for ${minutes} min`;
                 } else {
-                    let hours = Math.round(minutes/60, 1);
+                    let hours = Math.round(t/1000/60/60, 1);
                     uptime_display.innerHTML = `on for ${hours} h`;
                 }
                 
diff --git a/static/style.css b/static/style.css
index a9ecde7..765495f 100644
--- a/static/style.css
+++ b/static/style.css
@@ -30,6 +30,10 @@ main {
 	padding-top: 0.3em;
 }
 
+.hidden {
+	display: none;
+}
+
 header {
 	width: 100%;
 	border-bottom: 1px solid white;
-- 
GitLab