From bf4d86406b10752bf031440bd926ec4583dce225 Mon Sep 17 00:00:00 2001 From: ISA Date: Mon, 27 May 2024 11:05:48 +0200 Subject: [PATCH] =?UTF-8?q?Ger=C3=A4t=20in=20Popup=20anzeigen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.local | 4 ++-- components/MapComponent.js | 31 ++++++++++++++++++++++++------- config/config.js | 8 ++++---- pages/api/[...path].js | 4 ++-- public/img/poi-edit.png | Bin 0 -> 955 bytes 5 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 public/img/poi-edit.png diff --git a/.env.local b/.env.local index d20fccec5..89e6a81e8 100644 --- a/.env.local +++ b/.env.local @@ -1,6 +1,6 @@ -#DB_HOST=localhost -DB_HOST=192.168.10.58 +DB_HOST=localhost +#DB_HOST=192.168.10.58 DB_USER=root DB_PASSWORD="root#$" DB_NAME=talas_v5 diff --git a/components/MapComponent.js b/components/MapComponent.js index 2f12cf1a7..ed26f29cc 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -78,8 +78,8 @@ const MapComponent = ({ locations, onLocationUpdate }) => { const zoomTrigger = useRecoilValue(zoomTriggerState); const offlineTileLayer = "/mapTiles/{z}/{x}/{y}.png"; //const onlineTileLayer = "/mapTiles/{z}/{x}/{y}.png"; - const onlineTileLayer = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"; - //const onlineTileLayer = "http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png"; //Talas_v5 Server + //const onlineTileLayer = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"; + const onlineTileLayer = "http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png"; //Talas_v5 Server // Create map layers const TALAS = new L.layerGroup(); const ECI = new L.layerGroup(); @@ -888,6 +888,23 @@ const MapComponent = ({ locations, onLocationUpdate }) => { // Beispiel: openEditModal(markerId); } + //------------------------------------------ + + const fetchDeviceNameById = async (idLD) => { + try { + const response = await fetch(`/api/locationDeviceNameById?idLD=${idLD}`); + const data = await response.json(); + if (response.ok) { + return data.name; + } else { + throw new Error(data.error || "Gerät nicht gefunden"); + } + } catch (error) { + console.error("Fehler beim Abrufen des Gerätenamens:", error); + return "Unbekannt"; + } + }; + //------------------------------------------ // poiLayerRef(poiDbLayer) POI hinzufügen //-------------------------------------------- @@ -899,14 +916,14 @@ const MapComponent = ({ locations, onLocationUpdate }) => { poiLayerRef.current = new L.LayerGroup().addTo(map); // Fügen Sie die aktualisierten Marker hinzu - locations.forEach((location) => { + locations.forEach(async (location) => { const { latitude, longitude } = parsePoint(location.position); const poiTypName = poiTypMap.get(location.idPoiTyp) || "Unbekannt "; console.log("poiTypName in poiLayer:", poiTypName); //console.log("location.idPoiTyp poiLayer:", location.idPoiTyp); console.log("location.idPoiTyp poiLayer:", location); console.log("location.idPoiTyp:", location.idPoiTyp); - + const deviceName = await fetchDeviceNameById(location.idLD); const marker = L.marker([latitude, longitude], { icon: L.icon({ iconUrl: `/img/icons/pois/poi-marker-icon-${location.idPoiTyp}.png`, @@ -923,7 +940,7 @@ const MapComponent = ({ locations, onLocationUpdate }) => { { text: "POI Bearbeiten", //git stash save "POI Bearbeiten" - icon: "/img/edit_icon.png", + icon: "/img/poi-edit.png", callback: () => handleEditPoi(marker), }, ], @@ -934,7 +951,8 @@ const MapComponent = ({ locations, onLocationUpdate }) => { marker.bindPopup(`
${location.description || "Unbekannt"}
- ${poiTypName}
+ ${deviceName}
+ ${poiTypName}
`); @@ -954,7 +972,6 @@ const MapComponent = ({ locations, onLocationUpdate }) => { //Informationen an handlePoiSelect übergeben handlePoiSelect(poiData); console.log("poiData in MapComponent.js:", poiData); - }); marker.on("mouseout", function () { this.closePopup(); diff --git a/config/config.js b/config/config.js index aa73f21ea..7c20e7597 100644 --- a/config/config.js +++ b/config/config.js @@ -24,17 +24,17 @@ if (typeof window !== "undefined") { // Konstruktion von URLs, die auf spezifische Ressourcen auf dem Server zeigen //http://localhost:3000/?m=10&u=485 -/* mapGisStationsStaticDistrictUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsStaticDistrict?idMap=${c}&idUser=${user}`; //idMap: 10, idUser: 484 + mapGisStationsStaticDistrictUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsStaticDistrict?idMap=${c}&idUser=${user}`; //idMap: 10, idUser: 484 mapGisStationsStatusDistrictUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsStatusDistrict?idMap=${c}&idUser=${user}`; mapGisStationsMeasurementsUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsMeasurements?idMap=${c}`; mapGisSystemStaticUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${c}&idUser=${user}`; - mapDataIconUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GetIconsStatic`; */ + mapDataIconUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GetIconsStatic`; - mapGisStationsStaticDistrictUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsStaticDistrict`; + /* mapGisStationsStaticDistrictUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsStaticDistrict`; mapGisStationsStatusDistrictUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsStatusDistrict`; mapGisStationsMeasurementsUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsMeasurements`; mapGisSystemStaticUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic`; - mapDataIconUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GetIconsStatic`; + mapDataIconUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GetIconsStatic`; */ } // Export der definierten Variablen und URLs, damit sie in anderen Teilen der Anwendung verwendet werden können diff --git a/pages/api/[...path].js b/pages/api/[...path].js index 6e8472c21..85f48688b 100644 --- a/pages/api/[...path].js +++ b/pages/api/[...path].js @@ -2,8 +2,8 @@ import { createProxyMiddleware } from "http-proxy-middleware"; export default createProxyMiddleware({ - target: "http://192.168.10.58:3001", - //target: "http://10.10.0.13", // Ziel-URL des Proxys + //target: "http://192.168.10.58:3001", + target: "http://10.10.0.13", // Ziel-URL des Proxys //target: "http://192.168.10.187:3000", // Ziel-URL des Proxys changeOrigin: true, pathRewrite: { diff --git a/public/img/poi-edit.png b/public/img/poi-edit.png new file mode 100644 index 0000000000000000000000000000000000000000..3b1c5bebc6eabd55171ade32701212cd0f9159ff GIT binary patch literal 955 zcmV;s14R6ZP)Px&bxA})RCr$P+`VoSK@^7JZ>(@BbU;s?28o)KSc*|_Nf{{xrlh8bEn>%pj+9i~ z0~H7ggeVX~)LeiUC5~f^9eieY&YoGHFZE>CdETA z3mEU7Gk^h%1&nvk8NdL>0>-=N3}66b0ps0s1~7oJz~%0Hz245Z@4t>h3pY{VHh?<- zJ|N&@F~!$cqkd20lX37syc3+PM?>FD~ERS#zKo$SeGZc6?9`)}rz&`?Y;Lmqi6nGZ<#JtrrpicbD z2xpUFe=lYhY;6Dod;sCoWO#hbeE=K$8T(||k2){-RZsokSszK{Bzbu&VaJ`^W&(!|9F594yqnkRq-1cpep_xJ#srM zty17OEBpmg?|nZb5Tx>--rO) zjGujgZO6|#fCv0+19-vDGJq%i>;ibh&nkdN{A>bv#m^#uXMFPj-tkQX5P!D%Wb!_M z_=}~#+5-@OdEK?v0K{Ki^sX%c@z=j`s3idLuYcX69)S4&f7hlOfcTqVbgBg){$_l& z=K$i%@Kpj3Uyh$V0P*ASlLjDuJbtnO#4m@RBmnWt<5vzq{A&1>0uaACe(3>fA#8ITL9v(zcor8AmR>e?NE(B1+Ds-G`~Nq z0N(Ib?t;o5Egtc+3E&k!ivXVS%>#JHHw{31rKJeTMVR;%mLep;93vNqeh!dtnj<9w z3?NZb9K!&LxROmXfJ8}g3fFiDB(+nU{QXIno dinx+Z{{h(ey?=!`l}Z2r002ovPDHLkV1mm}tj_=d literal 0 HcmV?d00001