diff --git a/.env.local b/.env.local index 53122566b..dbe4108e7 100644 --- a/.env.local +++ b/.env.local @@ -29,8 +29,8 @@ DB_PORT=3306 NEXT_PUBLIC_BASE_URL="http://10.10.0.70/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" +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 diff --git a/components/PoiUpdateModal.js b/components/PoiUpdateModal.js index 162d7fb57..09940017b 100644 --- a/components/PoiUpdateModal.js +++ b/components/PoiUpdateModal.js @@ -17,9 +17,7 @@ const PoiUpdateModal = ({ onClose, poiData }) => { const [idLD, setIdLD] = useState(poiData ? poiData.idLD : ""); const [idLocationDevice, setIdLocationDevice] = useState(""); - const [description, setDescription] = useState( - poiData ? poiData.description : "" - ); + const [description, setDescription] = useState(poiData ? poiData.description : ""); // Log the initial POI data useEffect(() => { @@ -65,16 +63,11 @@ const PoiUpdateModal = ({ onClose, poiData }) => { const fetchDeviceId = async () => { if (poiData && poiData.idLD) { try { - const response = await fetch( - `/api/talas_v5_DB/locationDevice/getDeviceIdById?idLD=${poiData.idLD}` - ); + const response = await fetch(`/api/talas_v5_DB/locationDevice/getDeviceIdById?idLD=${poiData.idLD}`); const data = await response.json(); if (data) setDeviceName(data.name); } catch (error) { - console.error( - "Fehler beim Abrufen der Geräteinformation in PoiUpdateModel.js: ", - error - ); + console.error("Fehler beim Abrufen der Geräteinformation in PoiUpdateModel.js: ", error); } } }; @@ -86,12 +79,9 @@ const PoiUpdateModal = ({ onClose, poiData }) => { const handleDeletePoi = async () => { if (confirm("Sind Sie sicher, dass Sie diesen POI löschen möchten?")) { try { - const response = await fetch( - `/api/talas_v5_DB/pois/deletePoi?id=${poiId}`, - { - method: "DELETE", - } - ); + const response = await fetch(`/api/talas_v5_DB/pois/deletePoi?id=${poiId}`, { + method: "DELETE", + }); if (response.ok) { alert("POI wurde erfolgreich gelöscht."); onClose(); // Close the modal @@ -101,7 +91,7 @@ const PoiUpdateModal = ({ onClose, poiData }) => { throw new Error("Fehler beim Löschen des POI."); } } catch (error) { - console.error("Fehler beim Löschen des POI:", error); + console.error("Fehler beim Löschen des POI 1:", error); alert("Fehler beim Löschen des POI."); } } @@ -137,18 +127,13 @@ const PoiUpdateModal = ({ onClose, poiData }) => { setLocationDeviceData(data); console.log("Standort- und Gerätedaten poiData:", poiData); if (poiData && poiData.idLD) { - const selectedDevice = data.find( - (device) => device.id === 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 console.log("Selected Device:", selectedDevice); console.log("Selected devciceName:", deviceName); } } catch (error) { - console.error( - "Fehler beim Abrufen der Standort- und Gerätedaten:", - error - ); + console.error("Fehler beim Abrufen der Standort- und Gerätedaten:", error); } }; fetchData(); @@ -165,9 +150,7 @@ const PoiUpdateModal = ({ onClose, poiData }) => { console.log("Standort- und Gerätedaten 3:", data); console.log("Standort- und Gerätedaten 3 poiData:", poiData); // Findet das Gerät, das der aktuellen IDLD entspricht - const currentDevice = data.find( - (device) => device.idLD === currentPoi.idLD - ); + const currentDevice = data.find((device) => device.idLD === currentPoi.idLD); if (currentDevice) { setDeviceName(currentDevice.name); } @@ -184,9 +167,7 @@ const PoiUpdateModal = ({ onClose, poiData }) => { const handleSubmit = async (event) => { event.preventDefault(); - const idLDResponse = await fetch( - `/api/talas_v5_DB/locationDevice/getDeviceId?deviceName=${encodeURIComponent(deviceName)}` - ); + const idLDResponse = await fetch(`/api/talas_v5_DB/locationDevice/getDeviceId?deviceName=${encodeURIComponent(deviceName)}`); const idLDData = await idLDResponse.json(); const idLD = idLDData.idLD; try { @@ -210,9 +191,7 @@ const PoiUpdateModal = ({ onClose, poiData }) => { window.location.reload(); } else { const errorResponse = await response.json(); - throw new Error( - errorResponse.error || "Fehler beim Aktualisieren des POI." - ); + throw new Error(errorResponse.error || "Fehler beim Aktualisieren des POI."); } } catch (error) { console.error("Fehler beim Aktualisieren des POI:", error); @@ -224,14 +203,8 @@ const PoiUpdateModal = ({ onClose, poiData }) => { console.log("Selected POI:", selectedPoi); console.log("Selected POI Gerät id in poiUpdateModal.js:", selectedPoi.id); console.log("Selected POI Typ name in poiUpdateModal.js:", selectedPoi.typ); //als Typ in dropdown menu - console.log( - "Selected POI Beschreibung in poiUpdateModal.js:", - selectedPoi.description - ); - console.log( - "Selected POI Gerät deviceId in poiUpdateModal.js:", - selectedPoi.deviceId - ); + console.log("Selected POI Beschreibung in poiUpdateModal.js:", selectedPoi.description); + console.log("Selected POI Gerät deviceId in poiUpdateModal.js:", selectedPoi.deviceId); return (