From 19a62006ee6b750f7dc5760cb93bfc78e500ae4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Mon, 16 Nov 2020 15:02:54 +0100 Subject: [PATCH] Change logging (#17) --- rootfs/usr/share/www/index.html | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/rootfs/usr/share/www/index.html b/rootfs/usr/share/www/index.html index 5839435..e63664d 100644 --- a/rootfs/usr/share/www/index.html +++ b/rootfs/usr/share/www/index.html @@ -42,7 +42,7 @@ .spinner { width: 40px; height: 40px; - + cursor: pointer; position: relative; margin: 20px auto; } @@ -67,8 +67,13 @@ animation-delay: -1s; } - #log { - cursor: pointer; + pre { + display: block; + margin: auto; + max-width: 450px; + padding-bottom: 8px; + text-align: left; + white-space: pre-line; } @-webkit-keyframes sk-bounce { @@ -98,11 +103,11 @@
Home Assistant logo

Preparing Home Assistant

-
+
-

+      

       (this can take up to 20 minutes)
     
@@ -226,13 +231,7 @@

While waiting, some suggestions:

if (res.ok) { res.text().then(function (text) { const logElement = document.querySelector("#log") - let logLines = text - - if (!logElement.showFull) { - logLines = logLines.split("\n").slice(-2)[0] - } - - logElement.innerText = logLines + logElement.innerText = logElement.showFull ? text : "" .replace(/\s[A-Z]+\s\(\w+\)\s\[[\w.]+\]/gi, "") .replace(/\d{2}-\d{2}-\d{2}\s/gi, "") .replace(/\d{2}:\d{2}:\d{2}\s/gi, ""); @@ -252,9 +251,9 @@

While waiting, some suggestions:

scheduleTry(); fetchLogs(); - document.getElementById("log").addEventListener("click", function (event) { - const log = event.currentTarget - log.showFull = !log.showFull + document.getElementById("spinner").addEventListener("click", function (event) { + const logElement = document.querySelector("#log") + log.showFull = !logElement.showFull fetchLogs() });