diff --git a/components/imports.js b/components/imports.js deleted file mode 100644 index a81e36edb..000000000 --- a/components/imports.js +++ /dev/null @@ -1,162 +0,0 @@ -// imports.js -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 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"; - -export { - React, - useEffect, - useRef, - useState, - useCallback, - L, - marker, - config, - urls, - OverlappingMarkerSpiderfier, - DataSheet, - useRecoilState, - useRecoilValue, - useSetRecoilState, - gisStationsStaticDistrictState, - gisSystemStaticState, - mapLayersState, - selectedAreaState, - zoomTriggerState, - poiTypState, - AddPoiModalWindow, - poiReadFromDbTriggerAtom, - InformationCircleIcon, - PoiUpdateModal, - selectedPoiState, - currentPoiState, - ToastContainer, - toast, - mapIdState, - userIdState, - poiLayerVisibleState, - plusRoundIcon, - parsePoint, - findClosestPoints, - insertNewPOI, - removePOI, - createAndSetDevices, - handleEditPoi, - redrawPolyline, - restoreMapSettings, - checkOverlappingMarkers, - circleIcon, - startIcon, - endIcon, - fetchGisStatusStations, - fetchPriorityConfig, - fetchPoiData, - updateLocationInDatabase, - fetchUserRights, - fetchDeviceNameById, - addContextMenuToMarker, - MAP_VERSION, - layers, - zoomIn, - zoomOut, - centerHere, - initializeMap, - addItemsToMapContextMenu, - useGmaMarkersLayer, - useTalasMarkersLayer, - useEciMarkersLayer, - useGsmModemMarkersLayer, - useCiscoRouterMarkersLayer, - useWagoMarkersLayer, - useSiemensMarkersLayer, - useOtdrMarkersLayer, - useWdmMarkersLayer, - useMessstellenMarkersLayer, - useTalasiclMarkersLayer, - useDauzMarkersLayer, - useSmsfunkmodemMarkersLayer, - useUlafMarkersLayer, - useSonstigeMarkersLayer, - handlePoiSelect, - fetchGisStationsStaticDistrict, - fetchGisStationsStatusDistrict, - fetchGisStationsMeasurements, - fetchGisSystemStatic, - setupPolylines, - setupPOIs, - VersionInfoModal, - PoiUpdateModalWrapper, - AddPoiModalWindowWrapper, - useFetchPoiData, - usePoiTypData, - useMarkerLayers, - useLayerVisibility, - useLineData, -}; diff --git a/config/appVersion.js b/config/appVersion.js index 69a07849d..49cc696f5 100644 --- a/config/appVersion.js +++ b/config/appVersion.js @@ -1,2 +1,2 @@ // /config/appVersion -export const APP_VERSION = "1.1.3"; +export const APP_VERSION = "1.1.4"; diff --git a/pages/api/talas5/area.js b/pages/api/talas5/area.js deleted file mode 100644 index 69f571c97..000000000 --- a/pages/api/talas5/area.js +++ /dev/null @@ -1,24 +0,0 @@ -// pages/api/talas_v5/area.js -// Lesen von talas_v5 MySQL-Datenbank -> area Tabelle enthält DAUZ Geräte - -import getPool from "../../utils/mysqlPool"; // Verwende den Singleton-Pool - -export default async function handler(req, res) { - let connection; - - try { - const pool = getPool(); // Hole den Pool - connection = await pool.getConnection(); // Hole die Verbindung - - // Führe die Abfrage aus - const [results] = await connection.query("SELECT id, name FROM area WHERE id = ?", [req.query.id]); - - // Sende die 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" }); - } finally { - if (connection) connection.release(); // Gib die Verbindung zurück in den Pool - } -} diff --git a/pages/api/talas5/location_device.js b/pages/api/talas5/location_device.js deleted file mode 100644 index 40e901412..000000000 --- a/pages/api/talas5/location_device.js +++ /dev/null @@ -1,36 +0,0 @@ -// /pages/api/talas5/location_device.js -import getPool from "../../../utils/mysqlPool"; // Import Singleton-Pool - -// API-Handler -export default async function handler(req, res) { - const pool = getPool(); // Singleton-Pool verwenden - - let connection; - try { - // SQL-Query, um die Geräteinformationen aus location_device und devices zu erhalten - const sql = ` - SELECT ld.idLD, ld.iddevice, ld.name, d.idsystem_typ - FROM location_device ld - JOIN devices d ON ld.iddevice = d.iddevice - ORDER BY ld.name - `; - - connection = await pool.getConnection(); - - // Führe die Abfrage durch - const [results] = await connection.query(sql); - - if (!results.length) { - return res.status(404).json({ error: "Keine Geräte gefunden" }); - } - - // Geben Sie die Daten zurück - res.status(200).json(results); - } catch (error) { - // Loggen Sie den Fehler und geben Sie ihn zurück - console.error("Fehler beim Abrufen der Geräteinformationen:", error); - res.status(500).json({ error: "Fehler beim Abrufen der Geräteinformationen" }); - } finally { - if (connection) connection.release(); - } -} diff --git a/pages/api/talas5/webserviceMap/GisStationsMeasurements.js b/pages/api/talas5/webserviceMap/GisStationsMeasurements.js deleted file mode 100644 index 5aba69fc6..000000000 --- a/pages/api/talas5/webserviceMap/GisStationsMeasurements.js +++ /dev/null @@ -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'); - } - }; \ No newline at end of file diff --git a/pages/api/talas5/webserviceMap/GisStationsStaticDistrict.js b/pages/api/talas5/webserviceMap/GisStationsStaticDistrict.js deleted file mode 100644 index bf302f3d7..000000000 --- a/pages/api/talas5/webserviceMap/GisStationsStaticDistrict.js +++ /dev/null @@ -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'); - } - }; \ No newline at end of file diff --git a/pages/api/talas5/webserviceMap/GisStationsStatusDistrict.js b/pages/api/talas5/webserviceMap/GisStationsStatusDistrict.js deleted file mode 100644 index 27b0b442b..000000000 --- a/pages/api/talas5/webserviceMap/GisStationsStatusDistrict.js +++ /dev/null @@ -1,81 +0,0 @@ -// /pages/api/talas5/webserviceMap/GisStationsStatusDistrict.js -import getPool from "../../../../utils/mysqlPool"; // Singleton-Pool importieren - -export default async function handler(req, res) { - const pool = getPool(); // Singleton-Pool verwenden - let connection; // Verbindung deklarieren - - const { idMap, idUser } = req.query; - - if (!idMap || !idUser) { - return res.status(400).json({ error: "idMap and idUser are required" }); - } - - try { - // Verbindung aus dem Pool holen - connection = await pool.getConnection(); - - let onlySystem = -1; - let districtCounter = 0; - - // Get onlySystem - const [mapResult] = await connection.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 connection.query("SELECT count(*) as count FROM user_User_layer1 WHERE iduser = ?", [idUser]); - districtCounter = userLayerResult[0].count; - } - - // Query erstellen - 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 connection.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" }); - } finally { - // Stelle sicher, dass die Verbindung zurück in den Pool gegeben wird - if (connection) connection.release(); - } -} diff --git a/pages/api/talas5/webserviceMap/GisSystemStatic.js b/pages/api/talas5/webserviceMap/GisSystemStatic.js deleted file mode 100644 index b2fb56635..000000000 --- a/pages/api/talas5/webserviceMap/GisSystemStatic.js +++ /dev/null @@ -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'); - } -}; \ No newline at end of file diff --git a/pages/api/talas5/webserviceMap/gisStationsMeasurementsSQL.js b/pages/api/talas5/webserviceMap/gisStationsMeasurementsSQL.js deleted file mode 100644 index 7912816d4..000000000 --- a/pages/api/talas5/webserviceMap/gisStationsMeasurementsSQL.js +++ /dev/null @@ -1,56 +0,0 @@ -// /pages/api/talas5/webserviceMap/gisStationsMeasurementsSQL.js -import getPool from "../../../../utils/mysqlPool"; // Singleton-Pool importieren - -export default function handler(req, res) { - const pool = getPool(); // Singleton-Pool verwenden - - 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); - }); -} diff --git a/services/checkInternet.js b/services/checkInternet.js new file mode 100644 index 000000000..63e137485 --- /dev/null +++ b/services/checkInternet.js @@ -0,0 +1,5 @@ +export const checkInternet = () => { + fetch("https://tile.openstreetmap.org/1/1/1.png", { method: "HEAD" }) + .then((response) => setOnline(response.ok)) + .catch(() => setOnline(false)); +}; diff --git a/services/fetchDeviceNameById.js b/services/fetchDeviceNameById.js new file mode 100644 index 000000000..b492896e3 --- /dev/null +++ b/services/fetchDeviceNameById.js @@ -0,0 +1,14 @@ +export const fetchDeviceNameById = async (idLD) => { + try { + const response = await fetch(`/api/talas_v5_DB/locationDevice/locationDeviceNameById?idLD=${idLD}`); + const data = await response.json(); + if (response.ok) { + return data.name; + } else { + throw new Error("Gerät nicht gefunden"); + } + } catch (error) { + console.error("Fehler beim Abrufen des Gerätenamens in fetchDeviceNameById:", error); + return "Unbekannt"; + } +}; diff --git a/services/fetchGisStationsMeasurements.js b/services/fetchGisStationsMeasurements.js new file mode 100644 index 000000000..2283dc1f0 --- /dev/null +++ b/services/fetchGisStationsMeasurements.js @@ -0,0 +1,15 @@ +export const fetchGisStationsMeasurements = async (url, setGisStationsMeasurements) => { + try { + const response = await fetch(url); + const jsonResponse = await response.json(); + if (jsonResponse && jsonResponse.Statis) { + setGisStationsMeasurements(jsonResponse.Statis); + } else { + console.error('Erwartete Daten im "Statis"-Array nicht gefunden', jsonResponse); + setGisStationsMeasurements([]); + } + } catch (error) { + console.error("Fehler beim Laden der Daten: ", error); + setGisStationsMeasurements([]); + } +}; diff --git a/services/fetchGisStationsStaticDistrict.js b/services/fetchGisStationsStaticDistrict.js new file mode 100644 index 000000000..4c933ed9d --- /dev/null +++ b/services/fetchGisStationsStaticDistrict.js @@ -0,0 +1,17 @@ +import { setGisStationsStaticDistrict } from "../../redux/slices/gisStationsStaticDistrictSlice"; + +export const fetchGisStationsStaticDistrict = async (url, dispatch, fetchOptions) => { + try { + const response = await fetch(url, fetchOptions); + const jsonResponse = await response.json(); + if (jsonResponse && jsonResponse.Points) { + dispatch(setGisStationsStaticDistrict(jsonResponse.Points)); + } else { + console.error('Erwartete Daten im "Points"-Array nicht gefunden', jsonResponse); + dispatch(setGisStationsStaticDistrict([])); + } + } catch (error) { + console.error("Fehler beim Laden der Daten: ", error); + dispatch(setGisStationsStaticDistrict([])); + } +}; diff --git a/services/fetchGisStationsStatusDistrict.js b/services/fetchGisStationsStatusDistrict.js new file mode 100644 index 000000000..d9422811f --- /dev/null +++ b/services/fetchGisStationsStatusDistrict.js @@ -0,0 +1,15 @@ +export const fetchGisStationsStatusDistrict = async (url, setGisStationsStatusDistrict) => { + try { + const response = await fetch(url); + const jsonResponse = await response.json(); + if (jsonResponse && jsonResponse.Statis) { + setGisStationsStatusDistrict(jsonResponse.Statis); + } else { + console.error('Erwartete Daten im "Statis"-Array nicht gefunden', jsonResponse); + setGisStationsStatusDistrict([]); + } + } catch (error) { + console.error("Fehler beim Laden der Daten: ", error); + setGisStationsStatusDistrict([]); + } +}; diff --git a/services/fetchGisStatusStations.js b/services/fetchGisStatusStations.js new file mode 100644 index 000000000..218249457 --- /dev/null +++ b/services/fetchGisStatusStations.js @@ -0,0 +1,23 @@ +import fetchWithTimeout from "./fetchWithTimeout"; + +export const fetchGisStatusStations = async (idMap, idUser) => { + const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL; + return fetchWithTimeout( + `${SERVER_URL}/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`, + { + method: "GET", + headers: { + Connection: "close", + }, + }, + 5000 + ) + .then((response) => { + if (!response.ok) throw new Error(`Error: ${response.statusText}`); + return response.json(); + }) + .catch((error) => { + console.error("Fehler beim Abrufen der Daten in fetchGisStatusStations:", error); + throw error; + }); +}; diff --git a/services/fetchGisSystemStatic.js b/services/fetchGisSystemStatic.js new file mode 100644 index 000000000..2b04abc57 --- /dev/null +++ b/services/fetchGisSystemStatic.js @@ -0,0 +1,16 @@ +export const fetchGisSystemStatic = async (url, setGisSystemStatic, setGisSystemStaticLoaded) => { + try { + const response = await fetch(url); + const jsonResponse = await response.json(); + if (jsonResponse && jsonResponse.Systems) { + setGisSystemStatic(jsonResponse.Systems); + setGisSystemStaticLoaded(true); + } else { + console.error('Erwartete Daten im "Systems"-Array nicht gefunden', jsonResponse); + setGisSystemStatic([]); + } + } catch (error) { + console.error("Fehler beim Laden der Daten: ", error); + setGisSystemStatic([]); + } +}; diff --git a/services/fetchPoiData.js b/services/fetchPoiData.js new file mode 100644 index 000000000..7626ed466 --- /dev/null +++ b/services/fetchPoiData.js @@ -0,0 +1,16 @@ +export const fetchPoiData = async (idPoi) => { + try { + const response = await fetch(`/api/talas_v5_DB/pois/getPoiById?idPoi=${idPoi}`); + if (!response.ok) throw new Error("Fehler beim Abrufen der POI-Daten"); + const data = await response.json(); + return { + idPoi, + name: data.name, + description: data.description, + idLD: data.idLD, + }; + } catch (error) { + console.error("Fehler beim Abrufen der POI-Daten", error); + return null; + } +}; diff --git a/services/fetchUserRights.js b/services/fetchUserRights.js new file mode 100644 index 000000000..0fe66f526 --- /dev/null +++ b/services/fetchUserRights.js @@ -0,0 +1,26 @@ +import * as config from "../../config/config"; + +export const fetchUserRights = async () => { + let userRightsRequestCount = localStorage.getItem("userRightsRequestCount") || 0; + userRightsRequestCount++; + localStorage.setItem("userRightsRequestCount", userRightsRequestCount); + + console.log(`fetchUserRights wurde ${userRightsRequestCount} Mal aufgerufen.`); + + try { + const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${config.idMap}&idUser=${config.idUser}`, { + method: "GET", + headers: { Connection: "close" }, + }); + + if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`); + + const data = await response.json(); + if (!data || !data.Rights || !Array.isArray(data.Rights)) throw new Error("Invalid response structure"); + + return data.Rights.map((right) => right.IdRight); + } catch (error) { + console.error("Fehler beim Abrufen der Benutzerrechte", error); + return []; + } +}; diff --git a/services/fetchWithTimeout.js b/services/fetchWithTimeout.js new file mode 100644 index 000000000..d90e29c77 --- /dev/null +++ b/services/fetchWithTimeout.js @@ -0,0 +1,16 @@ +const fetchWithTimeout = (url, options, timeout = 5000) => { + const controller = new AbortController(); + const id = setTimeout(() => controller.abort(), timeout); + + return fetch(url, { ...options, signal: controller.signal }) + .then((response) => { + clearTimeout(id); + return response; + }) + .catch((error) => { + clearTimeout(id); + throw error; + }); +}; + +export default fetchWithTimeout; diff --git a/services/updateLocationInDatabase.js b/services/updateLocationInDatabase.js new file mode 100644 index 000000000..4038fbd81 --- /dev/null +++ b/services/updateLocationInDatabase.js @@ -0,0 +1,11 @@ +export const updateLocationInDatabase = async (id, newLatitude, newLongitude) => { + const response = await fetch("/api/talas_v5_DB/pois/updateLocation", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ id, latitude: newLatitude, longitude: newLongitude }), + }); + + if (!response.ok) { + console.error("Fehler beim Aktualisieren der Position"); + } +};