From 4a24cb1518171419915c95d6923f0261b77d73a1 Mon Sep 17 00:00:00 2001 From: ISA Date: Fri, 21 Feb 2025 14:33:21 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20API-URL=20f=C3=BCr=20Produktionsumgebun?= =?UTF-8?q?g=20korrigiert=20und=20Debug-Logs=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `getApiUrl` angepasst, um in der Produktionsumgebung die richtige URL zu verwenden. - Verbesserte Fehlerbehandlung in `handleFetchData` mit zusätzlichen `console.log`-Ausgaben. - Setzt `isChartOpen` explizit auf `true`, wenn das Chart geladen wird. - Dadurch funktioniert das Laden der Daten jetzt auch in der Produktionsumgebung. --- .../LoopChartActionBar.tsx | 28 +++++++++++++------ config/webVersion.ts | 2 +- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx index 17e3325..00af967 100644 --- a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx +++ b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx @@ -23,26 +23,35 @@ const LoopChartActionBar: React.FC = () => { * API-URL-Erstellung für Entwicklung und Produktion */ const getApiUrl = (mode: "DIA0" | "DIA1" | "DIA2", type: number) => { - return process.env.NODE_ENV === "development" - ? `/CPLmockData/kuesChartData/${mode}_${type}.json` - : `/CPL?seite.ACP&${mode}=${vonDatum};${bisDatum};${type}`; + const baseUrl = + process.env.NODE_ENV === "development" + ? `/CPLmockData/kuesChartData/${mode}_${type}.json` + : `/CPL?seite.ACP&${mode}=${vonDatum};${bisDatum};${selectedSlotType};${type};`; + + return baseUrl; }; + /** + * Funktion zum Laden der Messwerte + */ /** * Funktion zum Laden der Messwerte */ const handleFetchData = async () => { const type = selectedSlotType === "schleifenwiderstand" ? 4 : 3; + const apiUrl = getApiUrl(selectedMode, type); try { - const apiUrl = getApiUrl(selectedMode, type); - console.log("Mock JSON laden von:", apiUrl); + console.log("📡 API-Request an:", apiUrl); // Debugging + const response = await fetch(apiUrl, { + method: "GET", + headers: { "Content-Type": "application/json" }, + }); - const response = await fetch(apiUrl); if (!response.ok) throw new Error(`Fehler: ${response.status}`); const jsonData = await response.json(); - console.log("Geladene Daten:", jsonData); + console.log("✅ Daten erfolgreich geladen:", jsonData); if (Array.isArray(jsonData)) { dispatch(setChartData(jsonData)); @@ -53,12 +62,13 @@ const LoopChartActionBar: React.FC = () => { const lastDate = new Date(jsonData[0].t); dispatch(setVonDatum(firstDate.toISOString().split("T")[0])); dispatch(setBisDatum(lastDate.toISOString().split("T")[0])); + dispatch(setChartOpen(true)); // Chart öffnen } } else { - console.error("Erwartetes Array, aber erhalten:", jsonData); + console.error("⚠️ Erwartetes Array, aber erhalten:", jsonData); } } catch (error) { - console.error("Fehler beim Laden der Mock-Daten:", error); + console.error("❌ Fehler beim Laden der Produktions-Daten:", error); } }; diff --git a/config/webVersion.ts b/config/webVersion.ts index f76f56c..302d254 100644 --- a/config/webVersion.ts +++ b/config/webVersion.ts @@ -6,5 +6,5 @@ 2: Patch oder Hotfix (Bugfixes oder kleine Änderungen). */ -const webVersion = "1.6.83"; +const webVersion = "1.6.84"; export default webVersion;