fix: Geräte-Marker für Systeme ohne Statusdaten anzeigen (z. B. GMA)

- `createAndSetDevices.js` angepasst, sodass Marker auch ohne `statusDistrictData` erzeugt werden.
- Problem behoben, dass Marker wie GMA trotz vorhandener Koordinaten und Sichtbarkeit nicht gezeichnet wurden.
- Sicherheitsprüfung für Statusdaten optional gemacht, um Systems ohne Messdaten darzustellen.
This commit is contained in:
ISA
2025-07-30 11:13:34 +02:00
parent 6d33be56c0
commit 53c670feba
15 changed files with 87 additions and 41 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.306
NEXT_PUBLIC_APP_VERSION=1.1.307

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.306
NEXT_PUBLIC_APP_VERSION=1.1.307

View File

@@ -70,7 +70,8 @@ const useDynamicDeviceLayers = (map, GisSystemStatic, mapLayersVisibility, prior
const editMode = localStorage.getItem("editMode") === "true";
Object.entries(markerStates).forEach(([key, markers]) => {
const isVisible = mapLayersVisibility[key];
const isVisible = mapLayersVisibility[key] ?? true; // undefined = true
markers.forEach(marker => {
const hasLayer = map.hasLayer(marker);
if (editMode || !isVisible) {

View File

View File

@@ -797,30 +797,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
}
}, [poiIconsData, poiIconsStatus]);
//-----------------------------------------------------------------
useEffect(() => {
if (!map) return;
const editMode = localStorage.getItem("editMode") === "true";
Object.entries(markerStates).forEach(([systemName, markers]) => {
const isVisible = mapLayersVisibility[systemName];
markers.forEach(marker => {
const hasLayer = map.hasLayer(marker);
if (editMode || !isVisible) {
if (hasLayer) map.removeLayer(marker);
} else {
if (!hasLayer) marker.addTo(map);
}
});
});
// optional für alle zusammen
const allMarkers = Object.values(markerStates)
.filter(entry => Array.isArray(entry))
.flat();
checkOverlappingMarkers(map, allMarkers, plusRoundIcon);
}, [map, markerStates, mapLayersVisibility]);
//----------------------------------------------
useEffect(() => {
@@ -896,6 +872,21 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
}, [GisStationsStaticDistrict]);
const { Points = [] } = useSelector(selectGisStationsStaticDistrict);
useEffect(() => {}, [triggerUpdate]);
//--------------------------------------------------------------------------------
useEffect(() => {
console.log("📊 GisSystemStatic:", GisSystemStatic);
}, [GisSystemStatic]);
useEffect(() => {
if (Array.isArray(GisSystemStatic)) {
GisSystemStatic.forEach(system => {
const key = `system-${system.IdSystem}`;
if (!(key in mapLayersVisibility)) {
dispatch(setLayerVisibility({ key, value: true })); // Sichtbarkeit aktivieren
}
});
}
}, [GisSystemStatic, mapLayersVisibility, dispatch]);
//---------------------------------------------
//--------------------------------------------
return (

View File

@@ -9,7 +9,11 @@ import {
} from "@/redux/slices/database/polylines/polylineLayerVisibleSlice";
import { selectGisSystemStatic } from "@/redux/slices/webservice/gisSystemStaticSlice";
import { selectGisStationsStaticDistrict } from "@/redux/slices/webservice/gisStationsStaticDistrictSlice";
import { selectMapLayersState, setLayerVisibility } from "@/redux/slices/mapLayersSlice";
import {
selectMapLayersState,
setLayerVisibility,
setInitialLayers,
} from "@/redux/slices/mapLayersSlice";
import { setVisible } from "@/redux/slices/database/pois/poiLayerVisibleSlice";
import { incrementZoomTrigger } from "@/redux/slices/zoomTriggerSlice";
@@ -122,13 +126,16 @@ function MapLayersControlPanel() {
const initialVisibility = {};
GisSystemStatic.forEach(system => {
const visibility = system.Allow === 1;
initialVisibility[system.SystemName] = visibility;
dispatch(setLayerVisibility({ layer: system.SystemName, visibility }));
const key = `system-${system.IdSystem}`;
initialVisibility[key] = visibility;
dispatch(setLayerVisibility({ layer: key, visibility }));
console.log(
`🎯 Setting ${system.SystemName} visibility to ${visibility} (Allow=${system.Allow})`
);
});
localStorage.setItem("mapLayersVisibility", JSON.stringify(initialVisibility));
console.log("💾 Saved initial mapLayersVisibility to localStorage:", initialVisibility);
}
}
@@ -257,6 +264,16 @@ 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("|");

Binary file not shown.

4
package-lock.json generated
View File

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

View File

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

View File

@@ -33,10 +33,15 @@ app.prepare().then(() => {
const io = new Server(server);
// ✅ Globaler Cache für alle aktuellen Daten
const globalDataCache = new Map();
io.on("connection", socket => {
const { m: idMap, u: idUser } = socket.handshake.query;
console.log(`🔌 WebSocket verbunden (idMap=${idMap}, idUser=${idUser})`);
const cacheKey = `${idMap}_${idUser}`;
const endpoints = [
{
name: "GisLinesStatus",
@@ -69,6 +74,22 @@ app.prepare().then(() => {
const lastDataMap = {};
// ✅ Funktion um sofort alle verfügbaren Daten zu senden (für Browser-Reload)
const sendAllCurrentData = () => {
const cachedData = globalDataCache.get(cacheKey);
if (cachedData && Object.keys(cachedData).length > 0) {
console.log(
`📦 Sending all current data to client (${Object.keys(cachedData).length} endpoints)`
);
Object.entries(cachedData).forEach(([name, data]) => {
socket.emit(`${name}Updated`, data);
console.log(`🔄 Browser-Reload: ${name} data sent`);
});
} else {
console.log(`📭 No cached data available for ${cacheKey}, will fetch fresh data`);
}
};
const fetchData = async () => {
for (const { name, getUrl, mock } of endpoints) {
try {
@@ -99,6 +120,14 @@ app.prepare().then(() => {
}
const newDataStr = JSON.stringify(statis);
// ✅ Cache aktualisieren
if (!globalDataCache.has(cacheKey)) {
globalDataCache.set(cacheKey, {});
}
globalDataCache.get(cacheKey)[name] = statis;
// ✅ Nur bei Änderungen senden (setInterval-Logik)
if (newDataStr !== lastDataMap[name]) {
lastDataMap[name] = newDataStr;
socket.emit(`${name}Updated`, statis);
@@ -113,9 +142,15 @@ app.prepare().then(() => {
}
};
// fetchData immer ausführen unabhängig vom Modus
// ✅ Beim Connect: Sofort alle aktuellen Daten senden (für Browser-Reload)
sendAllCurrentData();
// ✅ Dann erste Datenabfrage durchführen
fetchData();
// ✅ setInterval für regelmäßige Updates (nur bei Änderungen)
const interval = setInterval(fetchData, 5000); // 5 Sekunden ,TALAS.web nutzt 12 Sekunden
socket.on("disconnect", () => {
clearInterval(interval);
console.log("❌ WebSocket getrennt");

View File

@@ -30,7 +30,8 @@ export const createAndSetDevices = async (
const systemConfig = Array.isArray(GisSystemStatic)
? GisSystemStatic.find(sys => sys.IdSystem === systemId)
: null;
if (!systemConfig || systemConfig.Allow !== 1) {
if (!systemConfig) {
console.warn(`🚫 Kein Marker für System ${systemId}, Allow = ${systemConfig?.Allow}`);
setMarkersFunction([]);
return;
}
@@ -42,7 +43,8 @@ export const createAndSetDevices = async (
const statusDistrictData = selectGisStationsStatusDistrict(state);
const measurementData = selectGisStationsMeasurements(state);
if (!staticDistrictData?.Points?.length || !statusDistrictData?.length) return;
if (!staticDistrictData?.Points?.length) return;
const hasStatus = Array.isArray(statusDistrictData) && statusDistrictData.length > 0;
const statisMap = new Map(statusDistrictData.map(s => [s.IdLD, s]));
const measurementsMap = new Map();

View File

View File

@@ -3,35 +3,35 @@
"IdSystem": 1,
"Name": "TALAS",
"Longname": "Talas Meldestationen",
"Allow": 0,
"Allow": 1,
"Icon": 1
},
{
"IdSystem": 2,
"Name": "ECI",
"Longname": "ECI Geräte",
"Allow": 0,
"Allow": 1,
"Icon": 2
},
{
"IdSystem": 3,
"Name": "ULAF",
"Longname": "ULAF Geräte",
"Allow": 0,
"Allow": 1,
"Icon": 3
},
{
"IdSystem": 5,
"Name": "GSM Modem",
"Longname": "LR77 GSM Modems",
"Allow": 0,
"Allow": 1,
"Icon": 5
},
{
"IdSystem": 6,
"Name": "Cisco Router",
"Longname": "Cisco Router",
"Allow": 0,
"Allow": 1,
"Icon": 6
},
{