const handleReboot = async (newIp = null) => {
const showWaitPage = () => {
const waitHTML = `
Bitte warten...
Bitte warten, CPL wird neu gestartet...
`;
document.documentElement.innerHTML = waitHTML;
// JavaScript für die Progress-Bar-Animation nach dem Hinzufügen der HTML-Struktur
let progress = 0;
const progressBar = document.getElementById("progress-bar");
const interval = setInterval(() => {
progress += 1;
progressBar.style.width = progress + "%";
if (progress >= 100) {
clearInterval(interval);
}
}, 300); // 300ms x 100 = 30 Sekunden
};
if (
window.confirm("Sind Sie sicher, dass Sie den CPL neu starten möchten?")
) {
showWaitPage();
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);
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;