update for app.js
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// static/js/connection-check.js
|
||||
|
||||
let connectionCheckInterval = null;
|
||||
let failedChecks = 0;
|
||||
const MAX_FAILED_CHECKS = 3;
|
||||
|
||||
function startConnectionCheck() {
|
||||
if (connectionCheckInterval) clearInterval(connectionCheckInterval);
|
||||
|
||||
connectionCheckInterval = setInterval(async () => {
|
||||
try {
|
||||
const res = await fetch('/api/status');
|
||||
const data = await res.json();
|
||||
|
||||
if (data.connected) {
|
||||
failedChecks = 0;
|
||||
updateStatus(true);
|
||||
} else {
|
||||
failedChecks++;
|
||||
if (failedChecks >= MAX_FAILED_CHECKS) {
|
||||
updateStatus(false, data.message || 'Mehrere Checks fehlgeschlagen');
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
failedChecks++;
|
||||
if (failedChecks >= MAX_FAILED_CHECKS) {
|
||||
updateStatus(false, 'Keine Antwort');
|
||||
}
|
||||
}
|
||||
}, 6000);
|
||||
}
|
||||
|
||||
window.startConnectionCheck = startConnectionCheck;
|
||||
Reference in New Issue
Block a user