fix: hide Firmware update button if admin not loged in
This commit is contained in:
@@ -1,16 +1,24 @@
|
||||
// /komponents/main/kabelueberwachung/kue705FO/handlers/firmwareUpdate.ts
|
||||
const firmwareUpdate = (slot: number) => {
|
||||
const url = `${window.location.origin}/CPL?/kabelueberwachung.html&KSU${slot}=1`;
|
||||
const isDev =
|
||||
typeof window !== "undefined" && window.location.hostname === "localhost";
|
||||
const url = isDev
|
||||
? `${window.location.origin}/api/cpl/kueSingleModuleUpdateMock?slot=${
|
||||
slot + 1
|
||||
}`
|
||||
: `${window.location.origin}/CPL?/kabelueberwachung.html&KSU${slot}=1`;
|
||||
|
||||
fetch(url, { method: "GET" })
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
alert(`Update an ${slot + 1} erfolgreich gestartet!`);
|
||||
} else {
|
||||
alert("Fehler beim Update!");
|
||||
}
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
alert(
|
||||
data.message || `Update an Slot ${slot + 1} erfolgreich gestartet!`
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Fehler:", error);
|
||||
alert("Fehler beim Update!");
|
||||
});
|
||||
};
|
||||
|
||||
export default firmwareUpdate;
|
||||
|
||||
@@ -246,7 +246,15 @@ export default function KueEinstellung({
|
||||
<div className="flex justify-end gap-2 p-0 rounded">
|
||||
{isAdminLoggedIn && (
|
||||
<button
|
||||
onClick={() => firmwareUpdate(slot)}
|
||||
onClick={() => {
|
||||
if (
|
||||
window.confirm(
|
||||
"Warnung: Das Firmware-Update kann einige Minuten dauern und das Gerät neu starten.\nMöchten Sie wirklich fortfahren?"
|
||||
)
|
||||
) {
|
||||
firmwareUpdate(slot);
|
||||
}
|
||||
}}
|
||||
className="bg-littwin-blue text-white px-4 py-2 rounded flex items-center"
|
||||
>
|
||||
Firmware Update
|
||||
|
||||
Reference in New Issue
Block a user