applikationsversion von Platzhalter anzeigen und in der Einstellung "Systemzeit übernehmen" vorbereitet, muss nur Platzhalter von Kai gesetzt werden

This commit is contained in:
ISA
2024-10-18 14:38:09 +02:00
parent b25951c7ba
commit d76b6b0c6b
5 changed files with 107 additions and 4 deletions

View File

@@ -139,6 +139,47 @@ function SettingModal({ showModal, onClose }) {
alert("Keine Änderungen vorgenommen.");
}
};
const handleSetDateTime = () => {
const currentDate = new Date();
// Format date and time as required by the system:
const year = currentDate.getFullYear().toString().slice(-2); // Last two digits of the year
const month = String(currentDate.getMonth() + 1).padStart(2, "0"); // Month (1-12)
const day = String(currentDate.getDate()).padStart(2, "0"); // Day (1-31)
const hours = String(currentDate.getHours()).padStart(2, "0"); // Hours (0-23)
const minutes = String(currentDate.getMinutes()).padStart(2, "0"); // Minutes (0-59)
const seconds = String(currentDate.getSeconds()).padStart(2, "0"); // Seconds (0-59)
// Date command
const dateCommand = `CLK00=${year}-${month}-${day}`;
// Time command
const timeCommand = `CLK01=${hours}-${minutes}-${seconds}`;
// Send the commands to the server using fetch and GET method
fetch(`/CPL?${dateCommand}`, { method: "GET" })
.then((response) => {
if (response.ok) {
alert("Datum erfolgreich gesetzt!");
return fetch(`/CPL?${timeCommand}`, { method: "GET" });
} else {
alert("Fehler beim Setzen des Datums!");
throw new Error("Date setting failed.");
}
})
.then((response) => {
if (response.ok) {
alert("Uhrzeit erfolgreich gesetzt!");
} else {
alert("Fehler beim Setzen der Uhrzeit!");
}
})
.catch((error) => {
console.error("Fehler:", error);
alert("Fehler beim Setzen von Datum und Uhrzeit!");
});
};
return (
<>
@@ -272,7 +313,7 @@ function SettingModal({ showModal, onClose }) {
"Möchten Sie wirklich die Systemzeit übernehmen?"
)
) {
setSystemUhr(new Date().toLocaleString());
handleSetDateTime();
}
}}
>