feat: priorityConfig vollständig auf Redux umgestellt – Slice, Thunk und Service integriert und zentral ausgelagert
This commit is contained in:
32
CHANGELOG.md
32
CHANGELOG.md
@@ -4,6 +4,38 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie
|
||||
|
||||
---
|
||||
|
||||
## [1.1.128] – 2025-05-21
|
||||
|
||||
### Changed
|
||||
|
||||
- 🧠 Neue Datenquelle `priorityConfig` vollständig in Redux integriert:
|
||||
- Neuer Service: `fetchPriorityConfigService.js` unter `/services/database/`
|
||||
- Neuer Thunk: `fetchPriorityConfigThunk.js` unter `/redux/thunks/database/`
|
||||
- Neuer Slice: `priorityConfigSlice.js` unter `/redux/slices/database/`
|
||||
- Registrierung im Store (`priorityConfigReducer`) ergänzt
|
||||
- `MapComponent.js` nutzt jetzt `dispatch(fetchPriorityConfigThunk())` zur Initialisierung
|
||||
- Alle alten `useState` + `fetch(...)` für Prioritätsdaten entfernt
|
||||
|
||||
### Fixed
|
||||
|
||||
- ❌ Fehler `fetchPriorityConfigThunk is not defined` behoben durch Import und richtigen Store-Zugriff
|
||||
- ❌ Bug: Redux Slice zeigte keine Daten – Ursache war fehlendes `dispatch` der Thunk-Funktion → behoben
|
||||
|
||||
### Cleanup
|
||||
|
||||
- 🧼 `fetchPriorityConfig` wird ausschließlich zentral über Redux gehandhabt
|
||||
|
||||
### Architekturhinweis
|
||||
|
||||
- 🔄 Komponente wie `MapComponent` ist der Trigger:
|
||||
Thunks, Services und Redux-Slices alleine führen nichts aus – sie müssen durch ein `dispatch(...)` aktiviert werden.
|
||||
|
||||
### Version
|
||||
|
||||
- 📦 Version erhöht auf **1.1.128**
|
||||
|
||||
---
|
||||
|
||||
## [1.1.127] – 2025-05-21
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -59,6 +59,8 @@ import { fetchGisSystemStaticThunk } from "../../redux/thunks/webservice/fetchGi
|
||||
import { fetchGisStationsStaticDistrictThunk } from "../../redux/thunks/webservice/fetchGisStationsStaticDistrictThunk";
|
||||
import { fetchGisStationsStatusDistrictThunk } from "../../redux/thunks/webservice/fetchGisStationsStatusDistrictThunk";
|
||||
import { fetchLocationDevicesThunk } from "../../redux/thunks/database/fetchLocationDevicesThunk";
|
||||
import { fetchPriorityConfigThunk } from "../../redux/thunks/database/fetchPriorityConfigThunk";
|
||||
import { selectPriorityConfig } from "../../redux/slices/database/priorityConfigSlice";
|
||||
|
||||
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const dispatch = useDispatch();
|
||||
@@ -70,7 +72,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const poiTypStatus = useSelector((state) => state.poiTypes.status);
|
||||
const isPoiTypLoaded = useSelector((state) => state.poiTypes.status === "succeeded");
|
||||
const [locationDeviceData, setLocationDeviceData] = useState([]);
|
||||
const [priorityConfig, setPriorityConfig] = useState([]);
|
||||
|
||||
const [menuItemAdded, setMenuItemAdded] = useState(false);
|
||||
const [isPopupOpen, setIsPopupOpen] = useState(false);
|
||||
|
||||
@@ -78,6 +80,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const statusSystem = useSelector((state) => state.gisSystemStatic.status);
|
||||
const statusStaticDistrict = useSelector((state) => state.gisStationsStaticDistrict.status);
|
||||
const statusStatusDistrict = useSelector((state) => state.gisStationsStatusDistrict.status);
|
||||
const priorityConfig = useSelector(selectPriorityConfig);
|
||||
|
||||
const openPopupWithCoordinates = (e) => {
|
||||
const coordinates = `${e.latlng.lat.toFixed(5)}, ${e.latlng.lng.toFixed(5)}`;
|
||||
@@ -211,7 +214,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
dispatch(setUserId(params.get("u")));
|
||||
}, [dispatch]);
|
||||
//---------------------------------------------------------------
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchPriorityConfigThunk());
|
||||
}, [dispatch]);
|
||||
//--------------------------------------------------------
|
||||
useEffect(() => {
|
||||
const endpoint = "/api/talas_v5_DB/gisLines/readGisLines";
|
||||
@@ -533,22 +538,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}, [map, poiLayerRef, isPoiTypLoaded, menuItemAdded, hasRights, isRightsLoaded]);
|
||||
//--------------------------------------------
|
||||
// rote Marker ganz oben wenn überlappen sind
|
||||
useEffect(() => {
|
||||
const fetchPriorityConfig = async () => {
|
||||
try {
|
||||
const res = await fetch("/api/talas_v5_DB/priorityConfig");
|
||||
if (!res.ok) {
|
||||
throw new Error(`HTTP error! status: ${res.status}`);
|
||||
}
|
||||
const data = await res.json();
|
||||
setPriorityConfig(data);
|
||||
} catch (error) {
|
||||
console.error("Failed to load priority configuration:", error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchPriorityConfig();
|
||||
}, []);
|
||||
//--------------------------------------------
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
// /config/appVersion
|
||||
export const APP_VERSION = "1.1.128";
|
||||
export const APP_VERSION = "1.1.129";
|
||||
|
||||
16
redux/slices/database/priorityConfigSlice.js
Normal file
16
redux/slices/database/priorityConfigSlice.js
Normal file
@@ -0,0 +1,16 @@
|
||||
// redux/slices/database/priorityConfigSlice.js
|
||||
import { fetchPriorityConfigThunk } from "../../thunks/database/fetchPriorityConfigThunk";
|
||||
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
const slice = createSlice({
|
||||
name: "priorityConfig",
|
||||
initialState: { data: [], status: "idle" },
|
||||
extraReducers: (builder) => {
|
||||
builder.addCase(fetchPriorityConfigThunk.fulfilled, (state, action) => {
|
||||
state.status = "succeeded";
|
||||
state.data = action.payload;
|
||||
});
|
||||
},
|
||||
});
|
||||
export default slice.reducer;
|
||||
export const selectPriorityConfig = (state) => state.priorityConfig.data;
|
||||
@@ -22,6 +22,7 @@ import readPoiMarkersStoreReducer from "./slices/readPoiMarkersStoreSlice";
|
||||
import selectedAreaReducer from "./slices/selectedAreaSlice";
|
||||
import zoomTriggerReducer from "./slices/zoomTriggerSlice";
|
||||
import urlParameterReducer from "./slices/urlParameterSlice";
|
||||
import priorityConfigReducer from "./slices/database/priorityConfigSlice";
|
||||
|
||||
export const store = configureStore({
|
||||
reducer: {
|
||||
@@ -46,5 +47,6 @@ export const store = configureStore({
|
||||
selectedArea: selectedAreaReducer,
|
||||
zoomTrigger: zoomTriggerReducer,
|
||||
urlParameter: urlParameterReducer,
|
||||
priorityConfig: priorityConfigReducer,
|
||||
},
|
||||
});
|
||||
|
||||
7
redux/thunks/database/fetchPriorityConfigThunk.js
Normal file
7
redux/thunks/database/fetchPriorityConfigThunk.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// /redux/thunks/database/fetchPriorityConfigThunk.js
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchPriorityConfigService } from "../../../services/database/fetchPriorityConfigService";
|
||||
|
||||
export const fetchPriorityConfigThunk = createAsyncThunk("priorityConfig/fetch", async () => {
|
||||
return await fetchPriorityConfigService();
|
||||
});
|
||||
6
services/database/fetchPriorityConfigService.js
Normal file
6
services/database/fetchPriorityConfigService.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// /services/database/fetchLocationDevicesService.js
|
||||
export const fetchPriorityConfigService = async () => {
|
||||
const response = await fetch("/api/talas_v5_DB/priorityConfig");
|
||||
if (!response.ok) throw new Error("Fehler beim Laden der Prioritätskonfiguration");
|
||||
return await response.json();
|
||||
};
|
||||
Reference in New Issue
Block a user