sdasd
All checks were successful
Deploy / deploy-staging (push) Successful in 6s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-04-27 01:30:00 +02:00
parent d04a2214dd
commit bff852291e
3 changed files with 67 additions and 5 deletions

View File

@@ -9,6 +9,10 @@
return d.toLocaleString('de-DE');
};
let refreshTimer = null;
let loadInFlight = false;
let loadErrorShown = false;
const apiCall = async (action, payload = {}) => {
const res = await fetch(`/module/pihole/api?action=${encodeURIComponent(action)}`,
{
@@ -240,6 +244,8 @@
};
const loadDashboard = async () => {
if (loadInFlight) return;
loadInFlight = true;
try {
const data = await apiCall('dashboard');
if (!data.ok) throw new Error(data.error || 'API error');
@@ -259,16 +265,32 @@
renderList(document.querySelector('[data-top-queries]'), data.aggregate?.top_queries, 'Keine Daten');
renderList(document.querySelector('[data-top-clients]'), data.aggregate?.query_sources, 'Keine Daten');
renderBlocked(document.querySelector('[data-recent-blocked]'), data.aggregate?.recent_blocked);
loadErrorShown = false;
const existing = page.querySelector('[data-pihole-load-error]');
if (existing) existing.remove();
} catch (err) {
const message = document.createElement('div');
message.className = 'card';
message.style.marginTop = '1rem';
let message = page.querySelector('[data-pihole-load-error]');
if (!message) {
message = document.createElement('div');
message.className = 'card';
message.style.marginTop = '1rem';
message.dataset.piholeLoadError = '1';
page.appendChild(message);
}
message.textContent = `Fehler beim Laden der Pi-hole Daten: ${err.message}`;
page.appendChild(message);
loadErrorShown = true;
} finally {
loadInFlight = false;
}
};
bindActionButtons();
bindForms();
loadDashboard();
refreshTimer = window.setInterval(loadDashboard, 1000);
window.addEventListener('beforeunload', () => {
if (refreshTimer !== null) {
window.clearInterval(refreshTimer);
}
});
})();