diff --git a/components/modales/settingsModal/handlers/handleReboot.js b/components/modales/settingsModal/handlers/handleReboot.js index f646563..680792a 100644 --- a/components/modales/settingsModal/handlers/handleReboot.js +++ b/components/modales/settingsModal/handlers/handleReboot.js @@ -1,18 +1,80 @@ -// components/modales/handlers/handleReboot.js -const handleReboot = () => { +const handleReboot = async () => { + // Zeigt eine einfache Warteanzeige direkt in der aktuellen Seite an + const showWaitPage = () => { + const waitHTML = ` + + + + + + Bitte warten... + + + +
+
+

Bitte warten, Ihre Anfrage wird bearbeitet...

+
+ + + `; + + // Ersetzt den gesamten HTML-Inhalt der Seite mit der Warteanzeige + document.documentElement.innerHTML = waitHTML; + }; + if ( window.confirm("Sind Sie sicher, dass Sie den CPL neu starten möchten?") ) { - let currentPath = window.location.pathname; - if (!currentPath.endsWith(".html")) { - currentPath += ".html"; - } + // Zeige die Warte-Seite direkt an + showWaitPage(); - const url = `${window.location.origin}/CPL?${currentPath}&BOOT=1`; + // Umleitung abhängig von der Umgebung nach 5 Sekunden + const redirectURL = + process.env.NODE_ENV === "production" ? "/dashboard.html" : "/dashboard"; + + setTimeout(() => { + window.location.href = `${window.location.origin}${redirectURL}`; + }, 35000); // getestet, Nach 35 Sekunden wird CPL rebootet + + // Führe den `fetch`-Aufruf zum Neustart aus (gleichzeitig) + const url = `${window.location.origin}/CPL?wait2reboot.html&BOOT=1`; console.log(url); - fetch(url, { method: "GET" }).finally(() => { - window.location.href = `/wait`; - }); + + fetch(url, { method: "GET" }) + .then(() => { + console.log("Neustart-Anfrage erfolgreich gesendet."); + }) + .catch((error) => { + console.error("Fehler beim Senden der Neustartanfrage:", error); + }); } };