Blinken der LEDs und des WebInterface in Sync
This commit is contained in:
+10
-1
@@ -9,6 +9,9 @@
|
||||
<body>
|
||||
<h1>Port Konfiguration</h1>
|
||||
<form id="portForm">
|
||||
<label>
|
||||
Blinkintervall (ms): <input type="number" id="blinkInput" name="blink_interval" min="1" value="">
|
||||
</label><br>
|
||||
<div id="portsContainer"></div>
|
||||
<input type="submit" value="Speichern">
|
||||
</form>
|
||||
@@ -19,6 +22,9 @@
|
||||
try {
|
||||
const response = await fetch('/portconfig/data');
|
||||
const data = await response.json();
|
||||
if (data.blink_interval !== undefined) {
|
||||
document.getElementById('blinkInput').value = data.blink_interval;
|
||||
}
|
||||
const container = document.getElementById('portsContainer');
|
||||
container.innerHTML = '';
|
||||
data.ports.forEach((port, index) => {
|
||||
@@ -46,11 +52,14 @@
|
||||
enabled: formData.has(`enabled${i}`)
|
||||
});
|
||||
}
|
||||
const blink = parseInt(formData.get('blink_interval')) || null;
|
||||
const payload = { ports };
|
||||
if (blink !== null) payload.blink_interval = blink;
|
||||
try {
|
||||
await fetch('/portconfig', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ ports })
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
alert('Konfiguration gespeichert!');
|
||||
loadConfig(); // Reload
|
||||
|
||||
Reference in New Issue
Block a user