chore: Entfernen des gesamten hooks-Verzeichnisses mit veralteten Daten-Hooks
- 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
This commit is contained in:
@@ -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};`;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
@@ -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 };
|
||||
}
|
||||
@@ -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};`;
|
||||
|
||||
Reference in New Issue
Block a user