delete: unused files/Mock files
This commit is contained in:
@@ -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" });
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -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,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -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" });
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -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" });
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
@@ -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`);
|
||||
}
|
||||
}
|
||||
@@ -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`);
|
||||
}
|
||||
}
|
||||
@@ -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" });
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -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`);
|
||||
}
|
||||
}
|
||||
@@ -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" });
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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" });
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user