feat: bedingte Weiterleitung nach 35 Sekunden CPL-Neustart basierend auf der Umgebung implementiert
- Zeigt Warte-Seite für 5 Sekunden an, bevor zur Dashboard-Seite weitergeleitet wird - Weiterleitung in der Produktion zu "/dashboard.html" und in der Entwicklung zu "/dashboard" - handleReboot angepasst, um nach 35 Sekunden CPL-Neustart die Verfügbarkeit sicherzustellen und Weiterleitung basierend auf NODE_ENV zu steuern
This commit is contained in:
@@ -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 = `
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Bitte warten...</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
background-color: #f4f4f9;
|
||||
color: #333;
|
||||
}
|
||||
.loader {
|
||||
border: 8px solid #f3f3f3;
|
||||
border-top: 8px solid #3498db;
|
||||
border-radius: 50%;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
animation: spin 1s linear infinite;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
.message {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="message">
|
||||
<div class="loader"></div>
|
||||
<p>Bitte warten, Ihre Anfrage wird bearbeitet...</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
|
||||
// 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);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user