Merge branch 'release/v1.1.52'
This commit is contained in:
@@ -28,7 +28,6 @@ import { setupPolylines } from "../../utils/polylines/setupPolylines.js";
|
|||||||
import { setupPOIs } from "../../utils/setupPOIs.js";
|
import { setupPOIs } from "../../utils/setupPOIs.js";
|
||||||
import VersionInfoModal from "../VersionInfoModal.js";
|
import VersionInfoModal from "../VersionInfoModal.js";
|
||||||
import useDrawLines from "../../hooks/layers/useDrawLines.js";
|
import useDrawLines from "../../hooks/layers/useDrawLines.js";
|
||||||
import useFetchPoiData from "../../hooks/useFetchPoiData.js";
|
|
||||||
import usePoiTypData from "../../hooks/usePoiTypData.js";
|
import usePoiTypData from "../../hooks/usePoiTypData.js";
|
||||||
import useLayerVisibility from "../../hooks/useLayerVisibility.js";
|
import useLayerVisibility from "../../hooks/useLayerVisibility.js";
|
||||||
import useLineData from "../../hooks/useLineData.js";
|
import useLineData from "../../hooks/useLineData.js";
|
||||||
@@ -83,6 +82,9 @@ import { updateCountdown, closePolylineContextMenu, forceCloseContextMenu } from
|
|||||||
//-------------------MapComponent.js hooks--------------------
|
//-------------------MapComponent.js hooks--------------------
|
||||||
import useInitializeMap from "./hooks/useInitializeMap";
|
import useInitializeMap from "./hooks/useInitializeMap";
|
||||||
import useLoadUserRights from "./hooks/useLoadUserRights";
|
import useLoadUserRights from "./hooks/useLoadUserRights";
|
||||||
|
import useFetchWebServiceMap from "./hooks/useFetchWebServiceMap";
|
||||||
|
import useFetchPoiData from "./hooks/useFetchPoiData.js";
|
||||||
|
import useRestoreMapSettings from "./hooks/useRestoreMapSettings";
|
||||||
|
|
||||||
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@@ -176,7 +178,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
|||||||
const [linesData, setLinesData] = useState([]);
|
const [linesData, setLinesData] = useState([]);
|
||||||
const mapLayersVisibility = useRecoilValue(mapLayersState);
|
const mapLayersVisibility = useRecoilValue(mapLayersState);
|
||||||
const selectedArea = useRecoilValue(selectedAreaState);
|
const selectedArea = useRecoilValue(selectedAreaState);
|
||||||
const poiData = useFetchPoiData("/api/talas_v5_DB/pois/poi-icons");
|
|
||||||
const [linePositions, setLinePositions] = useState([]);
|
const [linePositions, setLinePositions] = useState([]);
|
||||||
const { lineColors, tooltipContents } = useLineData(webserviceGisLinesStatusUrl, setLineStatusData);
|
const { lineColors, tooltipContents } = useLineData(webserviceGisLinesStatusUrl, setLineStatusData);
|
||||||
const [polylines, setPolylines] = useState([]);
|
const [polylines, setPolylines] = useState([]);
|
||||||
@@ -255,50 +257,11 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
|||||||
setUserId(params.get("u"));
|
setUserId(params.get("u"));
|
||||||
}, [setMapId, setUserId]);
|
}, [setMapId, setUserId]);
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
useEffect(() => {
|
useFetchWebServiceMap(mapGisStationsStatusDistrictUrl, mapGisStationsMeasurementsUrl, mapGisSystemStaticUrl, setGisStationsStatusDistrict, setGisStationsMeasurements, setGisSystemStatic, setGisSystemStaticLoaded);
|
||||||
const fetchWebServiceMap = async () => {
|
//Test in useEffect
|
||||||
try {
|
/* useEffect(() => {
|
||||||
// Zähler für externe API-Aufrufe in localStorage speichern
|
console.log("📌 Alle Marker in MapComponent in useFetchWebServiceMap:", allMarkers);
|
||||||
let requestCount = localStorage.getItem("fetchWebServiceMap") || 0;
|
}, [allMarkers]); */
|
||||||
requestCount = parseInt(requestCount, 10);
|
|
||||||
|
|
||||||
const fetchOptions = {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
Connection: "close", // Keep-Alive-Header hinzufügen
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Fetch GIS Stations Static District
|
|
||||||
/* await fetchGisStationsStaticDistrict(mapGisStationsStaticDistrictUrl, dispatch, fetchOptions);
|
|
||||||
requestCount++; // Zähler erhöhen
|
|
||||||
localStorage.setItem("fetchWebServiceMap", requestCount); */
|
|
||||||
//console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`);
|
|
||||||
|
|
||||||
// Fetch GIS Stations Status District
|
|
||||||
await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStationsStatusDistrict, fetchOptions);
|
|
||||||
requestCount++; // Zähler erhöhen
|
|
||||||
localStorage.setItem("fetchWebServiceMap", requestCount);
|
|
||||||
//console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`);
|
|
||||||
|
|
||||||
// Fetch GIS Stations Measurements
|
|
||||||
await fetchGisStationsMeasurements(mapGisStationsMeasurementsUrl, setGisStationsMeasurements, fetchOptions);
|
|
||||||
requestCount++; // Zähler erhöhen
|
|
||||||
localStorage.setItem("fetchWebServiceMap", requestCount);
|
|
||||||
//console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`);
|
|
||||||
|
|
||||||
// Fetch GIS System Static
|
|
||||||
await fetchGisSystemStatic(mapGisSystemStaticUrl, setGisSystemStatic, setGisSystemStaticLoaded, fetchOptions);
|
|
||||||
requestCount++; // Zähler erhöhen
|
|
||||||
localStorage.setItem("fetchWebServiceMap", requestCount);
|
|
||||||
//console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`);
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error fetching data:", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchWebServiceMap();
|
|
||||||
}, [dispatch, mapGisStationsStaticDistrictUrl]);
|
|
||||||
//--------------------------------------------------------
|
//--------------------------------------------------------
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const endpoint = "/api/talas_v5_DB/gisLines/readGisLines";
|
const endpoint = "/api/talas_v5_DB/gisLines/readGisLines";
|
||||||
@@ -330,38 +293,15 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
//--------------------------------------------
|
//--------------------------------------------
|
||||||
|
const [poiData, setPoiData] = useState([]);
|
||||||
// POIs Popup Informationen anzeigen
|
// POIs Popup Informationen anzeigen
|
||||||
useEffect(() => {
|
useFetchPoiData(setPoiTypMap, setPoiData);
|
||||||
const fetchPoiTypData = async () => {
|
//Test in useEffect
|
||||||
try {
|
/* useEffect(() => {
|
||||||
const response = await fetch("/api/talas_v5_DB/poiTyp/readPoiTyp");
|
console.log("📌 POI-Typ Map in MapComponent:", poiTypMap);
|
||||||
const data = await response.json();
|
console.log("📌 POI-Daten in MapComponent:", poiData);
|
||||||
if (!Array.isArray(data)) {
|
}, [poiTypMap, poiData]); */
|
||||||
console.warn(`Unerwartetes Format: ${JSON.stringify(data)}`);
|
|
||||||
throw new Error("Daten sind kein Array");
|
|
||||||
}
|
|
||||||
const map = new Map();
|
|
||||||
data.forEach((item) => map.set(item.idPoiTyp, item.name));
|
|
||||||
setPoiTypMap(map);
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Fehler beim Abrufen der poiTyp-Daten-1:", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const fetchPoiData = async () => {
|
|
||||||
try {
|
|
||||||
const response = await fetch("/api/talas_v5_DB/pois/poi-icons");
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error("Network response was not ok");
|
|
||||||
}
|
|
||||||
const data = await response.json();
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Fehler beim Abrufen der poiData-2:", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchPoiTypData();
|
|
||||||
fetchPoiData();
|
|
||||||
}, []);
|
|
||||||
//--------------------------------------------
|
//--------------------------------------------
|
||||||
// POIs auf die Karte zeichnen
|
// POIs auf die Karte zeichnen
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -562,8 +502,11 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
|||||||
|
|
||||||
//--------------------------------------------
|
//--------------------------------------------
|
||||||
//--------------------------------------------
|
//--------------------------------------------
|
||||||
|
useRestoreMapSettings(map);
|
||||||
|
//Test in useEffect
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (map) {
|
if (map) {
|
||||||
|
console.log("🗺️ Map-Einstellungen werden wiederhergestellt...");
|
||||||
restoreMapSettings(map);
|
restoreMapSettings(map);
|
||||||
}
|
}
|
||||||
}, [map]);
|
}, [map]);
|
||||||
|
|||||||
51
components/mainComponent/hooks/useFetchPoiData.js
Normal file
51
components/mainComponent/hooks/useFetchPoiData.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
// /components/mainComponent/hooks/useFetchWebServiceMap.js
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
const API_BASE_URL = process.env.NEXT_PUBLIC_API_PORT_3000; // API-URL aus .env.local
|
||||||
|
|
||||||
|
const useFetchPoiData = (setPoiTypMap, setPoiData) => {
|
||||||
|
useEffect(() => {
|
||||||
|
//console.log(`🌍 API_BASE_URL aus .env.local: ${API_BASE_URL}`);
|
||||||
|
|
||||||
|
//console.log("✅ useFetchPoiData wurde gestartet...");
|
||||||
|
// console.log(`🌍 API_BASE_URL: ${API_BASE_URL}`); // Debugging: Prüfen, ob die Umgebungsvariable korrekt geladen wird
|
||||||
|
|
||||||
|
const fetchPoiTypData = async () => {
|
||||||
|
try {
|
||||||
|
console.log("📡 Lade POI-Typ-Daten...");
|
||||||
|
const response = await fetch(`${API_BASE_URL}/api/talas_v5_DB/poiTyp/readPoiTyp`);
|
||||||
|
const data = await response.json();
|
||||||
|
if (!Array.isArray(data)) {
|
||||||
|
console.warn(`⚠️ Unerwartetes Format: ${JSON.stringify(data)}`);
|
||||||
|
throw new Error("Daten sind kein Array");
|
||||||
|
}
|
||||||
|
const map = new Map();
|
||||||
|
data.forEach((item) => map.set(item.idPoiTyp, item.name));
|
||||||
|
setPoiTypMap(map);
|
||||||
|
//console.log("✅ POI-Typ-Daten erfolgreich geladen!");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("❌ Fehler beim Abrufen der POI-Typ-Daten:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchPoiData = async () => {
|
||||||
|
try {
|
||||||
|
//console.log("📡 Lade POI-Icons...");
|
||||||
|
const response = await fetch(`${API_BASE_URL}/api/talas_v5_DB/pois/poi-icons`);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Netzwerkantwort war nicht ok, Status: ${response.status}`);
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
setPoiData(data);
|
||||||
|
//console.log("✅ POI-Icons erfolgreich geladen!", data);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("❌ Fehler beim Abrufen der POI-Daten:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchPoiTypData();
|
||||||
|
fetchPoiData();
|
||||||
|
}, [setPoiTypMap, setPoiData]);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useFetchPoiData;
|
||||||
52
components/mainComponent/hooks/useFetchWebServiceMap.js
Normal file
52
components/mainComponent/hooks/useFetchWebServiceMap.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
// /components/mainComponent/hooks/useFetchWebServiceMap.js
|
||||||
|
import { useEffect } from "react";
|
||||||
|
import { fetchGisStationsStatusDistrict } from "../../../services/api/fetchGisStationsStatusDistrict";
|
||||||
|
import { fetchGisStationsMeasurements } from "../../../services/api/fetchGisStationsMeasurements";
|
||||||
|
import { fetchGisSystemStatic } from "../../../services/api/fetchGisSystemStatic";
|
||||||
|
|
||||||
|
const useFetchWebServiceMap = (mapGisStationsStatusDistrictUrl, mapGisStationsMeasurementsUrl, mapGisSystemStaticUrl, setGisStationsStatusDistrict, setGisStationsMeasurements, setGisSystemStatic, setGisSystemStaticLoaded) => {
|
||||||
|
useEffect(() => {
|
||||||
|
//console.log("✅ useFetchWebServiceMap wurde ausgeführt!");
|
||||||
|
|
||||||
|
const fetchWebServiceMap = async () => {
|
||||||
|
try {
|
||||||
|
let requestCount = localStorage.getItem("fetchWebServiceMap") || 0;
|
||||||
|
requestCount = parseInt(requestCount, 10);
|
||||||
|
|
||||||
|
console.log("📡 Starte API-Anfragen...");
|
||||||
|
|
||||||
|
const fetchOptions = {
|
||||||
|
method: "GET",
|
||||||
|
headers: { Connection: "close" },
|
||||||
|
};
|
||||||
|
|
||||||
|
// GIS Stations Status District abrufen
|
||||||
|
//console.log("⏳ Abrufen von GIS Stations Status District...");
|
||||||
|
await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStationsStatusDistrict, fetchOptions);
|
||||||
|
// console.log("✅ fetchGisStationsStatusDistrict erfolgreich!");
|
||||||
|
requestCount++;
|
||||||
|
localStorage.setItem("fetchWebServiceMap", requestCount);
|
||||||
|
|
||||||
|
// GIS Stations Measurements abrufen
|
||||||
|
//console.log("⏳ Abrufen von GIS Stations Measurements...");
|
||||||
|
await fetchGisStationsMeasurements(mapGisStationsMeasurementsUrl, setGisStationsMeasurements, fetchOptions);
|
||||||
|
// console.log("✅ fetchGisStationsMeasurements erfolgreich!");
|
||||||
|
requestCount++;
|
||||||
|
localStorage.setItem("fetchWebServiceMap", requestCount);
|
||||||
|
|
||||||
|
// GIS System Static abrufen
|
||||||
|
//console.log("⏳ Abrufen von GIS System Static...");
|
||||||
|
await fetchGisSystemStatic(mapGisSystemStaticUrl, setGisSystemStatic, setGisSystemStaticLoaded, fetchOptions);
|
||||||
|
//console.log("✅ fetchGisSystemStatic erfolgreich!");
|
||||||
|
requestCount++;
|
||||||
|
localStorage.setItem("fetchWebServiceMap", requestCount);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("❌ Fehler beim Abrufen der WebService-Daten:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchWebServiceMap();
|
||||||
|
}, [mapGisStationsStatusDistrictUrl, mapGisStationsMeasurementsUrl, mapGisSystemStaticUrl]);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useFetchWebServiceMap;
|
||||||
12
components/mainComponent/hooks/useRestoreMapSettings.js
Normal file
12
components/mainComponent/hooks/useRestoreMapSettings.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import { restoreMapSettings } from "../../../utils/mapUtils.js"; // Stelle sicher, dass der Pfad korrekt ist
|
||||||
|
|
||||||
|
const useRestoreMapSettings = (map) => {
|
||||||
|
useEffect(() => {
|
||||||
|
if (map) {
|
||||||
|
restoreMapSettings(map);
|
||||||
|
}
|
||||||
|
}, [map]);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useRestoreMapSettings;
|
||||||
@@ -72,7 +72,7 @@ const addItemsToMapContextMenu = (
|
|||||||
const editMode = localStorage.getItem("editMode") === "true";
|
const editMode = localStorage.getItem("editMode") === "true";
|
||||||
if (editMode) {
|
if (editMode) {
|
||||||
console.log("editMode localStorage:", localStorage.getItem("editMode"));
|
console.log("editMode localStorage:", localStorage.getItem("editMode"));
|
||||||
console.log("editMode:", editMode);
|
//console.log("editMode:", editMode);
|
||||||
|
|
||||||
map.contextmenu.addItem({
|
map.contextmenu.addItem({
|
||||||
text: "POI hinzufügen",
|
text: "POI hinzufügen",
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
// /config/appVersion
|
// /config/appVersion
|
||||||
export const APP_VERSION = "1.1.49";
|
export const APP_VERSION = "1.1.53";
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
// hooks/useFetchPoiData.js
|
|
||||||
import { useState, useEffect } from "react";
|
|
||||||
|
|
||||||
const useFetchPoiData = (url) => {
|
|
||||||
const [poiData, setPoiData] = useState([]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const fetchPoiData = async () => {
|
|
||||||
try {
|
|
||||||
const response = await fetch(url);
|
|
||||||
if (!response.ok) throw new Error("Network response was not ok");
|
|
||||||
const data = await response.json();
|
|
||||||
setPoiData(data);
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Fehler beim Abrufen der poiData:", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchPoiData();
|
|
||||||
}, [url]);
|
|
||||||
|
|
||||||
return poiData;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default useFetchPoiData;
|
|
||||||
@@ -38,6 +38,7 @@ export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItems
|
|||||||
text: "Station öffnen (Tab)",
|
text: "Station öffnen (Tab)",
|
||||||
icon: "/img/screen_new.png",
|
icon: "/img/screen_new.png",
|
||||||
callback: (e) => {
|
callback: (e) => {
|
||||||
|
const editMode = localStorage.getItem("editMode") === "true";
|
||||||
const clickedElement = e.relatedTarget;
|
const clickedElement = e.relatedTarget;
|
||||||
|
|
||||||
if (!clickedElement) {
|
if (!clickedElement) {
|
||||||
@@ -45,12 +46,18 @@ export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItems
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prüfen, ob es ein POI ist (POIs haben idPoi in den Optionen)
|
||||||
|
if (clickedElement instanceof L.Marker && clickedElement.options?.idPoi) {
|
||||||
|
console.log("POI erkannt - Station öffnen deaktiviert.");
|
||||||
|
return; // Keine Aktion ausführen
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (clickedElement instanceof L.Marker || clickedElement?.options?.link) {
|
if (clickedElement instanceof L.Marker || clickedElement?.options?.link) {
|
||||||
const link = "http://" + window.location.hostname + "/talas5/devices/" + clickedElement.options.link;
|
const link = "http://" + window.location.hostname + "/talas5/devices/" + clickedElement.options.link;
|
||||||
if (link) {
|
if (link) {
|
||||||
console.log("Opening link in a new tab:", link);
|
console.log("Opening link in a new tab:", link);
|
||||||
window.open(link, "_blank");
|
//window.open(link, "_blank"); POI-Link öffnen in neuem Tab
|
||||||
} else {
|
} else {
|
||||||
console.error("No link found in the Marker options.");
|
console.error("No link found in the Marker options.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user