diff --git a/CHANGELOG.md b/CHANGELOG.md index 8060bf6cc..9e284ab39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,27 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie --- +## [1.1.127] – 2025-05-21 + +### Changed + +- 🧱 `fetchLocationDevices.js` wurde vollständig entfernt (lag zuvor unter `/redux/api/fromDB/`) +- Stattdessen wird der neue Service `fetchLocationDevicesService.js` in `/services/database/` verwendet +- Neuer Thunk `fetchLocationDevicesThunk.js` unter `/redux/thunks/database/` eingeführt +- `locationDevicesFromDBSlice.js` ersetzt durch `locationDevicesSlice.js` mit Anbindung an den neuen Thunk +- `MapComponent.js` nutzt jetzt `dispatch(fetchLocationDevicesThunk())` zur Initialisierung der Geräte + +### Cleanup + +- ❌ Alle direkten Service-Imports aus Slices entfernt (Schnittstelle liegt nun nur noch im Thunk) +- 🧼 Zugriff auf `fetchLocationDevicesFromDB()` ersetzt durch `fetchLocationDevicesThunk()` + +### Version + +- 📦 Version erhöht auf **1.1.127** + +--- + ## [1.1.126] – 2025-05-21 ### Cleanup diff --git a/components/mainComponent/MapComponent.js b/components/mainComponent/MapComponent.js index bc5afdd12..12ef4c769 100644 --- a/components/mainComponent/MapComponent.js +++ b/components/mainComponent/MapComponent.js @@ -38,13 +38,9 @@ import CoordinatePopup from "../CoordinatePopup.js"; //------------------------Daten aus API-------------------- import { fetchPoiDataService } from "../../services/database/fetchPoiDataService.js"; import { selectPolylineVisible, setPolylineVisible } from "../../redux/slices/polylineLayerVisibleSlice.js"; -import { fetchLocationDevicesFromDB } from "../../redux/slices/database/locationDevicesFromDBSlice"; - import { selectGisStationsStaticDistrict } from "../../redux/slices/webService/gisStationsStaticDistrictSlice"; - import { selectGisSystemStatic, setGisSystemStatic } from "../../redux/slices/webService/gisSystemStaticSlice"; import ShowAddStationPopup from "../AddPOIModal.js"; - import AddPOIOnPolyline from "../AddPOIOnPolyline"; import { enablePolylineEvents, disablePolylineEvents } from "../../utils/polylines/eventHandlers"; import { updateCountdown, closePolylineContextMenu } from "../../redux/slices/polylineContextMenuSlice"; @@ -57,11 +53,12 @@ import { setSelectedPoi } from "../../redux/slices/selectedPoiSlice"; import { setDisabled } from "../../redux/slices/polylineEventsDisabledSlice"; import { setMapId, setUserId } from "../../redux/slices/urlParameterSlice"; import { fetchPoiTypes } from "../../redux/slices/database/poiTypesSlice"; - +//-----------Redux-Thunks------------------- import { fetchGisStationsMeasurementsThunk } from "../../redux/thunks/webservice/fetchGisStationsMeasurementsThunk"; import { fetchGisSystemStaticThunk } from "../../redux/thunks/webservice/fetchGisSystemStaticThunk"; import { fetchGisStationsStaticDistrictThunk } from "../../redux/thunks/webservice/fetchGisStationsStaticDistrictThunk"; import { fetchGisStationsStatusDistrictThunk } from "../../redux/thunks/webservice/fetchGisStationsStatusDistrictThunk"; +import { fetchLocationDevicesThunk } from "../../redux/thunks/database/fetchLocationDevicesThunk"; const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { const dispatch = useDispatch(); @@ -912,7 +909,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { // speichere location devices in redux store useEffect(() => { - dispatch(fetchLocationDevicesFromDB()); + dispatch(fetchLocationDevicesThunk()); }, [dispatch]); useEffect(() => { diff --git a/config/appVersion.js b/config/appVersion.js index dc3752748..95404f387 100644 --- a/config/appVersion.js +++ b/config/appVersion.js @@ -1,2 +1,2 @@ // /config/appVersion -export const APP_VERSION = "1.1.127"; +export const APP_VERSION = "1.1.128"; diff --git a/redux/api/fromDB/fetchLocationDevices.js b/redux/api/fromDB/fetchLocationDevices.js deleted file mode 100644 index 53595dbdb..000000000 --- a/redux/api/fromDB/fetchLocationDevices.js +++ /dev/null @@ -1,8 +0,0 @@ -// /redux/api/fromDB/fetchLocationDevices.js -export const fetchLocationDevices = async () => { - const response = await fetch("/api/talas_v5_DB/locationDevice/locationDevices"); - if (!response.ok) { - throw new Error("Geräteliste konnte nicht geladen werden"); - } - return await response.json(); -}; diff --git a/redux/middleware/websocketMiddleware.js b/redux/middleware/websocketMiddleware.js deleted file mode 100644 index 75c39637d..000000000 --- a/redux/middleware/websocketMiddleware.js +++ /dev/null @@ -1,29 +0,0 @@ -// /redux/websocketMiddleware.js -const websocketMiddleware = () => { - let socket; - - return ({ dispatch }) => - (next) => - (action) => { - if (action.type === "WS_CONNECT") { - socket = new WebSocket(action.payload.url); - - socket.onmessage = (event) => { - const data = JSON.parse(event.data); - dispatch({ type: "WS_MESSAGE_RECEIVED", payload: data }); - }; - - socket.onclose = () => { - dispatch({ type: "WS_DISCONNECTED" }); - }; - } - - if (action.type === "WS_DISCONNECT" && socket) { - socket.close(); - } - - return next(action); - }; -}; - -export default websocketMiddleware; diff --git a/redux/slices/database/locationDevicesFromDBSlice.js b/redux/slices/database/locationDevicesFromDBSlice.js index c2524f5db..75fcf2675 100644 --- a/redux/slices/database/locationDevicesFromDBSlice.js +++ b/redux/slices/database/locationDevicesFromDBSlice.js @@ -1,10 +1,5 @@ -// /redux/slices/database/locationDevicesFromDBSlice.js -import { createSlice, createAsyncThunk } from "@reduxjs/toolkit"; -import { fetchLocationDevices } from "../../api/fromDB/fetchLocationDevices"; - -export const fetchLocationDevicesFromDB = createAsyncThunk("locationDevicesFromDB/fetchLocationDevicesFromDB", async () => { - return fetchLocationDevices(); -}); +import { createSlice } from "@reduxjs/toolkit"; +import { fetchLocationDevicesThunk } from "../../thunks/database/fetchLocationDevicesThunk"; const locationDevicesFromDBSlice = createSlice({ name: "locationDevicesFromDB", @@ -16,14 +11,14 @@ const locationDevicesFromDBSlice = createSlice({ reducers: {}, extraReducers: (builder) => { builder - .addCase(fetchLocationDevicesFromDB.pending, (state) => { + .addCase(fetchLocationDevicesThunk.pending, (state) => { state.status = "loading"; }) - .addCase(fetchLocationDevicesFromDB.fulfilled, (state, action) => { + .addCase(fetchLocationDevicesThunk.fulfilled, (state, action) => { state.status = "succeeded"; - state.devices = action.payload; // <-- Hier landen die Daten + state.devices = action.payload; }) - .addCase(fetchLocationDevicesFromDB.rejected, (state, action) => { + .addCase(fetchLocationDevicesThunk.rejected, (state, action) => { state.status = "failed"; state.error = action.error.message; }); @@ -31,3 +26,4 @@ const locationDevicesFromDBSlice = createSlice({ }); export default locationDevicesFromDBSlice.reducer; +export const selectLocationDevices = (state) => state.locationDevicesFromDB.devices; diff --git a/redux/thunks/database/fetchLocationDevicesThunk.js b/redux/thunks/database/fetchLocationDevicesThunk.js index 290d54fc0..d2e36fada 100644 --- a/redux/thunks/database/fetchLocationDevicesThunk.js +++ b/redux/thunks/database/fetchLocationDevicesThunk.js @@ -1,4 +1,4 @@ -// /redux/thunks/fetchLocationDevicesThunk.js +// /redux/thunks/database/fetchLocationDevicesThunk.js import { createAsyncThunk } from "@reduxjs/toolkit"; import { fetchLocationDevicesService } from "../../../services/database/fetchLocationDevicesService"; diff --git a/websocket-server.js b/websocket-server.js deleted file mode 100644 index d233ed4cb..000000000 --- a/websocket-server.js +++ /dev/null @@ -1,24 +0,0 @@ -const WebSocket = require("ws"); - -// Starte den WebSocket-Server auf Port 3001 -const wss = new WebSocket.Server({ port: 3001 }); - -wss.on("connection", (ws) => { - console.log("New WebSocket connection"); - - ws.on("message", (message) => { - console.log("Received:", message); - const parsedMessage = JSON.parse(message); - - // Beispielnachricht an den Client zurücksenden - if (parsedMessage.type === "test") { - ws.send(JSON.stringify({ message: `Hallo zurück, ${parsedMessage.message}` })); - } - }); - - ws.on("close", () => { - console.log("WebSocket connection closed"); - }); -}); - -console.log("WebSocket-Server läuft auf ws://localhost:3001");