feat: integriere Systemspannungen und Temperaturen mit Redux Thunk und Slice
- Neues Slice systemVoltTempSlice.ts erstellt für Speicherung von Spannungen und Verlauf - Thunk fetchSystemVoltTempThunk.ts implementiert für asynchrones Laden der Systemwerte - Service fetchSystemVoltTempService.ts verwendet API /api/cpl/systemVoltTempAPIHandler - Mock-Daten in systemVoltTempMockData.js definiert - system.tsx auf Redux umgestellt: useSelector für Werte und Verlauf, fetch per Thunk - store.ts angepasst: systemVoltTempSlice hinzugefügt - Chart.js Darstellung von Spannungen und Temperaturen mit Echtzeit-Update alle 5 Sekunden
This commit is contained in:
15
redux/thunks/fetchSystemVoltTempThunk.ts
Normal file
15
redux/thunks/fetchSystemVoltTempThunk.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
// /redux/thunks/fetchSystemVoltTempThunk.ts
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchSystemVoltTempService } from "../../services/fetchSystemVoltTempService";
|
||||
import { setVoltages, addHistory } from "../slices/systemVoltTempSlice";
|
||||
|
||||
export const fetchSystemVoltTempThunk = createAsyncThunk(
|
||||
"systemVoltTemp/fetch",
|
||||
async (_, { dispatch }) => {
|
||||
const data = await fetchSystemVoltTempService();
|
||||
if (data) {
|
||||
dispatch(setVoltages(data));
|
||||
dispatch(addHistory({ time: Date.now(), ...data }));
|
||||
}
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user