From 9e4a22924830502597efe7a84a6a5cb50fc72875 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 4 Sep 2024 19:26:08 +0200 Subject: [PATCH] Version 1.0.4 Links open in new tab for polylines and devices work it! --- .env.local | 42 +++++++++++++++++++++--------------------- utils/initializeMap.js | 12 +++++++++++- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/.env.local b/.env.local index 426f51759..0be25a82f 100644 --- a/.env.local +++ b/.env.local @@ -18,30 +18,30 @@ ######################### -DB_HOST=10.10.0.70 -DB_USER=root -DB_PASSWORD="root#$" -DB_NAME=talas_v5 -DB_PORT=3306 - - -######################### - -NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" -NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" -NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" -NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" -######################### - -#DB_HOST=192.168.10.167 +#DB_HOST=10.10.0.70 #DB_USER=root #DB_PASSWORD="root#$" #DB_NAME=talas_v5 #DB_PORT=3306 + + +######################### + +#NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" +#NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" +#NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" +#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" +#NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" +######################### + +DB_HOST=192.168.10.167 +DB_USER=root +DB_PASSWORD="root#$" +DB_NAME=talas_v5 +DB_PORT=3306 ######################### #URLs für den Client (clientseitig) -#NEXT_PUBLIC_BASE_URL="http://192.168.10.167/talas5/devices/" -#NEXT_PUBLIC_SERVER_URL="http://192.168.10.167" -#NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.167" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" +NEXT_PUBLIC_BASE_URL="http://192.168.10.167/talas5/devices/" +NEXT_PUBLIC_SERVER_URL="http://192.168.10.167" +NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.167" +NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" diff --git a/utils/initializeMap.js b/utils/initializeMap.js index 1d2054785..4e4b561a4 100644 --- a/utils/initializeMap.js +++ b/utils/initializeMap.js @@ -22,10 +22,20 @@ export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItems text: "Station öffnen (Tab)", icon: "/img/screen_new.png", callback: (e) => { + const link = localStorage.getItem("polylineLink"); const clickedElement = e.relatedTarget; // Überprüfe, ob der Kontextklick auf eine Polyline oder einen Marker erfolgt ist - if (clickedElement instanceof L.Marker || clickedElement instanceof L.Polyline) { + if (link) { + const newTab = window.open(link, "_blank"); + if (newTab) { + // Wenn der Tab geöffnet wird, lösche die `localStorage`-Einträge + localStorage.removeItem("polylineLink"); + localStorage.removeItem("lastElementType"); + } else { + console.error("Fehler: Das neue Tab konnte nicht geöffnet werden."); + } + } else if (clickedElement instanceof L.Marker || clickedElement instanceof L.Polyline) { openInNewTab(e, clickedElement); // Verwende openInNewTab für beide Fälle } else { console.error("Kein gültiges Ziel für den Kontextmenüeintrag");