This commit is contained in:
Ismail Ali
2025-06-26 22:56:20 +02:00
parent 137839da98
commit b9651a53a9
82 changed files with 7476 additions and 4171 deletions

View File

@@ -34,7 +34,6 @@ if (!mockFilePath) {
// Funktion zum Parsen bei jsSimulatedProd
function extractMockData(raw: string) {
const context = {};
const func = new Function(
"context",
`
@@ -81,11 +80,9 @@ export default async function handler(
const rawContent = fs.readFileSync(mockFilePath!, "utf-8");
// 3⃣ JSON vs JS Verarbeitung
const data =
mode === "json" ? JSON.parse(rawContent) : extractMockData(rawContent);
// 4⃣ Aktualisieren der Felder
if (typeof label === "string") data.win_de_label[id - 1] = label;
if (typeof invert === "number") data.win_de_invert[id - 1] = invert;
if (typeof timeFilter === "number")
@@ -97,7 +94,6 @@ export default async function handler(
if (typeof eingangOffline === "number")
data.win_de_offline[id - 1] = eingangOffline;
// 5⃣ Speichern
if (mode === "json") {
fs.writeFileSync(mockFilePath!, JSON.stringify(data, null, 2), "utf-8");
} else {
@@ -128,8 +124,12 @@ var win_de_label = ${JSON.stringify(data.win_de_label, null, 2)};
weighting,
eingangOffline,
});
} catch (err: any) {
console.error("Fehler beim Schreiben:", err);
} catch (err: unknown) {
if (err instanceof Error) {
console.error("Fehler beim Schreiben:", err.message);
} else {
console.error("Unbekannter Fehler beim Schreiben:", err);
}
return res.status(500).json({ error: "Update fehlgeschlagen" });
}
}