diff --git a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx index 07b0e6e..4570f75 100644 --- a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx +++ b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx @@ -30,37 +30,33 @@ const LoopChartActionBar: React.FC = () => { * @param mode - DIA0, DIA1 oder DIA2 * @param slotIndex - Slot für die Abfrage */ - const getApiUrl = (mode: "DIA0" | "DIA1" | "DIA2", slotIndex: number) => { - const baseUrl = - process.env.NODE_ENV === "development" - ? `/api/mockChartData?${mode}=true` - : `/CPL?seite.ACP&${mode}=${vonDatum};${bisDatum};${slotIndex}`; - - return baseUrl; + const getApiUrl = (mode: "DIA0" | "DIA1" | "DIA2") => { + return process.env.NODE_ENV === "development" + ? `/CPLmockData/kuesChartData/${mode}.json` + : `/CPL?seite.ACP&${mode}=${vonDatum};${bisDatum};${slotIndex}`; }; /** * Funktion zum Laden der Messwerte */ const handleFetchData = async () => { - const slotIndex = - selectedSlotType === "schleifenwiderstand" - ? schleifenwiderstand - : isolationswiderstand; - try { - const apiUrl = getApiUrl(selectedMode, slotIndex); - const response = await fetch(apiUrl); - const data = await response.json(); + const apiUrl = getApiUrl(selectedMode); + console.log("Mock JSON laden von:", apiUrl); - if (Array.isArray(data)) { - console.log("Daten geladen:", data); - dispatch(setChartData(data)); + const response = await fetch(apiUrl); + if (!response.ok) throw new Error(`Fehler: ${response.status}`); + + const jsonData = await response.json(); + console.log("Geladene Daten:", jsonData); + + if (Array.isArray(jsonData)) { + dispatch(setChartData(jsonData)); } else { - console.error("Erwartetes Array, aber erhalten:", data); + console.error("Erwartetes Array, aber erhalten:", jsonData); } } catch (error) { - console.error("Fehler beim Laden der Daten:", error); + console.error("Fehler beim Laden der Mock-Daten:", error); } }; diff --git a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx index 472a5d2..426cfbb 100644 --- a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx +++ b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx @@ -1,3 +1,4 @@ +// components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopMeasurementChart.tsx import React, { useEffect, useRef } from "react"; import { useSelector } from "react-redux"; import Chart from "chart.js/auto"; diff --git a/config/webVersion.ts b/config/webVersion.ts index 60e6c0e..1ca60d9 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.65"; +const webVersion = "1.6.66"; export default webVersion; diff --git a/pages/api/mockChartData.ts b/pages/api/mockChartData.ts deleted file mode 100644 index 2137555..0000000 --- a/pages/api/mockChartData.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { NextApiRequest, NextApiResponse } from "next"; - -// Feste Mock-Daten für DIA0, DIA1, DIA2 -const mockDataDIA0 = [ - { t: "2025-02-14 12:33:00", m: 11.0, v: 1, i: 11.0, a: 11.0 }, - { t: "2025-02-14 12:30:00", m: 11.2, v: 1, i: 11.0, a: 11.4 }, - { t: "2025-02-14 12:27:00", m: 10.8, v: 1, i: 10.5, a: 11.2 }, -]; - -const mockDataDIA1 = [ - { t: "2025-02-14 12:00:00", i: 10.5, a: 11.0, g: 10.8 }, - { t: "2025-02-14 11:00:00", i: 10.0, a: 10.8, g: 10.4 }, - { t: "2025-02-14 10:00:00", i: 9.5, a: 10.2, g: 9.8 }, -]; - -const mockDataDIA2 = [ - { t: "2025-02-14 00:00:00", i: 10.3, a: 10.9, g: 10.6 }, - { t: "2025-02-13 00:00:00", i: 9.8, a: 10.4, g: 10.1 }, -]; - -// API-Handler für Mock-Daten -export default function handler(req: NextApiRequest, res: NextApiResponse) { - const { DIA0, DIA1, DIA2 } = req.query; - - let responseData = []; - - if (DIA0) { - responseData = mockDataDIA0; - } else if (DIA1) { - responseData = mockDataDIA1; - } else if (DIA2) { - responseData = mockDataDIA2; - } else { - return res - .status(400) - .json({ - error: - "Kein gültiger Parameter übergeben. Verwende DIA0, DIA1 oder DIA2.", - }); - } - - res.status(200).json(responseData); -} diff --git a/public/CPLmockData/kuesChartData/DIA0.json b/public/CPLmockData/kuesChartData/DIA0.json new file mode 100644 index 0000000..44c2350 --- /dev/null +++ b/public/CPLmockData/kuesChartData/DIA0.json @@ -0,0 +1,5 @@ +[ + { "t": "2025-02-14 12:33:00", "m": 11.0, "v": 1, "i": 11.0, "a": 11.0 }, + { "t": "2025-02-14 12:30:00", "m": 11.2, "v": 1, "i": 11.0, "a": 11.4 }, + { "t": "2025-02-14 12:27:00", "m": 10.8, "v": 1, "i": 10.5, "a": 11.2 } +] diff --git a/public/CPLmockData/kuesChartData/DIA1.json b/public/CPLmockData/kuesChartData/DIA1.json new file mode 100644 index 0000000..1239d43 --- /dev/null +++ b/public/CPLmockData/kuesChartData/DIA1.json @@ -0,0 +1,5 @@ +[ + { "t": "2025-02-14 12:00:00", "i": 10.5, "a": 11.0, "g": 10.8 }, + { "t": "2025-02-14 11:00:00", "i": 10.0, "a": 10.8, "g": 10.4 }, + { "t": "2025-02-14 10:00:00", "i": 9.5, "a": 10.2, "g": 9.8 } +] diff --git a/public/CPLmockData/kuesChartData/DIA2.json b/public/CPLmockData/kuesChartData/DIA2.json new file mode 100644 index 0000000..9e27842 --- /dev/null +++ b/public/CPLmockData/kuesChartData/DIA2.json @@ -0,0 +1,4 @@ +[ + { "t": "2025-02-14 00:00:00", "i": 10.3, "a": 10.9, "g": 10.6 }, + { "t": "2025-02-13 00:00:00", "i": 9.8, "a": 10.4, "g": 10.1 } +]