mDNS und wifi stuff

This commit is contained in:
Carsten Graf
2025-06-05 17:38:34 +02:00
parent bc2218942a
commit fd17e92404
3 changed files with 125 additions and 4 deletions

View File

@@ -1,4 +1,3 @@
<!DOCTYPE html>
<html lang="de">
<head>
@@ -135,6 +134,36 @@
</div>
</div>
<div class="section" d="wifiSection" style="display: none;">
<h2>📡 WLAN-Konfiguration</h2>
<form id="wifiForm">
<div class="form-group">
<label for="wifi-ssid">WLAN Name (SSID):</label>
<input
type="text"
id="wifi-ssid"
name="ssid"
placeholder="WLAN-Name eingeben"
required
/>
</div>
<div class="form-group">
<label for="wifi-password">WLAN Passwort:</label>
<input
type="password"
id="wifi-password"
name="password"
placeholder="WLAN-Passwort eingeben"
/>
</div>
<div class="button-group">
<button type="submit" class="btn btn-primary">
💾 WLAN-Einstellungen speichern
</button>
</div>
</form>
</div>
<div class="section">
<h2>🔄 OTA Update</h2>
<div id="otaRestrictionNotice" class="restriction-notice" style="display: none;">
@@ -205,7 +234,8 @@
loadSystemInfo();
loadCurrentTime();
updateCurrentTimeDisplay();
loadLicence()
loadLicence();
loadWifiSettings();
};
// Aktuelle Zeit anzeigen (Live-Update)
@@ -423,6 +453,51 @@
.catch((error) => showMessage("Verbindungsfehler", "error"));
}
// WLAN-Einstellungen laden
function loadWifiSettings() {
fetch("/api/get-wifi")
.then(response => response.json())
.then(data => {
document.getElementById("wifi-ssid").value = data.ssid || "";
document.getElementById("wifi-password").value = data.password || "";
})
.catch(error => showMessage("Fehler beim Laden der WLAN-Einstellungen", "error"));
}
// WLAN-Einstellungen beim Laden der Seite abrufen
window.addEventListener('load', loadWifiSettings);
// WLAN-Formular Handler
document.getElementById("wifiForm").addEventListener("submit", function(e) {
e.preventDefault();
const ssid = document.getElementById("wifi-ssid").value;
const password = document.getElementById("wifi-password").value;
if (!ssid) {
showMessage("Bitte WLAN-Namen eingeben", "error");
return;
}
fetch("/api/set-wifi", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: `ssid=${encodeURIComponent(ssid)}&password=${encodeURIComponent(password)}`,
})
.then(response => response.json())
.then(data => {
if (data.success) {
showMessage("WLAN-Einstellungen erfolgreich gespeichert!", "success");
} else {
showMessage(data.error || "Fehler beim Speichern der WLAN-Einstellungen", "error");
}
})
.catch(error => showMessage("Verbindungsfehler", "error"));
});
// Update OTA button access based on license level
function updateOTAButtonAccess(licenseLevel) {
const otaButton = document.getElementById("otaUpdateBtn");