refactor: GIS-Redux-Slices reduziert auf 4 (statt 5) – veraltete Slices und Thunks entfernt, Code bereinigt
This commit is contained in:
23
CHANGELOG.md
23
CHANGELOG.md
@@ -4,6 +4,29 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie
|
||||
|
||||
---
|
||||
|
||||
## [1.1.123] – 2025-05-21
|
||||
|
||||
### Changed
|
||||
|
||||
- 🔁 GIS-Datenquellen konsolidiert: Statt 5 werden jetzt nur 4 zentrale Redux-Slices verwendet:
|
||||
- ✅ Beibehalten: `gisStationsMeasurements`, `gisStationsStaticDistrict`, `gisStationsStatusDistrict`, `gisSystemStatic`
|
||||
- ❌ Entfernt: `gisStationsStatic` (veraltet / wurde durch `StaticDistrict` ersetzt)
|
||||
|
||||
### Fixed
|
||||
|
||||
- `MapComponent.js` und `DataSheet.js` bereinigt:
|
||||
- Alle Zugriffe auf `gisStationsStatic` entfernt
|
||||
- Zugriff erfolgt nur noch über `selectGisStationsStaticDistrict`
|
||||
|
||||
### Cleanup
|
||||
|
||||
- 🧼 Thunks, Services und Slices konsistent:
|
||||
- Alle Slices verwenden jetzt zentrale Thunks
|
||||
- Nicht benötigte Dateien (`fetchGisStatusStationsService.js`, `fetchGisStatusStationsThunk.js`, `gisStationsStaticSlice.js`) entfernt
|
||||
- Redux DevTools zeigen saubere States mit `status: "succeeded"` für alle vier aktiven GIS-Quellen
|
||||
|
||||
---
|
||||
|
||||
## [1.1.122] – 2025-05-20
|
||||
|
||||
### Documentation
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import React, { useState, useEffect, use } from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import { setPoiMarkers } from "../redux/slices/readPoiMarkersStoreSlice";
|
||||
import { selectGisStationsStatic } from "../redux/slices/webService/gisStationsStaticSlice";
|
||||
import { selectGisStationsStaticDistrict } from "../redux/slices/webService/gisStationsStaticDistrictSlice";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { fetchPoiTypes } from "../redux/slices/db/poiTypesSlice";
|
||||
import { incrementTrigger } from "../redux/slices/poiReadFromDbTriggerSlice";
|
||||
@@ -51,7 +51,7 @@ const ShowAddStationPopup = ({ onClose, map, latlng }) => {
|
||||
}, [poiTypeId]);
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
const gisStationsStatic = useSelector(selectGisStationsStatic);
|
||||
const gisStationsStatic = useSelector(selectGisStationsStaticDistrict);
|
||||
const locationDeviceData = gisStationsStatic?.Points ?? [];
|
||||
|
||||
console.log("gisStationsStatic aus AddPOIModal:", gisStationsStatic);
|
||||
|
||||
@@ -5,9 +5,6 @@ import EditModeToggle from "./EditModeToggle";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { selectPolylineVisible, setPolylineVisible } from "../redux/slices/polylineLayerVisibleSlice";
|
||||
import { selectGisSystemStatic } from "../redux/slices/webService/gisSystemStaticSlice";
|
||||
import { fetchGisStationsStatic } from "../redux/slices/webService/gisStationsStaticSlice";
|
||||
|
||||
import { selectGisStationsStatic } from "../redux/slices/webService/gisStationsStaticSlice";
|
||||
import { selectGisStationsStaticDistrict } from "../redux/slices/webService/gisStationsStaticDistrictSlice";
|
||||
import { selectMapLayersState, setLayerVisibility } from "../redux/slices/mapLayersSlice";
|
||||
import { setVisible } from "../redux/slices/poiLayerVisibleSlice";
|
||||
@@ -23,7 +20,6 @@ function DataSheet() {
|
||||
const [systemListing, setSystemListing] = useState([]);
|
||||
const GisStationsStaticDistrict = useSelector(selectGisStationsStaticDistrict) || [];
|
||||
const GisSystemStatic = useSelector(selectGisSystemStatic) || [];
|
||||
const GisStationsStatic = useSelector(selectGisStationsStatic) || []; //Area-Name/Bereiche dropdownmenu
|
||||
|
||||
const polylineVisible = useSelector(selectPolylineVisible);
|
||||
|
||||
@@ -38,9 +34,6 @@ function DataSheet() {
|
||||
}
|
||||
};
|
||||
|
||||
const [bereicheVisible, setBereicheVisible] = useState(false); // NEU: Bereiche-Status
|
||||
const [standordVisible, setStandorteVisible] = useState(false); // NEU: Standorte-Status
|
||||
|
||||
useEffect(() => {
|
||||
// LocalStorage Werte laden
|
||||
const storedPoiVisible = localStorage.getItem("poiVisible");
|
||||
@@ -111,7 +104,7 @@ function DataSheet() {
|
||||
key: system.Name.replace(/[\s\-]+/g, ""), // Internen Schlüssel für die MapLayersVisibility-Logik
|
||||
}))
|
||||
);
|
||||
}, [GisStationsStaticDistrict, GisSystemStatic]);
|
||||
}, [GisStationsStaticDistrict]);
|
||||
|
||||
const handleCheckboxChange = (key, event) => {
|
||||
if (editMode) return;
|
||||
@@ -137,52 +130,27 @@ function DataSheet() {
|
||||
dispatch(incrementZoomTrigger());
|
||||
};
|
||||
|
||||
//---------------------------
|
||||
const handleBereicheCheckboxChange = (event) => {
|
||||
if (editMode) return;
|
||||
const { checked } = event.target;
|
||||
setBereicheVisible(checked);
|
||||
localStorage.setItem("bereicheVisible", checked);
|
||||
};
|
||||
const handleStandorteCheckboxChange = (event) => {
|
||||
if (editMode) return;
|
||||
const { checked } = event.target;
|
||||
setStandorteVisible(checked);
|
||||
localStorage.setItem("standorteVisible", checked);
|
||||
};
|
||||
//------------------------------
|
||||
useEffect(() => {
|
||||
// console.log("GisSystemStatic aus Redux:", GisSystemStatic); // ✅ Debugging: Ist es ein Array?
|
||||
}, [GisSystemStatic]);
|
||||
//-----------------------------
|
||||
console.log("🔍 GisStationsStaticDistrict Inhalt:", GisStationsStaticDistrict);
|
||||
|
||||
useEffect(() => {
|
||||
if (!GisStationsStatic || GisStationsStatic === null) {
|
||||
dispatch(fetchGisStationsStatic());
|
||||
}
|
||||
}, [GisStationsStatic, dispatch]);
|
||||
|
||||
//---------------------------
|
||||
useEffect(() => {
|
||||
console.log("🔍 GisStationsStatic Inhalt:", GisStationsStatic);
|
||||
|
||||
if (!GisStationsStatic) {
|
||||
console.warn("⚠️ GisStationsStatic ist `null` oder nicht geladen.");
|
||||
if (!GisStationsStaticDistrict) {
|
||||
console.warn("⚠️ GisStationsStaticDistrict ist `null` oder nicht geladen.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof GisStationsStatic !== "object") {
|
||||
console.warn("⚠️ GisStationsStatic ist kein Objekt:", GisStationsStatic);
|
||||
if (typeof GisStationsStaticDistrict !== "object") {
|
||||
console.warn("⚠️ GisStationsStaticDistrict ist kein Objekt:", GisStationsStaticDistrict);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GisStationsStatic.Points || !Array.isArray(GisStationsStatic.Points)) {
|
||||
console.warn("⚠️ GisStationsStatic.Points ist nicht vorhanden oder kein Array.", GisStationsStatic);
|
||||
if (!GisStationsStaticDistrict.Points || !Array.isArray(GisStationsStaticDistrict.Points)) {
|
||||
console.warn("⚠️ GisStationsStaticDistrict.Points ist nicht vorhanden oder kein Array.", GisStationsStaticDistrict);
|
||||
return;
|
||||
}
|
||||
|
||||
const seenNames = new Set();
|
||||
const filteredAreas = GisStationsStatic.Points.filter((item) => {
|
||||
const filteredAreas = GisStationsStaticDistrict.Points.filter((item) => {
|
||||
if (!item.Area_Name) return false; // Sicherstellen, dass Area_Name existiert
|
||||
const isUnique = !seenNames.has(item.Area_Name);
|
||||
if (isUnique) {
|
||||
@@ -199,7 +167,7 @@ function DataSheet() {
|
||||
);
|
||||
|
||||
console.log("📌 stationListing aktualisiert:", filteredAreas);
|
||||
}, [GisStationsStatic]);
|
||||
}, [GisStationsStaticDistrict]);
|
||||
|
||||
//---------------------------
|
||||
return (
|
||||
|
||||
@@ -39,14 +39,12 @@ import CoordinatePopup from "../CoordinatePopup.js";
|
||||
import { fetchPoiDataService } from "../../services/database/fetchPoiDataService.js";
|
||||
import { selectPolylineVisible, setPolylineVisible } from "../../redux/slices/polylineLayerVisibleSlice.js";
|
||||
import { fetchLocationDevicesFromDB } from "../../redux/slices/db/locationDevicesFromDBSlice";
|
||||
import { fetchGisStationsStaticDistrictFromWebService } from "../../redux/slices/webService/gisStationsStaticDistrictSlice";
|
||||
|
||||
import { selectGisStationsStaticDistrict } from "../../redux/slices/webService/gisStationsStaticDistrictSlice";
|
||||
import { fetchGisStationsStatusDistrictFromWebService } from "../../redux/slices/webService/gisStationsStatusDistrictSlice";
|
||||
import { fetchGisStationsMeasurementsFromWebService } from "../../redux/slices/webService/gisStationsMeasurementsSlice";
|
||||
import { fetchGisSystemStaticFromWebService } from "../../redux/slices/webService/gisSystemStaticSlice";
|
||||
|
||||
import { selectGisSystemStatic, setGisSystemStatic } from "../../redux/slices/webService/gisSystemStaticSlice";
|
||||
import ShowAddStationPopup from "../AddPOIModal.js";
|
||||
import { fetchGisStationsStatic } from "../../redux/slices/webService/gisStationsStaticSlice";
|
||||
|
||||
import AddPOIOnPolyline from "../AddPOIOnPolyline";
|
||||
import { enablePolylineEvents, disablePolylineEvents } from "../../utils/polylines/eventHandlers";
|
||||
import { updateCountdown, closePolylineContextMenu } from "../../redux/slices/polylineContextMenuSlice";
|
||||
@@ -60,6 +58,11 @@ import { setDisabled } from "../../redux/slices/polylineEventsDisabledSlice";
|
||||
import { setMapId, setUserId } from "../../redux/slices/urlParameterSlice";
|
||||
import { fetchPoiTypes } from "../../redux/slices/db/poiTypesSlice";
|
||||
|
||||
import { fetchGisStationsMeasurementsThunk } from "../../redux/thunks/fetchGisStationsMeasurementsThunk";
|
||||
import { fetchGisSystemStaticThunk } from "../../redux/thunks/fetchGisSystemStaticThunk";
|
||||
import { fetchGisStationsStaticDistrictThunk } from "../../redux/thunks/fetchGisStationsStaticDistrictThunk";
|
||||
import { fetchGisStationsStatusDistrictThunk } from "../../redux/thunks/fetchGisStationsStatusDistrictThunk";
|
||||
|
||||
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const dispatch = useDispatch();
|
||||
const countdown = useSelector((state) => state.polylineContextMenu.countdown);
|
||||
@@ -74,6 +77,11 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const [menuItemAdded, setMenuItemAdded] = useState(false);
|
||||
const [isPopupOpen, setIsPopupOpen] = useState(false);
|
||||
|
||||
const statusMeasurements = useSelector((state) => state.gisStationsMeasurements.status);
|
||||
const statusSystem = useSelector((state) => state.gisSystemStatic.status);
|
||||
const statusStaticDistrict = useSelector((state) => state.gisStationsStaticDistrict.status);
|
||||
const statusStatusDistrict = useSelector((state) => state.gisStationsStatusDistrict.status);
|
||||
|
||||
const openPopupWithCoordinates = (e) => {
|
||||
const coordinates = `${e.latlng.lat.toFixed(5)}, ${e.latlng.lng.toFixed(5)}`;
|
||||
setCurrentCoordinates(coordinates);
|
||||
@@ -873,6 +881,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
);
|
||||
}
|
||||
}, [map, menuItemAdded]);
|
||||
//--------------------------------------------
|
||||
|
||||
//--------------------------------------------
|
||||
// Beim ersten Client-Render den Wert aus localStorage laden
|
||||
@@ -880,6 +889,24 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const storedPolylineVisible = localStorage.getItem("polylineVisible") === "true";
|
||||
dispatch(setPolylineVisible(storedPolylineVisible));
|
||||
}, [dispatch]);
|
||||
//--------------------------------------------
|
||||
useEffect(() => {
|
||||
if (statusMeasurements === "idle") {
|
||||
dispatch(fetchGisStationsMeasurementsThunk());
|
||||
}
|
||||
}, [statusMeasurements, dispatch]);
|
||||
|
||||
useEffect(() => {
|
||||
if (statusSystem === "idle") {
|
||||
dispatch(fetchGisSystemStaticThunk());
|
||||
}
|
||||
}, [statusSystem, dispatch]);
|
||||
|
||||
useEffect(() => {
|
||||
if (statusStatusDistrict === "idle") {
|
||||
dispatch(fetchGisStationsStatusDistrictThunk());
|
||||
}
|
||||
}, [statusStatusDistrict, dispatch]);
|
||||
|
||||
//----------------------------------------------
|
||||
// speichere location devices in redux store
|
||||
@@ -889,26 +916,15 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}, [dispatch]);
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchGisStationsStaticDistrictFromWebService());
|
||||
dispatch(fetchGisStationsStaticDistrictThunk());
|
||||
}, [dispatch]);
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchGisStationsStatusDistrictFromWebService());
|
||||
dispatch(fetchGisStationsMeasurementsThunk());
|
||||
}, [dispatch]);
|
||||
useEffect(() => {
|
||||
dispatch(fetchGisStationsMeasurementsFromWebService());
|
||||
dispatch(fetchGisSystemStaticThunk());
|
||||
}, [dispatch]);
|
||||
useEffect(() => {
|
||||
dispatch(fetchGisSystemStaticFromWebService());
|
||||
}, [dispatch]);
|
||||
|
||||
const gisStationsStatic = useSelector((state) => state.gisStationsStatic.data);
|
||||
|
||||
useEffect(() => {
|
||||
if (!gisStationsStatic) {
|
||||
dispatch(fetchGisStationsStatic());
|
||||
}
|
||||
}, [gisStationsStatic, dispatch]);
|
||||
|
||||
//--------------------------------------
|
||||
useEffect(() => {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
// /config/appVersion
|
||||
export const APP_VERSION = "1.1.122";
|
||||
export const APP_VERSION = "1.1.124";
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "19.05.2025 NodeMap",
|
||||
"name": "21.05.2025 NodeMap",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
// /redux/slices/webService/gisStationsMeasurementsSlice.js
|
||||
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchGisStationsMeasurements } from "../../api/fromWebService/fetchGisStationsMeasurements";
|
||||
|
||||
export const fetchGisStationsMeasurementsFromWebService = createAsyncThunk("gisStationsMeasurements/fetchGisStationsMeasurementsFromWebService", async () => {
|
||||
return fetchGisStationsMeasurements();
|
||||
});
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
import { fetchGisStationsMeasurementsThunk } from "../../thunks/fetchGisStationsMeasurementsThunk";
|
||||
|
||||
const gisStationsMeasurementsSlice = createSlice({
|
||||
const slice = createSlice({
|
||||
name: "gisStationsMeasurements",
|
||||
initialState: {
|
||||
data: [],
|
||||
@@ -16,20 +13,19 @@ const gisStationsMeasurementsSlice = createSlice({
|
||||
reducers: {},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
.addCase(fetchGisStationsMeasurementsFromWebService.pending, (state) => {
|
||||
.addCase(fetchGisStationsMeasurementsThunk.pending, (state) => {
|
||||
state.status = "loading";
|
||||
})
|
||||
.addCase(fetchGisStationsMeasurementsFromWebService.fulfilled, (state, action) => {
|
||||
.addCase(fetchGisStationsMeasurementsThunk.fulfilled, (state, action) => {
|
||||
state.status = "succeeded";
|
||||
state.data = action.payload;
|
||||
})
|
||||
.addCase(fetchGisStationsMeasurementsFromWebService.rejected, (state, action) => {
|
||||
.addCase(fetchGisStationsMeasurementsThunk.rejected, (state, action) => {
|
||||
state.status = "failed";
|
||||
state.error = action.error.message;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export default slice.reducer;
|
||||
export const selectGisStationsMeasurements = (state) => state.gisStationsMeasurements.data;
|
||||
|
||||
export default gisStationsMeasurementsSlice.reducer;
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
// /redux/slices/webService/gisStationsStaticDistrictSlice.js
|
||||
// redux/slices/webService/gisStationsStaticDistrictSlice.js
|
||||
|
||||
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchGisStationsStaticDistrict } from "../../api/fromWebService/fetchGisStationsStaticDistrict";
|
||||
import { fetchGisStationsStaticDistrictService } from "../../../services/webservice/fetchGisStationsStaticDistrictService";
|
||||
|
||||
export const fetchGisStationsStaticDistrictFromWebService = createAsyncThunk("gisStationsStaticDistrict/fetchGisStationsStaticDistrictFromWebService", async () => {
|
||||
return fetchGisStationsStaticDistrict();
|
||||
});
|
||||
import { fetchGisStationsStaticDistrictThunk } from "../../thunks/fetchGisStationsStaticDistrictThunk";
|
||||
|
||||
const gisStationsStaticDistrictSlice = createSlice({
|
||||
const slice = createSlice({
|
||||
name: "gisStationsStaticDistrict",
|
||||
initialState: {
|
||||
data: [],
|
||||
data: { Points: [] }, // Daten als Objekt mit Points-Array
|
||||
status: "idle",
|
||||
error: null,
|
||||
},
|
||||
reducers: {},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
.addCase(fetchGisStationsStaticDistrictFromWebService.pending, (state) => {
|
||||
.addCase(fetchGisStationsStaticDistrictThunk.pending, (state) => {
|
||||
state.status = "loading";
|
||||
})
|
||||
.addCase(fetchGisStationsStaticDistrictFromWebService.fulfilled, (state, action) => {
|
||||
.addCase(fetchGisStationsStaticDistrictThunk.fulfilled, (state, action) => {
|
||||
state.status = "succeeded";
|
||||
state.data = action.payload;
|
||||
state.data = { Points: action.payload }; // kompatibel mit Zugriff .Points
|
||||
})
|
||||
.addCase(fetchGisStationsStaticDistrictFromWebService.rejected, (state, action) => {
|
||||
.addCase(fetchGisStationsStaticDistrictThunk.rejected, (state, action) => {
|
||||
state.status = "failed";
|
||||
state.error = action.error.message;
|
||||
});
|
||||
@@ -31,5 +30,4 @@ const gisStationsStaticDistrictSlice = createSlice({
|
||||
});
|
||||
|
||||
export const selectGisStationsStaticDistrict = (state) => state.gisStationsStaticDistrict.data;
|
||||
|
||||
export default gisStationsStaticDistrictSlice.reducer;
|
||||
export default slice.reducer;
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
// /redux/slices/webService/gisStationsStaticSlice.js
|
||||
// das ist für Datasheet dropdownmenu Bereiche/Area-Name
|
||||
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
||||
|
||||
// API-Fetch-Funktion für GIS Stations Static mit dynamischem URL-Parameter
|
||||
export const fetchGisStationsStatic = createAsyncThunk("gisStationsStatic/fetchGisStationsStatic", async (_, { rejectWithValue }) => {
|
||||
try {
|
||||
const host = window.location.hostname;
|
||||
const protocol = window.location.protocol;
|
||||
const apiPort = 80; // Oder aus einer Umgebungsvariable
|
||||
const apiBaseUrl = `${protocol}//${host}:${apiPort}/talas5/ClientData/WebServiceMap.asmx`;
|
||||
|
||||
// URL-Parameter aus der aktuellen Browser-URL holen
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const idMap = params.get("m");
|
||||
|
||||
const url = `${apiBaseUrl}/GisStationsStatic?idMap=${idMap}`;
|
||||
console.log("📡 API Request URL in redux slice:", url);
|
||||
|
||||
const response = await fetch(url);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("GisStationsStatic konnte nicht geladen werden");
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
return rejectWithValue(error.message);
|
||||
}
|
||||
});
|
||||
|
||||
// Redux-Slice
|
||||
const gisStationsStaticSlice = createSlice({
|
||||
name: "gisStationsStatic",
|
||||
initialState: {
|
||||
data: null,
|
||||
status: "idle",
|
||||
error: null,
|
||||
},
|
||||
reducers: {},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
.addCase(fetchGisStationsStatic.pending, (state) => {
|
||||
state.status = "loading";
|
||||
})
|
||||
.addCase(fetchGisStationsStatic.fulfilled, (state, action) => {
|
||||
state.status = "succeeded";
|
||||
state.data = action.payload;
|
||||
})
|
||||
.addCase(fetchGisStationsStatic.rejected, (state, action) => {
|
||||
state.status = "failed";
|
||||
state.error = action.payload;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
// Selector-Funktion
|
||||
export const selectGisStationsStatic = (state) => state.gisStationsStatic.data;
|
||||
|
||||
export default gisStationsStaticSlice.reducer;
|
||||
@@ -1,12 +1,11 @@
|
||||
// /redux/slices/webService/gisStationsStatusDistrictSlice.js
|
||||
|
||||
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchGisStationsStatusDistrict } from "../../api/fromWebService/fetchGisStationsStatusDistrict";
|
||||
import { fetchGisStationsStatusDistrictService } from "../../../services/webservice/fetchGisStationsStatusDistrictService";
|
||||
|
||||
export const fetchGisStationsStatusDistrictFromWebService = createAsyncThunk("gisStationsStatusDistrict/fetchGisStationsStatusDistrictFromWebService", async () => {
|
||||
return fetchGisStationsStatusDistrict();
|
||||
});
|
||||
import { fetchGisStationsStatusDistrictThunk } from "../../thunks/fetchGisStationsStatusDistrictThunk";
|
||||
|
||||
const gisStationsStatusDistrictSlice = createSlice({
|
||||
const slice = createSlice({
|
||||
name: "gisStationsStatusDistrict",
|
||||
initialState: {
|
||||
data: [],
|
||||
@@ -16,20 +15,19 @@ const gisStationsStatusDistrictSlice = createSlice({
|
||||
reducers: {},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
.addCase(fetchGisStationsStatusDistrictFromWebService.pending, (state) => {
|
||||
.addCase(fetchGisStationsStatusDistrictThunk.pending, (state) => {
|
||||
state.status = "loading";
|
||||
})
|
||||
.addCase(fetchGisStationsStatusDistrictFromWebService.fulfilled, (state, action) => {
|
||||
.addCase(fetchGisStationsStatusDistrictThunk.fulfilled, (state, action) => {
|
||||
state.status = "succeeded";
|
||||
state.data = action.payload;
|
||||
})
|
||||
.addCase(fetchGisStationsStatusDistrictFromWebService.rejected, (state, action) => {
|
||||
.addCase(fetchGisStationsStatusDistrictThunk.rejected, (state, action) => {
|
||||
state.status = "failed";
|
||||
state.error = action.error.message;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export default slice.reducer;
|
||||
export const selectGisStationsStatusDistrict = (state) => state.gisStationsStatusDistrict.data;
|
||||
|
||||
export default gisStationsStatusDistrictSlice.reducer;
|
||||
|
||||
@@ -1,32 +1,33 @@
|
||||
// /redux/slices/webService/gisSystemStaticSlice.js
|
||||
|
||||
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchGisSystemStatic } from "../../api/fromWebService/fetchGisSystemStatic";
|
||||
import { fetchGisSystemStaticService } from "../../../services/webservice/fetchGisSystemStaticService";
|
||||
|
||||
export const fetchGisSystemStaticFromWebService = createAsyncThunk("gisSystemStatic/fetchGisSystemStaticFromWebService", async () => {
|
||||
const response = await fetchGisSystemStatic();
|
||||
return response.Systems || []; // ✅ Hier sicherstellen, dass nur `Systems` gespeichert wird
|
||||
});
|
||||
import { fetchGisSystemStaticThunk } from "../../thunks/fetchGisSystemStaticThunk";
|
||||
|
||||
const gisSystemStaticSlice = createSlice({
|
||||
const slice = createSlice({
|
||||
name: "gisSystemStatic",
|
||||
initialState: {
|
||||
data: [], // ✅ Immer ein Array setzen
|
||||
data: [],
|
||||
status: "idle",
|
||||
error: null,
|
||||
},
|
||||
reducers: {
|
||||
setGisSystemStatic: (state, action) => {
|
||||
state.data = action.payload.Systems || []; // ✅ Falls `Systems` fehlt, leeres Array setzen
|
||||
},
|
||||
},
|
||||
reducers: {},
|
||||
extraReducers: (builder) => {
|
||||
builder.addCase(fetchGisSystemStaticFromWebService.fulfilled, (state, action) => {
|
||||
builder
|
||||
.addCase(fetchGisSystemStaticThunk.pending, (state) => {
|
||||
state.status = "loading";
|
||||
})
|
||||
.addCase(fetchGisSystemStaticThunk.fulfilled, (state, action) => {
|
||||
state.status = "succeeded";
|
||||
state.data = action.payload; // ✅ Jetzt sollte `data` direkt das `Systems`-Array enthalten
|
||||
state.data = action.payload;
|
||||
})
|
||||
.addCase(fetchGisSystemStaticThunk.rejected, (state, action) => {
|
||||
state.status = "failed";
|
||||
state.error = action.error.message;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export const { setGisSystemStatic } = gisSystemStaticSlice.actions;
|
||||
export default gisSystemStaticSlice.reducer;
|
||||
export const selectGisSystemStatic = (state) => state.gisSystemStatic.data || [];
|
||||
export default slice.reducer;
|
||||
export const selectGisSystemStatic = (state) => state.gisSystemStatic.data;
|
||||
|
||||
@@ -8,7 +8,7 @@ import gisStationsStaticDistrictReducer from "./slices/webService/gisStationsSta
|
||||
import gisStationsStatusDistrictReducer from "./slices/webService/gisStationsStatusDistrictSlice";
|
||||
import gisStationsMeasurementsReducer from "./slices/webService/gisStationsMeasurementsSlice";
|
||||
import gisSystemStaticReducer from "./slices/webService/gisSystemStaticSlice";
|
||||
import gisStationsStaticReducer from "./slices/webService/gisStationsStaticSlice";
|
||||
|
||||
import poiTypesReducer from "./slices/db/poiTypesSlice";
|
||||
import addPoiOnPolylineReducer from "./slices/addPoiOnPolylineSlice";
|
||||
import polylineContextMenuReducer from "./slices/polylineContextMenuSlice";
|
||||
@@ -33,7 +33,6 @@ export const store = configureStore({
|
||||
gisStationsStatusDistrict: gisStationsStatusDistrictReducer,
|
||||
gisStationsMeasurements: gisStationsMeasurementsReducer,
|
||||
gisSystemStatic: gisSystemStaticReducer,
|
||||
gisStationsStatic: gisStationsStaticReducer,
|
||||
poiTypes: poiTypesReducer,
|
||||
addPoiOnPolyline: addPoiOnPolylineReducer,
|
||||
polylineContextMenu: polylineContextMenuReducer,
|
||||
|
||||
11
redux/thunks/fetchGisStationsMeasurementsThunk.js
Normal file
11
redux/thunks/fetchGisStationsMeasurementsThunk.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// /redux/thunks/fetchGisStationsMeasurementsThunk.js
|
||||
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchGisStationsMeasurementsService } from "../../services/webservice/fetchGisStationsMeasurementsService";
|
||||
|
||||
/**
|
||||
* Redux-Thunk für fetchGisStationsMeasurements
|
||||
*/
|
||||
export const fetchGisStationsMeasurementsThunk = createAsyncThunk("gisStationsMeasurements/fetch", async () => {
|
||||
return await fetchGisStationsMeasurementsService();
|
||||
});
|
||||
11
redux/thunks/fetchGisStationsStaticDistrictThunk.js
Normal file
11
redux/thunks/fetchGisStationsStaticDistrictThunk.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// /redux/thunks/fetchGisStationsStaticDistrictThunk.js
|
||||
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchGisStationsStaticDistrictService } from "../../services/webservice/fetchGisStationsStaticDistrictService";
|
||||
|
||||
/**
|
||||
* Redux-Thunk für fetchGisStationsStaticDistrict
|
||||
*/
|
||||
export const fetchGisStationsStaticDistrictThunk = createAsyncThunk("gisStationsStaticDistrict/fetch", async () => {
|
||||
return await fetchGisStationsStaticDistrictService();
|
||||
});
|
||||
11
redux/thunks/fetchGisStationsStatusDistrictThunk.js
Normal file
11
redux/thunks/fetchGisStationsStatusDistrictThunk.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// /redux/thunks/fetchGisStationsStatusDistrictThunk.js
|
||||
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchGisStationsStatusDistrictService } from "../../services/webservice/fetchGisStationsStatusDistrictService";
|
||||
|
||||
/**
|
||||
* Redux-Thunk für fetchGisStationsStatusDistrict
|
||||
*/
|
||||
export const fetchGisStationsStatusDistrictThunk = createAsyncThunk("gisStationsStatusDistrict/fetch", async () => {
|
||||
return await fetchGisStationsStatusDistrictService();
|
||||
});
|
||||
11
redux/thunks/fetchGisSystemStaticThunk.js
Normal file
11
redux/thunks/fetchGisSystemStaticThunk.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// /redux/thunks/fetchGisSystemStaticThunk.js
|
||||
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchGisSystemStaticService } from "../../services/webservice/fetchGisSystemStaticService";
|
||||
|
||||
/**
|
||||
* Redux-Thunk für fetchGisSystemStatic
|
||||
*/
|
||||
export const fetchGisSystemStaticThunk = createAsyncThunk("gisSystemStatic/fetch", async () => {
|
||||
return await fetchGisSystemStaticService();
|
||||
});
|
||||
@@ -1,27 +0,0 @@
|
||||
// /services/webservice/fetchGisStatusStationsService.js
|
||||
import fetchWithTimeout from "../utils/fetchWithTimeout";
|
||||
|
||||
export const fetchGisStatusStationsService = async (idMap, idUser) => {
|
||||
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
|
||||
|
||||
const SERVER_URL = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80` : `${window.location.origin}`;
|
||||
|
||||
return fetchWithTimeout(
|
||||
`${SERVER_URL}/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Connection: "close",
|
||||
},
|
||||
},
|
||||
5000
|
||||
)
|
||||
.then((response) => {
|
||||
if (!response.ok) throw new Error(`Error: ${response.statusText}`);
|
||||
return response.json();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Fehler beim Abrufen der Daten in fetchGisStatusStations:", error);
|
||||
throw error;
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user