const handleReboot = async (newIp = null) => {
const showWaitPage = () => {
const waitHTML = `
Bitte warten...
Bitte warten, Ihre Anfrage wird bearbeitet...
`;
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;