refactor: Services nach Datenquelle getrennt – webservice/, database/ und utils/ Struktur eingeführt (v1.1.117)
This commit is contained in:
15
services/database/fetchDeviceNameByIdService.js
Normal file
15
services/database/fetchDeviceNameByIdService.js
Normal file
@@ -0,0 +1,15 @@
|
||||
// /services/api/fetchDeviceNameById.js
|
||||
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";
|
||||
}
|
||||
};
|
||||
18
services/database/fetchPoiData.js
Normal file
18
services/database/fetchPoiData.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// /services/api/fetchPoiData.js
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
13
services/database/updateLocationInDatabase.js
Normal file
13
services/database/updateLocationInDatabase.js
Normal file
@@ -0,0 +1,13 @@
|
||||
// /services/api/updateLocationInDatabase.js
|
||||
|
||||
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");
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user