Merge branch 'v306' into develop

This commit is contained in:
ISA
2025-07-30 15:35:05 +02:00
13 changed files with 61 additions and 33 deletions

View File

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

View File

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

View File

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

View File

View File

@@ -834,30 +834,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
} }
}, [poiIconsData, poiIconsStatus]); }, [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(() => { useEffect(() => {
@@ -933,6 +909,21 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
}, [GisStationsStaticDistrict]); }, [GisStationsStaticDistrict]);
const { Points = [] } = useSelector(selectGisStationsStaticDistrict); const { Points = [] } = useSelector(selectGisStationsStaticDistrict);
useEffect(() => {}, [triggerUpdate]); 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 ( return (

Binary file not shown.

4
package-lock.json generated
View File

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

View File

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

View File

@@ -33,10 +33,15 @@ app.prepare().then(() => {
const io = new Server(server); const io = new Server(server);
// ✅ Globaler Cache für alle aktuellen Daten
const globalDataCache = new Map();
io.on("connection", socket => { io.on("connection", socket => {
const { m: idMap, u: idUser } = socket.handshake.query; const { m: idMap, u: idUser } = socket.handshake.query;
console.log(`🔌 WebSocket verbunden (idMap=${idMap}, idUser=${idUser})`); console.log(`🔌 WebSocket verbunden (idMap=${idMap}, idUser=${idUser})`);
const cacheKey = `${idMap}_${idUser}`;
const endpoints = [ const endpoints = [
{ {
name: "GisLinesStatus", name: "GisLinesStatus",
@@ -69,6 +74,22 @@ app.prepare().then(() => {
const lastDataMap = {}; 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 () => { const fetchData = async () => {
for (const { name, getUrl, mock } of endpoints) { for (const { name, getUrl, mock } of endpoints) {
try { try {
@@ -99,6 +120,14 @@ app.prepare().then(() => {
} }
const newDataStr = JSON.stringify(statis); 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]) { if (newDataStr !== lastDataMap[name]) {
lastDataMap[name] = newDataStr; lastDataMap[name] = newDataStr;
socket.emit(`${name}Updated`, statis); 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(); fetchData();
// ✅ setInterval für regelmäßige Updates (nur bei Änderungen)
const interval = setInterval(fetchData, 5000); // 5 Sekunden ,TALAS.web nutzt 12 Sekunden const interval = setInterval(fetchData, 5000); // 5 Sekunden ,TALAS.web nutzt 12 Sekunden
socket.on("disconnect", () => { socket.on("disconnect", () => {
clearInterval(interval); clearInterval(interval);
console.log("❌ WebSocket getrennt"); console.log("❌ WebSocket getrennt");

View File

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

View File