From c9039de7e889e15df9d8042fc561652fa5bd558e Mon Sep 17 00:00:00 2001 From: Ismail Ali Date: Mon, 28 Apr 2025 21:40:39 +0200 Subject: [PATCH] chore: Entfernen des gesamten hooks-Verzeichnisses mit veralteten Daten-Hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - useDigitalInputsData.ts und useDigitalOutputsData.ts entfernt - Veraltete direkte Laden von window-Variablen aus Mock-Skripten entfernt - Alle Daten werden jetzt ausschließlich über Services und Redux Thunks verwaltet - Projektstruktur aufgeräumt und optimiert --- .../LoopChartActionBar.tsx | 3 +- config/webVersion.ts | 2 +- hooks/einausgaenge/useDigitalInputsData.ts | 56 ---------------- hooks/einausgaenge/useDigitalOutputsData.ts | 66 ------------------- services/fetchLoopChartDataService.ts | 3 +- 5 files changed, 3 insertions(+), 127 deletions(-) delete mode 100644 hooks/einausgaenge/useDigitalInputsData.ts delete mode 100644 hooks/einausgaenge/useDigitalOutputsData.ts diff --git a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx index a01dc11..7431fa4 100644 --- a/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx +++ b/components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx @@ -111,8 +111,7 @@ const LoopChartActionBar: React.FC = () => { const baseUrl = process.env.NODE_ENV === "development" - ? // ? `/CPLmockData/kuesChartData/slot${slotNumber}/${typeFolder}/${mode}.json` - `/api/cpl/slotDataAPIHandler?slot=${slotNumber}&messart=${typeFolder}&dia=${mode}&vonDatum=${vonDatum}&bisDatum=${bisDatum}` + ? `/api/cpl/slotDataAPIHandler?slot=${slotNumber}&messart=${typeFolder}&dia=${mode}&vonDatum=${vonDatum}&bisDatum=${bisDatum}` : `${window.location.origin}/CPL?seite.ACP&${mode}=${formatDate( vonDatum )};${formatDate(bisDatum)};${slotNumber};${type};`; diff --git a/config/webVersion.ts b/config/webVersion.ts index 4da2610..2778ae1 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.294"; +const webVersion = "1.6.295"; export default webVersion; diff --git a/hooks/einausgaenge/useDigitalInputsData.ts b/hooks/einausgaenge/useDigitalInputsData.ts deleted file mode 100644 index e66784c..0000000 --- a/hooks/einausgaenge/useDigitalInputsData.ts +++ /dev/null @@ -1,56 +0,0 @@ -"use client"; // hooks/einausgaenge/useDigitalInputsData.ts -import { useEffect, useState } from "react"; - -export function useDigitalInputData() { - const [mockData, setMockData] = useState({ - win_de: Array(32).fill(0), - win_counter: Array(32).fill(0), - win_flutter: Array(32).fill(0), - }); - const [isLoading, setIsLoading] = useState(true); - - useEffect(() => { - const isDevelopment = window.location.hostname === "localhost"; - const script = document.createElement("script"); - - script.src = isDevelopment - ? "/CPLmockData/SERVICE/de.js" - : "/CPL/SERVICE/de.js"; - script.async = true; - - script.onload = () => { - try { - if ( - typeof win_de !== "undefined" && - typeof win_counter !== "undefined" && - typeof win_flutter !== "undefined" - ) { - setMockData({ - win_de, - win_counter, - win_flutter, - }); - } else { - console.error("Mock-Daten konnten nicht geladen werden."); - } - } catch (error) { - console.error("Fehler beim Zugriff auf die globalen Daten:", error); - } finally { - setIsLoading(false); - } - }; - - script.onerror = () => { - console.error("Fehler beim Laden der Skript-Datei:", script.src); - setIsLoading(false); - }; - - document.body.appendChild(script); - - return () => { - document.body.removeChild(script); - }; - }, []); - - return { mockData, isLoading }; -} diff --git a/hooks/einausgaenge/useDigitalOutputsData.ts b/hooks/einausgaenge/useDigitalOutputsData.ts deleted file mode 100644 index 4fa41ad..0000000 --- a/hooks/einausgaenge/useDigitalOutputsData.ts +++ /dev/null @@ -1,66 +0,0 @@ -"use client"; -import { useEffect } from "react"; -import { useDispatch, useSelector } from "react-redux"; -import { RootState } from "../../redux/store"; -import { setDigitalOutputs } from "../../redux/slices/digitalOutputsSlice"; - -// Typ für digitale Ausgänge -interface DigitalOutput { - id: number; - label: string; - status: boolean; -} - -export function useDigitalOutputs() { - const dispatch = useDispatch(); - const digitalOutputs = useSelector( - (state: RootState) => state.digitalOutputs?.outputs ?? [] - ); - const isLoading = digitalOutputs.length === 0; - - useEffect(() => { - const isDev = window.location.hostname === "localhost"; - - const script = document.createElement("script"); - script.src = isDev ? "/CPLmockData/SERVICE/da.js" : "/CPL/SERVICE/da.js"; - script.async = true; - - script.onload = () => { - const da = window.win_da_state; - const bezeichnungen = window.win_da_bezeichnung; - - if ( - Array.isArray(da) && - Array.isArray(bezeichnungen) && - da.length === bezeichnungen.length - ) { - const outputs: DigitalOutput[] = da.map( - (status: number, index: number) => ({ - id: index + 1, - label: bezeichnungen[index] || `Ausgang ${index + 1}`, - status: status === 1, - }) - ); - - dispatch(setDigitalOutputs(outputs)); - } else { - console.error("Digitale Ausgänge konnten nicht geladen werden.", { - da_state: da, - da_bezeichnung: bezeichnungen, - }); - } - }; - - script.onerror = () => { - console.error("Fehler beim Laden der da.js-Datei."); - }; - - document.body.appendChild(script); - - return () => { - document.body.removeChild(script); - }; - }, [dispatch]); - - return { digitalOutputs, isLoading }; -} diff --git a/services/fetchLoopChartDataService.ts b/services/fetchLoopChartDataService.ts index bf4f43d..eea1055 100644 --- a/services/fetchLoopChartDataService.ts +++ b/services/fetchLoopChartDataService.ts @@ -23,8 +23,7 @@ const getApiUrl = ( : "unbekannterTyp"; return process.env.NEXT_PUBLIC_NODE_ENV === "development" - ? // ? `/CPLmockData/kuesChartData/slot${slotNumber}/${typeFolder}/${mode}.json` - `/api/cpl/slotDataAPIHandler?slot=${slotNumber}&messart=${typeFolder}&dia=${mode}&vonDatum=${vonDatum}&bisDatum=${bisDatum}` + ? `/api/cpl/slotDataAPIHandler?slot=${slotNumber}&messart=${typeFolder}&dia=${mode}&vonDatum=${vonDatum}&bisDatum=${bisDatum}` : `${window.location.origin}/CPL?seite.ACP&${mode}=${formatDate( vonDatum )};${formatDate(bisDatum)};${slotNumber};${type};`;