merge fix v1.0.8.1 Browser lädt ständig die Seite neu wenn keine Linien existieren

This commit is contained in:
ISA
2025-02-12 14:51:17 +01:00
parent 72c57b3f88
commit 6f1df8db94
69 changed files with 1038 additions and 4298 deletions

View File

@@ -0,0 +1,855 @@
// components/MapComponent.js //fix:v1.0.8.1 Browser lädt ständig die Karte neu
import React, { useEffect, useRef, useState, useCallback } from "react";
import L, { marker } from "leaflet";
import "leaflet/dist/leaflet.css";
import "leaflet-contextmenu/dist/leaflet.contextmenu.css";
import "leaflet-contextmenu";
import * as config from "../config/config.js";
import * as urls from "../config/urls.js";
import "leaflet.smooth_marker_bouncing";
import OverlappingMarkerSpiderfier from "overlapping-marker-spiderfier-leaflet";
import DataSheet from "./DataSheet.js";
import { useRecoilState, useRecoilValue, useSetRecoilState } from "recoil";
import { gisStationsStaticDistrictState } from "../store/atoms/gisStationState.js";
import { gisSystemStaticState } from "../store/atoms/gisSystemState.js";
import { mapLayersState } from "../store/atoms/mapLayersState.js";
import { selectedAreaState } from "../store/atoms/selectedAreaState.js";
import { zoomTriggerState } from "../store/atoms/zoomTriggerState.js";
import { poiTypState } from "../store/atoms/poiTypState.js";
import AddPoiModalWindow from "./pois/AddPoiModalWindow.js";
import { poiReadFromDbTriggerAtom } from "../store/atoms/poiReadFromDbTriggerAtom.js";
import { InformationCircleIcon } from "@heroicons/react/20/solid"; // oder 'outline'
import PoiUpdateModal from "./pois/PoiUpdateModal.js";
import { selectedPoiState } from "../store/atoms/poiState.js";
import { currentPoiState } from "../store/atoms/currentPoiState.js";
import { ToastContainer, toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import { mapIdState, userIdState } from "../store/atoms/urlParameterState.js";
import { poiLayerVisibleState } from "../store/atoms/poiLayerVisibleState.js";
import plusRoundIcon from "./PlusRoundIcon.js";
import { parsePoint, findClosestPoints } from "../utils/geometryUtils.js";
import { insertNewPOI, removePOI, handleEditPoi } from "../utils/poiUtils.js";
import { createAndSetDevices } from "../utils/createAndSetDevices.js";
import { redrawPolyline, restoreMapSettings, checkOverlappingMarkers } from "../utils/mapUtils.js";
import circleIcon from "./gisPolylines/icons/CircleIcon.js";
import startIcon from "./gisPolylines/icons/StartIcon.js";
import endIcon from "./gisPolylines/icons/EndIcon.js";
import { fetchGisStatusStations, fetchPriorityConfig, fetchPoiData, updateLocationInDatabase, fetchUserRights, fetchDeviceNameById } from "../services/apiService.js";
import { addContextMenuToMarker } from "../utils/addContextMenuToMarker.js";
import { MAP_VERSION } from "../config/settings.js";
import * as layers from "../config/layers.js";
import { zoomIn, zoomOut, centerHere } from "../utils/zoomAndCenterUtils.js";
import { initializeMap } from "../utils/initializeMap.js";
import { addItemsToMapContextMenu } from "./useMapContextMenu.js";
import useGmaMarkersLayer from "../hooks/layers/useGmaMarkersLayer.js"; // Import the custom hook
import useTalasMarkersLayer from "../hooks/layers/useTalasMarkersLayer.js"; // Import the custom hook
import useEciMarkersLayer from "../hooks/layers/useEciMarkersLayer.js";
import useGsmModemMarkersLayer from "../hooks/layers/useGsmModemMarkersLayer.js";
import useCiscoRouterMarkersLayer from "../hooks/layers/useCiscoRouterMarkersLayer.js";
//import useLteModemMarkersLayer from "../hooks/layers/useLteModemMarkersLayer";
import useWagoMarkersLayer from "../hooks/layers/useWagoMarkersLayer.js";
import useSiemensMarkersLayer from "../hooks/layers/useSiemensMarkersLayer.js";
import useOtdrMarkersLayer from "../hooks/layers/useOtdrMarkersLayer.js";
import useWdmMarkersLayer from "../hooks/layers/useWdmMarkersLayer.js";
import useMessstellenMarkersLayer from "../hooks/layers/useMessstellenMarkersLayer.js";
import useTalasiclMarkersLayer from "../hooks/layers/useTalasiclMarkersLayer.js";
import useDauzMarkersLayer from "../hooks/layers/useDauzMarkersLayer.js";
import useSmsfunkmodemMarkersLayer from "../hooks/layers/useSmsfunkmodemMarkersLayer.js";
import useUlafMarkersLayer from "../hooks/layers/useUlafMarkersLayer.js";
import useSonstigeMarkersLayer from "../hooks/layers/useSonstigeMarkersLayer.js";
import handlePoiSelect from "../utils/handlePoiSelect.js";
import { fetchGisStationsStaticDistrict, fetchGisStationsStatusDistrict, fetchGisStationsMeasurements, fetchGisSystemStatic } from "../services/fetchData.js";
import { setupPolylines } from "../utils/setupPolylines.js";
import { setupPOIs } from "../utils/setupPOIs.js";
import VersionInfoModal from "./VersionInfoModal.js";
//--------------------------------------------
import PoiUpdateModalWrapper from "./pois/PoiUpdateModalWrapper";
import AddPoiModalWindowWrapper from "./pois/AddPoiModalWindowWrapper";
import useFetchPoiData from "../hooks/useFetchPoiData";
import usePoiTypData from "../hooks/usePoiTypData";
import useMarkerLayers from "../hooks/useMarkerLayers";
import useLayerVisibility from "../hooks/useLayerVisibility";
import useLineData from "../hooks/useLineData.js";
import useCreateAndSetDevices from "../hooks/useCreateAndSetDevices";
//import { useCreateAndSetDevices } from "../hooks/useCreateAndSetDevices";
import { useMapComponentState } from "../hooks/useMapComponentState";
import { polylineEventsDisabledState } from "../store/atoms/polylineEventsDisabledState";
import { disablePolylineEvents, enablePolylineEvents } from "../utils/setupPolylines";
import { polylineLayerVisibleState } from "../store/atoms/polylineLayerVisibleState";
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
const polylineVisible = useRecoilValue(polylineLayerVisibleState);
const [editMode, setEditMode] = useState(false); // editMode Zustand
const { deviceName, setDeviceName } = useMapComponentState();
const { poiTypData, isPoiTypLoaded } = usePoiTypData("/api/talas_v5_DB/poiTyp/readPoiTyp");
//const [deviceName, setDeviceName] = useState("");
const [locationDeviceData, setLocationDeviceData] = useState([]);
const [priorityConfig, setPriorityConfig] = useState([]);
const [menuItemAdded, setMenuItemAdded] = useState(false);
const poiLayerVisible = useRecoilValue(poiLayerVisibleState);
const [isRightsLoaded, setIsRightsLoaded] = useState(false);
const [hasRights, setHasRights] = useState(false);
const [mapId, setMapId] = useRecoilState(mapIdState);
const [userId, setUserId] = useRecoilState(userIdState);
const [AddPoiModalWindowState, setAddPoiModalWindowState] = useState(false);
const [userRights, setUserRights] = useState(null);
const setSelectedPoi = useSetRecoilState(selectedPoiState);
const [showPoiUpdateModal, setShowPoiUpdateModal] = useState(false);
const [currentPoiData, setCurrentPoiData] = useState(null);
const setCurrentPoi = useSetRecoilState(currentPoiState);
const [showVersionInfoModal, setShowVersionInfoModal] = useState(false);
const zoomTrigger = useRecoilValue(zoomTriggerState);
const [gisSystemStaticLoaded, setGisSystemStaticLoaded] = useState(false);
const [poiTypMap, setPoiTypMap] = useState(new Map());
const [showPopup, setShowPopup] = useState(false);
const poiReadTrigger = useRecoilValue(poiReadFromDbTriggerAtom);
const poiLayerRef = useRef(null); // Referenz auf die Layer-Gruppe für Datenbank-Marker
const mapRef = useRef(null); // Referenz auf das DIV-Element der Karte
const [map, setMap] = useState(null); // Zustand der Karteninstanz
const [oms, setOms] = useState(null); // State für OMS-Instanz
const [GisStationsStaticDistrict, setGisStationsStaticDistrict] = useRecoilState(gisStationsStaticDistrictState);
const [GisStationsStatusDistrict, setGisStationsStatusDistrict] = useState([]); // Zustand für Statusdaten
const [GisStationsMeasurements, setGisStationsMeasurements] = useState([]); // Zustand für Messdaten
const [GisSystemStatic, setGisSystemStatic] = useRecoilState(gisSystemStaticState); // Zustand für Systemdaten
// Konstanten für die URLs
const mapGisStationsStaticDistrictUrl = config.mapGisStationsStaticDistrictUrl;
const mapGisStationsStatusDistrictUrl = config.mapGisStationsStatusDistrictUrl;
const mapGisStationsMeasurementsUrl = config.mapGisStationsMeasurementsUrl;
const mapGisSystemStaticUrl = config.mapGisSystemStaticUrl;
const webserviceGisLinesStatusUrl = config.webserviceGisLinesStatusUrl;
//console.log("priorityConfig in MapComponent1: ", priorityConfig);
const [gmaMarkers, setGmaMarkers] = useState([]); //--------------------station.System === 11 alle sind untetschiedlich Nummern
const [talasMarkers, setTalasMarkers] = useState([]);
const [eciMarkers, setEciMarkers] = useState([]);
const [gsmModemMarkers, setGsmModemMarkers] = useState([]);
const [ciscoRouterMarkers, setCiscoRouterMarkers] = useState([]);
const [wagoMarkers, setWagoMarkers] = useState([]);
const [siemensMarkers, setSiemensMarkers] = useState([]);
const [otdrMarkers, setOtdrMarkers] = useState([]);
const [wdmMarkers, setWdmMarkers] = useState([]);
const [messstellenMarkers, setMessstellenMarkers] = useState([]);
const [talasiclMarkers, setTalasiclMarkers] = useState([]);
const [dauzMarkers, setDauzMarkers] = useState([]);
const [smsfunkmodemMarkers, setSmsfunkmodemMarkers] = useState([]);
const [ulafMarkers, setUlafMarkers] = useState([]);
const [sonstigeMarkers, setSonstigeMarkers] = useState([]);
//const [lteModemMarkers, setLteModemMarkers] = useState([]);
const [lineStatusData, setLineStatusData] = useState([]);
const [linesData, setLinesData] = useState([]);
const mapLayersVisibility = useRecoilValue(mapLayersState);
const selectedArea = useRecoilValue(selectedAreaState);
const poiData = useFetchPoiData("/api/talas_v5_DB/pois/poi-icons");
const [linePositions, setLinePositions] = useState([]);
const { lineColors, tooltipContents } = useLineData(webserviceGisLinesStatusUrl, setLineStatusData);
const [polylines, setPolylines] = useState([]);
const [markers, setMarkers] = useState([]);
const closePopup = () => setShowPopup(false);
const [newPoint, setNewPoint] = useState(null);
const [newCoords, setNewCoords] = useState(null);
const [tempMarker, setTempMarker] = useState(null);
const [popupCoordinates, setPopupCoordinates] = useState({
lat: 52.52,
lng: 13.405,
});
const handleAddStation = (stationData) => {
setAddPoiModalWindowState(false);
closePopup(); // Schließt das Popup nach dem Hinzufügen
};
const openVersionInfoModal = () => {
setShowVersionInfoModal(true);
};
const closeVersionInfoModal = () => {
setShowVersionInfoModal(false);
};
const [currentZoom, setCurrentZoom] = useState(() => {
const storedZoom = localStorage.getItem("mapZoom");
return storedZoom ? parseInt(storedZoom, 10) : 12;
});
const [currentCenter, setCurrentCenter] = useState(() => {
const storedCenter = localStorage.getItem("mapCenter");
try {
return storedCenter ? JSON.parse(storedCenter) : [53.111111, 8.4625];
} catch (e) {
console.error("Error parsing stored map center:", e);
return [53.111111, 8.4625];
}
});
const [polylineEventsDisabled, setPolylineEventsDisabled] = useRecoilState(polylineEventsDisabledState); // Recoil State
//---------------------------------------------------------------
/* useEffect(() => {
fetchGisStatusStations(12, 484); // Beispielaufruf mit idMap = 10 und idUser = 484
}, []); */
useEffect(() => {
const params = new URL(window.location.href).searchParams;
setMapId(params.get("m"));
setUserId(params.get("u"));
}, [setMapId, setUserId]);
useEffect(() => {
if (map && poiLayerRef.current && isPoiTypLoaded && !menuItemAdded && isRightsLoaded) {
//console.log("Überprüfung der Berechtigung vor addItemsToMapContextMenu: ", hasRights);
addItemsToMapContextMenu(hasRights);
}
}, [
map,
poiLayerRef,
isPoiTypLoaded,
menuItemAdded, // Hinzufügen zu den Abhängigkeiten, um den Effekt korrekt zu steuern
hasRights, // Sicherstellen, dass hasRights berücksichtigt wird
isRightsLoaded, // Überprüfung, ob die Rechte geladen sind
]);
useEffect(() => {
const fetchAndSetUserRights = async () => {
const rights = await fetchUserRights();
setUserRights(rights);
setIsRightsLoaded(true);
// Sicherstellen, dass `rights` ein Array ist, bevor `.includes()` aufgerufen wird
setHasRights(localStorage.getItem("editMode") && Array.isArray(rights) && rights.includes(56));
};
fetchAndSetUserRights();
}, []);
useGmaMarkersLayer(
map,
gmaMarkers,
GisStationsMeasurements,
layers.MAP_LAYERS.GMA,
oms,
mapLayersVisibility.GMA // Übergebe die Sichtbarkeitsbedingung als Parameter
);
useSmsfunkmodemMarkersLayer(
map,
oms,
GisSystemStatic,
priorityConfig,
mapLayersVisibility.SMSFunkmodem // Sichtbarkeitsstatus aus dem State
);
useEffect(() => {
const fetchWebServiceMap = async () => {
try {
// Zähler für externe API-Aufrufe in localStorage speichern
let requestCount = localStorage.getItem("fetchWebServiceMap") || 0;
requestCount = parseInt(requestCount, 10);
const fetchOptions = {
method: "GET",
headers: {
Connection: "close", // Keep-Alive-Header hinzufügen
},
};
/*
await fetchGisStationsStaticDistrict(mapGisStationsStaticDistrictUrl, setGisStationsStaticDistrict, fetchOptions);
await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStationsStatusDistrict, fetchOptions);
await fetchGisStationsMeasurements(mapGisStationsMeasurementsUrl, setGisStationsMeasurements, fetchOptions);
await fetchGisSystemStatic(mapGisSystemStaticUrl, setGisSystemStatic, setGisSystemStaticLoaded, fetchOptions);
*/
// Fetch GIS Stations Static District
await fetchGisStationsStaticDistrict(mapGisStationsStaticDistrictUrl, setGisStationsStaticDistrict, fetchOptions);
requestCount++; // Zähler erhöhen
localStorage.setItem("fetchWebServiceMap", requestCount);
//console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`);
// Fetch GIS Stations Status District
await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStationsStatusDistrict, fetchOptions);
requestCount++; // Zähler erhöhen
localStorage.setItem("fetchWebServiceMap", requestCount);
//console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`);
// Fetch GIS Stations Measurements
await fetchGisStationsMeasurements(mapGisStationsMeasurementsUrl, setGisStationsMeasurements, fetchOptions);
requestCount++; // Zähler erhöhen
localStorage.setItem("fetchWebServiceMap", requestCount);
//console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`);
// Fetch GIS System Static
await fetchGisSystemStatic(mapGisSystemStaticUrl, setGisSystemStatic, setGisSystemStaticLoaded, fetchOptions);
requestCount++; // Zähler erhöhen
localStorage.setItem("fetchWebServiceMap", requestCount);
//console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`);
} catch (error) {
console.error("Error fetching data:", error);
}
};
fetchWebServiceMap();
}, []);
//--------------------------------------------------------
useEffect(() => {
const endpoint = "/api/talas_v5_DB/gisLines/readGisLines";
//const endpoint = "http://localhost/talas5/ClientData/WebServiceMap.asmx/GisLinesStatus?idMap=10";
fetch(endpoint)
.then((response) => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then((data) => {
const newLinePositions = data.map((item) => {
//console.log("item.idLD", item.idLD);
//console.log("item.idModul", item.idModul);
if (item.points && Array.isArray(item.points)) {
return {
coordinates: item.points.map((point) => [point.x, point.y]),
idModul: item.idModul,
idLD: item.idLD,
};
} else {
throw new Error("Points missing or not an array");
}
});
setLinePositions(newLinePositions);
})
.catch((error) => {
console.error("Error fetching data:", error.message);
});
}, []);
//--------------------------------------------
useEffect(() => {
const fetchPoiTypData = async () => {
try {
const response = await fetch("/api/talas_v5_DB/poiTyp/readPoiTyp");
const data = await response.json();
if (data.warning) {
toast.warn(data.warning, { position: "top-center", autoClose: 5000 });
setPoiTypMap(new Map()); // Leere Map setzen
return;
}
if (!Array.isArray(data)) {
console.warn(`Unerwartetes Format: ${JSON.stringify(data)}`);
throw new Error("Daten sind kein Array");
}
const map = new Map();
data.forEach((item) => map.set(item.idPoiTyp, item.name));
setPoiTypMap(map);
} catch (error) {
console.error("Fehler beim Abrufen der poiTyp-Daten in MapComponent.js :", error);
}
};
fetchPoiTypData();
}, []);
//--------------------------------------------
useEffect(() => {
const fetchPoiData = async () => {
try {
const response = await fetch("/api/talas_v5_DB/pois/poi-icons");
if (!response.ok) {
throw new Error("Network response was not ok");
}
const data = await response.json();
} catch (error) {
console.error("Fehler beim Abrufen der poiData-2:", error);
}
};
//--------------------------------------------
fetchPoiData();
}, []);
useEffect(() => {
if (map) {
const dbLayer = new L.LayerGroup().addTo(map); // Define dbLayer here
return () => {
dbLayer.remove();
};
}
}, [map]);
useEffect(() => {
if (map && !poiLayerRef.current) {
poiLayerRef.current = new L.LayerGroup().addTo(map);
}
return () => {
if (map && poiLayerRef.current) {
map.removeLayer(poiLayerRef.current);
poiLayerRef.current = new L.LayerGroup().addTo(map);
}
locations.forEach((location) => {});
};
//console.log("trigger in MapComponent.js:", poiReadTrigger);
}, [map, locations, poiReadTrigger]);
//--------------------------------------------
useEffect(() => {
if (poiData.length === 0) return;
setupPOIs(map, locations, poiData, poiTypMap, userRights, poiLayerRef, setSelectedPoi, setLocationDeviceData, setDeviceName, setCurrentPoi, poiLayerVisible, fetchPoiData, toast, setShowPoiUpdateModal, setCurrentPoiData, deviceName);
}, [map, locations, onLocationUpdate, poiReadTrigger, isPoiTypLoaded, userRights, poiLayerVisible, poiData, poiTypMap]);
//---------------------------------------------
//console.log("priorityConfig in MapComponent2: ", priorityConfig);
useEffect(() => {
if (gisSystemStaticLoaded && map) {
}
}, [gisSystemStaticLoaded, map, GisSystemStatic, priorityConfig]);
//useCreateAndSetDevices(1, talasMarkers, GisSystemStatic, priorityConfig);
useLayerVisibility(map, talasMarkers, mapLayersVisibility, "TALAS", oms);
useLayerVisibility(map, eciMarkers, mapLayersVisibility, "ECI", oms);
useLayerVisibility(map, gsmModemMarkers, mapLayersVisibility, "GSMModem", oms);
useLayerVisibility(map, ciscoRouterMarkers, mapLayersVisibility, "CiscoRouter", oms);
//useLayerVisibility(map, lteModemMarkers, mapLayersVisibility, "LTEModem", oms);
useLayerVisibility(map, wagoMarkers, mapLayersVisibility, "WAGO", oms);
useLayerVisibility(map, siemensMarkers, mapLayersVisibility, "Siemens", oms);
useLayerVisibility(map, otdrMarkers, mapLayersVisibility, "OTDR", oms);
useLayerVisibility(map, wdmMarkers, mapLayersVisibility, "WDM", oms);
useLayerVisibility(map, gmaMarkers, mapLayersVisibility, "GMA", oms);
useLayerVisibility(map, sonstigeMarkers, mapLayersVisibility, "Sonstige", oms);
useLayerVisibility(map, talasiclMarkers, mapLayersVisibility, "TALASICL", oms);
useLayerVisibility(map, dauzMarkers, mapLayersVisibility, "DAUZ", oms);
useLayerVisibility(map, smsfunkmodemMarkers, mapLayersVisibility, "SMSModem", oms);
useLayerVisibility(map, messstellenMarkers, mapLayersVisibility, "Messstellen", oms);
useLayerVisibility(map, ulafMarkers, mapLayersVisibility, "ULAF", oms);
useEffect(() => {
if (map) {
var x = 51.41321407879154;
var y = 7.739617925303934;
var zoom = 7;
if (map && map.flyTo) {
map.flyTo([x, y], zoom);
} else {
console.error("Map object is not ready or does not have flyTo method");
}
}
}, [map, zoomTrigger]);
//--------------------------------------------
useEffect(() => {
if (map) {
// Sammle alle Marker in einer einzigen Liste
const allMarkers = [
...talasMarkers,
...eciMarkers,
...gsmModemMarkers,
...ciscoRouterMarkers,
...wagoMarkers,
...siemensMarkers,
...otdrMarkers,
...wdmMarkers,
...gmaMarkers,
...messstellenMarkers,
...talasiclMarkers,
...dauzMarkers,
...smsfunkmodemMarkers,
...sonstigeMarkers,
...ulafMarkers,
];
// Überprüfe überlappende Marker und füge das "Plus"-Icon hinzu
checkOverlappingMarkers(map, allMarkers, plusRoundIcon);
}
}, [map, talasMarkers, eciMarkers, gsmModemMarkers, ciscoRouterMarkers, wagoMarkers, siemensMarkers, otdrMarkers, wdmMarkers, gmaMarkers, messstellenMarkers, talasiclMarkers, dauzMarkers, smsfunkmodemMarkers, sonstigeMarkers, ulafMarkers]);
//--------------------------------------------
useEffect(() => {
const fetchData = async () => {
try {
const response1 = await fetch(webserviceGisLinesStatusUrl);
const data1 = await response1.json();
//console.log("data1.Statis", data1.Statis);
const reversedData = data1.Statis.reverse();
setLineStatusData(reversedData);
const response2 = await fetch("/api/talas_v5_DB/gisLines/readGisLines");
const data2 = await response2.json();
const colorsByModule = {};
reversedData.forEach((stat) => {
const matchingLine = data2.find((item) => item.idLD === stat.IdLD && item.idModul === stat.Modul);
if (matchingLine) {
colorsByModule[matchingLine.idModul] = stat.PrioColor;
//console.log("Übereinstimmung gefunden für: ", stat);
setLinesData(matchingLine);
}
});
//setLineColors(colorsByModule);
} catch (error) {
console.error("Error fetching data:", error);
}
};
fetchData();
}, []);
//--------------------------------------------
//Tooltip an mouse position anzeigen für die Linien
useEffect(() => {
if (!map) return;
// Entferne alte Marker und Polylinien
markers.forEach((marker) => marker.remove());
polylines.forEach((polyline) => polyline.remove());
// Setze neue Marker und Polylinien mit den aktuellen Daten
const { markers: newMarkers, polylines: newPolylines } = setupPolylines(
map,
linePositions,
lineColors,
tooltipContents,
setNewCoords,
tempMarker,
polylineVisible // polylineVisible wird jetzt korrekt übergeben
);
newPolylines.forEach((polyline, index) => {
const tooltipContent = tooltipContents[`${linePositions[index].idLD}-${linePositions[index].idModul}`] || "Standard-Tooltip-Inhalt";
polyline.bindTooltip(tooltipContent, {
permanent: false,
direction: "auto",
sticky: true,
offset: [20, 0],
pane: "tooltipPane",
});
polyline.on("mouseover", (e) => {
const tooltip = polyline.getTooltip();
if (tooltip) {
const mousePos = e.containerPoint;
const mapSize = map.getSize();
let direction = "right";
if (mousePos.x > mapSize.x - 100) {
direction = "left";
} else if (mousePos.x < 100) {
direction = "right";
}
if (mousePos.y > mapSize.y - 100) {
direction = "top";
} else if (mousePos.y < 100) {
direction = "bottom";
}
tooltip.options.direction = direction;
polyline.openTooltip(e.latlng);
}
});
polyline.on("mouseout", () => {
polyline.closeTooltip();
});
});
setMarkers(newMarkers);
setPolylines(newPolylines);
}, [map, linePositions, lineColors, tooltipContents, newPoint, newCoords, tempMarker, polylineVisible]);
//--------------------------------------------
useEffect(() => {
if (map) {
restoreMapSettings(map);
}
}, [map]);
useEffect(() => {
if (map) {
const handleMapMoveEnd = (event) => {
const newCenter = map.getCenter();
const newZoom = map.getZoom();
setCurrentCenter([newCenter.lat, newCenter.lng]);
setCurrentZoom(newZoom);
localStorage.setItem("mapCenter", JSON.stringify([newCenter.lat, newCenter.lng]));
localStorage.setItem("mapZoom", newZoom);
};
map.on("moveend", handleMapMoveEnd);
map.on("zoomend", handleMapMoveEnd);
return () => {
map.off("moveend", handleMapMoveEnd);
map.off("zoomend", handleMapMoveEnd);
};
}
}, [map]);
//--------------------------------------------
useEffect(() => {
if (selectedArea && map) {
const station = GisStationsStaticDistrict.find((s) => s.Area_Name === selectedArea);
if (station) {
map.flyTo([station.X, station.Y], 14);
}
}
}, [selectedArea, map, GisStationsStaticDistrict]);
useEffect(() => {
if (zoomTrigger && map) {
map.flyTo([51.41321407879154, 7.739617925303934], 7);
}
}, [zoomTrigger, map]);
useEffect(() => {
if (map && poiLayerRef.current && isPoiTypLoaded && !menuItemAdded && isRightsLoaded) {
addItemsToMapContextMenu(map, menuItemAdded, setMenuItemAdded, hasRights, setShowPopup, setPopupCoordinates);
}
}, [map, poiLayerRef, isPoiTypLoaded, menuItemAdded, hasRights, isRightsLoaded]);
//--------------------------------------------
// rote Marker ganz oben wenn überlappen sind
useEffect(() => {
const fetchPriorityConfig = async () => {
try {
const res = await fetch("/api/talas_v5_DB/priorityConfig");
if (!res.ok) {
throw new Error(`HTTP error! status: ${res.status}`);
}
const data = await res.json();
setPriorityConfig(data);
} catch (error) {
console.error("Failed to load priority configuration:", error);
}
};
fetchPriorityConfig();
}, []);
//--------------------------------------------
useEffect(() => {
if (mapRef.current && !map) {
initializeMap(mapRef, setMap, setOms, setMenuItemAdded, addItemsToMapContextMenu, hasRights, setPolylineEventsDisabled);
}
}, [mapRef, map, hasRights, setPolylineEventsDisabled]);
useEffect(() => {
if (map) {
if (polylineEventsDisabled) {
disablePolylineEvents(window.polylines);
} else {
enablePolylineEvents(window.polylines, window.lineColors);
}
}
}, [map, polylineEventsDisabled]);
useEffect(() => {
if (map) {
console.log("6- Karteninstanz (map) wurde jetzt erfolgreich initialisiert");
// Setze die Karteninstanz in den Recoil-Atom
}
}, [map]);
//--------------------------------------------
useEffect(() => {
const initializeContextMenu = () => {
if (map) {
map.whenReady(() => {
setTimeout(() => {
if (map.contextmenu) {
//console.log("Contextmenu ist vorhanden");
} else {
console.warn("Contextmenu ist nicht verfügbar.");
}
}, 500);
});
}
};
initializeContextMenu();
}, [map]);
//--------------------------------------------
//Tooltip Werte aktualisieren
useEffect(() => {
if (!map) return; // Stelle sicher, dass die Karte initialisiert ist
const updateGmaData = async () => {
try {
const fetchOptions = {
method: "GET",
headers: {
Connection: "close",
},
};
// Aktualisiere die Messdaten
await fetchGisStationsMeasurements(mapGisStationsMeasurementsUrl, setGisStationsMeasurements, fetchOptions);
// Aktualisiere die Marker-Layer
// useGmaMarkersLayer(map, gmaMarkers, GisStationsMeasurements, layers.MAP_LAYERS.GMA, oms);
} catch (error) {
console.error("Fehler beim Aktualisieren der GMA-Daten:", error);
}
};
// Initialer Datenabruf
updateGmaData();
// Setze ein Intervall, um die Daten alle 5 Sekunden zu aktualisieren
const intervalId = setInterval(() => {
updateGmaData();
}, 5000);
// Cleanup-Funktion, um das Intervall zu entfernen, wenn die Komponente entladen wird
return () => clearInterval(intervalId);
}, [map, gmaMarkers, layers.MAP_LAYERS.GMA, oms, mapGisStationsMeasurementsUrl]);
//---------------------------------
const gmaLayerRef = useRef(null);
const talasLayerRef = useRef(null);
const eciMarkersLayerRef = useRef(null);
const gsmModemMarkersLayerRef = useRef(null);
const ciscoRouterMarkersLayerRef = useRef(null);
const wagoMarkersLayerRef = useRef(null);
const siemensMarkersLayerRef = useRef(null);
const otdrMarkersLayerRef = useRef(null);
const wdmMarkersLayerRef = useRef(null);
const messstellenMarkersLayerRef = useRef(null);
const talasiclMarkersLayerRef = useRef(null);
const dauzMarkersLayerRef = useRef(null);
const smsfunkmodemMarkersLayerRef = useRef(null);
const ulafMarkersLayerRef = useRef(null);
const sonstigeMarkersLayerRef = useRef(null);
useEffect(() => {
if (!gisSystemStaticLoaded || !map) return; // Sicherstellen, dass die Karte und Daten geladen sind
const layerGroups = [
{ ref: gmaLayerRef, id: 11, setState: setGmaMarkers },
{ ref: talasLayerRef, id: 1, setState: setTalasMarkers },
{ ref: eciMarkersLayerRef, id: 2, setState: setEciMarkers },
{ ref: gsmModemMarkersLayerRef, id: 5, setState: setGsmModemMarkers },
{ ref: ciscoRouterMarkersLayerRef, id: 6, setState: setCiscoRouterMarkers },
{ ref: wagoMarkersLayerRef, id: 7, setState: setWagoMarkers },
{ ref: siemensMarkersLayerRef, id: 8, setState: setSiemensMarkers },
{ ref: otdrMarkersLayerRef, id: 9, setState: setOtdrMarkers },
{ ref: wdmMarkersLayerRef, id: 10, setState: setWdmMarkers },
{ ref: messstellenMarkersLayerRef, id: 13, setState: setMessstellenMarkers },
{ ref: talasiclMarkersLayerRef, id: 100, setState: setTalasiclMarkers },
{ ref: dauzMarkersLayerRef, id: 110, setState: setDauzMarkers },
{ ref: smsfunkmodemMarkersLayerRef, id: 111, setState: setSmsfunkmodemMarkers },
{ ref: ulafMarkersLayerRef, id: 0, setState: setUlafMarkers },
{ ref: sonstigeMarkersLayerRef, id: 200, setState: setSonstigeMarkers },
];
// Initialisiere LayerGroups nur einmal
layerGroups.forEach(({ ref }) => {
if (!ref.current) {
ref.current = new L.LayerGroup().addTo(map);
}
});
const updateMarkers = ({ ref, id, setState }) => {
if (ref.current) {
ref.current.clearLayers(); // Entferne alte Marker
}
// Erstelle und füge neue Marker hinzu
createAndSetDevices(
id,
(newMarkers) => {
setState(newMarkers); // Zustand aktualisieren
newMarkers.forEach((marker) => ref.current.addLayer(marker)); // Marker zur LayerGroup hinzufügen
// Überprüfe auf überlappende Marker und füge das Plus-Icon hinzu
checkOverlappingMarkers(map, newMarkers, plusRoundIcon);
},
GisSystemStatic,
priorityConfig
);
};
// Aktualisiere alle Marker-Gruppen
const updateAllMarkers = () => {
layerGroups.forEach(updateMarkers);
};
// Initiales Update
updateAllMarkers();
// Setze ein Intervall für regelmäßige Updates
const intervalId = setInterval(() => {
updateAllMarkers();
}, 20000); // 20 Sekunden
// Aufräumen bei Komponentenentladung
return () => {
clearInterval(intervalId); // Entferne Intervall
// LayerGroups leeren
layerGroups.forEach(({ ref }) => {
if (ref.current) {
ref.current.clearLayers();
}
});
};
}, [gisSystemStaticLoaded, map, GisSystemStatic, priorityConfig]);
//---------------------------------------
//----------------------------------
//---------------------------------------
return (
<>
<ToastContainer />
<div>{showPoiUpdateModal && <PoiUpdateModal onClose={() => setShowPoiUpdateModal(false)} poiData={currentPoiData} onSubmit={() => {}} latlng={popupCoordinates} />}</div>
<div>
{showPopup && (
<div className="fixed inset-0 bg-black bg-opacity-10 flex justify-center items-center z-[1000]" onClick={closePopup}>
<div className="relative bg-white p-6 rounded-lg shadow-lg" onClick={(e) => e.stopPropagation()}>
<button onClick={closePopup} className="absolute top-0 right-0 mt-2 mr-2 p-1 text-gray-700 hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-gray-600" aria-label="Close">
<svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
<AddPoiModalWindow onClose={closePopup} onSubmit={handleAddStation} latlng={popupCoordinates} />
</div>
</div>
)}
</div>
<DataSheet className="z-50" />
<div id="map" ref={mapRef} className="z-0" style={{ height: "100vh", width: "100vw" }}></div>
<div className="absolute bottom-3 left-3 w-72 p-4 bg-white rounded-lg shadow-md z-50">
<div className="flex justify-between items-center">
<div>
<span className="text-black text-lg font-semibold"> TALAS.Map </span>
<br />
<span className="text-black text-lg">Version {MAP_VERSION}</span>
</div>
<div>
<button onClick={openVersionInfoModal}>
<InformationCircleIcon className="text-blue-900 h-8 w-8 pr-1" title="Weitere Infos" />
</button>
</div>
</div>
</div>
<VersionInfoModal showVersionInfoModal={showVersionInfoModal} closeVersionInfoModal={closeVersionInfoModal} MAP_VERSION={MAP_VERSION} />
</>
);
};
export default MapComponent;

View File

@@ -335,6 +335,10 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
try {
const response = await fetch("/api/talas_v5_DB/poiTyp/readPoiTyp");
const data = await response.json();
if (!Array.isArray(data)) {
console.warn(`Unerwartetes Format: ${JSON.stringify(data)}`);
throw new Error("Daten sind kein Array");
}
const map = new Map();
data.forEach((item) => map.set(item.idPoiTyp, item.name));
setPoiTypMap(map);
@@ -519,7 +523,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
console.warn("WARNUNG: gis_lines ist kein Array, wird ignoriert.");
return;
}
const matchingLine = data2.find((item) => item.idLD === statis.IdLD && item.idModul === statis.Modul);
const matchingLine = data2.find((item) => item.idLD === stat.IdLD && item.idModul === stat.Modul);
if (matchingLine) {
colorsByModule[matchingLine.idModul] = stat.PrioColor;

View File

@@ -53,7 +53,7 @@ const AddPoiModalWindow = ({ onClose, map, latlng }) => {
// Filtere die Geräte basierend auf den sichtbaren Systemen
filterDevices(locationDeviceData);
} catch (error) {
console.error("Fehler beim Abrufen der Daten:", error);
console.error("Fehler beim Abrufen der Daten in AddPoiModalWindow.js :", error);
}
};

View File

@@ -1,79 +0,0 @@
import { useEffect } from "react";
import { addContextMenuToMarker } from "../../utils/addContextMenuToMarker";
const useMarkersLayer = (map, markers, GisStationsMeasurements, GMA, oms) => {
useEffect(() => {
if (!map) return;
// Entferne alte Marker
GMA.clearLayers();
// Hinzufügen neuer Marker
markers.forEach((marker) => {
// Finde die Messungen, die zu diesem Marker gehören
const relevantMeasurements = GisStationsMeasurements.filter((m) => m.Area_Name === marker.options.areaName);
let measurements = {};
let area_name = marker.options.areaName;
relevantMeasurements.forEach((m) => {
measurements[m.Na] = m.Val;
});
// Überprüfe, ob die Messwerte vorhanden sind, und setze Standardwerte
const lt = measurements["LT"] || "---";
const fbt = measurements["FBT"] || "---";
const gt = measurements["GT"] || "---";
const rlf = measurements["RLF"] || "---";
console.log(`Station oder Bereich ${area_name} - LT: ${lt}, FBT: ${fbt}, GT: ${gt}, RLF: ${rlf}`);
// Tooltip für den Marker binden
marker.bindTooltip(
`
<div class="p-0 rounded-lg bg-white bg-opacity-90">
<div class="font-bold text-sm text-black">
<span>${area_name}</span>
</div>
<div class="font-bold text-xxs text-blue-700">
<span>LT : ${lt} °C</span>
</div>
<div class="font-bold text-xxs text-red-700">
<span>FBT : ${fbt} °C</span>
</div>
<div class="font-bold text-xxs text-yellow-500">
<span>GT : ${gt}</span>
</div>
<div class="font-bold text-xxs text-green-700">
<span>RLF : ${rlf} %</span>
</div>
</div>
`,
{
permanent: true,
direction: "auto",
offset: [60, 0],
}
);
// Ereignisse für das Öffnen und Schließen des Tooltips
marker.on("mouseover", function () {
this.openPopup();
});
marker.on("mouseout", function () {
this.closePopup();
});
// Kontextmenü hinzufügen
addContextMenuToMarker(marker);
// Füge den Marker zur Layer-Gruppe hinzu
GMA.addLayer(marker);
oms.addMarker(marker);
});
map.addLayer(GMA);
}, [map, markers, GisStationsMeasurements, GMA, oms]);
};
export default useMarkersLayer;

132
hooks/useLineData-old.js Normal file
View File

@@ -0,0 +1,132 @@
// hooks/useLineData.js //fix v1.0.8.1
import { useEffect, useState } from "react";
import { toast } from "react-toastify";
import { SERVER_URL } from "../config/urls";
import { useDispatch, useSelector } from "react-redux";
const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => {
const dispatch = useDispatch();
const messages = useSelector((state) => state.messages);
const [lineColors, setLineColors] = useState({});
const [tooltipContents, setTooltipContents] = useState({});
useEffect(() => {
let isCancelled = false;
const fetchData = async () => {
try {
const response1 = await fetch(webserviceGisLinesStatusUrl);
if (!response1.ok) throw new Error("Fehler bei GIS-Linienstatus");
const data1 = await response1.json();
const response2 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/readGisLines`);
if (!response2.ok) throw new Error("Fehler beim Abrufen der GIS-Linien");
const data2 = await response2.json();
const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/device/getAllStationsNames`);
if (!response3.ok) throw new Error("Fehler beim Abrufen der Stationsnamen");
const namesData = await response3.json();
if (!isCancelled) {
if (!data1.Statis || data1.Statis.length === 0) {
toast.warn("Keine Linienstatus-Daten verfügbar!", { position: "top-center", autoClose: 5000 });
setLineStatusData([]);
return;
}
const colorsByModule = {};
const newTooltipContents = {};
const valueMap = {};
const sortedStatis = [...data1.Statis].sort((a, b) => a.Level - b.Level);
sortedStatis.forEach((statis) => {
const key = `${statis.IdLD}-${statis.Modul}`;
if (!valueMap[key]) {
valueMap[key] = {
messages: [],
messwert: undefined,
schleifenwert: undefined,
};
}
if (statis.DpName.endsWith("_Messwert") && statis.Value !== "True" && !valueMap[key].messwert) {
valueMap[key].messwert = statis.Value;
}
if (statis.DpName.endsWith("_Schleifenwert") && !valueMap[key].schleifenwert) {
valueMap[key].schleifenwert = statis.Value;
}
if (statis.Message && statis.Message !== "?") {
valueMap[key].messages.push({
message: statis.Message,
prioColor: statis.PrioColor && statis.PrioColor !== "#ffffff" ? statis.PrioColor : "green",
});
}
});
sortedStatis.forEach((statis) => {
const key = `${statis.IdLD}-${statis.Modul}`;
const matchingLine = data2.find((item) => item.idLD === statis.IdLD && item.idModul === statis.Modul);
if (matchingLine) {
const values = valueMap[key];
const messageDisplay = values.messages.map((msg) => `<span class="inline-block text-gray-800"><span class="inline-block w-2 h-2 rounded-full mr-2" style="background-color: ${msg.prioColor};"></span>${msg.message}</span><br>`).join("");
colorsByModule[key] = values.messages.length > 0 ? values.messages[0].prioColor : "green";
newTooltipContents[key] = `
<div class="bg-white rounded-lg m-0 p-2 w-[210px]">
<span class="text-lg font-semibold text-gray-900">${statis.ModulName || "Unknown"}</span>
<br>
<span class="text-md font-bold text-gray-800">${statis.ModulTyp || "N/A"}</span>
<br>
<span class="text-md font-bold text-gray-800">Slot: ${statis.Modul || "N/A"}</span>
<br>
<span class="text-md font-bold text-gray-800">Station: ${namesData[matchingLine.idLD] || "N/A"}</span>
<br>
<div style="max-width: 100%; overflow-wrap: break-word; word-break: break-word; white-space: normal;">
${messageDisplay}
</div>
<br>
${values.messwert ? `<span class="inline-block text-gray-800">Messwert: ${values.messwert}</span><br>` : ""}
${values.schleifenwert ? `<span class="inline-block text-gray-800">Schleifenwert: ${values.schleifenwert}</span>` : ""}
</div>
`;
}
});
setLineColors(colorsByModule);
setTooltipContents(newTooltipContents);
setLineStatusData(data1.Statis);
}
} catch (error) {
//console.error("Fehler beim Abrufen der Daten in useLineData.js:", error);
// toast.error("Fehler beim Abrufen der Linienstatus-Daten!", { position: "top-center", autoClose: 5000 });
console.warn("Fehler beim Abrufen der Linienstatus-Daten in useLineData.js ");
}
};
const scheduleNextFetch = () => {
if (!isCancelled) {
fetchData();
setTimeout(scheduleNextFetch, 30000);
}
};
fetchData();
scheduleNextFetch();
return () => {
isCancelled = true;
localStorage.removeItem("contextMenuExpired");
};
}, [webserviceGisLinesStatusUrl, setLineStatusData]);
return { lineColors, tooltipContents };
};
export default useLineData;

View File

@@ -1,19 +1,47 @@
// hooks/usePoiTypData.js
import { useState, useEffect } from "react";
import { useState, useEffect, useRef } from "react";
import { toast } from "react-toastify"; // Toast für Warnungen importieren
const usePoiTypData = (url) => {
const [poiTypData, setPoiTypData] = useState([]);
const [isPoiTypLoaded, setIsPoiTypLoaded] = useState(false);
const retryCountRef = useRef(0);
const maxRetries = 2;
useEffect(() => {
const fetchPoiTypData = async () => {
try {
const response = await fetch(url);
const data = await response.json();
if (!Array.isArray(data)) {
console.warn(`Unerwartetes Format: ${JSON.stringify(data)}`);
if (data.warning) {
toast.warn(data.warning, { position: "top-center", autoClose: 5000 });
setPoiTypData([]); // Leeres Array setzen
setIsPoiTypLoaded(true);
return;
}
throw new Error("Daten sind kein Array");
}
// Erfolgreich geladen, also Reset des Retry-Zählers
setPoiTypData(data);
setIsPoiTypLoaded(true);
retryCountRef.current = 0;
} catch (error) {
console.error("Fehler beim Abrufen der poiTyp-Daten:", error);
console.error("Fehler beim Abrufen der poiTyp-Daten in usePoiTypData.js :", error);
if (retryCountRef.current < maxRetries) {
retryCountRef.current++;
console.log(`Neuer Versuch (${retryCountRef.current}/${maxRetries}) in 5 Sekunden...`);
setTimeout(fetchPoiTypData, 5000);
} else {
console.error("Maximale Anzahl an Fehlversuchen erreicht. Stoppe weitere Abrufe.");
setIsPoiTypLoaded(true);
}
}
};

View File

@@ -1,20 +0,0 @@
// pages/api/[...path].js
import { createProxyMiddleware } from "http-proxy-middleware";
//import { SERVER_URL } from "../config/urls.js";
//console.log("SERVER_URL:", SERVER_URL); // Debug-Ausgabe
export default createProxyMiddleware({
//target: "http://192.168.10.58:3001",
// Stationen bekommen
//target: "http://10.10.0.13", // Ziel-URL des Proxys // API Aufruf zum mapGisStationsStaticDistrictUrl, mapGisStationsStatusDistrictUrl, mapGisStationsMeasurementsUrl, mapGisSystemStaticUrl und mapDataIconUrl
target: `${process.env.NEXT_PUBLIC_SERVER_URL}`, //
//target: urls.PROXY_TARGET,
//target: "http://localhost:3000", // Ziel-URL des Proxys
//target: "http://192.168.10.187:3000", // Ziel-URL des Proxys
//target: "http://192.168.10.14",
changeOrigin: true,
pathRewrite: {
"^/api": "/", // Optional: Entfernt /api aus dem Pfad, wenn das Backend dies nicht erfordert
},
logLevel: "debug", // Setzt das Logging-Level auf "debug" für detaillierte Ausgaben
});

View File

@@ -1,20 +0,0 @@
// pages/api/get-talasIP.js
export default function handler(req, res) {
// Der x-forwarded-for Header könnte mehrere IP-Adressen enthalten, getrennt durch Kommas
let clientIp =
req.headers["x-forwarded-for"]?.split(",").map((ip) => ip.trim())[0] ||
req.socket.remoteAddress;
// Entfernen möglicher IPv6 "mapped" IPv4 Adressen
if (clientIp?.includes("::ffff:")) {
clientIp = clientIp.split("::ffff:")[1];
}
// Nur IPv4 Adressen weitergeben, IPv6 Adressen ausschließen
if (clientIp && clientIp.includes(":")) {
clientIp = ""; // Dies setzt die IP auf leer, wenn es sich um eine IPv6-Adresse handelt
}
res.status(200).json({ ip: clientIp });
}

View File

@@ -1,34 +0,0 @@
// /pages/api/gis-proxy.js
// Importieren der erforderlichen Module
import httpProxy from "http-proxy";
import Cookies from "cookies";
// Erstellen eines Proxy-Servers
const proxy = httpProxy.createProxyServer();
export default (req, res) => {
return new Promise((resolve) => {
// CORS-Headers einstellen
res.setHeader("Access-Control-Allow-Credentials", true);
res.setHeader("Access-Control-Allow-Origin", "*");
// Cookies initialisieren
const cookies = new Cookies(req, res);
const targetUrl = `${process.env.NEXT_PUBLIC_SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic`;
// Proxy-Konfiguration und Event-Listener
req.on("data", () => {});
req.on("end", () => {
proxy.web(req, res, { target: targetUrl, changeOrigin: true, selfHandleResponse: false }, (e) => {
if (e) {
console.error(e);
res.status(500).json({ error: "Proxy-Fehler", e });
}
resolve();
});
});
// Weiterleitung der Headers
req.headers.cookie = cookies.get("cookie-name") || "";
});
};

View File

@@ -1,64 +0,0 @@
// /pages/api/linesColorApi.js
// http://10.10.0.13/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict
//In DB gis_lines idLD und idModul anpassen entsprechend
// /pages/api/linesColorApi.js
import NextCors from "nextjs-cors";
export default async function handler(req, res) {
// Run the cors middleware
await NextCors(req, res, {
// Options
methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
origin: "*", // Erlauben Sie alle Ursprünge, oder geben Sie spezifische Ursprünge an
optionsSuccessStatus: 200, // Legacy-Browser-Unterstützung für 204
});
const response = {
Name: "Liste aller Statis der Linien",
Zeitstempel: new Date().toISOString(), // Aktuellen Zeitstempel hinzufügen
IdMap: "10",
Statis: [
/* {
IdLD: 50922,
Modul: 1,
DpName: "KUE01_Ausfall",
ModulName: "42 Wippershain Sender",
// ModulTyp: "nicht vorhanden",
ModulTyp: "KÜ705-FO",
Message: "KUEG 01: 42 Wippershain Sender Messwerkausfall kommend",
Level: 4,
PrioColor: "#FFFF00",
PrioName: "system",
Value: "10 MOhm",
},
{
IdLD: 25440,
Modul: 3,
DpName: "KUE03_Ausfall",
ModulName: "42 Solz Sender",
//ModulTyp: "nicht vorhanden",
ModulTyp: "KÜSS V2",
Message: "KUEG 03: 42 Solz Sender Messwerkausfall kommend",
Level: 4,
PrioColor: "#FF0000",
PrioName: "system",
Value: "10 MOhm",
},
{
IdLD: 25440,
Modul: 4,
DpName: "KUE04_Ausfall",
ModulName: "42/13 Bad Hersfeld Gaswerk",
ModulTyp: "Kue705-FO",
Message: "KUEG 04: 42/13 Bad Hersfeld Gaswerk Messwerkausfall kommend",
Level: 4,
PrioColor: "#FF00FF",
PrioName: "system",
Value: "10 MOhm",
}, */
],
};
res.status(200).json(response);
}

View File

@@ -1,29 +0,0 @@
// pages/api/rights.js
export default function handler(req, res) {
const { idMap, idUser } = req.query;
// Beispielhafte Rechte, die je nach idMap und idUser variieren können
const rights = {
'10': [
{ IdRight: 1, Name: "Zugriff auf Dashboard" },
{ IdRight: 56, Name: "Erweiterte Berechtigungen" }
],
'2': [
{ IdRight: 2, Name: "Zugriff auf Einstellungen" }
],
'1': [
{ IdRight: 10, Name: "Admin-Zugriff" },
{ IdRight: 11, Name: "Zugriff auf alle Daten" }
]
};
// Prüfung, ob eine gültige idMap und idUser vorhanden sind
if (rights[idMap] && idUser === '484') {
// Rückgabe der spezifischen Rechte basierend auf der idMap und idUser
res.status(200).json({ Rights: rights[idMap] });
} else {
// Rückgabe leerer Rechte für ungültige idMap oder andere Benutzer
res.status(200).json({ Rights: [] });
}
}

View File

@@ -1,40 +0,0 @@
// pages/api/talas_v5/area.js
// Lesen von talas_v5 MySQL-Datenbank -> area Tabelle enthält DAUZ Geräte
// Wenn gebraucht wird, dann nutzen ansonsten löschen
import mysql from "mysql";
const dbConfig = {
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,
};
//console.log("my dbconfig: ", dbConfig);
export default function handler(req, res) {
const connection = mysql.createConnection(dbConfig);
connection.connect((err) => {
if (err) {
console.error("Fehler beim Verbinden:", err.stack);
res.status(500).json({ error: "Verbindungsfehler zur Datenbank" });
return;
}
//console.log("Verbunden als ID", connection.threadId);
//Fehler weil, existiertdie Tabelle auf localhost:3000 nicht
connection.query("SELECT ..., ..., ..., ... FROM ... WHERE ... = ...", (error, results) => {
if (error) {
console.error("Fehler beim Abrufen der API", error);
res.status(500).json({ error: "Fehler bei der Abfrage" });
return;
}
// Wichtig: Senden Sie die Antwort zurück
res.status(200).json(results);
connection.end();
});
});
}

View File

@@ -1,42 +0,0 @@
// Importieren des mysql2 Pakets
import mysql from "mysql2";
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
// Ein Hilfsfunktion, um Anfragen zu vereinfachen
function queryDatabase(query, params) {
return new Promise((resolve, reject) => {
pool.query(query, params, (error, results) => {
if (error) {
return reject(error);
}
resolve(results);
});
});
}
// API-Handler
export default async function handler(req, res) {
try {
// Dein SQL-Query und die Parameter
const sql = "SELECT idLD, iddevice, name FROM location_device WHERE iddevice = ?";
const params = [160]; // Beispielparameter
// Ausführen der Datenbankabfrage
const results = await queryDatabase(sql, params);
res.status(200).json(results);
} catch (error) {
console.error("Fehler beim Abrufen der API", error);
res.status(500).json({ error: "Fehler bei der Abfrage" });
}
}

View File

@@ -1,116 +0,0 @@
// /pages/api/talas5/webserviceMap/GisStationsMeasurements.js
const GisStationsMeasurements = {
"Name": "Liste aller Messungen der Geraete",
"Zeitstempel": "2024-05-31T15:25:32.5047629+02:00",
"IdMap": "10",
"Statis": [
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 3,
"Na": "FBT",
"Val": "20.5",
"Unit": "°C",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 10,
"Na": "GT",
"Val": "nicht ermittelbar",
"Unit": "°C",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 2,
"Na": "LT",
"Val": "Datenlücke",
"Unit": "°C",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 6,
"Na": "RLF",
"Val": "100.0",
"Unit": "%",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 11,
"Na": "TPT",
"Val": "8.3",
"Unit": "°C",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 12,
"Na": "TT1",
"Val": "---",
"Unit": "°C",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 16,
"Na": "WFD",
"Val": "0.12",
"Unit": "mm",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 8,
"Na": "WGM",
"Val": "---",
"Unit": "m/s",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 9,
"Na": "WGS",
"Val": "---",
"Unit": "m/s",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
}
]
}
// Export an async function handler for the API route.
export default async function handler(req, res) {
// Initialize an empty params object to store query parameters.
const params = {
idMap: req.query.idMap,
};
// Check if the requested ID map and user match certain conditions.
if (params.idMap === '10') {
// If the conditions are met, return the GisStationsMeasurements object with a 200 status code.
res.status(200).json(GisStationsMeasurements);
} else {
// If not, return a 404 error with the message "Not Found".
res.status(404).send('Not Found');
}
};

View File

@@ -1,281 +0,0 @@
// /pages/api/talas5/webserviceMap/GisStationsStaticDistrict.js
const GisStationsStaticDistrict = {
"Name": "Liste aller Geraete einer bestimmten Karte",
"Zeitstempel": "2024-05-31T15:26:56.9235766+02:00",
"IdMap": "10",
"Points": [
{
"LD_Name": "CPL Bentheim",
"IdLD": 50017,
"Device": "CPL V3.5 mit 16 Kü",
"Link": "cpl.aspx?ver=35&kue=16&id=50017",
"Location_Name": "Technikraum",
"Location_Short": "BEHE",
"IdLocation": 17448,
"Area_Name": "Bad-Bentheim",
"Area_Short": "BEHE--00",
"IdArea": 16418,
"X": 51.5728,
"Y": 9.00056,
"Icon": 20,
"System": 1,
"Active": 0
},
{
"LD_Name": "Drucker",
"IdLD": 50084,
"Device": "Basisgerät",
"Link": "basis.aspx?ver=1&id=50084",
"Location_Name": "Technikraum",
"Location_Short": "SLUE",
"IdLocation": 17776,
"Area_Name": "Schlüchtern II",
"Area_Short": "SLUE--00",
"IdArea": 14688,
"X": 53.2455,
"Y": 8.1614,
"Icon": 14,
"System": 200,
"Active": 0
},
{
"LD_Name": "Türkontakt",
"IdLD": 50666,
"Device": "ECI",
"Link": "eci.aspx?ver=1&id=50666",
"Location_Name": "Technikraum",
"Location_Short": "SLUE",
"IdLocation": 17776,
"Area_Name": "Schlüchtern II",
"Area_Short": "SLUE--00",
"IdArea": 14688,
"X": 53.2455,
"Y": 8.1614,
"Icon": 17,
"System": 2,
"Active": 0
},
{
"LD_Name": "Triptis",
"IdLD": 50888,
"Device": "CPL 200",
"Link": "cpl.aspx?ver=30&kue=16&id=50888",
"Location_Name": "Technikraum",
"Location_Short": "SLUE",
"IdLocation": 17776,
"Area_Name": "Schlüchtern II",
"Area_Short": "SLUE--00",
"IdArea": 14688,
"X": 53.2455,
"Y": 8.1614,
"Icon": 20,
"System": 1,
"Active": 0
},
{
"LD_Name": "Rodaborn I",
"IdLD": 50889,
"Device": "cpl.mio V>6",
"Link": "cplmio.aspx?ver=1&id=50889",
"Location_Name": "Technikraum",
"Location_Short": "SLUE",
"IdLocation": 17776,
"Area_Name": "Schlüchtern II",
"Area_Short": "SLUE--00",
"IdArea": 14688,
"X": 53.2455,
"Y": 8.1614,
"Icon": 20,
"System": 1,
"Active": 0
},
{
"LD_Name": "Rodaborn II",
"IdLD": 50900,
"Device": "cpl.mio V>6",
"Link": "cplmio.aspx?ver=1&id=50900",
"Location_Name": "Technikraum",
"Location_Short": "SLUE",
"IdLocation": 17776,
"Area_Name": "Schlüchtern II",
"Area_Short": "SLUE--00",
"IdArea": 14688,
"X": 53.2455,
"Y": 8.1614,
"Icon": 20,
"System": 1,
"Active": 0
},
{
"LD_Name": "Hermsdorf",
"IdLD": 50901,
"Device": "CPL V3.5 mit 24 Kü",
"Link": "cpl.aspx?ver=35&kue=24&id=50901",
"Location_Name": "Technikraum",
"Location_Short": "SLUE",
"IdLocation": 17776,
"Area_Name": "Schlüchtern II",
"Area_Short": "SLUE--00",
"IdArea": 14688,
"X": 53.2455,
"Y": 8.1614,
"Icon": 20,
"System": 1,
"Active": 1
},
{
"LD_Name": "GMA Littwin (TEST)",
"IdLD": 50004,
"Device": "Glättemeldeanlage",
"Link": "gma.aspx?ver=1&id=50004",
"Location_Name": "RG Relaisraum",
"Location_Short": "REZR",
"IdLocation": 18624,
"Area_Name": "Renzenhof (RG)",
"Area_Short": "REZHRG00",
"IdArea": 16570,
"X": 53.246036,
"Y": 8.163293,
"Icon": 1,
"System": 11,
"Active": 0
},
{
"LD_Name": "NRS Testserver",
"IdLD": 50005,
"Device": "Notruf Server",
"Link": "nrs_server.aspx?ver=1&id=50005",
"Location_Name": "(EV Ammersricht BZR REL)",
"Location_Short": "AMME",
"IdLocation": 21118,
"Area_Name": "Ammersricht BZR (FGN)",
"Area_Short": "AMMER--00",
"IdArea": 15958,
"X": 52.52726,
"Y": 12.165488,
"Icon": 19,
"System": 8,
"Active": 0
},
{
"LD_Name": "Gateway 2",
"IdLD": 50007,
"Device": "Notruf Server",
"Link": "nrs_server.aspx?ver=1&id=50007",
"Location_Name": "(EV Ammersricht BZR REL)",
"Location_Short": "AMME",
"IdLocation": 21118,
"Area_Name": "Ammersricht BZR (FGN)",
"Area_Short": "AMMER--00",
"IdArea": 15958,
"X": 52.52726,
"Y": 12.165488,
"Icon": 19,
"System": 8,
"Active": 0
},
{
"LD_Name": "Basisgerät mit SNMP MVP",
"IdLD": 50669,
"Device": "Basisgerät + SNMP",
"Link": "basisSNMP.aspx?&ver=1&id=50669",
"Location_Name": "Mylinghauserstraße Engelbert",
"Location_Short": "G-GEVELSBE-1",
"IdLocation": 24012,
"Area_Name": "Gevelsberg",
"Area_Short": "GMA-GEVELSBE",
"IdArea": 20919,
"X": 51.316799,
"Y": 7.33281,
"Icon": 14,
"System": 200,
"Active": 1
},
{
"LD_Name": "Server 3",
"IdLD": 50009,
"Device": "Notruf Server",
"Link": "nrs_server.aspx?ver=1&id=50009",
"Location_Name": "Militärringstraße Militärringstraße",
"Location_Short": "G-KÃLN-1",
"IdLocation": 24015,
"Area_Name": "Köln",
"Area_Short": "GMA-KÃLN",
"IdArea": 20921,
"X": 50.898399,
"Y": 6.92278,
"Icon": 19,
"System": 8,
"Active": 0
},
{
"LD_Name": "ICL Test 5",
"IdLD": 50054,
"Device": "ICL",
"Link": "icl.aspx?ver=1&id=50054",
"Location_Name": "Recheder Mühlenweg Dortmund-Ems-Kanal",
"Location_Short": "G-OLFEN-SE-1",
"IdLocation": 24022,
"Area_Name": "Olfen-Selm",
"Area_Short": "GMA-OLFEN-SE",
"IdArea": 20926,
"X": 51.702202,
"Y": 7.40822,
"Icon": 23,
"System": 100,
"Active": 0
},
{
"LD_Name": "ICL Test 3",
"IdLD": 50052,
"Device": "ICL",
"Link": "icl.aspx?ver=1&id=50052",
"Location_Name": "Weidenstraße Hestenberg",
"Location_Short": "G-PLETTENB-1",
"IdLocation": 24024,
"Area_Name": "Plettenberg",
"Area_Short": "GMA-PLETTENB",
"IdArea": 20928,
"X": 51.224098,
"Y": 7.86969,
"Icon": 23,
"System": 100,
"Active": 0
},
{
"LD_Name": "Test Februar Kai",
"IdLD": 50912,
"Device": "Dauerzählstelle DZ",
"Link": "dauz.aspx?ver=1&id=50912",
"Location_Name": "In der Hoffnung Kiesberg - BG Ost",
"Location_Short": "G-WUPPERTA-4",
"IdLocation": 24039,
"Area_Name": "Wuppertal",
"Area_Short": "GMA-WUPPERTA",
"IdArea": 20937,
"X": 51.238899,
"Y": 7.12715,
"Icon": 14,
"System": 110,
"Active": 1
}
]
}
// Export an async function handler for the API route.
export default async function handler(req, res) {
// Initialize an empty params object to store query parameters.
const params = {
idMap: req.query.idMap,
idUser: req.query.idUser
};
// Check if the requested ID map and user match certain conditions.
if (params.idMap === '10' && params.idUser === '484') {
// If the conditions are met, return the GisStationsStaticDistrict object with a 200 status code.
res.status(200).json(GisStationsStaticDistrict);
} else {
// If not, return a 404 error with the message "Not Found".
res.status(404).send('Not Found');
}
};

View File

@@ -1,84 +0,0 @@
// /pages/api/talas5/webserviceMap/gisStationsMeasurementsSQL.js
import mysql from "mysql2/promise";
// Erstellen eines Verbindungspools anstelle einer einzelnen Verbindung
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default async function handler(req, res) {
const { idMap, idUser } = req.query;
if (!idMap || !idUser) {
return res.status(400).json({ error: "idMap and idUser are required" });
}
try {
let onlySystem = -1;
let districtCounter = 0;
// Get onlySystem
const [mapResult] = await pool.query("SELECT idsystem_typ FROM maps WHERE id = ?", [idMap]);
if (mapResult.length > 0) {
onlySystem = mapResult[0].idsystem_typ ?? -1;
}
// Get districtCounter
if (idUser > 0) {
const [userLayerResult] = await pool.query("SELECT count(*) as count FROM user_User_layer1 WHERE iduser = ?", [idUser]);
districtCounter = userLayerResult[0].count;
}
// Building the query
let query = `
SELECT ld.idLD, dc.message, p.level, p.name, p.color, ld.idDevice, de.isService, dc.idIcon
FROM location as l
LEFT JOIN location_coordinates AS co ON l.idLocation = co.idLocation and co.idMaps = ?
LEFT JOIN location_device AS ld ON ld.idLocation = l.idLocation
LEFT JOIN datapoint as d ON d.idLD = ld.idLD
LEFT JOIN datapoint_conditions AS dc ON dc.idcondition = d.last_message_condition
LEFT JOIN prio AS p ON p.idPrio = dc.idprio
LEFT JOIN devices AS de ON de.idDevice = ld.idDevice
LEFT JOIN area as a on a.idArea = l.idArea
WHERE p.level < 100 AND co.X > 0
`;
const queryParams = [idMap];
if (districtCounter > 0) {
query += ` AND a.iddistrict IN (SELECT iddistrict FROM user_user_layer1 WHERE iduser = ?)`;
queryParams.push(idUser);
}
if (onlySystem >= 0) {
query += ` AND de.idsystem_typ = ?`;
queryParams.push(onlySystem);
}
query += ` ORDER BY p.level desc`;
const [results] = await pool.query(query, queryParams);
const mpss = {
IdMap: idMap.toString(),
Statis: results.map((row) => ({
IdLD: row.idLD ?? -1,
Le: row.level ?? -1,
Me: row.message ?? "?",
Na: row.name ?? "?",
Co: row.color ?? "#ffffff",
Feld: row.idDevice ?? -1,
Icon: row.idIcon ?? 0,
})),
};
res.status(200).json(mpss);
} catch (error) {
console.error("Fehler beim Laden der Daten:", error);
res.status(500).json({ error: "Interner Serverfehler" });
}
}

View File

@@ -1,273 +0,0 @@
// /pages/api/webServiceMap.js
const gisSystemStatic = {
"Name": "Liste aller angezeigten Systeme",
"Zeitstempel": "2024-05-31T15:08:49.8599542+02:00",
"IdMap": "10",
"Systems": [
{
"IdSystem": 1,
"Name": "TALAS",
"Longname": "Talas Meldestationen",
"Allow": 1,
"Icon": 1
},
{
"IdSystem": 2,
"Name": "ECI",
"Longname": "ECI Geräte",
"Allow": 1,
"Icon": 2
},
{
"IdSystem": 5,
"Name": "GSM Modem",
"Longname": "LR77 GSM Modems",
"Allow": 1,
"Icon": 5
},
{
"IdSystem": 6,
"Name": "Cisco Router",
"Longname": "Cisco Router",
"Allow": 1,
"Icon": 6
},
{
"IdSystem": 7,
"Name": "WAGO",
"Longname": "WAGO I/O Systeme",
"Allow": 1,
"Icon": 7
},
{
"IdSystem": 8,
"Name": "Siemens",
"Longname": "Siemens Notrufsystem",
"Allow": 0,
"Icon": 8
},
{
"IdSystem": 9,
"Name": "OTDR",
"Longname": "Glasfaserüberwachung OTU",
"Allow": 0,
"Icon": 9
},
{
"IdSystem": 10,
"Name": "WDM",
"Longname": " Wavelength Division Multiplexing",
"Allow": 0,
"Icon": 10
},
{
"IdSystem": 11,
"Name": "GMA",
"Longname": "Glättemeldeanlagen",
"Allow": 1,
"Icon": 11
},
{
"IdSystem": 13,
"Name": "Messstellen",
"Longname": "Messstellen",
"Allow": 0,
"Icon": 13
},
{
"IdSystem": 100,
"Name": "TALAS ICL",
"Longname": "Talas ICL Unterstationen",
"Allow": 1,
"Icon": 100
},
{
"IdSystem": 110,
"Name": "DAUZ",
"Longname": "Dauerzählstellen",
"Allow": 1,
"Icon": 110
},
{
"IdSystem": 111,
"Name": "SMS-Funkmodem",
"Longname": "SMS-Funkmodem",
"Allow": 0,
"Icon": 111
},
{
"IdSystem": 200,
"Name": "Sonstige",
"Longname": "Sonstige",
"Allow": 1,
"Icon": 200
}
],
"Rights": [
{
"IdRight": 1
},
{
"IdRight": 2
},
{
"IdRight": 3
},
{
"IdRight": 5
},
{
"IdRight": 6
},
{
"IdRight": 7
},
{
"IdRight": 8
},
{
"IdRight": 10
},
{
"IdRight": 11
},
{
"IdRight": 12
},
{
"IdRight": 20
},
{
"IdRight": 22
},
{
"IdRight": 23
},
{
"IdRight": 25
},
{
"IdRight": 30
},
{
"IdRight": 40
},
{
"IdRight": 41
},
{
"IdRight": 42
},
{
"IdRight": 43
},
{
"IdRight": 44
},
{
"IdRight": 45
},
{
"IdRight": 46
},
{
"IdRight": 47
},
{
"IdRight": 48
},
{
"IdRight": 49
},
{
"IdRight": 50
},
{
"IdRight": 51
},
{
"IdRight": 52
},
{
"IdRight": 55
},
{
"IdRight": 56
},
{
"IdRight": 60
},
{
"IdRight": 61
},
{
"IdRight": 62
},
{
"IdRight": 63
},
{
"IdRight": 64
},
{
"IdRight": 65
},
{
"IdRight": 68
},
{
"IdRight": 69
},
{
"IdRight": 70
},
{
"IdRight": 71
},
{
"IdRight": 72
},
{
"IdRight": 73
},
{
"IdRight": 79
},
{
"IdRight": 80
},
{
"IdRight": 90
},
{
"IdRight": 93
},
{
"IdRight": 94
},
{
"IdRight": 95
},
{
"IdRight": 96
}
]
}
// Export an async function handler for the API route.
export default async function handler(req, res) {
// Initialize an empty params object to store query parameters.
const params = {
idMap: req.query.idMap,
idUser: req.query.idUser
};
// Check if the requested ID map and user match certain conditions.
if (params.idMap === '10' && params.idUser === '484') {
// If the conditions are met, return the gisSystemStatic object with a 200 status code.
res.status(200).json(gisSystemStatic);
} else {
// If not, return a 404 error with the message "Not Found".
res.status(404).send('Not Found');
}
};

View File

@@ -1,74 +0,0 @@
// /pages/api/talas5/webserviceMap/gisStationsMeasurementsSQL.js
import mysql from "mysql2";
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
pool.on("connection", function (connection) {
console.log("Database connected successfully.");
});
pool.on("error", function (err) {
console.error("Fehler beim Verbinden:", err);
});
export default function handler(req, res) {
const idMap = req.query.idMap;
if (req.method !== "GET") {
return res.status(405).json({ error: "Nur GET Methode erlaubt" });
}
const sqlQuery = `
SELECT
ld.idLD,
dp.idDP,
dp.name AS Na,
dp.value AS Val,
dp.unit AS Unit,
mg.name AS Gr,
ld.idLocation,
area.Name AS Area_Name
FROM location_device as ld
LEFT JOIN location_coordinates AS co ON ld.idLocation = co.idLocation and co.idMaps = ?
LEFT JOIN devices AS de ON de.idDevice = ld.idDevice
LEFT JOIN datapoint AS dp ON ld.idLD = dp.idLD
LEFT JOIN message_group AS mg ON dp.idmessage_group = mg.idmessage_group
LEFT JOIN location AS loc ON ld.idLocation = loc.idLocation
LEFT JOIN area AS area ON loc.idArea = area.idArea
WHERE co.X > 0 AND dp.idmessage_group>0 AND length(dp.unit)> 0 AND length(dp.value)> 0
`;
pool.query(sqlQuery, [idMap], (error, results) => {
if (error) {
console.error("Fehler beim Abrufen der gis_lines:", error);
return res.status(500).json({ error: "Fehler beim Abrufen der gis_lines" });
}
const response = {
Name: "Liste aller Messungen der Geraete",
Zeitstempel: new Date().toISOString(),
IdMap: idMap,
Statis: results.map((row) => ({
IdLD: row.idLD,
IdDP: row.idDP,
Na: row.Na,
Val: row.Val,
Unit: row.Unit,
Gr: row.Gr,
IdLocation: row.idLocation,
Area_Name: row.Area_Name,
})),
};
res.json(response);
});
}

View File

@@ -1,50 +0,0 @@
// /pages/api/talas_v5_DB/gisLines/readGisLines.js
import mysql from "mysql2/promise";
import { store } from "../../../redux/store"; // Redux-Store importieren
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default async function handler(req, res) {
if (req.method !== "GET") {
return res.status(405).json({ error: "Nur GET Methode erlaubt" });
}
// **Hole `idLD`-Werte aus Redux**
const state = store.getState();
const activeLines = state.lineVisibility.activeLines;
const activeIds = Object.keys(activeLines); // Alle `idLD` in Redux
if (activeIds.length === 0) {
return res.status(404).json({ error: "Keine aktiven Geräte in Redux gefunden" });
}
// **SQL-Query mit Filterung**
const query = `
SELECT *
FROM talas_v5.gis_lines
WHERE idLD IN (${activeIds.map(() => "?").join(",")});`;
try {
console.log("🔍 Aktive Linien in Redux:", activeIds);
const [results] = await pool.query(query, activeIds); // Verwende aktive `idLD` als Parameter
if (results.length > 0) {
res.status(200).json(results);
console.log("✅ GIS-Linien erfolgreich abgerufen:", results.length, "Linien gefunden.");
} else {
res.status(404).json({ error: "Keine passenden Linien gefunden" });
}
} catch (error) {
console.error("Fehler beim Abrufen der gis_lines:", error);
res.status(500).json({ error: "Fehler beim Abrufen der gis_lines" });
}
}

View File

@@ -1,58 +0,0 @@
import mysql from "mysql2/promise";
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default async function handler(req, res) {
if (req.method !== "POST") {
return res.status(405).json({ error: "Nur POST Methode erlaubt" });
}
const { idLD, idModul, newCoordinates } = req.body;
if (!idLD || !idModul || !newCoordinates) {
return res.status(400).json({ error: "Fehlende Daten" });
}
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 = ?;";
let connection;
try {
// Hole eine Verbindung aus dem Pool
connection = await pool.getConnection();
// Beginne eine Transaktion
await connection.beginTransaction();
// Führe die Abfrage aus
const [results] = await connection.query(query, [newLineString, idLD, idModul]);
// Commit der Transaktion
await connection.commit();
console.log("Transaction Complete.");
res.status(200).json({
success: "Updated successfully.",
affectedRows: results.affectedRows,
});
} catch (error) {
// Rollback im Falle eines Fehlers
if (connection) await connection.rollback();
console.error("Fehler beim Aktualisieren der gis_lines:", error);
res.status(500).json({ error: "Fehler beim Aktualisieren der gis_lines" });
} finally {
// Stelle sicher, dass die Verbindung zurückgegeben wird
if (connection) connection.release();
}
}

View File

@@ -1,41 +0,0 @@
// API in /api/talas_v5_DB/locationDevice/getDeviceId.js
import mysql from "mysql2/promise";
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default async function handler(req, res) {
if (req.method !== "GET") {
return res.status(405).json({ error: "Nur GET Methode erlaubt" });
}
const { deviceName } = req.query;
if (!deviceName) {
return res.status(400).json({ error: "deviceName ist erforderlich" });
}
const query = "SELECT idLD FROM location_device WHERE name = ?";
try {
// Ausführen der Abfrage mit dem Pool
const [results] = await pool.query(query, [deviceName]);
if (results.length > 0) {
res.status(200).json({ idLD: results[0].idLD });
} else {
res.status(404).json({ error: "Gerät nicht gefunden" });
}
} catch (error) {
console.error("Fehler beim Abrufen der Geräte-ID:", error);
res.status(500).json({ error: "Fehler beim Abrufen der Geräte-ID" });
}
}

View File

@@ -1,40 +0,0 @@
// API in /api/talas_v5_DB/locationDevice/locationDeviceNameById.js
import mysql from "mysql2/promise";
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default async function handler(req, res) {
if (req.method !== "GET") {
return res.status(405).json({ error: "Nur GET Methode erlaubt" });
}
const { idLD } = req.query;
if (!idLD) {
return res.status(400).json({ error: "idLD ist erforderlich" });
}
try {
const query = "SELECT name FROM location_device WHERE idLD = ?";
const [results] = await pool.query(query, [idLD]);
if (results.length > 0) {
res.status(200).json({ name: results[0].name });
} else {
res.status(404).json({ error: "Gerät nicht gefunden", idLD });
}
} catch (error) {
console.error("Fehler beim Abrufen des Gerätenamens:", error);
res.status(500).json({ error: "Fehler beim Abrufen des Gerätenamens" });
}
}

View File

@@ -1,32 +0,0 @@
// API in /api/talas_v5_DB/locationDevice/locationDevices.js
import mysql from "mysql2/promise";
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default async function handler(req, res) {
if (req.method !== "GET") {
return res.status(405).json({ error: "Nur GET Methode erlaubt" });
}
const query = "SELECT * FROM location_device WHERE iddevice = 160";
try {
// Ausführen der Abfrage mit dem Verbindungspool
const [results] = await pool.query(query);
res.status(200).json(results);
} catch (error) {
console.error("Fehler beim Abrufen der Geräteinformationen:", error);
res.status(500).json({ error: "Fehler beim Abrufen der Geräteinformationen" });
}
}

View File

@@ -1,37 +0,0 @@
// pages/api/talas_v5_DB/poiTyp/readPoiTyp.js
import mysql from "mysql2/promise";
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default async function handler(req, res) {
if (req.method !== "GET") {
res.setHeader("Allow", ["GET"]);
return res.status(405).end(`Method ${req.method} Not Allowed`);
}
const query = "SELECT * FROM poityp";
try {
// Ausführen der Abfrage mit dem Verbindungspool
const [results] = await pool.query(query);
if (results.length === 0) {
return res.status(404).json({ message: "Keine Einträge gefunden" });
}
res.status(200).json(results);
} catch (error) {
console.error("Fehler beim Abfragen der Datenbank:", error);
res.status(500).json({ error: "Ein Fehler ist aufgetreten" });
}
}

View File

@@ -1,37 +0,0 @@
// pages/api/addLocation.js
import mysql from "mysql";
const pool = mysql.createPool({
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,
connectionLimit: 10, // Maximale Anzahl gleichzeitiger Verbindungen
});
export default 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
const query = "INSERT INTO poi (description, idPoiTyp, position, idLD) VALUES (?, ?, ST_GeomFromText(?),?)";
const point = `POINT(${longitude} ${latitude})`;
const values = [name, poiTypeId, point, idLD];
// Verwende den Pool, um eine Verbindung zu bekommen und die Query auszuführen
pool.query(query, values, (error, results) => {
if (error) {
console.error("Fehler beim Einfügen des Standorts:", error);
return res.status(500).json({ error: "Ein Fehler ist aufgetreten" });
}
res.status(200).json({
id: results.insertId,
message: "Standort erfolgreich hinzugefügt",
});
});
} else {
res.setHeader("Allow", ["POST"]);
res.status(405).end(`Method ${req.method} Not Allowed`);
}
}

View File

@@ -1,42 +0,0 @@
// pages/api/talas_v5_DB/pois/deletePoi.js
import mysql from "mysql2/promise";
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default async function handler(req, res) {
if (req.method !== "DELETE") {
return res.status(405).json({ error: "Nur DELETE Methode erlaubt" });
}
const { id } = req.query; // ID aus der Anfrage holen
if (!id) {
return res.status(400).json({ error: "POI ID ist erforderlich" });
}
const query = "DELETE FROM poi WHERE idPoi = ?";
try {
// Ausführen der Abfrage mit dem Verbindungspool
const [results] = await pool.query(query, [id]);
if (results.affectedRows > 0) {
res.status(200).json({ message: "POI erfolgreich gelöscht" });
} else {
res.status(404).json({ error: "POI nicht gefunden" });
}
} catch (error) {
console.error("Fehler beim Löschen des POI 3:", error);
res.status(500).json({ error: "Fehler beim Löschen des POI" });
}
}

View File

@@ -1,43 +0,0 @@
// pages/api/talas_v5_DB/pois/getPoiById.js
import mysql from "mysql2/promise";
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default async function handler(req, res) {
if (req.method !== "GET") {
res.setHeader("Allow", ["GET"]);
return res.status(405).end(`Method ${req.method} Not Allowed`);
}
const { idPoi } = req.query;
if (!idPoi) {
return res.status(400).json({ error: "idPoi ist erforderlich" });
}
const query = "SELECT description FROM poi WHERE idPoi = ?";
try {
// Ausführen der Abfrage mit dem Verbindungspool
const [results] = await pool.query(query, [idPoi]);
if (results.length === 0) {
return res.status(404).json({ error: "POI nicht gefunden" });
}
res.status(200).json(results[0]);
} catch (error) {
console.error("Fehler bei der Abfrage:", error);
res.status(500).json({ error: "Fehler bei der Abfrage" });
}
}

View File

@@ -1,36 +0,0 @@
// pages/api/talas_v5_DB/pois/poi-icons.js
import mysql from "mysql2/promise";
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default async function handler(req, res) {
if (req.method !== "GET") {
return res.status(405).json({ error: "Nur GET Methode erlaubt" });
}
const query = `
SELECT p.idPoi, i.path
FROM poi p
JOIN poiTyp pt ON p.idPoiTyp = pt.idPoiTyp
JOIN poiicons i ON pt.icon = i.idpoiicons;
`;
try {
// Ausführen der Abfrage mit dem Verbindungspool
const [results] = await pool.query(query);
res.status(200).json(results);
} catch (error) {
console.error("Fehler beim Abrufen der Icons:", error);
res.status(500).json({ error: "Fehler beim Abrufen der Icons" });
}
}

View File

@@ -1,32 +0,0 @@
// pages/api/talas_v5_DB/pois/readLocations.js
import mysql from "mysql2/promise";
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default async function handler(req, res) {
const query = `
SELECT idPoi, description, idPoiTyp, idLD, ST_AsText(position) AS position
FROM poi
`;
try {
// Ausführen der Abfrage mit dem Verbindungspool
const [results] = await pool.query(query);
// Senden der Antwort zurück
res.status(200).json(results);
} catch (error) {
console.error("Fehler beim Abrufen der API:", error);
res.status(500).json({ error: "Fehler bei der Abfrage" });
}
}

View File

@@ -1,82 +0,0 @@
// pages/api/talas_v5_DB/pois/updateLocation.js
import mysql from "mysql2/promise";
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
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,
charset: "utf8mb4",
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default async function handler(req, res) {
if (req.method !== "POST") {
res.setHeader("Allow", ["POST"]);
return res.status(405).end(`Method ${req.method} Not Allowed`);
}
const { id, latitude, longitude } = req.body;
if (!id || latitude === undefined || longitude === undefined) {
return res.status(400).json({ error: "id, latitude, und longitude sind erforderlich" });
}
const query = "UPDATE poi SET position = POINT(?, ?) WHERE idPoi = ?";
try {
const [result] = await pool.query(query, [longitude, latitude, id]);
if (result.affectedRows > 0) {
res.status(200).json({ success: true });
} else {
res.status(404).json({ error: "POI nicht gefunden" });
}
} catch (error) {
console.error("Fehler beim Aktualisieren der Position:", error);
res.status(500).json({ error: "Ein Fehler ist aufgetreten" });
}
}
/* import mysql from "mysql";
import util from "util";
const dbConfig = {
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,
charset: "utf8mb4",
};
export default async function handler(req, res) {
if (req.method !== "POST") {
res.setHeader("Allow", ["POST"]);
return res.status(405).end(`Method ${req.method} Not Allowed`);
}
const { id, latitude, longitude } = req.body;
const connection = mysql.createConnection(dbConfig);
// Promisify the query method
const query = util.promisify(connection.query).bind(connection);
try {
await query("UPDATE poi SET position = POINT(?, ?) WHERE idPoi = ?", [
longitude,
latitude,
id,
]);
res.status(200).json({ success: true });
} catch (error) {
console.error(error);
res.status(500).json({ error: "Ein Fehler ist aufgetreten" });
} finally {
connection.end();
}
} */

View File

@@ -1,45 +0,0 @@
// pages/api/talas_v5_DB/pois/updatePoi.js
import mysql from "mysql2/promise";
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default async function handler(req, res) {
if (req.method !== "POST") {
return res.status(405).json({ error: "Nur POST Methode erlaubt" });
}
const { idPoi, description, idPoiTyp, idLD } = req.body;
if (!idPoi) {
return res.status(400).json({ error: "POI ID ist erforderlich" });
}
const query = `
UPDATE talas_v5.poi
SET description = ?, idPoiTyp = ?, idLD = ?
WHERE idPoi = ?
`;
try {
const [results] = await pool.query(query, [description, idPoiTyp, idLD, idPoi]);
if (results.affectedRows > 0) {
res.status(200).json({ message: "POI erfolgreich aktualisiert" });
} else {
res.status(404).json({ error: "POI nicht gefunden" });
}
} catch (error) {
console.error("Fehler beim Aktualisieren des POI:", error);
res.status(500).json({ error: "Fehler beim Aktualisieren des POI" });
}
}

View File

@@ -1,31 +0,0 @@
// pages/api/talas_v5_DB/priorityConfig.js
// in tals5 http://10.10.0.13/talas5/Management/PriorityConfig.aspx beinhaltet die Tabelle prio die Prioritäten der Meldungen (Level 1-4) oder (0-4) je nachdem DB-Design
// das ist die API, die die Prioritäten zurückgibt
import mysql from "mysql2/promise";
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default async function handler(req, res) {
try {
// Ausführen der Datenbankabfrage
const query = "SELECT idprio, level, name, color FROM prio";
const results = await pool.query(query);
// Wichtig: Senden Sie die Antwort zurück
res.status(200).json(results[0]); // Da mysql2 Tuple [rows, fields] zurückgibt, wählen wir nur rows mit [0]
} catch (error) {
console.error("Fehler beim Abrufen der API", error);
res.status(500).json({ error: "Fehler bei der Abfrage" });
}
}

View File

@@ -1,43 +0,0 @@
// /pages/api/talas_v5_DB/station/getAllStationsNames.js
import mysql from "mysql2/promise";
// Verbindungspool-Konfiguration
const pool = mysql.createPool({
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,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
export default async function handler(req, res) {
if (req.method !== "GET") {
res.setHeader("Allow", ["GET"]);
return res.status(405).end(`Method ${req.method} Not Allowed`);
}
try {
// Abrufen aller idLD und ihrer Namen
const [results] = await pool.query("SELECT idLD, name FROM location_device");
if (results.length === 0) {
return res.status(404).json({ error: "No data found" });
}
// Struktur der Antwort anpassen
const namesMap = results.reduce((map, { idLD, name }) => {
if (!map[idLD]) {
map[idLD] = name; // Stelle sicher, dass hier keine Duplikate oder Überschreibungen entstehen
}
return map;
}, {});
res.status(200).json(namesMap);
} catch (err) {
console.error("Fehler beim Abrufen der Daten:", err);
res.status(500).json({ error: "Error retrieving data from the database" });
}
}

View File

@@ -1,20 +0,0 @@
// pages/api/[...path].js
import { createProxyMiddleware } from "http-proxy-middleware";
import { SERVER_URL } from "../config/urls.js";
console.log("SERVER_URL:", SERVER_URL); // Debug-Ausgabe
export default createProxyMiddleware({
//target: "http://192.168.10.58:3001",
// Stationen bekommen
//target: "http://10.10.0.13", // Ziel-URL des Proxys // API Aufruf zum mapGisStationsStaticDistrictUrl, mapGisStationsStatusDistrictUrl, mapGisStationsMeasurementsUrl, mapGisSystemStaticUrl und mapDataIconUrl
target: `${SERVER_URL}`, //
//target: urls.PROXY_TARGET,
//target: "http://localhost:3000", // Ziel-URL des Proxys
//target: "http://192.168.10.187:3000", // Ziel-URL des Proxys
//target: "http://192.168.10.14",
changeOrigin: true,
pathRewrite: {
"^/api": "/", // Optional: Entfernt /api aus dem Pfad, wenn das Backend dies nicht erfordert
},
logLevel: "debug", // Setzt das Logging-Level auf "debug" für detaillierte Ausgaben
});

View File

@@ -1,20 +0,0 @@
// pages/api/get-talasIP.js
export default function handler(req, res) {
// Der x-forwarded-for Header könnte mehrere IP-Adressen enthalten, getrennt durch Kommas
let clientIp =
req.headers["x-forwarded-for"]?.split(",").map((ip) => ip.trim())[0] ||
req.socket.remoteAddress;
// Entfernen möglicher IPv6 "mapped" IPv4 Adressen
if (clientIp?.includes("::ffff:")) {
clientIp = clientIp.split("::ffff:")[1];
}
// Nur IPv4 Adressen weitergeben, IPv6 Adressen ausschließen
if (clientIp && clientIp.includes(":")) {
clientIp = ""; // Dies setzt die IP auf leer, wenn es sich um eine IPv6-Adresse handelt
}
res.status(200).json({ ip: clientIp });
}

View File

@@ -1,34 +0,0 @@
// /pages/api/gis-proxy.js
// Importieren der erforderlichen Module
import httpProxy from "http-proxy";
import Cookies from "cookies";
// Erstellen eines Proxy-Servers
const proxy = httpProxy.createProxyServer();
export default (req, res) => {
return new Promise((resolve) => {
// CORS-Headers einstellen
res.setHeader("Access-Control-Allow-Credentials", true);
res.setHeader("Access-Control-Allow-Origin", "*");
// Cookies initialisieren
const cookies = new Cookies(req, res);
const targetUrl = `${process.env.NEXT_PUBLIC_SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic`;
// Proxy-Konfiguration und Event-Listener
req.on("data", () => {});
req.on("end", () => {
proxy.web(req, res, { target: targetUrl, changeOrigin: true, selfHandleResponse: false }, (e) => {
if (e) {
console.error(e);
res.status(500).json({ error: "Proxy-Fehler", e });
}
resolve();
});
});
// Weiterleitung der Headers
req.headers.cookie = cookies.get("cookie-name") || "";
});
};

View File

@@ -1,64 +0,0 @@
// /pages/api/linesColorApi.js
// http://10.10.0.13/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict
//In DB gis_lines idLD und idModul anpassen entsprechend
// /pages/api/linesColorApi.js
import NextCors from "nextjs-cors";
export default async function handler(req, res) {
// Run the cors middleware
await NextCors(req, res, {
// Options
methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
origin: "*", // Erlauben Sie alle Ursprünge, oder geben Sie spezifische Ursprünge an
optionsSuccessStatus: 200, // Legacy-Browser-Unterstützung für 204
});
const response = {
Name: "Liste aller Statis der Linien",
Zeitstempel: new Date().toISOString(), // Aktuellen Zeitstempel hinzufügen
IdMap: "10",
Statis: [
/* {
IdLD: 50922,
Modul: 1,
DpName: "KUE01_Ausfall",
ModulName: "42 Wippershain Sender",
// ModulTyp: "nicht vorhanden",
ModulTyp: "KÜ705-FO",
Message: "KUEG 01: 42 Wippershain Sender Messwerkausfall kommend",
Level: 4,
PrioColor: "#FFFF00",
PrioName: "system",
Value: "10 MOhm",
},
{
IdLD: 25440,
Modul: 3,
DpName: "KUE03_Ausfall",
ModulName: "42 Solz Sender",
//ModulTyp: "nicht vorhanden",
ModulTyp: "KÜSS V2",
Message: "KUEG 03: 42 Solz Sender Messwerkausfall kommend",
Level: 4,
PrioColor: "#FF0000",
PrioName: "system",
Value: "10 MOhm",
},
{
IdLD: 25440,
Modul: 4,
DpName: "KUE04_Ausfall",
ModulName: "42/13 Bad Hersfeld Gaswerk",
ModulTyp: "Kue705-FO",
Message: "KUEG 04: 42/13 Bad Hersfeld Gaswerk Messwerkausfall kommend",
Level: 4,
PrioColor: "#FF00FF",
PrioName: "system",
Value: "10 MOhm",
}, */
],
};
res.status(200).json(response);
}

View File

@@ -1,29 +0,0 @@
// pages/api/rights.js
export default function handler(req, res) {
const { idMap, idUser } = req.query;
// Beispielhafte Rechte, die je nach idMap und idUser variieren können
const rights = {
'10': [
{ IdRight: 1, Name: "Zugriff auf Dashboard" },
{ IdRight: 56, Name: "Erweiterte Berechtigungen" }
],
'2': [
{ IdRight: 2, Name: "Zugriff auf Einstellungen" }
],
'1': [
{ IdRight: 10, Name: "Admin-Zugriff" },
{ IdRight: 11, Name: "Zugriff auf alle Daten" }
]
};
// Prüfung, ob eine gültige idMap und idUser vorhanden sind
if (rights[idMap] && idUser === '484') {
// Rückgabe der spezifischen Rechte basierend auf der idMap und idUser
res.status(200).json({ Rights: rights[idMap] });
} else {
// Rückgabe leerer Rechte für ungültige idMap oder andere Benutzer
res.status(200).json({ Rights: [] });
}
}

View File

@@ -1,40 +0,0 @@
// pages/api/talas_v5/area.js
// Lesen von talas_v5 MySQL-Datenbank -> area Tabelle enthält DAUZ Geräte
// Wenn gebraucht wird, dann nutzen ansonsten löschen
import mysql from "mysql";
const dbConfig = {
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,
};
//console.log("my dbconfig: ", dbConfig);
export default function handler(req, res) {
const connection = mysql.createConnection(dbConfig);
connection.connect((err) => {
if (err) {
console.error("Fehler beim Verbinden:", err.stack);
res.status(500).json({ error: "Verbindungsfehler zur Datenbank" });
return;
}
//console.log("Verbunden als ID", connection.threadId);
//Fehler weil, existiertdie Tabelle auf localhost:3000 nicht
connection.query("SELECT ..., ..., ..., ... FROM ... WHERE ... = ...", (error, results) => {
if (error) {
console.error("Fehler beim Abrufen der API", error);
res.status(500).json({ error: "Fehler bei der Abfrage" });
return;
}
// Wichtig: Senden Sie die Antwort zurück
res.status(200).json(results);
connection.end();
});
});
}

View File

@@ -1,39 +0,0 @@
// pages/api/talas_v5/location_device.js
// talas_v5 Datenbank -> location_device Tabelle enthält DAUZ Geräte
import mysql from "mysql";
const dbConfig = {
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,
};
//console.log("my dbconfig: ", dbConfig);
export default function handler(req, res) {
const connection = mysql.createConnection(dbConfig);
connection.connect((err) => {
if (err) {
console.error("Fehler beim Verbinden:", err.stack);
res.status(500).json({ error: "Verbindungsfehler zur Datenbank" });
return;
}
//console.log("Verbunden als ID", connection.threadId);
//Fehler weil, existiertdie Tabelle auf localhost:3000 nicht
connection.query("SELECT idLD, iddevice, iddevice, name FROM location_device WHERE iddevice = 160", (error, results) => {
if (error) {
console.error("Fehler beim Abrufen der API", error);
res.status(500).json({ error: "Fehler bei der Abfrage" });
return;
}
// Wichtig: Senden Sie die Antwort zurück
res.status(200).json(results);
connection.end();
});
});
}

View File

@@ -1,116 +0,0 @@
// /pages/api/talas5/webserviceMap/GisStationsMeasurements.js
const GisStationsMeasurements = {
"Name": "Liste aller Messungen der Geraete",
"Zeitstempel": "2024-05-31T15:25:32.5047629+02:00",
"IdMap": "10",
"Statis": [
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 3,
"Na": "FBT",
"Val": "20.5",
"Unit": "°C",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 10,
"Na": "GT",
"Val": "nicht ermittelbar",
"Unit": "°C",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 2,
"Na": "LT",
"Val": "Datenlücke",
"Unit": "°C",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 6,
"Na": "RLF",
"Val": "100.0",
"Unit": "%",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 11,
"Na": "TPT",
"Val": "8.3",
"Unit": "°C",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 12,
"Na": "TT1",
"Val": "---",
"Unit": "°C",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 16,
"Na": "WFD",
"Val": "0.12",
"Unit": "mm",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 8,
"Na": "WGM",
"Val": "---",
"Unit": "m/s",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
},
{
"IdLD": 50004,
"IdL": 18624,
"IdDP": 9,
"Na": "WGS",
"Val": "---",
"Unit": "m/s",
"Gr": "GMA",
"Area_Name": "Renzenhof (RG)"
}
]
}
// Export an async function handler for the API route.
export default async function handler(req, res) {
// Initialize an empty params object to store query parameters.
const params = {
idMap: req.query.idMap,
};
// Check if the requested ID map and user match certain conditions.
if (params.idMap === '10') {
// If the conditions are met, return the GisStationsMeasurements object with a 200 status code.
res.status(200).json(GisStationsMeasurements);
} else {
// If not, return a 404 error with the message "Not Found".
res.status(404).send('Not Found');
}
};

View File

@@ -1,281 +0,0 @@
// /pages/api/talas5/webserviceMap/GisStationsStaticDistrict.js
const GisStationsStaticDistrict = {
"Name": "Liste aller Geraete einer bestimmten Karte",
"Zeitstempel": "2024-05-31T15:26:56.9235766+02:00",
"IdMap": "10",
"Points": [
{
"LD_Name": "CPL Bentheim",
"IdLD": 50017,
"Device": "CPL V3.5 mit 16 Kü",
"Link": "cpl.aspx?ver=35&kue=16&id=50017",
"Location_Name": "Technikraum",
"Location_Short": "BEHE",
"IdLocation": 17448,
"Area_Name": "Bad-Bentheim",
"Area_Short": "BEHE--00",
"IdArea": 16418,
"X": 51.5728,
"Y": 9.00056,
"Icon": 20,
"System": 1,
"Active": 0
},
{
"LD_Name": "Drucker",
"IdLD": 50084,
"Device": "Basisgerät",
"Link": "basis.aspx?ver=1&id=50084",
"Location_Name": "Technikraum",
"Location_Short": "SLUE",
"IdLocation": 17776,
"Area_Name": "Schlüchtern II",
"Area_Short": "SLUE--00",
"IdArea": 14688,
"X": 53.2455,
"Y": 8.1614,
"Icon": 14,
"System": 200,
"Active": 0
},
{
"LD_Name": "Türkontakt",
"IdLD": 50666,
"Device": "ECI",
"Link": "eci.aspx?ver=1&id=50666",
"Location_Name": "Technikraum",
"Location_Short": "SLUE",
"IdLocation": 17776,
"Area_Name": "Schlüchtern II",
"Area_Short": "SLUE--00",
"IdArea": 14688,
"X": 53.2455,
"Y": 8.1614,
"Icon": 17,
"System": 2,
"Active": 0
},
{
"LD_Name": "Triptis",
"IdLD": 50888,
"Device": "CPL 200",
"Link": "cpl.aspx?ver=30&kue=16&id=50888",
"Location_Name": "Technikraum",
"Location_Short": "SLUE",
"IdLocation": 17776,
"Area_Name": "Schlüchtern II",
"Area_Short": "SLUE--00",
"IdArea": 14688,
"X": 53.2455,
"Y": 8.1614,
"Icon": 20,
"System": 1,
"Active": 0
},
{
"LD_Name": "Rodaborn I",
"IdLD": 50889,
"Device": "cpl.mio V>6",
"Link": "cplmio.aspx?ver=1&id=50889",
"Location_Name": "Technikraum",
"Location_Short": "SLUE",
"IdLocation": 17776,
"Area_Name": "Schlüchtern II",
"Area_Short": "SLUE--00",
"IdArea": 14688,
"X": 53.2455,
"Y": 8.1614,
"Icon": 20,
"System": 1,
"Active": 0
},
{
"LD_Name": "Rodaborn II",
"IdLD": 50900,
"Device": "cpl.mio V>6",
"Link": "cplmio.aspx?ver=1&id=50900",
"Location_Name": "Technikraum",
"Location_Short": "SLUE",
"IdLocation": 17776,
"Area_Name": "Schlüchtern II",
"Area_Short": "SLUE--00",
"IdArea": 14688,
"X": 53.2455,
"Y": 8.1614,
"Icon": 20,
"System": 1,
"Active": 0
},
{
"LD_Name": "Hermsdorf",
"IdLD": 50901,
"Device": "CPL V3.5 mit 24 Kü",
"Link": "cpl.aspx?ver=35&kue=24&id=50901",
"Location_Name": "Technikraum",
"Location_Short": "SLUE",
"IdLocation": 17776,
"Area_Name": "Schlüchtern II",
"Area_Short": "SLUE--00",
"IdArea": 14688,
"X": 53.2455,
"Y": 8.1614,
"Icon": 20,
"System": 1,
"Active": 1
},
{
"LD_Name": "GMA Littwin (TEST)",
"IdLD": 50004,
"Device": "Glättemeldeanlage",
"Link": "gma.aspx?ver=1&id=50004",
"Location_Name": "RG Relaisraum",
"Location_Short": "REZR",
"IdLocation": 18624,
"Area_Name": "Renzenhof (RG)",
"Area_Short": "REZHRG00",
"IdArea": 16570,
"X": 53.246036,
"Y": 8.163293,
"Icon": 1,
"System": 11,
"Active": 0
},
{
"LD_Name": "NRS Testserver",
"IdLD": 50005,
"Device": "Notruf Server",
"Link": "nrs_server.aspx?ver=1&id=50005",
"Location_Name": "(EV Ammersricht BZR REL)",
"Location_Short": "AMME",
"IdLocation": 21118,
"Area_Name": "Ammersricht BZR (FGN)",
"Area_Short": "AMMER--00",
"IdArea": 15958,
"X": 52.52726,
"Y": 12.165488,
"Icon": 19,
"System": 8,
"Active": 0
},
{
"LD_Name": "Gateway 2",
"IdLD": 50007,
"Device": "Notruf Server",
"Link": "nrs_server.aspx?ver=1&id=50007",
"Location_Name": "(EV Ammersricht BZR REL)",
"Location_Short": "AMME",
"IdLocation": 21118,
"Area_Name": "Ammersricht BZR (FGN)",
"Area_Short": "AMMER--00",
"IdArea": 15958,
"X": 52.52726,
"Y": 12.165488,
"Icon": 19,
"System": 8,
"Active": 0
},
{
"LD_Name": "Basisgerät mit SNMP MVP",
"IdLD": 50669,
"Device": "Basisgerät + SNMP",
"Link": "basisSNMP.aspx?&ver=1&id=50669",
"Location_Name": "Mylinghauserstraße Engelbert",
"Location_Short": "G-GEVELSBE-1",
"IdLocation": 24012,
"Area_Name": "Gevelsberg",
"Area_Short": "GMA-GEVELSBE",
"IdArea": 20919,
"X": 51.316799,
"Y": 7.33281,
"Icon": 14,
"System": 200,
"Active": 1
},
{
"LD_Name": "Server 3",
"IdLD": 50009,
"Device": "Notruf Server",
"Link": "nrs_server.aspx?ver=1&id=50009",
"Location_Name": "Militärringstraße Militärringstraße",
"Location_Short": "G-KÃLN-1",
"IdLocation": 24015,
"Area_Name": "Köln",
"Area_Short": "GMA-KÃLN",
"IdArea": 20921,
"X": 50.898399,
"Y": 6.92278,
"Icon": 19,
"System": 8,
"Active": 0
},
{
"LD_Name": "ICL Test 5",
"IdLD": 50054,
"Device": "ICL",
"Link": "icl.aspx?ver=1&id=50054",
"Location_Name": "Recheder Mühlenweg Dortmund-Ems-Kanal",
"Location_Short": "G-OLFEN-SE-1",
"IdLocation": 24022,
"Area_Name": "Olfen-Selm",
"Area_Short": "GMA-OLFEN-SE",
"IdArea": 20926,
"X": 51.702202,
"Y": 7.40822,
"Icon": 23,
"System": 100,
"Active": 0
},
{
"LD_Name": "ICL Test 3",
"IdLD": 50052,
"Device": "ICL",
"Link": "icl.aspx?ver=1&id=50052",
"Location_Name": "Weidenstraße Hestenberg",
"Location_Short": "G-PLETTENB-1",
"IdLocation": 24024,
"Area_Name": "Plettenberg",
"Area_Short": "GMA-PLETTENB",
"IdArea": 20928,
"X": 51.224098,
"Y": 7.86969,
"Icon": 23,
"System": 100,
"Active": 0
},
{
"LD_Name": "Test Februar Kai",
"IdLD": 50912,
"Device": "Dauerzählstelle DZ",
"Link": "dauz.aspx?ver=1&id=50912",
"Location_Name": "In der Hoffnung Kiesberg - BG Ost",
"Location_Short": "G-WUPPERTA-4",
"IdLocation": 24039,
"Area_Name": "Wuppertal",
"Area_Short": "GMA-WUPPERTA",
"IdArea": 20937,
"X": 51.238899,
"Y": 7.12715,
"Icon": 14,
"System": 110,
"Active": 1
}
]
}
// Export an async function handler for the API route.
export default async function handler(req, res) {
// Initialize an empty params object to store query parameters.
const params = {
idMap: req.query.idMap,
idUser: req.query.idUser
};
// Check if the requested ID map and user match certain conditions.
if (params.idMap === '10' && params.idUser === '484') {
// If the conditions are met, return the GisStationsStaticDistrict object with a 200 status code.
res.status(200).json(GisStationsStaticDistrict);
} else {
// If not, return a 404 error with the message "Not Found".
res.status(404).send('Not Found');
}
};

View File

@@ -1,100 +0,0 @@
import mysql from "mysql2/promise";
const dbConfig = {
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 async function handler(req, res) {
const { idMap, idUser } = req.query;
if (!idMap || !idUser) {
res.status(400).json({ error: "idMap and idUser are required" });
return;
}
let connection;
try {
connection = await mysql.createConnection(dbConfig);
let onlySystem = -1;
let districtCounter = 0;
// Get onlySystem
const [mapResult] = await connection.execute(
"SELECT idsystem_typ FROM maps WHERE id = ?",
[idMap]
);
if (mapResult.length > 0) {
onlySystem = mapResult[0].idsystem_typ ?? -1;
}
// Get districtCounter
if (idUser > 0) {
const [userLayerResult] = await connection.execute(
"SELECT count(*) as count FROM user_User_layer1 WHERE iduser = ?",
[idUser]
);
districtCounter = userLayerResult[0].count;
}
// Get GisStatusStations
let query = `
SELECT ld.idLD, dc.message, p.level, p.name, p.color, ld.idDevice, de.isService, dc.idIcon
FROM location as l
LEFT JOIN location_coordinates AS co ON l.idLocation = co.idLocation and co.idMaps = ?
LEFT JOIN location_device AS ld ON ld.idLocation = l.idLocation
LEFT JOIN datapoint as d ON d.idLD = ld.idLD
LEFT JOIN datapoint_conditions AS dc ON dc.idcondition = d.last_message_condition
LEFT JOIN prio AS p ON p.idPrio = dc.idprio
LEFT JOIN devices AS de ON de.idDevice = ld.idDevice
LEFT JOIN area as a on a.idArea = l.idArea
WHERE p.level < 100 AND co.X > 0
`;
if (districtCounter > 0) {
query += ` AND a.iddistrict IN (SELECT iddistrict FROM user_user_layer1 WHERE iduser = ?)`;
}
if (onlySystem >= 0) {
query += ` AND de.idsystem_typ = ?`;
}
query += ` ORDER BY p.level desc`;
const queryParams = [idMap];
if (districtCounter > 0) {
queryParams.push(idUser);
}
if (onlySystem >= 0) {
queryParams.push(onlySystem);
}
const [results] = await connection.execute(query, queryParams);
const mpss = {
IdMap: idMap.toString(),
Statis: results.map((row) => ({
IdLD: row.idLD ?? -1,
Le: row.level ?? -1,
Me: row.message ?? "?",
Na: row.name ?? "?",
Co: row.color ?? "#ffffff",
Feld: row.idDevice ?? -1,
Icon: row.idIcon ?? 0,
})),
};
res.status(200).json(mpss);
} catch (error) {
console.error("Fehler beim Laden der Daten:", error);
res.status(500).json({ error: "Interner Serverfehler" });
} finally {
if (connection) {
await connection.end();
}
}
}

View File

@@ -1,273 +0,0 @@
// /pages/api/webServiceMap.js
const gisSystemStatic = {
"Name": "Liste aller angezeigten Systeme",
"Zeitstempel": "2024-05-31T15:08:49.8599542+02:00",
"IdMap": "10",
"Systems": [
{
"IdSystem": 1,
"Name": "TALAS",
"Longname": "Talas Meldestationen",
"Allow": 1,
"Icon": 1
},
{
"IdSystem": 2,
"Name": "ECI",
"Longname": "ECI Geräte",
"Allow": 1,
"Icon": 2
},
{
"IdSystem": 5,
"Name": "GSM Modem",
"Longname": "LR77 GSM Modems",
"Allow": 1,
"Icon": 5
},
{
"IdSystem": 6,
"Name": "Cisco Router",
"Longname": "Cisco Router",
"Allow": 1,
"Icon": 6
},
{
"IdSystem": 7,
"Name": "WAGO",
"Longname": "WAGO I/O Systeme",
"Allow": 1,
"Icon": 7
},
{
"IdSystem": 8,
"Name": "Siemens",
"Longname": "Siemens Notrufsystem",
"Allow": 0,
"Icon": 8
},
{
"IdSystem": 9,
"Name": "OTDR",
"Longname": "Glasfaserüberwachung OTU",
"Allow": 0,
"Icon": 9
},
{
"IdSystem": 10,
"Name": "WDM",
"Longname": " Wavelength Division Multiplexing",
"Allow": 0,
"Icon": 10
},
{
"IdSystem": 11,
"Name": "GMA",
"Longname": "Glättemeldeanlagen",
"Allow": 1,
"Icon": 11
},
{
"IdSystem": 13,
"Name": "Messstellen",
"Longname": "Messstellen",
"Allow": 0,
"Icon": 13
},
{
"IdSystem": 100,
"Name": "TALAS ICL",
"Longname": "Talas ICL Unterstationen",
"Allow": 1,
"Icon": 100
},
{
"IdSystem": 110,
"Name": "DAUZ",
"Longname": "Dauerzählstellen",
"Allow": 1,
"Icon": 110
},
{
"IdSystem": 111,
"Name": "SMS-Funkmodem",
"Longname": "SMS-Funkmodem",
"Allow": 0,
"Icon": 111
},
{
"IdSystem": 200,
"Name": "Sonstige",
"Longname": "Sonstige",
"Allow": 1,
"Icon": 200
}
],
"Rights": [
{
"IdRight": 1
},
{
"IdRight": 2
},
{
"IdRight": 3
},
{
"IdRight": 5
},
{
"IdRight": 6
},
{
"IdRight": 7
},
{
"IdRight": 8
},
{
"IdRight": 10
},
{
"IdRight": 11
},
{
"IdRight": 12
},
{
"IdRight": 20
},
{
"IdRight": 22
},
{
"IdRight": 23
},
{
"IdRight": 25
},
{
"IdRight": 30
},
{
"IdRight": 40
},
{
"IdRight": 41
},
{
"IdRight": 42
},
{
"IdRight": 43
},
{
"IdRight": 44
},
{
"IdRight": 45
},
{
"IdRight": 46
},
{
"IdRight": 47
},
{
"IdRight": 48
},
{
"IdRight": 49
},
{
"IdRight": 50
},
{
"IdRight": 51
},
{
"IdRight": 52
},
{
"IdRight": 55
},
{
"IdRight": 56
},
{
"IdRight": 60
},
{
"IdRight": 61
},
{
"IdRight": 62
},
{
"IdRight": 63
},
{
"IdRight": 64
},
{
"IdRight": 65
},
{
"IdRight": 68
},
{
"IdRight": 69
},
{
"IdRight": 70
},
{
"IdRight": 71
},
{
"IdRight": 72
},
{
"IdRight": 73
},
{
"IdRight": 79
},
{
"IdRight": 80
},
{
"IdRight": 90
},
{
"IdRight": 93
},
{
"IdRight": 94
},
{
"IdRight": 95
},
{
"IdRight": 96
}
]
}
// Export an async function handler for the API route.
export default async function handler(req, res) {
// Initialize an empty params object to store query parameters.
const params = {
idMap: req.query.idMap,
idUser: req.query.idUser
};
// Check if the requested ID map and user match certain conditions.
if (params.idMap === '10' && params.idUser === '484') {
// If the conditions are met, return the gisSystemStatic object with a 200 status code.
res.status(200).json(gisSystemStatic);
} else {
// If not, return a 404 error with the message "Not Found".
res.status(404).send('Not Found');
}
};

View File

@@ -1,70 +0,0 @@
import mysql from "mysql";
const dbConfig = {
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,
};
const connection = mysql.createConnection(dbConfig);
connection.connect((err) => {
if (err) {
console.error("Fehler beim Verbinden:", err.stack);
return;
}
console.log("Database connected successfully.");
});
export default function handler(req, res) {
const idMap = req.query.idMap;
if (req.method !== "GET") {
return res.status(405).json({ error: "Nur GET Methode erlaubt" });
}
connection.query(`
SELECT
ld.idLD,
dp.idDP,
dp.name AS Na,
dp.value AS Val,
dp.unit AS Unit,
mg.name AS Gr,
ld.idLocation,
area.Name AS Area_Name
FROM location_device as ld
LEFT JOIN location_coordinates AS co ON ld.idLocation = co.idLocation and co.idMaps = ${idMap}
LEFT JOIN devices AS de ON de.idDevice = ld.idDevice
LEFT JOIN datapoint AS dp ON ld.idLD = dp.idLD
LEFT JOIN message_group AS mg ON dp.idmessage_group = mg.idmessage_group
LEFT JOIN location AS loc ON ld.idLocation = loc.idLocation
LEFT JOIN area AS area ON loc.idArea = area.idArea
WHERE co.X > 0 AND dp.idmessage_group>0 AND length(dp.unit)> 0 AND length(dp.value)> 0
`, (error, results) => {
if (error) {
console.error("Fehler beim Abrufen der gis_lines:", error);
return res
.status(500)
.json({ error: "Fehler beim Abrufen der gis_lines" });
}
const response = {
"Name": "Liste aller Messungen der Geraete",
"Zeitstempel": new Date().toISOString(),
"IdMap":idMap,
"Statis": results.map((row) => ({
IdLD: row.idLD,
IdDP: row.idDP,
Na: row.Na,
Val: row.Val,
Unit: row.Unit,
Gr: row.Gr,
IdLocation: row.IdLocation,
Area_Name: row.Area_Name,
})),
};
res.json(response);
});
}

View File

@@ -1,37 +0,0 @@
// /pages/api/talas_v5_DB/gisLines/readGisLines.js
import mysql from "mysql";
const dbConfig = {
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,
};
const connection = mysql.createConnection(dbConfig);
connection.connect((err) => {
if (err) {
console.error("Fehler beim Verbinden:", err.stack);
return;
}
//console.log("Database connected successfully.");
});
export default function handler(req, res) {
if (req.method !== "GET") {
return res.status(405).json({ error: "Nur GET Methode erlaubt" });
}
const query = "SELECT * FROM talas_v5.gis_lines;";
connection.query(query, (error, results) => {
if (error) {
console.error("Fehler beim Abrufen der gis_lines:", error);
return res.status(500).json({ error: "Fehler beim Abrufen der gis_lines" });
}
if (results.length > 0) {
res.json(results);
} else {
res.status(404).json({ error: "Gerät nicht gefunden" });
}
});
}

View File

@@ -1,61 +0,0 @@
// /pages/api/talas_v5_DB/gisLines/updateLineCoordinates.js
import mysql from "mysql";
const dbConfig = {
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,
};
const connection = mysql.createConnection(dbConfig);
connection.connect((err) => {
if (err) {
console.error("Fehler beim Verbinden:", err.stack);
return;
}
//console.log("Database connected successfully.");
});
export default function handler(req, res) {
if (req.method !== "POST") {
return res.status(405).json({ error: "Nur POST Methode erlaubt" });
}
const { idLD, idModul, newCoordinates } = req.body;
if (!idLD || !idModul || !newCoordinates) {
return res.status(400).json({ error: "Fehlende Daten" });
}
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 = ?;";
connection.beginTransaction((err) => {
if (err) {
throw err;
}
connection.query(query, [newLineString, idLD, idModul], (error, results, fields) => {
if (error) {
return connection.rollback(() => {
console.error("Fehler beim Aktualisieren der gis_lines:", error);
res.status(500).json({ error: "Fehler beim Aktualisieren der gis_lines" });
});
}
connection.commit((err) => {
if (err) {
return connection.rollback(() => {
throw err;
});
}
console.log("Transaction Complete.");
res.status(200).json({
success: "Updated successfully.",
affectedRows: results.affectedRows,
});
});
});
});
}

View File

@@ -1,40 +0,0 @@
// API in /api/talas_v5_DB/locationDevice/getDeviceId.js
import mysql from "mysql";
const dbConfig = {
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,
};
const connection = mysql.createConnection(dbConfig);
connection.connect((err) => {
if (err) {
console.error("Fehler beim Verbinden:", err.stack);
return;
}
});
export default function handler(req, res) {
if (req.method !== "GET") {
return res.status(405).json({ error: "Nur GET Methode erlaubt" });
}
const { deviceName } = req.query;
const query = "SELECT idLD FROM location_device WHERE name = ?";
connection.query(query, [deviceName], (error, results) => {
if (error) {
console.error("Fehler beim Abrufen der Geräte-ID:", error);
return res
.status(500)
.json({ error: "Fehler beim Abrufen der Geräte-ID" });
}
if (results.length > 0) {
res.json({ idLD: results[0].idLD });
} else {
res.status(404).json({ error: "Gerät nicht gefunden" });
}
});
}

View File

@@ -1,46 +0,0 @@
// API in /api/talas_v5_DB/locationDevice/locationDeviceNameById.js
import mysql from "mysql";
const dbConfig = {
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,
};
const connection = mysql.createConnection(dbConfig);
connection.connect((err) => {
if (err) {
console.error("Fehler beim Verbinden:", err.stack);
return;
}
});
export default async function handler(req, res) {
if (req.method !== "GET") {
return res.status(405).json({ error: "Nur GET Methode erlaubt" });
}
const { idLD } = req.query;
try {
const query = "SELECT name FROM location_device WHERE idLD = ?";
const [results] = await new Promise((resolve, reject) => {
connection.query(query, [idLD], (error, results) => {
if (error) {
return reject(error);
}
resolve(results);
});
});
if (results.length > 0) {
res.json({ name: results[0].name });
} else {
res.status(404).json({ error: "Gerät nicht gefunden", idLD, results });
}
} catch (error) {
console.error("Fehler beim Abrufen des Gerätenamens in locationDeviceNameById.js :", error);
res.status(500).json({ error: "Fehler beim Abrufen des Gerätenamens" });
}
}

View File

@@ -1,35 +0,0 @@
// API in /api/talas_v5_DB/locationDevice/locationDevices.js
import mysql from "mysql";
const dbConfig = {
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,
};
const connection = mysql.createConnection(dbConfig);
connection.connect((err) => {
if (err) {
console.error("Fehler beim Verbinden:", err.stack);
return;
}
});
export default function handler(req, res) {
if (req.method !== "GET") {
return res.status(405).json({ error: "Nur GET Methode erlaubt" });
}
const query = "SELECT * FROM location_device WHERE iddevice = 160";
connection.query(query, (error, results) => {
if (error) {
console.error("Fehler beim Abrufen der Geräteinformationen:", error);
return res
.status(500)
.json({ error: "Fehler beim Abrufen der Geräteinformationen" });
}
res.json(results);
});
}

View File

@@ -1,33 +0,0 @@
// pages/api/talas_v5_DB/poiTyp/readPoiTyp.js
import mysql from "mysql";
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") {
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" });
}
if (results.length === 0) {
return res.status(404).json({ message: "Keine Einträge gefunden" });
}
res.status(200).json(results);
});
} else {
res.setHeader("Allow", ["GET"]);
res.status(405).end(`Method ${req.method} Not Allowed`);
}
}

View File

@@ -1,38 +0,0 @@
// pages/api/talas_v5_DB/pois/addLocation.js
import mysql from "mysql";
const dbConfig = {
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 === "POST") {
const { name, poiTypeId, latitude, longitude, idLD } = req.body;
console.log("Received data:", req.body); // Überprüfen der empfangenen Daten
const connection = mysql.createConnection(dbConfig);
const query =
"INSERT INTO poi (description, idPoiTyp, position, idLD) VALUES (?, ?, ST_GeomFromText(?),?)";
const point = `POINT(${longitude} ${latitude})`;
const values = [name, poiTypeId, point, idLD]; // Stellen Sie sicher, dass poiTypeId korrekt ist
connection.query(query, values, (error, results) => {
connection.end();
if (error) {
console.error("Fehler beim Einfügen des Standorts:", error);
return res.status(500).json({ error: "Ein Fehler ist aufgetreten" });
}
res.status(200).json({
id: results.insertId,
message: "Standort erfolgreich hinzugefügt",
});
});
} else {
res.setHeader("Allow", ["POST"]);
res.status(405).end(`Method ${req.method} Not Allowed`);
}
}

View File

@@ -1,45 +0,0 @@
// pages/api/talas_v5_DB/pois/deletePoi.js
import mysql from "mysql";
// Datenbankkonfiguration
const dbConfig = {
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,
};
const connection = mysql.createConnection(dbConfig);
connection.connect((err) => {
if (err) {
console.error("Fehler beim Verbinden:", err.stack);
return;
}
console.log("Verbunden als ID", connection.threadId);
});
export default function handler(req, res) {
if (req.method !== "DELETE") {
return res.status(405).json({ error: "Nur DELETE Methode erlaubt" });
}
const { id } = req.query; // ID aus der Anfrage holen
if (!id) {
return res.status(400).json({ error: "POI ID ist erforderlich" });
}
const query = "DELETE FROM poi WHERE idPoi = ?";
connection.query(query, [id], (error, results) => {
if (error) {
console.error("Fehler beim Löschen des POI 4:", error);
return res.status(500).json({ error: "Fehler beim Löschen des POI" });
}
if (results.affectedRows > 0) {
res.json({ message: "POI erfolgreich gelöscht" });
} else {
res.status(404).json({ error: "POI nicht gefunden" });
}
});
}

View File

@@ -1,42 +0,0 @@
// pages/api/talas_v5_DB/pois/getPoiById.js
import mysql from "mysql";
const dbConfig = {
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") {
const { idPoi } = req.query;
const connection = mysql.createConnection(dbConfig);
connection.connect((err) => {
if (err) {
console.error("Fehler beim Verbinden:", err.stack);
return res
.status(500)
.json({ error: "Verbindungsfehler zur Datenbank" });
}
const query = "SELECT description FROM poi WHERE idPoi = ?";
connection.query(query, [idPoi], (error, results) => {
connection.end();
if (error) {
console.error("Fehler bei der Abfrage:", error);
return res.status(500).json({ error: "Fehler bei der Abfrage" });
}
if (results.length === 0) {
return res.status(404).json({ error: "POI nicht gefunden" });
}
res.status(200).json(results[0]);
});
});
} else {
res.setHeader("Allow", ["GET"]);
res.status(405).end(`Method ${req.method} Not Allowed`);
}
}

View File

@@ -1,42 +0,0 @@
// pages/api/talas_v5_DB/pois/poi-icons.js
import mysql from "mysql";
const dbConfig = {
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,
};
const connection = mysql.createConnection(dbConfig);
connection.connect((err) => {
if (err) {
console.error("Fehler beim Verbinden:", err.stack);
return;
}
});
export default function handler(req, res) {
if (req.method !== "GET") {
return res.status(405).json({ error: "Nur GET Methode erlaubt" });
}
const query = `SELECT p.idPoi, i.path
FROM poi p
JOIN poiTyp pt ON p.idPoiTyp = pt.idPoiTyp
JOIN poiicons i ON pt.icon = i.idpoiicons;`;
connection.query(query, (error, results) => {
try {
if (error) {
throw error;
}
res.json(results);
} catch (err) {
console.error("Fehler beim Abrufen der icons:", err);
res.status(500).json({ error: "Fehler beim Abrufen der icons" });
}
});
}

View File

@@ -1,42 +0,0 @@
// pages/api/talas_v5_DB/pois/readLocations.js
import mysql from "mysql";
const dbConfig = {
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,
};
//console.log("my dbconfig: ", dbConfig);
export default function handler(req, res) {
const connection = mysql.createConnection(dbConfig);
connection.connect((err) => {
if (err) {
console.error("Fehler beim Verbinden:", err.stack);
res.status(500).json({ error: "Verbindungsfehler zur Datenbank" });
return;
}
//console.log("Verbunden als ID", connection.threadId);
connection.query("SELECT idPoi, description, idPoiTyp, idLD, ST_AsText(position) AS position FROM poi", (error, results) => {
if (error) {
console.error("Fehler beim Abrufen der API", error);
res.status(500).json({ error: "Fehler bei der Abfrage" });
return;
}
// Wichtig: Senden Sie die Antwort zurück
res.status(200).json(results);
/* console.log(
"--------------- location.js ---------------",
"results in location.js : ",
results,
"---------------------- location.js end ---------------------------"
); */
connection.end();
});
});
}

View File

@@ -1,39 +0,0 @@
// pages/api/talas_v5_DB/pois/updateLocation.js
import mysql from "mysql";
import util from "util";
const dbConfig = {
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,
charset: "utf8mb4",
};
export default async function handler(req, res) {
if (req.method !== "POST") {
res.setHeader("Allow", ["POST"]);
return res.status(405).end(`Method ${req.method} Not Allowed`);
}
const { id, latitude, longitude } = req.body;
const connection = mysql.createConnection(dbConfig);
// Promisify the query method
const query = util.promisify(connection.query).bind(connection);
try {
await query("UPDATE poi SET position = POINT(?, ?) WHERE idPoi = ?", [
longitude,
latitude,
id,
]);
res.status(200).json({ success: true });
} catch (error) {
console.error(error);
res.status(500).json({ error: "Ein Fehler ist aufgetreten" });
} finally {
connection.end();
}
}

View File

@@ -1,46 +0,0 @@
// pages/api/talas_v5_DB/pois/updatePoi.js
import mysql from "mysql";
const dbConfig = {
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,
};
const connection = mysql.createConnection(dbConfig);
connection.connect((err) => {
if (err) {
console.error("Fehler beim Verbinden:", err.stack);
return;
}
//console.log("Verbunden als ID", connection.threadId);
});
export default function handler(req, res) {
if (req.method !== "POST") {
return res.status(405).json({ error: "Nur POST Methode erlaubt" });
}
const { idPoi, description, idPoiTyp, idLD } = req.body; // Stellen Sie sicher, dass die Felder korrekt benannt sind
//console.log("Empfangene Daten:", req.body); // Loggen der empfangenen Daten zur Überprüfung
if (!idPoi) {
return res.status(400).json({ error: "POI ID ist erforderlich" });
}
const query = "UPDATE talas_v5.poi SET description = ?, idPoiTyp = ?, idLD = ? WHERE idPoi = ?";
connection.query(query, [description, idPoiTyp, idLD, idPoi], (error, results) => {
if (error) {
console.error("Fehler beim Aktualisieren des POI:", error);
return res.status(500).json({ error: "Fehler beim Aktualisieren des POI" });
}
if (results.affectedRows > 0) {
res.json({ message: "POI erfolgreich aktualisiert" });
} else {
res.status(404).json({ error: "POI nicht gefunden" });
}
});
}

View File

@@ -1,40 +0,0 @@
// pages/api/talas_v5_DB/priorityConfig.js
// in tals5 http://10.10.0.13/talas5/Management/PriorityConfig.aspx beinhaltet die Tabelle prio die Prioritäten der Meldungen (Level 1-4) oder (0-4) je nachdem DB-Design
// das ist die API, die die Prioritäten zurückgibt
import mysql from "mysql";
const dbConfig = {
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,
};
//console.log("my dbconfig: ", dbConfig);
export default function handler(req, res) {
const connection = mysql.createConnection(dbConfig);
connection.connect((err) => {
if (err) {
console.error("Fehler beim Verbinden:", err.stack);
res.status(500).json({ error: "Verbindungsfehler zur Datenbank" });
return;
}
//console.log("Verbunden als ID", connection.threadId);
//Fehler weil, existiertdie Tabelle auf localhost:3000 nicht
connection.query("SELECT idprio, level, name, color FROM prio ", (error, results) => {
if (error) {
console.error("Fehler beim Abrufen der API", error);
res.status(500).json({ error: "Fehler bei der Abfrage" });
return;
}
// Wichtig: Senden Sie die Antwort zurück
res.status(200).json(results);
connection.end();
});
});
}

Binary file not shown.

View File

@@ -31,7 +31,7 @@ export default async function handler(req, res) {
res.status(200).json(namesMap);
} catch (err) {
console.error("Fehler beim Abrufen der Daten:", err);
console.error("Fehler beim Abrufen der Daten /device/getAllStationsNames.js :", err);
res.status(500).json({ error: "Error retrieving data from the database" });
} finally {
if (connection) connection.release(); // Gib die Verbindung zurück in den Pool

View File

@@ -1,46 +0,0 @@
// /pages/api/talas_v5_DB/device/getAllStationsNamesMock.js
export default function handler(req, res) {
// JSON-Daten hier
const stationNames = {
50035: "CPL Schulungssystem",
50036: "CPL Varel",
50039: "MIO Schulungssystem",
50040: "LTE-Modem Belecke",
50041: "LTE-Modem Halver",
50042: "LTE-Modem Lipperbruch",
50043: "GMA Bunde",
50044: "GMA Albrechtsplatz",
50045: "Cisco Router Engelbert",
50046: "Cisco-Router Schmallenberg",
50050: "GMA Testgerät",
50051: "GMA Beleke",
50052: "Router 1",
50055: "Testgerät 2",
50063: "Testgerät 1",
50064: "CPL Meldestation A",
50066: "CPL USV Raum",
50067: "Kontrollmodul 1",
50068: "Kontrollmodul 2",
50071: "Testgerät MIK-245",
50076: "SMS Funkmodem",
50077: "Notrufserver",
50078: "OGETest",
50079: "OGETest",
50080: "Insel",
50081: "CPL Test",
50082: "Buchhaim",
50083: "Zählstelle B35",
50084: "TEST JOL",
50085: "KH Westerstede (Master CPL 232)",
50086: "KH Oldenburg CPL 2 (Master CPL 233)",
50087: "PWC Gebäude A (LON, Slave von 232)",
50088: "PWC Gebäude B (CPL 231, Slave von 232)",
50089: "LR 77",
50091: "DC Server",
50092: "DZ WIS 1",
};
// Sende die JSON-Daten als Antwort
res.status(200).json(stationNames);
}

View File

@@ -1,751 +0,0 @@
{
"Name": "Liste aller Statis der Linien",
"Zeitstempel": "2024-09-09T12:29:42.5075786+02:00",
"IdMap": "12",
"Statis": [
{
"IdLD": 50035,
"Modul": 4,
"DpName": "KUE04_Messwertalarm",
"ModulName": "Ost LWL",
"ModulTyp": "Kü605µF",
"Message": "KÜG 04: Isolationsminderung kommend",
"Level": 2,
"PrioColor": "#FF9900",
"PrioName": "major",
"Value": "True"
},
{
"IdLD": 50035,
"Modul": 3,
"DpName": "KUE03_Aderbruch",
"ModulName": "Ost",
"ModulTyp": "Kü705-FO",
"Message": "KÜG 03: Aderbruch kommend",
"Level": 1,
"PrioColor": "#FF0000",
"PrioName": "critical",
"Value": "?"
},
{
"IdLD": 50035,
"Modul": 4,
"DpName": "KUE04_Aderbruch",
"ModulName": "Ost LWL",
"ModulTyp": "Kü605µF",
"Message": "KÜG 04: Aderbruch kommend",
"Level": 1,
"PrioColor": "#FF0000",
"PrioName": "critical",
"Value": "?"
},
{
"IdLD": 50035,
"Modul": 5,
"DpName": "KUE05_Aderbruch",
"ModulName": " West",
"ModulTyp": "Kü605µC",
"Message": "KÜG 05: Aderbruch kommend",
"Level": 1,
"PrioColor": "#FF0000",
"PrioName": "critical",
"Value": "?"
},
{
"IdLD": 50035,
"Modul": 6,
"DpName": "KUE06_Aderbruch",
"ModulName": "K54 AP12",
"ModulTyp": "Kü705-FO",
"Message": "KÜG 06: Aderbruch kommend",
"Level": 1,
"PrioColor": "#FF0000",
"PrioName": "critical",
"Value": "?"
},
{
"IdLD": 50035,
"Modul": 1,
"DpName": "KUE01_Messwert",
"ModulName": "Nord",
"ModulTyp": "Kü705-FO",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "51.5 MOhm"
},
{
"IdLD": 50035,
"Modul": 2,
"DpName": "KUE02_Messwert",
"ModulName": "Süd",
"ModulTyp": "Kü705-FO",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "30 MOhm"
},
{
"IdLD": 50035,
"Modul": 6,
"DpName": "KUE06_Messwert",
"ModulName": "K54 AP12",
"ModulTyp": "Kü705-FO",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0 MOhm"
},
{
"IdLD": 50035,
"Modul": 7,
"DpName": "KUE07_Messwert",
"ModulName": "Kreuzung 50Hz",
"ModulTyp": "KÜSS V2",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0 MOhm"
},
{
"IdLD": 50035,
"Modul": 8,
"DpName": "KUE08_Messwert",
"ModulName": "Querung EWE",
"ModulTyp": "KÜSS V2",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0 MOhm"
},
{
"IdLD": 50035,
"Modul": 21,
"DpName": "KUE21_Messwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.61 MOhm"
},
{
"IdLD": 50035,
"Modul": 22,
"DpName": "KUE22_Messwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.72 MOhm"
},
{
"IdLD": 50035,
"Modul": 1,
"DpName": "KUE01_Schleifenwert",
"ModulName": "Nord",
"ModulTyp": "Kü705-FO",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.61 kOhm"
},
{
"IdLD": 50035,
"Modul": 2,
"DpName": "KUE02_Schleifenwert",
"ModulName": "Süd",
"ModulTyp": "Kü705-FO",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.79 kOhm"
},
{
"IdLD": 50035,
"Modul": 4,
"DpName": "KUE04_Schleifenwert",
"ModulName": "Ost LWL",
"ModulTyp": "Kü605µF",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "64.01 kOhm"
},
{
"IdLD": 50035,
"Modul": 5,
"DpName": "KUE05_Schleifenwert",
"ModulName": " West",
"ModulTyp": "Kü605µC",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "64.01 kOhm"
},
{
"IdLD": 50035,
"Modul": 6,
"DpName": "KUE06_Schleifenwert",
"ModulName": "K54 AP12",
"ModulTyp": "Kü705-FO",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0 kOhm"
},
{
"IdLD": 50035,
"Modul": 7,
"DpName": "KUE07_Schleifenwert",
"ModulName": "Kreuzung 50Hz",
"ModulTyp": "KÜSS V2",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0 kOhm"
},
{
"IdLD": 50035,
"Modul": 8,
"DpName": "KUE08_Schleifenwert",
"ModulName": "Querung EWE",
"ModulTyp": "KÜSS V2",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0 kOhm"
},
{
"IdLD": 50036,
"Modul": 1,
"DpName": "KUE01_Messwert",
"ModulName": "Friedrichsfehn",
"ModulTyp": "Kü705-FO",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "10.5 MOhm"
},
{
"IdLD": 50036,
"Modul": 2,
"DpName": "KUE02_Messwert",
"ModulName": "Köln",
"ModulTyp": "Kü605µC",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "10 MOhm"
},
{
"IdLD": 50036,
"Modul": 3,
"DpName": "KUE03_Messwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "200 MOhm"
},
{
"IdLD": 50036,
"Modul": 4,
"DpName": "KUE04_Messwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0 MOhm"
},
{
"IdLD": 50036,
"Modul": 5,
"DpName": "KUE05_Messwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "11.5 MOhm"
},
{
"IdLD": 50036,
"Modul": 8,
"DpName": "KUE08_Messwert",
"ModulName": "Köln",
"ModulTyp": "KÜSS V2",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0 Events"
},
{
"IdLD": 50036,
"Modul": 9,
"DpName": "KUE09_Messwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "11 MOhm"
},
{
"IdLD": 50036,
"Modul": 10,
"DpName": "KUE10_Messwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "11 MOhm"
},
{
"IdLD": 50036,
"Modul": 11,
"DpName": "KUE11_Messwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "11 MOhm"
},
{
"IdLD": 50036,
"Modul": 12,
"DpName": "KUE12_Messwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "11 MOhm"
},
{
"IdLD": 50036,
"Modul": 1,
"DpName": "KUE01_Schleifenwert",
"ModulName": "Friedrichsfehn",
"ModulTyp": "Kü705-FO",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "2.32 kOhm"
},
{
"IdLD": 50036,
"Modul": 2,
"DpName": "KUE02_Schleifenwert",
"ModulName": "Köln",
"ModulTyp": "Kü605µC",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "2.15 kOhm"
},
{
"IdLD": 50036,
"Modul": 6,
"DpName": "KUE06_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "64.01 kOhm"
},
{
"IdLD": 50036,
"Modul": 7,
"DpName": "KUE07_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "64.01 kOhm"
},
{
"IdLD": 50036,
"Modul": 8,
"DpName": "KUE08_Schleifenwert",
"ModulName": "Köln",
"ModulTyp": "KÜSS V2",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0 kOhm"
},
{
"IdLD": 50071,
"Modul": 1,
"DpName": "KUE01_Messwert",
"ModulName": "Test 1",
"ModulTyp": "Kü705-FO",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.1 MOhm"
},
{
"IdLD": 50071,
"Modul": 2,
"DpName": "KUE02_Messwert",
"ModulName": "Test 2",
"ModulTyp": "Kü705-FO",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.1 MOhm"
},
{
"IdLD": 50071,
"Modul": 3,
"DpName": "KUE03_Messwert",
"ModulName": "Test 3",
"ModulTyp": "Kü705-FO",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.1 MOhm"
},
{
"IdLD": 50071,
"Modul": 4,
"DpName": "KUE04_Messwert",
"ModulName": "Test 4",
"ModulTyp": "Kü605µF",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.1 MOhm"
},
{
"IdLD": 50071,
"Modul": 5,
"DpName": "KUE05_Messwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.1 MOhm"
},
{
"IdLD": 50071,
"Modul": 6,
"DpName": "KUE06_Messwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.1 MOhm"
},
{
"IdLD": 50071,
"Modul": 7,
"DpName": "KUE07_Messwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.1 Events"
},
{
"IdLD": 50071,
"Modul": 8,
"DpName": "KUE08_Messwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "51 Events"
},
{
"IdLD": 50071,
"Modul": 11,
"DpName": "KUE11_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.59 kOhm"
},
{
"IdLD": 50071,
"Modul": 12,
"DpName": "KUE12_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.61 kOhm"
},
{
"IdLD": 50071,
"Modul": 13,
"DpName": "KUE13_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.58 kOhm"
},
{
"IdLD": 50071,
"Modul": 14,
"DpName": "KUE14_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.6 kOhm"
},
{
"IdLD": 50071,
"Modul": 15,
"DpName": "KUE15_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.6 kOhm"
},
{
"IdLD": 50071,
"Modul": 16,
"DpName": "KUE16_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0.57 kOhm"
},
{
"IdLD": 50082,
"Modul": 6,
"DpName": "KUE06_Messwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0 MOhm"
},
{
"IdLD": 50082,
"Modul": 7,
"DpName": "KUE07_Messwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "10 MOhm"
},
{
"IdLD": 50082,
"Modul": 6,
"DpName": "KUE06_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0 kOhm"
},
{
"IdLD": 50082,
"Modul": 7,
"DpName": "KUE07_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "2.74 kOhm"
},
{
"IdLD": 50086,
"Modul": 1,
"DpName": "KUE01_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "201 kOhm"
},
{
"IdLD": 50086,
"Modul": 2,
"DpName": "KUE02_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "201 kOhm"
},
{
"IdLD": 50086,
"Modul": 3,
"DpName": "KUE03_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "201 kOhm"
},
{
"IdLD": 50086,
"Modul": 4,
"DpName": "KUE04_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "0 kOhm"
},
{
"IdLD": 50086,
"Modul": 11,
"DpName": "KUE11_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "4.01 kOhm"
},
{
"IdLD": 50086,
"Modul": 12,
"DpName": "KUE12_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "4.01 kOhm"
},
{
"IdLD": 50086,
"Modul": 13,
"DpName": "KUE13_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "4.01 kOhm"
},
{
"IdLD": 50086,
"Modul": 14,
"DpName": "KUE14_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "4.01 kOhm"
},
{
"IdLD": 50086,
"Modul": 15,
"DpName": "KUE15_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "4.01 kOhm"
},
{
"IdLD": 50086,
"Modul": 16,
"DpName": "KUE16_Schleifenwert",
"ModulName": "?",
"ModulTyp": "?",
"Message": "?",
"Level": -1,
"PrioColor": "#ffffff",
"PrioName": "?",
"Value": "4.01 kOhm"
}
]
}

View File

@@ -2,34 +2,29 @@
import getPool from "../../../../utils/mysqlPool"; // Singleton-Pool importieren
export default async function handler(req, res) {
const pool = getPool();
const pool = getPool(); // Singleton-Pool verwenden
let connection;
if (req.method !== "GET") {
return res.status(405).json({ error: "Nur GET Methode erlaubt" });
}
const databaseName = process.env.NEXT_PUBLIC_DB_NAME; //talas_v5
const query = `SELECT * FROM ${databaseName}.gis_lines;`;
const query = "SELECT * FROM gis_lines;";
try {
// Verbindung aus dem Pool holen
connection = await pool.getConnection();
// Abfrage ausführen
const [results] = await connection.query(query);
if (results.length > 0) {
return res.status(200).json(results);
res.status(200).json(results);
} else {
console.warn(`WARNUNG: Die Tabelle ${databaseName}.gis_lines ist leer oder existiert nicht.`);
return res.status(200).json({ message: `Die Tabelle ${databaseName}.gis_lines ist leer oder existiert nicht.` });
res.status(404).json({ error: "Keine Daten gefunden" });
}
} catch (error) {
if (error.code === "ER_NO_SUCH_TABLE") {
console.warn(`WARNUNG: Die Tabelle ${databaseName}.gis_lines existiert nicht.`);
return res.status(200).json({ message: `Die Tabelle ${databaseName}.gis_lines existiert nicht.` });
}
console.error("Fehler beim Abrufen der gis_lines:", error);
return res.status(500).json({ error: "Fehler beim Abrufen der gis_lines" });
res.status(500).json({ error: "Fehler beim Abrufen der gis_lines" });
} finally {
if (connection) connection.release();
if (connection) connection.release(); // Verbindung freigeben
}
}

View File

@@ -20,7 +20,7 @@ export default async function handler(req, res) {
const [results] = await connection.query(query);
if (results.length === 0) {
return res.status(404).json({ message: "Keine Einträge gefunden" });
return res.status(200).json({ warning: "Keine Einträge gefunden in readPoiTyp.js" });
}
res.status(200).json(results);

View File

@@ -15,7 +15,7 @@ export default async function handler(req, res) {
}
const query = `
UPDATE talas_v5.poi
UPDATE poi
SET description = ?, idPoiTyp = ?, idLD = ?
WHERE idPoi = ?
`;

View File

@@ -31,7 +31,7 @@ export default async function handler(req, res) {
res.status(200).json(namesMap);
} catch (err) {
console.error("Fehler beim Abrufen der Daten:", err);
console.error("Fehler beim Abrufen der Daten in /station/getAllStationsNames.js:", err);
res.status(500).json({ error: "Error retrieving data from the database" });
} finally {
if (connection) connection.release(); // Gib die Verbindung zurück in den Pool

View File

@@ -50,7 +50,7 @@ export const fetchGisStatusStations = async (idMap, idUser) => {
const data = await response.json();
return data;
} catch (error) {
console.error("Fehler beim Abrufen der Daten:", error);
console.error("Fehler beim Abrufen der Daten in /services/apiService.js :", error);
throw error;
}
}, 500); // Debounce-Zeit auf 500ms gesetzt

View File

@@ -81,7 +81,7 @@ export const createAndSetMarkers = async (systemId, setMarkersFunction) => {
setMarkersFunction(markersData);
}
} catch (error) {
console.error("Error fetching data: ", error);
console.error("Error fetching data in utils/utils.js : ", error);
}
};
//----------------------------------------------
@@ -106,7 +106,7 @@ export const fetchGisStatusStations = async (idMap, idUser) => {
console.log("GisStatusStations:", data);
return data;
} catch (error) {
console.error("Fehler beim Abrufen der Daten:", error);
console.error("Fehler beim Abrufen der Daten in utils/utils.js :", error);
}
};
//----------------------------------------------