diff --git a/.env.development b/.env.development index 9c858e4..718ab40 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.523 +NEXT_PUBLIC_APP_VERSION=1.6.525 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 bad7e26..aa54173 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.523 +NEXT_PUBLIC_APP_VERSION=1.6.525 NEXT_PUBLIC_CPL_MODE=production \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e16c06..aa65015 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +## [1.6.525] – 2025-07-02 + +- fix: Toast-Benachrichtigungen wiederhergestellt durch Einbindung von ToastContainer + +- in _app.tsx hinzugefügt +- react-toastify funktioniert jetzt wie vorgesehen (z. B. Firmware-Update Feedback) +- autoClose-Zeit für bessere Sichtbarkeit ggf. angepasst + +--- +## [1.6.524] – 2025-07-02 + +- fix: Toast-Benachrichtigungen wiederhergestellt durch Einbindung von ToastContainer + +- in _app.tsx hinzugefügt +- react-toastify funktioniert jetzt wie vorgesehen (z. B. Firmware-Update Feedback) +- autoClose-Zeit für bessere Sichtbarkeit ggf. angepasst + +--- ## [1.6.523] – 2025-07-02 - fix: ConfirmModal-Zustand in Redux ausgelagert zur Stabilisierung diff --git a/components/main/kabelueberwachung/kue705FO/modals/KueEinstellung.tsx b/components/main/kabelueberwachung/kue705FO/modals/KueEinstellung.tsx index 17ab199..32c8ea9 100644 --- a/components/main/kabelueberwachung/kue705FO/modals/KueEinstellung.tsx +++ b/components/main/kabelueberwachung/kue705FO/modals/KueEinstellung.tsx @@ -13,6 +13,7 @@ import { openConfirmModal, closeConfirmModal, } from "@/redux/slices/confirmModalSlice"; +import { startFirmwareUpdateThunk } from "@/redux/thunks/startFirmwareUpdateThunk"; interface Props { slot: number; @@ -57,8 +58,13 @@ export default function KueEinstellung({ (state: RootState) => state.confirmModal.open ); - const [isUpdating, setIsUpdating] = useState(false); - const [progress, setProgress] = useState(0); + const isUpdating = useSelector( + (state: RootState) => state.firmwareProgress.isUpdating + ); + const progress = useSelector( + (state: RootState) => state.firmwareProgress.progress + ); + const [formData, setFormData] = useState(() => { if (typeof window !== "undefined") { const cache = window.__kueCache?.[`slot_${slot}`]; @@ -265,38 +271,13 @@ export default function KueEinstellung({ onConfirm={async () => { dispatch(closeConfirmModal()); toast.info("Firmware-Update gestartet. Bitte warten..."); - setIsUpdating(true); - setProgress(0); - - const totalDuration = 5000; - const intervalMs = 50; - const steps = totalDuration / intervalMs; - let currentStep = 0; - - const interval = setInterval(() => { - currentStep++; - const newProgress = Math.min((currentStep / steps) * 100, 100); - setProgress(newProgress); - - if (currentStep >= steps) { - clearInterval(interval); - setProgress(100); - setTimeout(() => { - toast.success( - "✅ Firmwareupdate erfolgreich abgeschlossen." - ); - setIsUpdating(false); - }, 300); - } - }, intervalMs); + dispatch(startFirmwareUpdateThunk(slot)); // Start Redux-Prozess try { await firmwareUpdate(slot); } catch (err) { console.error("Firmware-Update-Fehler:", err); - clearInterval(interval); toast.error("❌ Fehler beim Firmwareupdate"); - setIsUpdating(false); } }} /> diff --git a/package-lock.json b/package-lock.json index b94631a..10747a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cpl-v4", - "version": "1.6.523", + "version": "1.6.525", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cpl-v4", - "version": "1.6.523", + "version": "1.6.525", "dependencies": { "@fontsource/roboto": "^5.1.0", "@iconify-icons/ri": "^1.2.10", diff --git a/package.json b/package.json index 11fa70a..915c0c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cpl-v4", - "version": "1.6.523", + "version": "1.6.525", "private": true, "scripts": { "dev": "next dev", diff --git a/redux/slices/firmwareProgressSlice.ts b/redux/slices/firmwareProgressSlice.ts new file mode 100644 index 0000000..646adc2 --- /dev/null +++ b/redux/slices/firmwareProgressSlice.ts @@ -0,0 +1,28 @@ +// redux/slices/firmwareProgressSlice.ts +import { createSlice, PayloadAction } from "@reduxjs/toolkit"; + +interface State { + progress: number; + isUpdating: boolean; +} + +const initialState: State = { + progress: 0, + isUpdating: false, +}; + +export const firmwareProgressSlice = createSlice({ + name: "firmwareProgress", + initialState, + reducers: { + setProgress: (state, action: PayloadAction) => { + state.progress = action.payload; + }, + setIsUpdating: (state, action: PayloadAction) => { + state.isUpdating = action.payload; + }, + }, +}); + +export const { setProgress, setIsUpdating } = firmwareProgressSlice.actions; +export default firmwareProgressSlice.reducer; diff --git a/redux/store.ts b/redux/store.ts index 44572ce..bc46e24 100644 --- a/redux/store.ts +++ b/redux/store.ts @@ -28,6 +28,7 @@ import selectedAnalogInputReducer from "./slices/selectedAnalogInputSlice"; import messagesReducer from "./slices/messagesSlice"; import firmwareUpdateReducer from "@/redux/slices/firmwareUpdateSlice"; import confirmModalReducer from "./slices/confirmModalSlice"; +import firmwareProgressReducer from "./slices/firmwareProgressSlice"; const store = configureStore({ reducer: { @@ -58,6 +59,7 @@ const store = configureStore({ messages: messagesReducer, firmwareUpdate: firmwareUpdateReducer, confirmModal: confirmModalReducer, + firmwareProgress: firmwareProgressReducer, }, }); diff --git a/redux/thunks/startFirmwareUpdateThunk.ts b/redux/thunks/startFirmwareUpdateThunk.ts new file mode 100644 index 0000000..31dae43 --- /dev/null +++ b/redux/thunks/startFirmwareUpdateThunk.ts @@ -0,0 +1,31 @@ +// redux/thunks/startFirmwareUpdateThunk.ts +import { AppDispatch } from "../store"; +import { + setProgress, + setIsUpdating, +} from "@/redux/slices/firmwareProgressSlice"; + +export const startFirmwareUpdateThunk = + (slot: number) => async (dispatch: AppDispatch) => { + dispatch(setIsUpdating(true)); + dispatch(setProgress(0)); + + const totalDuration = 5 * 60 * 1000; + const intervalMs = 1000; + const steps = totalDuration / intervalMs; + let currentStep = 0; + + const interval = setInterval(() => { + currentStep++; + const percent = Math.min((currentStep / steps) * 100, 100); + dispatch(setProgress(percent)); + + if (currentStep >= steps) { + clearInterval(interval); + dispatch(setProgress(100)); + setTimeout(() => { + dispatch(setIsUpdating(false)); + }, 500); + } + }, intervalMs); + };