// Import common js
-import { loadModals, showToast, sortTable, initSortableTable, resetSorting } from './common.js';
+import { loadModals, showToast, sortTable, initSortableTable, resetSorting, filterData, clearSearch } from './common.js';
import { reloadDNS, reloadDHCP } from './services.js';
import { apiMap, fetchData } from './api.js';
return false;
}
-// -----------------------------
-// filter aliases in the table
-// -----------------------------
-function filterAliases() {
- const query = document.getElementById("searchInput").value.toLowerCase();
- const rows = document.querySelectorAll("#dataTable tbody tr");
-
- rows.forEach(row => {
- const text = row.textContent.toLowerCase();
- row.style.display = text.includes(query) ? "" : "none";
- });
-}
-
-// -----------------------------
-// Clear search on ESC key
-// -----------------------------
-async function clearSearch() {
- const input = document.getElementById("searchInput");
- if (input) {
- input.value = "";
- input.blur();
- }
- viewAliases = [...allAliases];
- await loadAliases(false);
-}
-
// -----------------------------
// Action Handlers
// -----------------------------
// clean input on load
input.value = "";
// live filter for each keystroke
- input.addEventListener("input", filterAliases);
+ input.addEventListener("input", filterData);
// Escape management when focus is in the input
input.addEventListener("keydown", (e) => {
if (e.key === "Escape") {
e.stopPropagation(); // evita che arrivi al listener globale
resetSorting(sortState);
clearSearch(); // svuota input e ricarica tabella (come definito nella tua funzione)
- filterAliases(''); // ripristina tabella
+ viewAliases = [...allAliases];
+ loadAliases(false);
+ filterData(''); // ripristina tabella'');
}
});
}
e.preventDefault(); // evita side-effect (es. chiusure di modali del browser)
resetSorting(sortState);
clearSearch(); // svuota input e ricarica tabella (come definito nella tua funzione)
- filterAliases(''); // ripristina tabella
+ viewAliases = [...allAliases];
+ loadAliases(false);
+ filterData(''); // ripristina tabella'');
}
// Button event delegation (Enter, Space)
throw err;
}
return items;
-}
\ No newline at end of file
+}
}
/**
- * Opzionale: inizializza aria-sort='none'
+ * Optional: set aria-sort='none' on all headers on page load for better accessibility.
*/
export function initSortableTable() {
const table = document.getElementById("dataTable");
const ths = table.querySelectorAll("thead th");
ths.forEach(th => th.setAttribute("aria-sort", "none"));
}
+
+/**
+ * Live filter: mostra solo le righe che contengono il testo di ricerca (case-insensitive)
+ */
+export function filterData() {
+ const query = document.getElementById("searchInput").value.toLowerCase();
+ const rows = document.querySelectorAll("#dataTable tbody tr");
+
+ rows.forEach(row => {
+ const text = row.textContent.toLowerCase();
+ row.style.display = text.includes(query) ? "" : "none";
+ });
+}
+
+/**
+ * Clear search input and reset table filter
+ */
+export function clearSearch() {
+ const input = document.getElementById("searchInput");
+ if (input) {
+ input.value = "";
+ input.blur();
+ }
+}
// Import common js
-import { loadModals, isValidIPv4, isValidIPv6, isValidMAC, showToast, sortTable, initSortableTable, resetSorting } from './common.js';
+import { loadModals, isValidIPv4, isValidIPv6, isValidMAC, showToast, sortTable, initSortableTable, resetSorting, filterData, clearSearch } from './common.js';
import { reloadDNS, reloadDHCP } from './services.js';
import { apiMap, fetchData } from './api.js';
return false;
}
-// -----------------------------
-// filter devices in the table
-// -----------------------------
-function filterDevices() {
- const query = document.getElementById("searchInput").value.toLowerCase();
- const rows = document.querySelectorAll("#dataTable tbody tr");
-
- rows.forEach(row => {
- const text = row.textContent.toLowerCase();
- row.style.display = text.includes(query) ? "" : "none";
- });
-}
-
-// -----------------------------
-// Clear search on ESC key
-// -----------------------------
-async function clearSearch() {
- const input = document.getElementById("searchInput");
- if (input) {
- input.value = "";
- input.blur();
- }
- viewDevices = [...allDevices];
- await loadDevices(false);
-}
-
// -----------------------------
// Action Handlers
// -----------------------------
// clean input on load
input.value = "";
// live filter for each keystroke
- input.addEventListener("input", filterDevices);
+ input.addEventListener("input", filterData);
// Escape management when focus is in the input
input.addEventListener("keydown", (e) => {
if (e.key === "Escape") {
e.stopPropagation(); // evita che arrivi al listener globale
resetSorting(sortState);
clearSearch(); // svuota input e ricarica tabella (come definito nella tua funzione)
- filterDevices(''); // ripristina tabella
+ viewDevices = [...allDevices];
+ loadDevices(false);
+ filterData(''); // ripristina tabella'');
}
});
}
e.preventDefault(); // evita side-effect (es. chiusure di modali del browser)
resetSorting(sortState);
clearSearch(); // svuota input e ricarica tabella (come definito nella tua funzione)
- filterDevices(''); // ripristina tabella
+ viewDevices = [...allDevices];
+ loadDevices(false);
+ filterData(''); // ripristina tabella'');
}
// Button event delegation (Enter, Space)
// Import common js
-import { loadModals, isValidIPv4, isValidIPv6, isValidMAC, showToast, sortTable, initSortableTable, resetSorting } from './common.js';
+import { loadModals, isValidIPv4, isValidIPv6, isValidMAC, showToast, sortTable, initSortableTable, resetSorting, filterData, clearSearch } from './common.js';
import { reloadDNS, reloadDHCP } from './services.js';
import { apiMap, fetchData } from './api.js';
return false;
}
-// -----------------------------
-// filter hosts in the table
-// -----------------------------
-function filterHosts() {
- const query = document.getElementById("searchInput").value.toLowerCase();
- const rows = document.querySelectorAll("#dataTable tbody tr");
-
- rows.forEach(row => {
- const text = row.textContent.toLowerCase();
- row.style.display = text.includes(query) ? "" : "none";
- });
-}
-
-// -----------------------------
-// Clear search on ESC key
-// -----------------------------
-async function clearSearch() {
- const input = document.getElementById("searchInput");
- if (input) {
- input.value = "";
- input.blur();
- }
- viewHosts = [...allHosts];
- await loadHosts(false);
-}
-
// -----------------------------
// Action Handlers
// -----------------------------
// clean input on load
input.value = "";
// live filter for each keystroke
- input.addEventListener("input", filterHosts);
+ input.addEventListener("input", filterData);
// Escape management when focus is in the input
input.addEventListener("keydown", (e) => {
if (e.key === "Escape") {
e.stopPropagation(); // evita che arrivi al listener globale
resetSorting(sortState);
clearSearch(); // svuota input e ricarica tabella (come definito nella tua funzione)
- filterHosts(''); // ripristina tabella
+ viewHosts = [...allHosts];
+ loadHosts(false);
+ filterData(''); // ripristina tabella
}
});
}
e.preventDefault(); // evita side-effect (es. chiusure di modali del browser)
resetSorting(sortState);
clearSearch(); // svuota input e ricarica tabella (come definito nella tua funzione)
- filterHosts(''); // ripristina tabella
+ viewHosts = [...allHosts];
+ loadHosts(false);
+ filterData(''); // ripristina tabella
}
// Button event delegation (Enter, Space)
// Import common js
-import { loadModals, isValidIPv4, isValidIPv6, isValidMAC, showToast, sortTable, initSortableTable, resetSorting } from './common.js';
+import { loadModals, isValidIPv4, isValidIPv6, isValidMAC, showToast, sortTable, initSortableTable, resetSorting, filterData, clearSearch } from './common.js';
import { reloadDNS, reloadDHCP } from './services.js';
import { apiMap, fetchData } from './api.js';
return false;
}
-// -----------------------------
-// filter dhcp leases in the table
-// -----------------------------
-function filterLeases() {
- const query = document.getElementById("searchInput").value.toLowerCase();
- const rows = document.querySelectorAll("#dataTable tbody tr");
-
- rows.forEach(row => {
- const text = row.textContent.toLowerCase();
- row.style.display = text.includes(query) ? "" : "none";
- });
-}
-
-// -----------------------------
-// Clear search on ESC key
-// -----------------------------
-async function clearSearch() {
- const input = document.getElementById("searchInput");
- if (input) {
- input.value = "";
- input.blur();
- }
- viewLeases = [...allLeases];
- await loadLeases(false);
-}
-
// -----------------------------
// Action Handlers
// -----------------------------
// clean input on load
input.value = "";
// live filter for each keystroke
- input.addEventListener("input", filterLeases);
+ input.addEventListener("input", filterData);
// Escape management when focus is in the input
input.addEventListener("keydown", (e) => {
if (e.key === "Escape") {
e.stopPropagation(); // evita che arrivi al listener globale
resetSorting(sortState);
clearSearch(); // svuota input e ricarica tabella (come definito nella tua funzione)
- filterLeases(''); // ripristina tabella
+ viewLeases = [...allLeases];
+ loadLeases(false);
+ filterData(''); // ripristina tabella'');
}
});
}
e.preventDefault(); // evita side-effect (es. chiusure di modali del browser)
resetSorting(sortState);
clearSearch(); // svuota input e ricarica tabella (come definito nella tua funzione)
- filterLeases(''); // ripristina tabella
+ viewLeases = [...allLeases];
+ loadLeases(false);
+ filterData(''); // ripristina tabella'');
}
// Button event delegation (Enter, Space)
</div>
</div>
</div>
-</div>
\ No newline at end of file
+</div>