diff --git a/web/static/app.js b/web/static/app.js index 1ac33e2..68766cf 100644 --- a/web/static/app.js +++ b/web/static/app.js @@ -6,15 +6,29 @@ var refreshTimer = null; // Initialize document.addEventListener('DOMContentLoaded', function() { + loadConfig(); refreshAll(); - startAutoRefresh(); }); -function startAutoRefresh() { +function loadConfig() { + fetch(API_BASE + '/api/config') + .then(function(res) { return res.json(); }) + .then(function(config) { + var interval = config.refresh_interval || 5; + startAutoRefresh(interval); + document.getElementById('refresh-info').textContent = 'Refresh: ' + interval + 's'; + }) + .catch(function(e) { + console.error('Load config failed:', e); + startAutoRefresh(5); + }); +} + +function startAutoRefresh(intervalSeconds) { if (refreshTimer) { clearInterval(refreshTimer); } - refreshTimer = setInterval(refreshAll, 5000); + refreshTimer = setInterval(refreshAll, intervalSeconds * 1000); } function refreshAll() { @@ -323,6 +337,8 @@ function saveSettings() { if (data.success) { alert('Settings saved!'); closeSettingsModal(); + // Reload config to apply new refresh interval + loadConfig(); refreshAll(); } })