diff --git a/.env.local b/.env.local index 1ae3ed34f..74656a298 100644 --- a/.env.local +++ b/.env.local @@ -7,13 +7,13 @@ DB_NAME=talas_v5 DB_PORT=3306 # Public Settings (Client braucht IP/Domain) , Variablen mit dem Präfix "NEXT_PUBLIC" ist in Browser sichtbar -NEXT_PUBLIC_DEBUG_LOG=true +NEXT_PUBLIC_DEBUG_LOG=false #auf dem Entwicklungsrechner dev läuft auf Port 3000 und auf dem Server prod auf Port 80, aber der WebService ist immer auf PORT 80 NEXT_PUBLIC_API_PORT_MODE=prod -NEXT_PUBLIC_USE_MOCKS=false +NEXT_PUBLIC_USE_MOCKS=true # Der Unterordner talas5 gleich hinter der IP-Adresse (oder Servername) muss konfigurierbar sein. # Es muss auch möglich sein kein Unterorder anzugeben (z.B. nur http://talasserver/). diff --git a/components/TestScript.js b/components/TestScript.js deleted file mode 100644 index 4a193d892..000000000 --- a/components/TestScript.js +++ /dev/null @@ -1,37 +0,0 @@ -// components/TestScript.js -import { useEffect } from "react"; -import setupPolylinesCode from "!!raw-loader!../utils/polylines/setupPolylines.js"; // Lädt die gesamte setupPolylines.js als Text - -export default function TestScript() { - useEffect(() => { - // Regulärer Ausdruck für "Stützpunkt entfernen" im Kontextmenü - const removeRegex = /marker\.on\("mouseover", function \(\) {\s*this\.bindContextMenu\({\s*contextmenuItems: \[\s*\{\s*text: "Stützpunkt entfernen"/; - - // Regulärer Ausdruck für "Stützpunkt hinzufügen" im Kontextmenü - const addRegex = /contextmenuItems: \[\s*\{\s*text: "Stützpunkt hinzufügen"/; - - // Stilvorlagen für das Konsolen-Logging - const successStyle = "color: #fff; background-color: #28a745; padding: 4px 8px; font-size: 14px; border-radius: 4px;"; - const failStyle = "color: #fff; background-color: #dc3545; padding: 4px 8px; font-size: 14px; border-radius: 4px;"; - const neutralStyle = "color: #006400; font-size: 14px; background-color: #f0f0f0; padding: 4px 8px; border-radius: 4px;"; - - // Überprüfung für "Stützpunkt entfernen" - if (removeRegex.test(setupPolylinesCode)) { - console.log("%c✔ Test bestanden: Der Text für 'Stützpunkt entfernen' wurde gefunden.", successStyle); - } else { - console.log("%c✘ Test fehlgeschlagen: Der Text für 'Stützpunkt entfernen' wurde nicht gefunden.", failStyle); - } - - // Überprüfung für "Stützpunkt hinzufügen" - if (addRegex.test(setupPolylinesCode)) { - console.log("%c✔ Test bestanden: Der Text für 'Stützpunkt hinzufügen' wurde gefunden.", successStyle); - } else { - //console.log("%c✘ Test fehlgeschlagen: Der Text für 'Stützpunkt hinzufügen' wurde nicht gefunden.", failStyle); - } - - // Beispiel einer neutralen Nachricht (falls benötigt) - console.log("%cℹ️ Info: Überprüfung abgeschlossen.", neutralStyle); - }, []); - - return null; // Keine visuelle Ausgabe erforderlich -} diff --git a/components/contextmenu/useMapContextMenu.js b/components/contextmenu/useMapContextMenu.js index 2ed3524e3..7ccd85712 100644 --- a/components/contextmenu/useMapContextMenu.js +++ b/components/contextmenu/useMapContextMenu.js @@ -12,7 +12,7 @@ const addItemsToMapContextMenu = ( setPopupCoordinates, openPopupWithCoordinates // Hier wird die Funktion als Parameter hinzugefügt ) => { - const openPoiModal = (e) => { + const openPoiModal = e => { setShowCoordinatesModal(false); // ✅ Jetzt verfügbar, weil als Parameter übergeben setPopupCoordinates(e.latlng); setShowPoiModal(true); @@ -29,7 +29,7 @@ const addItemsToMapContextMenu = ( map.contextmenu.addItem({ text: "Reinzoomen", icon: "img/zoom_in.png", - callback: (e) => { + callback: e => { const currentZoom = map.getZoom(); const newZoom = Math.min(15, currentZoom + 3); // Stellt sicher, dass max. 15 erreicht wird const zoomDifference = Math.abs(newZoom - currentZoom); // Anzahl der Zoom-Stufen @@ -61,7 +61,7 @@ const addItemsToMapContextMenu = ( map.contextmenu.addItem({ text: "Hier zentrieren", icon: "img/center_focus.png", - callback: (e) => { + callback: e => { map.panTo(e.latlng); }, }); @@ -71,8 +71,9 @@ const addItemsToMapContextMenu = ( if (!menuItemAdded && map && map.contextmenu) { const editMode = localStorage.getItem("editMode") === "true"; if (editMode) { - console.log("editMode localStorage:", localStorage.getItem("editMode")); - //console.log("editMode:", editMode); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("editMode localStorage:", localStorage.getItem("editMode")); + } map.contextmenu.addItem({ text: "POI hinzufügen", diff --git a/components/mainComponent/MapComponent.js b/components/mainComponent/MapComponent.js index 31145b01b..35422e420 100644 --- a/components/mainComponent/MapComponent.js +++ b/components/mainComponent/MapComponent.js @@ -148,7 +148,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { // Konstanten für die URLs - //console.log("priorityConfig in MapComponent1: ", priorityConfig); //----------------------------------------- const [linePositions, setLinePositions] = useState([]); const { lineColors, tooltipContents } = useLineData(); @@ -234,7 +233,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { } locations.forEach(location => {}); }; - //console.log("trigger in MapComponent.js:", poiReadTrigger); }, [map, locations, poiReadTrigger]); //-------------------------------------------- @@ -275,7 +273,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { ]); //--------------------------------------------- - //console.log("priorityConfig in MapComponent2: ", priorityConfig); + useEffect(() => { if (map) { } @@ -319,7 +317,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { ); newPolylines.forEach((polyline, index) => { - //console.log("polyline: ", polyline); const tooltipContent = tooltipContents[`${linePositions[index].idLD}-${linePositions[index].idModul}`] || "Die Linie ist noch nicht in Webservice vorhanden oder bekommt keine Daten"; @@ -380,14 +377,18 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { //Test in useEffect useEffect(() => { if (map) { - console.log("🗺️ Map-Einstellungen werden wiederhergestellt..."); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("🗺️ Map-Einstellungen werden wiederhergestellt..."); + } restoreMapSettings(map); } }, [map]); //-------------------------------------------- useEffect(() => { if (map) { - console.log("map in MapComponent: ", map); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("map in MapComponent: ", map); + } const handleMapMoveEnd = event => { const newCenter = map.getCenter(); const newZoom = map.getZoom(); @@ -411,8 +412,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { //-------------------------------------------- // Area in DataSheet ->dropdownmenu useEffect(() => { - //console.log("🔍 GisStationsStaticDistrict Inhalt:", GisStationsStaticDistrict); - // Sicherstellen, dass `Points` existiert und ein Array ist const points = GisStationsStaticDistrict?.Points; @@ -420,7 +419,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { const station = points.find(s => s.Area_Name === selectedArea); if (station) { - console.log("📌 Gefundene Station:", station); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("📌 Gefundene Station:", station); + } map.flyTo([station.X, station.Y], 14); } else { console.warn("⚠️ Keine passende Station für die Area gefunden:", selectedArea); @@ -464,7 +465,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { //-------------------------------------------- useEffect(() => { if (map) { - console.log("6- Karteninstanz (map) wurde jetzt erfolgreich initialisiert"); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("6- Karteninstanz (map) wurde jetzt erfolgreich initialisiert"); + } } }, [map]); //-------------------------------------------- @@ -474,7 +477,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { map.whenReady(() => { setTimeout(() => { if (map.contextmenu) { - //console.log("Contextmenu ist vorhanden"); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + //console.log("Contextmenu ist vorhanden"); + } } else { console.warn("Contextmenu ist nicht verfügbar."); } @@ -499,7 +504,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { const handleLocationUpdate = async (idLocation, idMap, newCoords) => { try { await dispatch(updateAreaThunk({ idLocation, idMap, newCoords })).unwrap(); - console.log("Koordinaten erfolgreich aktualisiert:", result); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("Koordinaten erfolgreich aktualisiert:", result); + } } catch (error) { console.error("Fehler beim Aktualisieren der Location:", error); } @@ -661,15 +668,15 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { //-------------------------------------- useEffect(() => { if (isPolylineContextMenuOpen && countdownActive) { - //console.log("🔄 Starte Redux-Countdown für Kontextmenü!"); - const interval = setInterval(() => { dispatch(updateCountdown()); // console.log(`⏳ Redux Countdown: ${countdown} Sekunden`); if (countdown <= 2) { - console.log("🚀 Kontextmenü wird wegen Countdown < 2 geschlossen."); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("🚀 Kontextmenü wird wegen Countdown < 2 geschlossen."); + } dispatch(closePolylineContextMenu()); if (window.map?.contextmenu) { @@ -690,7 +697,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { useEffect(() => { if (map) { window.map = map; - console.log("✅ window.map wurde gesetzt:", window.map); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("✅ window.map wurde gesetzt:", window.map); + } } }, [map]); @@ -756,7 +765,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { // 🧠 Optional für Debugging für überlappende Markers useEffect(() => { if (oms) { - console.log("📌 OMS ready:", oms); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("📌 OMS ready:", oms); + } window.oms = oms; // Für Debugging global } }, [oms]); @@ -764,7 +775,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { //---------------------------------------------- useEffect(() => { if (process.env.NODE_ENV === "development") { - alert("🚧 Development Mode aktiviert – Mock-Daten werden verwendet!"); + console.log("🚧 Development Mode aktiviert – Mock-Daten werden verwendet!"); + } else { + console.log("Production Mode aktiviert"); } }, []); //--------------------------------------------- diff --git a/components/uiWidgets/mapLayersControlPanel/MapLayersControlPanel.js b/components/uiWidgets/mapLayersControlPanel/MapLayersControlPanel.js index 8c6298d2c..cd9dc07b9 100644 --- a/components/uiWidgets/mapLayersControlPanel/MapLayersControlPanel.js +++ b/components/uiWidgets/mapLayersControlPanel/MapLayersControlPanel.js @@ -143,7 +143,9 @@ function MapLayersControlPanel() { //------------------------------ useEffect(() => { - console.log("🔍 GisStationsStaticDistrict Inhalt:", GisStationsStaticDistrict); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("🔍 GisStationsStaticDistrict Inhalt:", GisStationsStaticDistrict); + } if (!GisStationsStaticDistrict) { console.warn("⚠️ GisStationsStaticDistrict ist `null` oder nicht geladen."); @@ -172,8 +174,9 @@ function MapLayersControlPanel() { } return isUnique; }); - - console.log("📌 stationListing aktualisiert:", filteredAreas); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("📌 stationListing aktualisiert:", filteredAreas); + } }, [GisStationsStaticDistrict, GisSystemStatic]); //--------------------------- diff --git a/config/appVersion.js b/config/appVersion.js index a5d449b41..a2ba3996c 100644 --- a/config/appVersion.js +++ b/config/appVersion.js @@ -1,2 +1,2 @@ // /config/appVersion -export const APP_VERSION = "1.1.235"; +export const APP_VERSION = "1.1.236"; diff --git a/hooks/useAreaMarkersLayer.js b/hooks/useAreaMarkersLayer.js index 7f907daea..fb7d5eece 100644 --- a/hooks/useAreaMarkersLayer.js +++ b/hooks/useAreaMarkersLayer.js @@ -90,7 +90,9 @@ const useAreaMarkersLayer = (map, oms, apiUrl, onUpdateSuccess) => { newCoords: { x: lat, y: lng }, }) ).unwrap(); - console.log("✔️ Koordinaten erfolgreich aktualisiert:", { lat, lng }); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("✔️ Koordinaten erfolgreich aktualisiert:", { lat, lng }); + } onUpdateSuccess?.(); // optionaler Callback } catch (error) { console.error("❌ Fehler beim Aktualisieren der Koordinaten:", error); diff --git a/lib/OverlappingMarkerSpiderfier.js b/lib/OverlappingMarkerSpiderfier.js index 5093ae240..6116e243b 100644 --- a/lib/OverlappingMarkerSpiderfier.js +++ b/lib/OverlappingMarkerSpiderfier.js @@ -62,7 +62,7 @@ export class OverlappingMarkerSpiderfier { } nearbyMarkers(marker) { - return this.markers.filter((m) => { + return this.markers.filter(m => { const distance = this.map.distance(marker.getLatLng(), m.getLatLng()); return distance < this.nearbyDistance && marker !== m; }); @@ -74,7 +74,10 @@ export class OverlappingMarkerSpiderfier { markers.forEach((marker, i) => { const angle = this.circleStartAngle + (i * 2 * Math.PI) / markers.length; const legLength = this.circleFootSeparation * (2 + i / markers.length); - const newPt = L.point(centerPt.x + legLength * Math.cos(angle), centerPt.y + legLength * Math.sin(angle)); + const newPt = L.point( + centerPt.x + legLength * Math.cos(angle), + centerPt.y + legLength * Math.sin(angle) + ); const newLatLng = this.map.layerPointToLatLng(newPt); if (!marker._oms) { @@ -99,7 +102,7 @@ export class OverlappingMarkerSpiderfier { //--------------------------------------------------------------------------------------------- unspiderfy() { - this.markers.forEach((marker) => { + this.markers.forEach(marker => { if (marker._oms && marker._oms.spidered) { // Falls eine Linie existiert, entferne sie aus der Karte if (marker._oms.leg) { @@ -115,7 +118,9 @@ export class OverlappingMarkerSpiderfier { // 🔥 Künstliches Click-Event auslösen, um die UI zu aktualisieren setTimeout(() => { this.map.fire("click"); - console.log("Click-Event ausgelöst in OverlappingMarkerspiderfier.js in unspiderfy "); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("Click-Event ausgelöst in OverlappingMarkerspiderfier.js in unspiderfy "); + } }, 10); // Kurze Verzögerung, um sicherzustellen, dass die UI neu gerendert wird } diff --git a/pages/api/health.js b/pages/api/health.js new file mode 100644 index 000000000..f64e70923 --- /dev/null +++ b/pages/api/health.js @@ -0,0 +1,133 @@ +// /pages/api/health.js +export default async function handler(req, res) { + const basePath = "talas5"; + const protocol = "http"; + const hostname = "10.10.0.70"; + const port = "80"; + const idMap = "12"; + const idUser = "484"; + const idLD = "50922"; + + const buildUrl = method => + `${protocol}://${hostname}:${port}/${basePath}/ClientData/WebServiceMap.asmx/${method}?idMap=${idMap}&idUser=${idUser}`; + + const externalUrls = { + GisStationsStaticDistrict: buildUrl("GisStationsStaticDistrict"), + GisLinesStatus: `${protocol}://${hostname}:${port}/${basePath}/ClientData/WebServiceMap.asmx/GisLinesStatus?idMap=${idMap}`, + GisStationsMeasurements: buildUrl("GisStationsMeasurements"), + GisStationsStatusDistrict: buildUrl("GisStationsStatusDistrict"), + GisSystemStatic: buildUrl("GisSystemStatic"), + }; + + const internalApiBase = "http://localhost:3000"; + + const internalApis = { + //area + readArea: `${internalApiBase}/api/talas_v5_DB/area/readArea?m=${idMap}`, + //device + getAllStationsNames: `${internalApiBase}/api/talas_v5_DB/device/getAllStationsNames`, + getDevices: `${internalApiBase}/api/talas_v5_DB/device/getDevices`, + //gisLines + readGisLines: `${internalApiBase}/api/talas_v5_DB/gisLines/readGisLines`, + //locationDevice + getDeviceId: `${internalApiBase}/api/talas_v5_DB/locationDevice/getDeviceId`, + locationDeviceNameById: `${internalApiBase}/api/talas_v5_DB/locationDevice/locationDeviceNameById?idLD=${idLD}`, + locationDevices: `${internalApiBase}/api/talas_v5_DB/locationDevice/locationDevices`, + //pois + addPoi: `${internalApiBase}/api/talas_v5_DB/pois/addPoi`, + deletePoi: `${internalApiBase}/api/talas_v5_DB/pois/deletePoi`, + getPoiById: `${internalApiBase}/api/talas_v5_DB/pois/getPoiById`, + poiIcons: `${internalApiBase}/api/talas_v5_DB/pois/poi-icons`, + readAllPOIs: `${internalApiBase}/api/talas_v5_DB/pois/readAllPOIs`, + updateLocation: `${internalApiBase}/api/talas_v5_DB/pois/updateLocation`, + updatePoi: `${internalApiBase}/api/talas_v5_DB/pois/updatePoi`, + //poiTyp + readPoiTyp: `${internalApiBase}/api/talas_v5_DB/poiTyp/readPoiTyp`, + //station + getAllStationsNames: `${internalApiBase}/api/talas_v5_DB/station/getAllStationsNames`, + getDevices: `${internalApiBase}/api/talas_v5_DB/station/getDevices`, + // + priorityConfig: `${internalApiBase}/api/talas_v5_DB/priorityConfig`, + }; + + const results = {}; + + // Prüfe externe Webservices + await Promise.all( + Object.entries(externalUrls).map(async ([name, url]) => { + try { + const response = await fetch(url); + results[name] = { + ok: response.ok, + status: response.status, + url, + }; + + if (name === "GisSystemStatic" && response.ok) { + const data = await response.json(); + results["UserRights"] = { + ok: Array.isArray(data.Rights), + length: data.Rights?.length || 0, + }; + } + } catch (error) { + results[name] = { + ok: false, + error: error.message, + url, + }; + } + }) + ); + + // Prüfe interne API-Routen + await Promise.all( + Object.entries(internalApis).map(async ([name, url]) => { + try { + const response = await fetch(url); + results[`API_${name}`] = { + ok: response.ok, + status: response.status, + url, + }; + } catch (error) { + results[`API_${name}`] = { + ok: false, + error: error.message, + url, + }; + } + }) + ); + + // Prüfe Mock-Status + const useMocksEnv = process.env.NEXT_PUBLIC_USE_MOCKS; + results["MockMode"] = { + expected: "false", + actual: useMocksEnv, + ok: useMocksEnv === "false", + info: + useMocksEnv === "false" + ? "✅ Mockdaten deaktiviert – Live-Daten aktiv." + : "⚠️ Mockdaten aktiv – nicht für Produktion geeignet!", + }; + + // Prüfe Konfiguration der .env.production + results["envConfig"] = { + NODE_ENV: process.env.NODE_ENV || "undefined", + DB_HOST: process.env.DB_HOST || "❌ fehlt", + NEXT_PUBLIC_USE_MOCKS: useMocksEnv || "❌ fehlt", + status: + process.env.NODE_ENV === "production" && useMocksEnv === "false" && process.env.DB_HOST + ? "✅ .env.production scheint korrekt." + : "⚠️ Bitte .env.production prüfen – möglicherweise fehlt etwas.", + }; + + const allOk = Object.values(results).every(r => r.ok); + + res.status(allOk ? 200 : 207).json({ + status: allOk ? "ok" : "partial", + version: "1.0.0", + services: results, + }); +} diff --git a/pages/api/talas_v5_DB.zip b/pages/api/talas_v5_DB.zip new file mode 100644 index 000000000..42da8d2de Binary files /dev/null and b/pages/api/talas_v5_DB.zip differ diff --git a/pages/api/talas_v5_DB/area/updateArea.js b/pages/api/talas_v5_DB/area/updateArea.js index 8098c4a87..b7d23c316 100644 --- a/pages/api/talas_v5_DB/area/updateArea.js +++ b/pages/api/talas_v5_DB/area/updateArea.js @@ -2,7 +2,9 @@ import getPool from "../../../../utils/mysqlPool"; export default async function handler(req, res) { - console.log("Request erhalten:", req.method, req.body); // Debugging + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("Request erhalten:", req.method, req.body); // Debugging + } const pool = getPool(); @@ -15,7 +17,9 @@ export default async function handler(req, res) { const { idLocation, idMap, x, y } = req.body; if (!idLocation || !idMap || x === undefined || y === undefined) { - return res.status(400).json({ error: "Alle Felder (idLocation, idMap, x, y) sind erforderlich" }); + return res + .status(400) + .json({ error: "Alle Felder (idLocation, idMap, x, y) sind erforderlich" }); } let connection; @@ -23,18 +27,25 @@ export default async function handler(req, res) { try { // Verbindung zur Datenbank herstellen connection = await pool.getConnection(); - const query = "UPDATE location_coordinates SET x = ?, y = ? WHERE idLocation = ? AND idMaps = ?"; + const query = + "UPDATE location_coordinates SET x = ?, y = ? WHERE idLocation = ? AND idMaps = ?"; const [result] = await connection.query(query, [x, y, idLocation, idMap]); // Erfolgreiche Aktualisierung prüfen if (result.affectedRows > 0) { - return res.status(200).json({ success: true, message: "Koordinaten erfolgreich aktualisiert" }); + return res + .status(200) + .json({ success: true, message: "Koordinaten erfolgreich aktualisiert" }); } else { - return res.status(404).json({ error: "Kein Eintrag gefunden, der aktualisiert werden konnte" }); + return res + .status(404) + .json({ error: "Kein Eintrag gefunden, der aktualisiert werden konnte" }); } } catch (error) { console.error("Fehler beim Aktualisieren der Koordinaten:", error); - return res.status(500).json({ error: "Interner Serverfehler beim Aktualisieren der Koordinaten" }); + return res + .status(500) + .json({ error: "Interner Serverfehler beim Aktualisieren der Koordinaten" }); } finally { if (connection) { connection.release(); diff --git a/pages/api/talas_v5_DB/device/getDevices.js b/pages/api/talas_v5_DB/device/getDevices.js index 4bc41e534..d4f069dd9 100644 --- a/pages/api/talas_v5_DB/device/getDevices.js +++ b/pages/api/talas_v5_DB/device/getDevices.js @@ -1,5 +1,5 @@ // /pages/api/talas_v5_DB/device/getDevices.js -import getPool from "../../../../utils/mysqlPool"; // Import Singleton-Pool +import getPool from "@/utils/mysqlPool"; // Import Singleton-Pool // API-Handler export default async function handler(req, res) { diff --git a/pages/api/talas_v5_DB/gisLines/updateLineCoordinates.js b/pages/api/talas_v5_DB/gisLines/updateLineCoordinates.js index df5c425e8..ddca05e28 100644 --- a/pages/api/talas_v5_DB/gisLines/updateLineCoordinates.js +++ b/pages/api/talas_v5_DB/gisLines/updateLineCoordinates.js @@ -13,9 +13,12 @@ export default async function handler(req, res) { return res.status(400).json({ error: "Fehlende Daten" }); } - const newLineString = `LINESTRING(${newCoordinates.map((coord) => `${coord[0]} ${coord[1]}`).join(",")})`; + const newLineString = `LINESTRING(${newCoordinates + .map(coord => `${coord[0]} ${coord[1]}`) + .join(",")})`; - const query = "UPDATE talas_v5.gis_lines SET points = ST_GeomFromText(?) WHERE idLD = ? AND idModul = ?;"; + const query = + "UPDATE talas_v5.gis_lines SET points = ST_GeomFromText(?) WHERE idLD = ? AND idModul = ?;"; let connection; @@ -31,8 +34,9 @@ export default async function handler(req, res) { // Commit der Transaktion await connection.commit(); - - console.log("Transaction Complete."); + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("Transaction Complete."); + } res.status(200).json({ success: "Updated successfully.", affectedRows: results.affectedRows, diff --git a/pages/api/talas_v5_DB/pois/addPoi.js b/pages/api/talas_v5_DB/pois/addPoi.js index 5ea8044f5..8585a634f 100644 --- a/pages/api/talas_v5_DB/pois/addPoi.js +++ b/pages/api/talas_v5_DB/pois/addPoi.js @@ -6,9 +6,12 @@ export default async function handler(req, res) { if (req.method === "POST") { const { name, poiTypeId, latitude, longitude, idLD } = req.body; - console.log("Received data:", req.body); // Überprüfen der empfangenen Daten + if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") { + console.log("Received data:", req.body); // Überprüfen der empfangenen Daten + } - const query = "INSERT INTO poi (description, idPoiTyp, position, idLD) VALUES (?, ?, ST_GeomFromText(?),?)"; + const query = + "INSERT INTO poi (description, idPoiTyp, position, idLD) VALUES (?, ?, ST_GeomFromText(?),?)"; const point = `POINT(${longitude} ${latitude})`; const values = [name, poiTypeId, point, idLD]; diff --git a/pages/index.js b/pages/index.js index 58777a5ee..9741084e1 100644 --- a/pages/index.js +++ b/pages/index.js @@ -9,15 +9,16 @@ import { addPoiThunk } from "../redux/thunks/database/pois/addPoiThunk"; import { selectPoiMarkers } from "../redux/slices/database/pois/poiMarkersSlice"; import { selectAddPoiStatus, selectAddPoiError } from "../redux/slices/database/pois/addPoiSlice"; -const MapComponentWithNoSSR = dynamic(() => import("../components/mainComponent/MapComponent"), { ssr: false }); -const TestScriptWithNoSSR = dynamic(() => import("../components/TestScript"), { ssr: false }); +const MapComponentWithNoSSR = dynamic(() => import("../components/mainComponent/MapComponent"), { + ssr: false, +}); export default function Home() { const dispatch = useDispatch(); // Redux State const locations = useSelector(selectPoiMarkers); - const poiReadTrigger = useSelector((state) => state.poiReadFromDbTrigger.trigger); + const poiReadTrigger = useSelector(state => state.poiReadFromDbTrigger.trigger); const addPoiStatus = useSelector(selectAddPoiStatus); const addPoiError = useSelector(selectAddPoiError); @@ -27,7 +28,7 @@ export default function Home() { // URL-Parameter auslesen und POIs laden useEffect(() => { - const getURLParameter = (name) => { + const getURLParameter = name => { const params = new URLSearchParams(window.location.search); return params.get(name); }; @@ -58,7 +59,6 @@ export default function Home() { return (
❌ Fehler: {addPoiError}
}