You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.4 KiB
88 lines
2.4 KiB
/* =======================================================================
|
|
File: static/js/log_view.js
|
|
Purpose:
|
|
Log viewer functionality:
|
|
- filtering
|
|
- clearing
|
|
- auto-scroll
|
|
- refresh support for dashboard polling
|
|
======================================================================= */
|
|
|
|
console.log(">>> log_view.js LOADING…");
|
|
|
|
/* ---------------------------------------------------------
|
|
Log filtering
|
|
--------------------------------------------------------- */
|
|
let LOG_FILTER = "ALL";
|
|
|
|
function applyLogFilter() {
|
|
console.log(">>> log_view.js applyLogFilter(), filter =", LOG_FILTER);
|
|
|
|
const lines = $$(".log-line");
|
|
console.log(">>> log_view.js number of log-line elements:", lines.length);
|
|
|
|
lines.forEach((line) => {
|
|
const text = line.innerText;
|
|
line.style.display =
|
|
LOG_FILTER === "ALL" || text.includes(LOG_FILTER) ? "block" : "none";
|
|
});
|
|
}
|
|
|
|
/* ---------------------------------------------------------
|
|
UI bindings
|
|
--------------------------------------------------------- */
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
console.log(">>> log_view.js DOMContentLoaded");
|
|
|
|
const filterSel = $("#log-filter");
|
|
const clearBtn = $("#log-clear");
|
|
const output = $("#log-output");
|
|
|
|
if (!filterSel) {
|
|
console.log(">>> log_view.js: No log viewer found on this page.");
|
|
return;
|
|
}
|
|
|
|
console.log(">>> log_view.js: log viewer detected.");
|
|
|
|
// Filter dropdown
|
|
filterSel.addEventListener("change", () => {
|
|
LOG_FILTER = filterSel.value;
|
|
console.log(">>> log_view.js filter changed to:", LOG_FILTER);
|
|
applyLogFilter();
|
|
});
|
|
|
|
// Clear log window
|
|
if (clearBtn) {
|
|
clearBtn.addEventListener("click", () => {
|
|
console.log(">>> log_view.js log-clear clicked → clearing output");
|
|
if (output) output.innerHTML = "";
|
|
});
|
|
}
|
|
});
|
|
|
|
/* ---------------------------------------------------------
|
|
Append a line to the log output
|
|
--------------------------------------------------------- */
|
|
function logAppend(lineText) {
|
|
const output = $("#log-output");
|
|
|
|
if (!output) {
|
|
console.log(">>> log_view.js logAppend() SKIPPED — no #log-output");
|
|
return;
|
|
}
|
|
|
|
console.log(">>> log_view.js logAppend():", lineText);
|
|
|
|
const div = document.createElement("div");
|
|
div.className = "log-line";
|
|
div.innerText = lineText;
|
|
|
|
output.appendChild(div);
|
|
|
|
applyLogFilter();
|
|
autoScroll(output);
|
|
}
|
|
|
|
console.log(">>> log_view.js LOADED");
|