diff --git a/.env.development b/.env.development index 3969689..398d3c9 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.676 +NEXT_PUBLIC_APP_VERSION=1.6.677 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 e7a4531..3e64057 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.676 +NEXT_PUBLIC_APP_VERSION=1.6.677 NEXT_PUBLIC_CPL_MODE=production \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index cc2a3e0..a518bc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [1.6.677] – 2025-08-01 + +- fix: link in console + +--- ## [1.6.676] – 2025-08-01 - fix: richtige Link in system fetch service diff --git a/components/main/system/DetailModal.tsx b/components/main/system/DetailModal.tsx index dc5ea89..fe643e1 100644 --- a/components/main/system/DetailModal.tsx +++ b/components/main/system/DetailModal.tsx @@ -135,6 +135,7 @@ export const DetailModal = ({ datasets: [], }); const [isLoading, setIsLoading] = useState(false); + const [shouldUpdateChart, setShouldUpdateChart] = useState(false); const vonDatum = useSelector( (state: RootState) => state.kabelueberwachungChartSlice.vonDatum ); @@ -197,6 +198,13 @@ export const DetailModal = ({ // API-Request beim Klick auf "Daten laden" const handleFetchData = () => { setIsLoading(true); + + // Clear previous chart data + setChartData({ datasets: [] }); + + // Flag setzen, dass Chart nach Datenempfang aktualisiert werden soll + setShouldUpdateChart(true); + switch (selectedKey) { case "+5V": dispatch(getSystemspannung5VplusThunk(zeitraum)); @@ -233,12 +241,6 @@ export const DetailModal = ({ chartRef.current.resetZoom(); } }, [zeitraum]); - // beim start soll der Chart einmal aufgerufen wird, also einmal der Button "Daten laden" geklickt werden - useEffect(() => { - if (isOpen && selectedKey) { - handleFetchData(); - } - }, [isOpen, selectedKey]); // Chart.js animation complete callback to set isLoading false useEffect(() => { @@ -257,6 +259,40 @@ export const DetailModal = ({ } }, [chartData, isLoading]); + // Update chart data when Redux data changes (only after button click) + useEffect(() => { + if (shouldUpdateChart && reduxData && reduxData.length > 0) { + console.log("Redux data for chart:", reduxData); + + // Convert Redux data to Chart.js format + const chartDataPoints = reduxData.map((entry) => ({ + x: new Date(entry.t).getTime(), + y: entry.m || entry.a || entry.i || 0, // Use current value, max, min, or 0 + })); + + const newChartData = { + datasets: [ + { + label: selectedKey || "Messwerte", + data: chartDataPoints, + borderColor: "#00AEEF", // littwin-blue + backgroundColor: "rgba(0, 174, 239, 0.2)", // littwin-blue mit Transparenz + tension: 0.1, + fill: false, + }, + ], + }; + + console.log("Chart data points:", chartDataPoints); + setChartData(newChartData); + setShouldUpdateChart(false); // Reset flag + } else if (shouldUpdateChart && (!reduxData || reduxData.length === 0)) { + console.log("No Redux data available"); + setChartData({ datasets: [] }); + setShouldUpdateChart(false); // Reset flag + } + }, [reduxData, selectedKey, shouldUpdateChart]); + if (!isOpen || !selectedKey) return null; return ( diff --git a/package-lock.json b/package-lock.json index d4cc638..23c233d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cpl-v4", - "version": "1.6.676", + "version": "1.6.677", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cpl-v4", - "version": "1.6.676", + "version": "1.6.677", "dependencies": { "@fontsource/roboto": "^5.1.0", "@headlessui/react": "^2.2.4", diff --git a/package.json b/package.json index 6aaa0d1..ac70d19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cpl-v4", - "version": "1.6.676", + "version": "1.6.677", "private": true, "scripts": { "dev": "next dev",