diff --git a/.env.local b/.env.local index 9a3771f80..975de0335 100644 --- a/.env.local +++ b/.env.local @@ -5,4 +5,6 @@ DB_HOST=localhost DB_USER=root DB_PASSWORD="root#$" DB_NAME=talas_v5 -DB_PORT=3306 \ No newline at end of file +DB_PORT=3306 +######################### Kontetmenü -> Station in tab öffnen +BASE_URL=http://10.10.0.13/talas5/devices/ \ No newline at end of file diff --git a/components/MapComponent.js b/components/MapComponent.js index 7259fe34b..08f34cae4 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -167,8 +167,27 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { const lineLayer = new L.LayerGroup(); const [gisSystemStaticLoaded, setGisSystemStaticLoaded] = useState(false); + const [baseUrl, setBaseUrl] = useState(""); + useEffect(() => { + fetch("/api/get-talasIP") + .then((response) => response.json()) + .then((data) => { + const ip = data.ip; + if (ip) { + // Erstellen Sie die Basis-URL mit der erhaltenen IP + const newBaseUrl = `http://${ip}/talas5/devices/`; + setBaseUrl(newBaseUrl); + console.log("Base URL set to:", newBaseUrl); + } + }) + .catch((error) => { + console.error("Error fetching IP:", error); + // Hier können Sie einen Fallback einstellen, falls die IP-Abfrage fehlschlägt + setBaseUrl("http://default-ip/talas5/devices/"); + }); + }, []); - const baseUrl = "http://10.10.0.13/talas5/devices/"; // für Station öffnen in neuer tab und gleicher tab, im localhost gab es keine Probleme mit der Frame + //const baseUrl = "http://10.10.0.13/talas5/devices/"; // für Station öffnen in neuer tab und gleicher tab, im localhost gab es keine Probleme mit der Frame //const baseUrl = "http://localhost/talas5/devices/"; const [isPoiTypLoaded, setIsPoiTypLoaded] = useState(false); const [poiTypMap, setPoiTypMap] = useState(new Map()); @@ -980,15 +999,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { openInNewTab(e, clickedMarker); }, }, - { - text: "Station öffnen", - icon: "/img/screen_same.png", - //callback: (e) => openInSameWindow(e, marker), - callback: (e) => { - const clickedMarker = e.relatedTarget; // Zugriff auf den Marker, der das Event ausgelöst hat - openInSameWindow(e, clickedMarker); - }, - }, "-", // Divider { diff --git a/pages/api/get-talasIP.js b/pages/api/get-talasIP.js new file mode 100644 index 000000000..1216fbbb7 --- /dev/null +++ b/pages/api/get-talasIP.js @@ -0,0 +1,20 @@ +// pages/api/get-talasIP.js + +export default function handler(req, res) { + // Der x-forwarded-for Header könnte mehrere IP-Adressen enthalten, getrennt durch Kommas + let clientIp = + req.headers["x-forwarded-for"]?.split(",").map((ip) => ip.trim())[0] || + req.socket.remoteAddress; + + // Entfernen möglicher IPv6 "mapped" IPv4 Adressen + if (clientIp?.includes("::ffff:")) { + clientIp = clientIp.split("::ffff:")[1]; + } + + // Nur IPv4 Adressen weitergeben, IPv6 Adressen ausschließen + if (clientIp && clientIp.includes(":")) { + clientIp = ""; // Dies setzt die IP auf leer, wenn es sich um eine IPv6-Adresse handelt + } + + res.status(200).json({ ip: clientIp }); +} diff --git a/pages/api/linesColorApi.js b/pages/api/linesColorApi.js index 9ac678c69..cae5d90e4 100644 --- a/pages/api/linesColorApi.js +++ b/pages/api/linesColorApi.js @@ -17,7 +17,7 @@ export default function handler(req, res) { IdModul: 3, Na: "system", Le: 4, - Co: "#FF00FF", + Co: "#018915", Me: "Eingang DE05 kommend", Feld: 3, Icon: 0,