Verzögerung eingebaut
This commit is contained in:
@@ -72,6 +72,34 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin_section">
|
||||
<div class="admin_section_header">
|
||||
<p class="eyebrow">Latenz-Simulation</p>
|
||||
</div>
|
||||
<div class="admin_quick_link_card">
|
||||
<div>
|
||||
<strong>Signallaufzeit</strong>
|
||||
<p>Verzögert Steuerbefehle (Controller + Web-GUI) und Kamerabild gleichzeitig.</p>
|
||||
</div>
|
||||
<div class="delay_control">
|
||||
<select id="delay_select" class="delay_select" onchange="setDelay(parseFloat(this.value))">
|
||||
<option value="0">0 s – kein Delay</option>
|
||||
<option value="1">1 s</option>
|
||||
<option value="2">2 s</option>
|
||||
<option value="3">3 s</option>
|
||||
<option value="4">4 s</option>
|
||||
<option value="5">5 s</option>
|
||||
<option value="6">6 s</option>
|
||||
<option value="7">7 s</option>
|
||||
<option value="8">8 s</option>
|
||||
<option value="9">9 s</option>
|
||||
<option value="10">10 s</option>
|
||||
</select>
|
||||
<span id="delay_status" class="delay_status_text"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin_section">
|
||||
<div class="admin_section_header">
|
||||
<p class="eyebrow">Systemstatus</p>
|
||||
@@ -246,9 +274,43 @@
|
||||
}
|
||||
}
|
||||
|
||||
function updateDelayButtons(seconds) {
|
||||
var sel = document.getElementById('delay_select');
|
||||
if (sel) sel.value = String(seconds);
|
||||
}
|
||||
|
||||
async function fetchDelay() {
|
||||
try {
|
||||
var response = await fetch(adminApiBase + '/api/delay');
|
||||
if (!response.ok) return;
|
||||
var data = await response.json();
|
||||
updateDelayButtons(data.delay_seconds);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
async function setDelay(seconds) {
|
||||
var statusEl = document.getElementById('delay_status');
|
||||
if (statusEl) statusEl.textContent = 'Setze…';
|
||||
try {
|
||||
var response = await fetch(adminApiBase + '/api/delay', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({delay_seconds: seconds})
|
||||
});
|
||||
var data = await response.json();
|
||||
updateDelayButtons(seconds);
|
||||
if (statusEl) statusEl.textContent = data.status || 'Gesetzt';
|
||||
window.setTimeout(function() { if (statusEl) statusEl.textContent = ''; }, 2000);
|
||||
} catch (e) {
|
||||
if (statusEl) statusEl.textContent = 'Fehler';
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('load', function () {
|
||||
fetchStatus();
|
||||
fetchDelay();
|
||||
window.setInterval(fetchStatus, 10000);
|
||||
window.setInterval(fetchDelay, 5000);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user