MQTT messages. Button anleren, Wifi frontend

This commit is contained in:
Carsten Graf
2025-06-05 23:34:11 +02:00
parent 3b4f63f072
commit e0d3031d6f
10 changed files with 269 additions and 114 deletions

View File

@@ -134,8 +134,11 @@
</div>
</div>
<div class="section" d="wifiSection" style="display: none;">
<div class="section" id="wifiSection">
<h2>📡 WLAN-Konfiguration</h2>
<div id="wifiRestrictionNotice" class="restriction-notice" style="display: none;">
🔒 WLAN-Konfiguration ist nur mit Lizenz Level 3 oder höher verfügbar. Aktuelle Lizenz: Level <span id="currentLicenseLevel">0</span>
</div>
<form id="wifiForm">
<div class="form-group">
<label for="wifi-ssid">WLAN Name (SSID):</label>
@@ -157,7 +160,7 @@
/>
</div>
<div class="button-group">
<button type="submit" class="btn btn-primary">
<button type="submit" id="wifiSubmitBtn" class="btn btn-primary">
💾 WLAN-Einstellungen speichern
</button>
</div>
@@ -413,6 +416,7 @@
// Check license level and update OTA button accordingly
updateOTAButtonAccess(data.tier || 0);
updateWifiButtonAccess(data.tier || 0)
})
.catch((error) => console.log("Info konnte nicht geladen werden"));
}
@@ -501,8 +505,8 @@
// Update OTA button access based on license level
function updateOTAButtonAccess(licenseLevel) {
const otaButton = document.getElementById("otaUpdateBtn");
const restrictionNotice = document.getElementById("otaRestrictionNotice");
const currentLevelSpan = document.getElementById("currentLicenseLevel");
const otarestrictionNotice = document.getElementById("otaRestrictionNotice");
const otacurrentLevelSpan = document.getElementById("currentLicenseLevel");
const level = parseInt(licenseLevel) || 0;
@@ -510,16 +514,44 @@
// License level 2 or higher - enable OTA
otaButton.classList.remove("btn-disabled");
otaButton.disabled = false;
restrictionNotice.style.display = "none";
otarestrictionNotice.style.display = "none";
} else {
// License level below 2 - disable OTA
otaButton.classList.add("btn-disabled");
otaButton.disabled = true;
restrictionNotice.style.display = "block";
currentLevelSpan.textContent = level;
otarestrictionNotice.style.display = "block";
otacurrentLevelSpan.textContent = level;
}
}
function updateWifiButtonAccess(licenseLevel) {
const wifiSubmitBtn = document.getElementById("wifiSubmitBtn");
const wifiForm = document.getElementById("wifiForm");
const wifiRestrictionNotice = document.getElementById("wifiRestrictionNotice");
const wifiCurrentLevelSpan = document.getElementById("currentLicenseLevel");
const level = parseInt(licenseLevel) || 0;
if (level >= 3) {
// License level 3 or higher - enable form
wifiSubmitBtn.classList.remove("btn-disabled");
wifiSubmitBtn.disabled = false;
wifiForm.querySelectorAll('input').forEach(input => {
input.disabled = false;
});
wifiRestrictionNotice.style.display = "none";
} else {
// License level below 3 - disable form
wifiSubmitBtn.classList.add("btn-disabled");
wifiSubmitBtn.disabled = true;
wifiForm.querySelectorAll('input').forEach(input => {
input.disabled = true;
});
wifiRestrictionNotice.style.display = "block";
wifiCurrentLevelSpan.textContent = level;
}
}
// OTA Update function with license check
function performOTAUpdate() {
const otaButton = document.getElementById("otaUpdateBtn");