feat: Firmwareupdate für alle KÜ-Module mit Fortschrittsanzeige und Abschlussmeldung
- ProgressModal-Komponente implementiert, die während des Updates angezeigt wird - Firmwareupdate dauert 5 Minuten (Mock-Simulation) - Nach Abschluss erscheint automatisch ein Toast-Hinweis - Verbesserte Benutzerführung durch blockierendes Modal während Update - Logging in kueFirmwareUpdateLog.json integriert (Mock)
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
// pages/api/cpl/kueFirmwareUpdateMock.ts
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
// Hilfsfunktion für künstliche Verzögerung
|
||||
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
try {
|
||||
const logFilePath = path.join(
|
||||
process.cwd(),
|
||||
@@ -22,22 +29,22 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
existingLog = JSON.parse(fileContent);
|
||||
}
|
||||
|
||||
// Letzten 50 Einträge speichern
|
||||
const updatedLog = [logEntry, ...existingLog].slice(0, 50);
|
||||
|
||||
fs.writeFileSync(logFilePath, JSON.stringify(updatedLog, null, 2), "utf-8");
|
||||
|
||||
console.log("🕒 Starte Firmware-Mock-Wartezeit (5 Minuten)...");
|
||||
await delay(10000); // 5 Minuten simulieren (300.000 ms)
|
||||
|
||||
console.log("✅ Firmwareupdate-Mock abgeschlossen.");
|
||||
res.status(200).json({
|
||||
status: "success",
|
||||
log: logEntry,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Firmwareupdate-Mock:", error);
|
||||
res
|
||||
.status(500)
|
||||
.json({
|
||||
status: "error",
|
||||
message: "Fehler beim Speichern des Firmwareupdates",
|
||||
});
|
||||
console.error("❌ Fehler beim Firmwareupdate-Mock:", error);
|
||||
res.status(500).json({
|
||||
status: "error",
|
||||
message: "Fehler beim Speichern des Firmwareupdates",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user