From: Giorgio Ravera Date: Thu, 18 Jun 2026 16:11:04 +0000 (+0200) Subject: Right click to copy logs X-Git-Tag: v0.0.2~12 X-Git-Url: http://git.giorgioravera.it/?a=commitdiff_plain;h=4bc90c243610d7e6ce42efc3d3bf8a74d080e0ad;p=network-manager.git Right click to copy logs --- diff --git a/TODO.md b/TODO.md index 8978c73..844e6d2 100644 --- a/TODO.md +++ b/TODO.md @@ -51,6 +51,23 @@ --- +## 📝 Logs + +- [x] Log Generation +- [x] Application Log Visualization +- [x] Access Log Visualization +- [ ] DNS Log Visualization +- [ ] DHCP Log Visualization +- [X] Live Log Streaming +- [ ] Log Filtering by Level +- [ ] Time Range Filtering +- [X] Multi-Row Selection +- [ ] Export Logs (CSV/TXT) +- [X] Copy Selected Logs (right click on selected) +- [X] Auto Scroll (tail -f) + +--- + ## 🧩 Configuration Generation ### 🧪 BIND (DNS) diff --git a/frontend/js/logs.js b/frontend/js/logs.js index 06b124e..5e1bf77 100644 --- a/frontend/js/logs.js +++ b/frontend/js/logs.js @@ -144,9 +144,26 @@ function renderLogs(text, isNearBottom, previousScroll, previousHeight) { lastSelectedRowId = rowId; }); - // double click to copy - div.addEventListener("dblclick", async () => { - await navigator.clipboard.writeText(line); + + // right click to copy logs + div.addEventListener("contextmenu", async (e) => { + + e.preventDefault(); + + // se la riga non è selezionata la seleziono + if (!selectedRows.has(rowId)) { + + selectedRows.clear(); + + document + .querySelectorAll(".log-row.selected") + .forEach(r => r.classList.remove("selected")); + + selectedRows.add(rowId); + div.classList.add("selected"); + } + + await copySelectedLogs(); }); div.innerHTML = @@ -185,6 +202,42 @@ function renderLogs(text, isNearBottom, previousScroll, previousHeight) { } } +// ----------------------------- +// copy logs +// ----------------------------- +async function copySelectedLogs() { + + const rows = Array.from(document.querySelectorAll(".log-row")); + + const selectedTexts = rows + .filter(row => selectedRows.has(row.dataset.rowId)) + .map(row => row.textContent.trim()); + + if (!selectedTexts.length) { + showToast("No rows selected", false); + return; + } + + try { + + await navigator.clipboard.writeText( + selectedTexts.join("\n") + ); + + showToast( + `${selectedTexts.length} log(s) copied`, + true + ); + + } catch (err) { + + showToast( + "Error copying logs", + false + ); + } +} + // ----------------------------- // update dropdown menu // -----------------------------