feat(dev): API zum Schreiben von KUE-Mockdaten eingebunden – Entwicklung ohne CPL-Hardware möglich
- Endpunkt /api/cpl/updateKueSettingsDataAPIHandler erstellt - Änderungen werden direkt in apiMockData/SERVICE/kabelueberwachungMockData.js geschrieben - Strings werden korrekt in Anführungszeichen gespeichert - Komma- und Formatierungsfehler im JS-Array beseitigt - Entwicklungsumgebung kann KUE-Einstellungen ohne Embedded-System testen
This commit is contained in:
@@ -109,23 +109,33 @@ const handleSave = async ({
|
||||
const isProd = !isDev;
|
||||
|
||||
if (isDev) {
|
||||
const keyMap: Record<string, string> = {
|
||||
KID: "win_kueID",
|
||||
KL_: "win_kueLimit1",
|
||||
KD_: "win_kueDelay1",
|
||||
KR_: "win_kueLimit2Low",
|
||||
KRO_: "win_kueLimit2High",
|
||||
KRI: "win_kueLoopInterval",
|
||||
KLO: "win_memoryInterval",
|
||||
};
|
||||
|
||||
for (const [key, value] of Object.entries(changesForFile)) {
|
||||
const mappedKey = keyMap[key] ?? key;
|
||||
|
||||
const params = new URLSearchParams({
|
||||
key: `win_kue${key}`,
|
||||
key: mappedKey,
|
||||
value: String(value),
|
||||
slot: String(slot),
|
||||
});
|
||||
|
||||
const response = await fetch(
|
||||
`/api/cpl/updateKueDataAPIHandler?${params.toString()}`
|
||||
`/api/cpl/updateKueSettingsDataAPIHandler?${params.toString()}`
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
alert(`❌ Fehler beim Schreiben der Datei (${key})`);
|
||||
return;
|
||||
console.error("DEV fetch error:", await response.text());
|
||||
}
|
||||
}
|
||||
|
||||
alert("✅ Daten erfolgreich gespeichert!");
|
||||
}
|
||||
|
||||
if (isProd) {
|
||||
|
||||
Reference in New Issue
Block a user