selectedChartData slice erstellt

This commit is contained in:
Ismail Ali
2025-03-26 21:08:17 +01:00
parent 626322b079
commit 99d727a925
6 changed files with 69 additions and 32 deletions

View File

@@ -37,8 +37,9 @@ const Kue705FO: React.FC<Kue705FOProps> = ({
`Rendering Kue705FO - SlotIndex: ${slotIndex}, ModulName: ${modulName}` `Rendering Kue705FO - SlotIndex: ${slotIndex}, ModulName: ${modulName}`
); */ ); */
const selectedChartData = useSelector( const selectedChartData = useSelector(
(state: RootState) => state.variables.selectedChartData (state: RootState) => state.selectedChartData.selectedChartData
); );
const dispatch = useDispatch(); const dispatch = useDispatch();
const chartRef = useRef(null); const chartRef = useRef(null);

View File

@@ -6,7 +6,6 @@ import { RootState } from "../../../redux/store";
const VersionInfo: React.FC = () => { const VersionInfo: React.FC = () => {
const appVersion = const appVersion =
//useSelector((state: RootState) => state.variables.appVersion) ||
useSelector((state: RootState) => state.systemSettings.appVersion) || useSelector((state: RootState) => state.systemSettings.appVersion) ||
"Unbekannt"; "Unbekannt";
const webVersion = useSelector( const webVersion = useSelector(

View File

@@ -6,5 +6,5 @@
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen). 2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
*/ */
const webVersion = "1.6.171"; const webVersion = "1.6.172";
export default webVersion; export default webVersion;

View File

@@ -0,0 +1,22 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
interface SelectedChartDataState {
selectedChartData: any;
}
const initialState: SelectedChartDataState = {
selectedChartData: null,
};
const selectedChartDataSlice = createSlice({
name: "selectedChartData",
initialState,
reducers: {
setSelectedChartData(state, action: PayloadAction<any>) {
state.selectedChartData = action.payload;
},
},
});
export const { setSelectedChartData } = selectedChartDataSlice.actions;
export default selectedChartDataSlice.reducer;

View File

@@ -19,6 +19,7 @@ import loopChartReducer from "./slices/loopChartSlice";
import tdmChartReducer from "./slices/tdmChartSlice"; import tdmChartReducer from "./slices/tdmChartSlice";
import tdrDataByIdReducer from "./slices/tdrDataByIdSlice"; import tdrDataByIdReducer from "./slices/tdrDataByIdSlice";
import kueDataReducer from "./slices/kueDataSlice"; import kueDataReducer from "./slices/kueDataSlice";
import selectedChartDataReducer from "./slices/selectedChartDataSlice";
const store = configureStore({ const store = configureStore({
reducer: { reducer: {
@@ -40,6 +41,7 @@ const store = configureStore({
tdmChart: tdmChartReducer, tdmChart: tdmChartReducer,
tdrDataById: tdrDataByIdReducer, tdrDataById: tdrDataByIdReducer,
kueData: kueDataReducer, kueData: kueDataReducer,
selectedChartData: selectedChartDataReducer,
}, },
}); });

View File

@@ -1,36 +1,49 @@
// /services/fetchSystemSettings.ts // /services/fetchSystemSettings.ts
export const fetchSystemSettings = async () => { export const fetchSystemSettings = async () => {
if (typeof window === "undefined") return null; try {
if (typeof window === "undefined") return null;
// ✅ System.js nur bei Bedarf nachladen (Pfad abhängig von Umgebung) await new Promise<void>((resolve, reject) => {
const scriptSrc = const script = document.createElement("script");
process.env.NODE_ENV === "production" script.src = "/CPLmockData/SERVICE/System.js"; // ggf. anpassen
? "/CPL?/CPL/SERVICE/System.js" script.async = true;
: "/CPLmockData/SERVICE/System.js"; script.onload = () => resolve();
script.onerror = () => reject("❌ Fehler beim Laden von System.js");
document.body.appendChild(script);
});
await new Promise<void>((resolve, reject) => { const {
const script = document.createElement("script"); win_deviceName,
script.src = scriptSrc; win_mac1,
script.async = true; win_ip,
script.onload = () => resolve(); win_subnet,
script.onerror = () => reject("❌ Fehler beim Laden von System.js"); win_gateway,
document.body.appendChild(script); win_cplInternalTimestamp,
}); win_ntp1,
win_ntp2,
win_ntp3,
win_ntpTimezone,
win_ntpActive,
win_appVersion,
} = window as any;
const win = window as any; return {
deviceName: win_deviceName,
return { mac1: win_mac1,
deviceName: win.win_deviceName || "", ip: win_ip,
mac1: win.win_mac1 || "", subnet: win_subnet,
ip: win.win_ip || "", gateway: win_gateway,
subnet: win.win_subnet || "", cplInternalTimestamp: win_cplInternalTimestamp,
gateway: win.win_gateway || "", ntp1: win_ntp1,
cplInternalTimestamp: win.win_cplInternalTimestamp || "", ntp2: win_ntp2,
ntp1: win.win_ntp1 || "", ntp3: win_ntp3,
ntp2: win.win_ntp2 || "", ntpTimezone: win_ntpTimezone,
ntp3: win.win_ntp3 || "", ntpActive: win_ntpActive === "1",
ntpTimezone: win.win_ntpTimezone || "", appVersion: win_appVersion, // ✅ jetzt korrekt
ntpActive: win.win_ntpActive || false, };
}; } catch (error) {
console.error("❌ Fehler beim Laden der Systemdaten:", error);
return null;
}
}; };