diff options
| author | Ahmed AbdelHalim <[email protected]> | 2025-09-07 17:50:36 +0200 |
|---|---|---|
| committer | Ahmed AbdelHalim <[email protected]> | 2025-09-07 17:50:36 +0200 |
| commit | ff63742a2fa138c230fb2e080708d03ed888c248 (patch) | |
| tree | 10a5061a93cd6a91217d837a0a3a22a0bb17c54e /static/js/app.js | |
| parent | 17168a489392847794de0aed15fe395230a38261 (diff) | |
Add basic login and clean up config
Diffstat (limited to 'static/js/app.js')
| -rw-r--r-- | static/js/app.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/static/js/app.js b/static/js/app.js index db8ed8a..dd2aa75 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -112,6 +112,8 @@ const ConnectionManager = { // Status management const StatusManager = { + intervalId: null, + // Load and display WireGuard status async loadStatus() { try { @@ -126,10 +128,35 @@ const StatusManager = { Utils.renderError(App.elements.statusArea, error.message); } }, + + startAutoRefresh() { + // Clear any existing interval first + this.stopAutoRefresh(); + // Start new interval + this.intervalId = setInterval(() => this.loadStatus(), 5000); + }, + + stopAutoRefresh() { + if (this.intervalId) { + clearInterval(this.intervalId); + this.intervalId = null; + } + } }; // Initialize the application document.addEventListener('DOMContentLoaded', () => { StatusManager.loadStatus(); ConnectionManager.loadConnections(); + StatusManager.startAutoRefresh(); +}); + +// Pause when tab is hidden, resume when visible +document.addEventListener('visibilitychange', () => { + if (document.hidden) { + StatusManager.stopAutoRefresh(); + } else { + StatusManager.loadStatus(); // Immediate refresh when back + StatusManager.startAutoRefresh(); + } }); |
