- handleSubmit aktualisiert, um geänderte IP-Adresse an handleReboot zu übergeben - handleReboot angepasst, um nach Neustart dynamisch zur neuen IP-Adresse weiterzuleiten - Weiterleitung abhängig von Umgebung: in Produktion zu "/dashboard.html" und in Entwicklung zu "/dashboard" - 33 Sekunden Wartezeit hinzugefügt, um CPL-Verfügbarkeit nach Neustart sicherzustellen
78 lines
2.2 KiB
JavaScript
78 lines
2.2 KiB
JavaScript
const handleReboot = async (newIp = null) => {
|
|
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>
|
|
`;
|
|
document.documentElement.innerHTML = waitHTML;
|
|
};
|
|
|
|
if (
|
|
window.confirm("Sind Sie sicher, dass Sie den CPL neu starten möchten?")
|
|
) {
|
|
showWaitPage();
|
|
|
|
// Leite zur neuen IP oder zur ursprünglichen IP basierend auf der Umgebung weiter
|
|
const baseRedirectURL = newIp ? `https://${newIp}` : window.location.origin;
|
|
const redirectPath =
|
|
process.env.NODE_ENV === "production" ? "/dashboard.html" : "/dashboard";
|
|
|
|
setTimeout(() => {
|
|
window.location.href = `${baseRedirectURL}${redirectPath}`;
|
|
}, 33000); // Nach 33 Sekunden umleiten
|
|
|
|
const url = `${window.location.origin}/CPL?wait2reboot.html&BOOT=1`;
|
|
console.log(url);
|
|
|
|
fetch(url, { method: "GET" })
|
|
.then(() => {
|
|
console.log("Neustart-Anfrage erfolgreich gesendet.");
|
|
})
|
|
.catch((error) => {
|
|
console.error("Fehler beim Senden der Neustartanfrage:", error);
|
|
});
|
|
}
|
|
};
|
|
|
|
export default handleReboot;
|