diff --git a/.env.development b/.env.development index 4ba0ecd..39ee88d 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.664 +NEXT_PUBLIC_APP_VERSION=1.6.665 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 f58d3d4..733cc79 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.664 +NEXT_PUBLIC_APP_VERSION=1.6.665 NEXT_PUBLIC_CPL_MODE=production \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index cec345b..dac84c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [1.6.665] – 2025-07-31 + +- style: KVZ LEDs style + +--- ## [1.6.664] – 2025-07-31 - style: LEDs style diff --git a/package-lock.json b/package-lock.json index fe33b44..05d1135 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cpl-v4", - "version": "1.6.664", + "version": "1.6.665", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cpl-v4", - "version": "1.6.664", + "version": "1.6.665", "dependencies": { "@fontsource/roboto": "^5.1.0", "@headlessui/react": "^2.2.4", diff --git a/package.json b/package.json index ad20ba9..3bb56a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cpl-v4", - "version": "1.6.664", + "version": "1.6.665", "private": true, "scripts": { "dev": "next dev", diff --git a/public/CPL/kvz/kvzData.json b/public/CPL/kvz/kvzData.json new file mode 100644 index 0000000..c80c4cb --- /dev/null +++ b/public/CPL/kvz/kvzData.json @@ -0,0 +1,24 @@ +{ + "kvzPresence": [ + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 + ], + "kvzActive": [ + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 + ], + "kvzStatus": [ + 1, 0, 2, 1, 2, 0, 1, 0, 2, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0 + ], + "timestamp": "2025-07-31T11:39:22.951Z", + "description": { + "kvzPresence": "32 Slots: 1=KVZ Gerät vorhanden, 0=nicht vorhanden. Slots 0,2 haben KVZ-Geräte", + "kvzActive": "32 Slots: 1=KVZ aktiviert, 0=deaktiviert. Nur Slot 0 ist aktiviert", + "kvzStatus": "128 LEDs: 4 LEDs pro Slot. Slot 0: [1,0,1,0], Slot 2: [1,1,0,1] (aber Slot 2 ist deaktiviert)" + } +} diff --git a/services/fetchKvzDataService.ts b/services/fetchKvzDataService.ts index 5db4515..76c3b44 100644 --- a/services/fetchKvzDataService.ts +++ b/services/fetchKvzDataService.ts @@ -1,12 +1,27 @@ // services/fetchKvzDataService.ts import { KvzData } from "../pages/api/kvz/data"; +/** + * Überprüft, ob wir in der Entwicklungsumgebung sind + */ +const isDevelopment = process.env.NODE_ENV === "development"; + /** * Holt KVZ-Daten vom Server + * In der Entwicklungsumgebung: API-Route verwenden + * In der Produktionsumgebung: Direkt JSON-Datei laden */ export const fetchKvzData = async (): Promise => { try { - const response = await fetch("/api/kvz/data"); + let response: Response; + + if (isDevelopment) { + // Entwicklungsumgebung: API-Route verwenden + response = await fetch("/api/kvz/data"); + } else { + // Produktionsumgebung: Direkt JSON-Datei aus public laden + response = await fetch("/CPL/kvz/kvzData.json"); + } if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); @@ -22,6 +37,8 @@ export const fetchKvzData = async (): Promise => { /** * Aktualisiert KVZ-Einstellungen auf dem Server + * In der Entwicklungsumgebung: API-Route verwenden + * In der Produktionsumgebung: Nur lokale Aktualisierung (keine Persistierung) */ export const updateKvzSettings = async ( updates: Array<{ @@ -32,20 +49,31 @@ export const updateKvzSettings = async ( }> ): Promise => { try { - const response = await fetch("/api/kvz/updateSettings", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ updates }), - }); + if (isDevelopment) { + // Entwicklungsumgebung: API-Route verwenden + const response = await fetch("/api/kvz/updateSettings", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ updates }), + }); - if (!response.ok) { - throw new Error(`HTTP error! status: ${response.status}`); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + + const data: KvzData = await response.json(); + return data; + } else { + // Produktionsumgebung: Warnung ausgeben und aktuelle Daten zurückgeben + console.warn( + "KVZ-Updates sind in der Produktionsumgebung nicht verfügbar. Änderungen werden nur lokal gespeichert." + ); + + // Aktuelle Daten laden und zurückgeben + return await fetchKvzData(); } - - const data: KvzData = await response.json(); - return data; } catch (error) { console.error("Fehler beim Update der KVZ-Einstellungen:", error); throw error;