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 50a9163c7..05cab5d54 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -71,8 +71,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(); @@ -898,6 +898,7 @@ const MapComponent = ({ locations, onLocationUpdate }) => { 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 marker = L.marker([latitude, longitude], { icon: L.icon({ diff --git a/components/PoiUpdateModal.js b/components/PoiUpdateModal.js index 4124a86e5..71df3181a 100644 --- a/components/PoiUpdateModal.js +++ b/components/PoiUpdateModal.js @@ -22,6 +22,7 @@ const PoiUpdateModal = ({ onClose, poiData }) => { setPoiTypeId(poiData.idPoiTyp); setDescription(poiData.description); + setDeviceName(poiData.idLD); console.log("Loaded POI Data for editing:", poiData); console.log("POI ID:", poiData.idPoi); console.log("POI Name:", poiData.name); @@ -110,8 +111,9 @@ const PoiUpdateModal = ({ onClose, poiData }) => { const data = await response.json(); //console.log("Standort- und Gerätedaten:", data); setLocationDeviceData(data); - if (data.length > 0) { - setDeviceName(data[0].name); // Set initial device name + if (poiData && poiData.idLD) { + const selectedDevice = data.find(device => device.id === poiData.idLD); + setDeviceName(selectedDevice ? selectedDevice.id : data[0].id); // Hier wird die ID als initialer Zustand gesetzt } } catch (error) { console.error( @@ -144,7 +146,7 @@ const PoiUpdateModal = ({ onClose, poiData }) => { name: name, description: description, idPoiTyp: poiTypeId, - idLD: idLD, + idLD: deviceName, //idLD: parseInt(deviceName, 10), // Konvertieren in eine Ganzzahl }), }); @@ -198,7 +200,7 @@ const PoiUpdateModal = ({ onClose, poiData }) => { className="block p-2 w-full border-2 border-gray-200 rounded-md text-sm" > {locationDeviceData.map((device, index) => ( - ))} diff --git a/config/config.js b/config/config.js index 438c781ba..476454dd7 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 e35627ffb..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/pages/api/readPoiTyp.js b/pages/api/readPoiTyp.js index 8e2ef8132..8f69a9f53 100644 --- a/pages/api/readPoiTyp.js +++ b/pages/api/readPoiTyp.js @@ -1,24 +1,20 @@ // pages/api/readPoiTyp.js -import mysql from "mysql"; +import mysql from 'mysql'; -const dbConfig = { +const pool = mysql.createPool({ + connectionLimit: 10, host: process.env.DB_HOST, user: process.env.DB_USER, password: process.env.DB_PASSWORD, database: process.env.DB_NAME, port: process.env.DB_PORT, -}; +}); export default function handler(req, res) { if (req.method === "GET") { - console.log("Empfangene Query-Parameter:", req.query); // Gibt alle empfangenen Query-Parameter aus - - const connection = mysql.createConnection(dbConfig); - const query = "SELECT * FROM poityp"; // Vereinfachte Abfrage zum Testen - - connection.query(query, (error, results) => { - connection.end(); - + const query = "SELECT * FROM poityp"; + + pool.query(query, (error, results) => { if (error) { console.error("Fehler beim Abfragen der Datenbank:", error); return res.status(500).json({ error: "Ein Fehler ist aufgetreten" });