Skip to content

Commit

Permalink
added a save button to the debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
doudar committed Dec 16, 2024
1 parent 6066601 commit 718f402
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions data/status.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>SmartSpin2k Status</title>
<style>html{background-color:#03245c}</style>
<style>
html {
background-color: #03245c
}
</style>
</head>

<body>
<div class="page-container">
<header>
Expand Down Expand Up @@ -105,6 +111,9 @@ <h2>Debug Console</h2>
</label>
</div>
<pre id="debug" class="debug-console">Loading</pre>
<div class="button-group">
<button id="saveLogButton" class="secondary-button">Save Debug Log</button>
</div>
</div>
</div>
</main>
Expand Down Expand Up @@ -148,7 +157,7 @@ <h2>Debug Console</h2>

function requestConfigValues() {
if (updatePending) return;

updatePending = true;
fetch('/configJSON')
.then(response => response.json())
Expand All @@ -166,7 +175,7 @@ <h2>Debug Console</h2>

function requestRuntimeValues() {
if (updatePending) return;

updatePending = true;
fetch('/runtimeConfigJSON')
.then(response => response.json())
Expand Down Expand Up @@ -202,16 +211,16 @@ <h2>Debug Console</h2>

websocket.onmessage = (evt) => {
if (!evt?.data) return;

lastLogMessageTime = Date.now();
logEntries.push(evt.data);

if (logEntries.length > maxLogentries) {
logEntries = logEntries.slice(1, logEntries.length - 10);
}

debugElement.innerHTML = logEntries.join("<br>");

if (followElement.checked) {
debugElement.scrollTop = debugElement.scrollHeight - debugElement.clientHeight;
}
Expand Down Expand Up @@ -239,6 +248,22 @@ <h2>Debug Console</h2>
setTimeout(requestRuntimeValues, 200);
startUpdate();
});

document.getElementById('saveLogButton').addEventListener('click', () => {
const debugElement = document.getElementById('debug');
const logContent = debugElement.textContent;
const blob = new Blob([logContent], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'debug_log.txt';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
});

</script>
</body>
</html>

</html>

0 comments on commit 718f402

Please sign in to comment.