From ecb818e2487909adeabf38a558ff349f991565f6 Mon Sep 17 00:00:00 2001 From: ISA Date: Tue, 1 Jul 2025 07:17:40 +0200 Subject: [PATCH] fix: hide Firmware update button if admin not loged in --- .env.development | 2 +- .env.production | 2 +- .npmrc | 1 + CHANGELOG.md | 5 ++++ .../kue705FO/handlers/firmwareUpdate.ts | 22 ++++++++++------ .../kue705FO/modals/KueEinstellung.tsx | 10 +++++++- .../GeneralSettings.tsx | 10 ++++---- .../singleModuleUpdateResponse.json | 4 +++ package-lock.json | 4 +-- package.json | 2 +- pages/api/cpl/kueSingleModuleUpdateMock.ts | 25 +++++++++++++++++++ 11 files changed, 69 insertions(+), 18 deletions(-) create mode 100644 .npmrc create mode 100644 mocks/device-cgi-simulator/firmwareUpdate/singleModuleUpdateResponse.json create mode 100644 pages/api/cpl/kueSingleModuleUpdateMock.ts diff --git a/.env.development b/.env.development index 5ea6aff..3bd0317 100644 --- a/.env.development +++ b/.env.development @@ -6,6 +6,6 @@ NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false NEXT_PUBLIC_EXPORT_STATIC=false NEXT_PUBLIC_USE_CGI=false # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.6.510 +NEXT_PUBLIC_APP_VERSION=1.6.511 NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter) diff --git a/.env.production b/.env.production index 276ffe3..3924c8f 100644 --- a/.env.production +++ b/.env.production @@ -5,5 +5,5 @@ NEXT_PUBLIC_CPL_API_PATH=/CPL NEXT_PUBLIC_EXPORT_STATIC=true NEXT_PUBLIC_USE_CGI=true # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.6.510 +NEXT_PUBLIC_APP_VERSION=1.6.511 NEXT_PUBLIC_CPL_MODE=production \ No newline at end of file diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..c0c80ba --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +engine-strict=false diff --git a/CHANGELOG.md b/CHANGELOG.md index 073597a..413111f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [1.6.511] – 2025-07-01 + +- feat: alle KÜs Firmware update + +--- ## [1.6.510] – 2025-06-30 - feat: handleKueFirmwareUpdate diff --git a/components/main/kabelueberwachung/kue705FO/handlers/firmwareUpdate.ts b/components/main/kabelueberwachung/kue705FO/handlers/firmwareUpdate.ts index fc76215..b922304 100644 --- a/components/main/kabelueberwachung/kue705FO/handlers/firmwareUpdate.ts +++ b/components/main/kabelueberwachung/kue705FO/handlers/firmwareUpdate.ts @@ -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; diff --git a/components/main/kabelueberwachung/kue705FO/modals/KueEinstellung.tsx b/components/main/kabelueberwachung/kue705FO/modals/KueEinstellung.tsx index e237b91..b5a03f2 100644 --- a/components/main/kabelueberwachung/kue705FO/modals/KueEinstellung.tsx +++ b/components/main/kabelueberwachung/kue705FO/modals/KueEinstellung.tsx @@ -246,7 +246,15 @@ export default function KueEinstellung({
{isAdminLoggedIn && ( - {isAdmin && ( + {isAdminLoggedIn && (