fix: Systemtyp Berechtigung der User werden nicht beachtet

This commit is contained in:
ISA
2025-07-30 15:19:53 +02:00
parent 53c670feba
commit 4ee6d42a61
6 changed files with 92 additions and 43 deletions

View File

@@ -25,4 +25,4 @@ NEXT_PUBLIC_USE_MOCKS=true
NEXT_PUBLIC_BASE_PATH=/talas5
# Oder leer lassen für direkten Zugriff -> NEXT_PUBLIC_BASE_PATH=
# App-Versionsnummer
NEXT_PUBLIC_APP_VERSION=1.1.307
NEXT_PUBLIC_APP_VERSION=1.1.308

View File

@@ -26,4 +26,4 @@ NEXT_PUBLIC_BASE_PATH=/talas5
# Oder leer lassen für direkten Zugriff -> NEXT_PUBLIC_BASE_PATH=
# App-Versionsnummer
NEXT_PUBLIC_APP_VERSION=1.1.307
NEXT_PUBLIC_APP_VERSION=1.1.308

View File

@@ -9,11 +9,7 @@ import {
} from "@/redux/slices/database/polylines/polylineLayerVisibleSlice";
import { selectGisSystemStatic } from "@/redux/slices/webservice/gisSystemStaticSlice";
import { selectGisStationsStaticDistrict } from "@/redux/slices/webservice/gisStationsStaticDistrictSlice";
import {
selectMapLayersState,
setLayerVisibility,
setInitialLayers,
} from "@/redux/slices/mapLayersSlice";
import { selectMapLayersState, setLayerVisibility } from "@/redux/slices/mapLayersSlice";
import { setVisible } from "@/redux/slices/database/pois/poiLayerVisibleSlice";
import { incrementZoomTrigger } from "@/redux/slices/zoomTriggerSlice";
@@ -61,12 +57,21 @@ function MapLayersControlPanel() {
console.log("📢 Event 'polylineVisibilityChanged' dispatched");
}, 100);
// Wenn Kabelstrecken aktiviert wird, aktiviere automatisch auch TALAS (IdSystem 1)
if (checked) {
dispatch(setLayerVisibility({ layer: "TALAS", visibility: true }));
localStorage.setItem(
"mapLayersVisibility",
JSON.stringify({ ...mapLayersVisibility, TALAS: true })
);
const talasKey = "system-1"; // TALAS hat IdSystem 1
dispatch(setLayerVisibility({ layer: talasKey, visibility: true }));
// Kartenspezifischer localStorage-Key verwenden
const mapId = localStorage.getItem("currentMapId");
const userId = localStorage.getItem("currentUserId");
const mapStorageKey =
mapId && userId ? `mapLayersVisibility_m${mapId}_u${userId}` : "mapLayersVisibility";
const updatedVisibility = { ...mapLayersVisibility, [talasKey]: true };
localStorage.setItem(mapStorageKey, JSON.stringify(updatedVisibility));
console.log("🔗 Kabelstrecken aktiviert → TALAS automatisch aktiviert");
}
};
@@ -112,8 +117,15 @@ function MapLayersControlPanel() {
}, 200);
}
const storedMapLayersVisibility = localStorage.getItem("mapLayersVisibility");
console.log("📦 MapLayers localStorage value:", storedMapLayersVisibility);
// Kartenspezifischer localStorage-Key verwenden
const mapId = localStorage.getItem("currentMapId");
const userId = localStorage.getItem("currentUserId");
const mapStorageKey =
mapId && userId ? `mapLayersVisibility_m${mapId}_u${userId}` : "mapLayersVisibility";
const storedMapLayersVisibility = localStorage.getItem(mapStorageKey);
console.log(`📦 MapLayers localStorage value for ${mapStorageKey}:`, storedMapLayersVisibility);
if (storedMapLayersVisibility) {
const parsedVisibility = JSON.parse(storedMapLayersVisibility);
Object.keys(parsedVisibility).forEach(key => {
@@ -125,18 +137,16 @@ function MapLayersControlPanel() {
if (Array.isArray(GisSystemStatic)) {
const initialVisibility = {};
GisSystemStatic.forEach(system => {
const systemKey = `system-${system.IdSystem}`;
const visibility = system.Allow === 1;
const key = `system-${system.IdSystem}`;
initialVisibility[key] = visibility;
dispatch(setLayerVisibility({ layer: key, visibility }));
initialVisibility[systemKey] = visibility;
dispatch(setLayerVisibility({ layer: systemKey, visibility }));
console.log(
`🎯 Setting ${system.SystemName} visibility to ${visibility} (Allow=${system.Allow})`
`🎯 Setting ${systemKey} (${system.Name}) visibility to ${visibility} (Allow=${system.Allow})`
);
});
localStorage.setItem("mapLayersVisibility", JSON.stringify(initialVisibility));
console.log("💾 Saved initial mapLayersVisibility to localStorage:", initialVisibility);
localStorage.setItem(mapStorageKey, JSON.stringify(initialVisibility));
console.log(`💾 Saved initial mapLayersVisibility to ${mapStorageKey}:`, initialVisibility);
}
}
@@ -204,10 +214,32 @@ function MapLayersControlPanel() {
const { checked } = event.target;
dispatch(setLayerVisibility({ layer: key, visibility: checked }));
localStorage.setItem(
"mapLayersVisibility",
JSON.stringify({ ...mapLayersVisibility, [key]: checked })
);
// Kartenspezifischer localStorage-Key verwenden
const mapId = localStorage.getItem("currentMapId");
const userId = localStorage.getItem("currentUserId");
const mapStorageKey =
mapId && userId ? `mapLayersVisibility_m${mapId}_u${userId}` : "mapLayersVisibility";
localStorage.setItem(mapStorageKey, JSON.stringify({ ...mapLayersVisibility, [key]: checked }));
// Wenn TALAS (system-1) deaktiviert wird, deaktiviere automatisch auch Kabelstrecken
if (key === "system-1" && !checked) {
console.log("🔗 TALAS deaktiviert → Kabelstrecken automatisch deaktiviert");
// Kabelstrecken deaktivieren
setKabelstreckenVisible(false);
localStorage.setItem("kabelstreckenVisible", "false");
localStorage.setItem("polylineVisible", "false");
dispatch(setPolylineVisible(false));
// Event für Kabelstrecken auslösen
setTimeout(() => {
const polylineEvent = new Event("polylineVisibilityChanged");
window.dispatchEvent(polylineEvent);
console.log("📢 Event 'polylineVisibilityChanged' dispatched (auto-deactivated)");
}, 50);
}
setTimeout(() => {
const event = new Event("visibilityChanged");
@@ -264,16 +296,6 @@ function MapLayersControlPanel() {
console.log("📌 stationListing aktualisiert:", filteredAreas);
}
}, [GisStationsStaticDistrict, GisSystemStatic]);
//---------------------------
// ✅ Redux mapLayers mit GisSystemStatic initialisieren
useEffect(() => {
if (Array.isArray(GisSystemStatic) && GisSystemStatic.length > 0) {
console.log("🔧 Initializing mapLayers in Redux with GisSystemStatic:", GisSystemStatic);
dispatch(setInitialLayers(GisSystemStatic));
}
}, [GisSystemStatic, dispatch]);
//---------------------------
useEffect(() => {
const next = (GisStationsStaticDistrict.Points || []).map(p => p.Area_Name).join("|");

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "nodemap",
"version": "1.1.307",
"version": "1.1.308",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "nodemap",
"version": "1.1.307",
"version": "1.1.308",
"dependencies": {
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",

View File

@@ -1,6 +1,6 @@
{
"name": "nodemap",
"version": "1.1.307",
"version": "1.1.308",
"dependencies": {
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",

View File

@@ -15,15 +15,42 @@ const mapLayersSlice = createSlice({
},
setLayerVisibility: (state, action) => {
const { layer, visibility } = action.payload;
if (state[layer] !== undefined) {
state[layer] = visibility;
}
state[layer] = visibility; // Entferne die Bedingung, um sicherzustellen, dass Werte gesetzt werden
},
setInitialLayers: (state, action) => {
const systems = action.payload; // Array of GisSystem
// Versuche kartenspezifische localStorage-Werte zu laden
const mapId =
typeof localStorage !== "undefined" ? localStorage.getItem("currentMapId") : null;
const userId =
typeof localStorage !== "undefined" ? localStorage.getItem("currentUserId") : null;
const mapStorageKey =
mapId && userId ? `mapLayersVisibility_m${mapId}_u${userId}` : "mapLayersVisibility";
let existingVisibility = {};
if (typeof localStorage !== "undefined") {
try {
const stored = localStorage.getItem(mapStorageKey);
if (stored) {
existingVisibility = JSON.parse(stored);
}
} catch (error) {
console.error("Error loading stored visibility:", error);
}
}
systems.forEach(system => {
const key = `system-${system.IdSystem}`;
state[key] = system.Allow === 1; // true wenn Allow=1, false wenn Allow=0
// Prüfe ob bereits ein localStorage-Wert existiert
if (existingVisibility.hasOwnProperty(key)) {
// Verwende gespeicherten Wert (Benutzer-Einstellung hat Priorität)
state[key] = existingVisibility[key];
} else {
// Verwende Allow-Wert als Standard (nur für neue Systeme)
state[key] = system.Allow === 1;
}
});
},
},