changed direct backend access
This commit is contained in:
@@ -264,14 +264,13 @@
|
||||
|
||||
// Einstellungen laden beim Seitenaufruf
|
||||
window.onload = function () {
|
||||
loadLicence();
|
||||
loadSettings();
|
||||
loadWifiSettings();
|
||||
loadSystemInfo();
|
||||
loadCurrentTime();
|
||||
updateCurrentTimeDisplay();
|
||||
loadLicence();
|
||||
loadWifiSettings();
|
||||
loadLocations();
|
||||
};
|
||||
|
||||
// Aktuelle Zeit anzeigen (Live-Update)
|
||||
@@ -460,7 +459,7 @@
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
document.getElementById("licencekey").value = data.licence || "";
|
||||
|
||||
loadLocations();
|
||||
})
|
||||
.catch((error) =>
|
||||
showMessage("Fehler beim Laden der Lizenz", "error")
|
||||
@@ -790,33 +789,41 @@
|
||||
//location functions
|
||||
// Locations laden und Dropdown befüllen
|
||||
function loadLocations() {
|
||||
fetch("/api/location/")
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
const select = document.getElementById("locationSelect");
|
||||
|
||||
// Vorhandene Optionen löschen (außer der ersten "Bitte wählen...")
|
||||
while (select.children.length > 1) {
|
||||
select.removeChild(select.lastChild);
|
||||
}
|
||||
|
||||
// Neue Optionen aus Backend-Response hinzufügen
|
||||
data.forEach((location) => {
|
||||
const option = document.createElement("option");
|
||||
option.value = location.id;
|
||||
option.textContent = location.name;
|
||||
select.appendChild(option);
|
||||
});
|
||||
|
||||
// Aktuell gespeicherten Standort laden
|
||||
loadCurrentLocation();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("Locations konnten nicht geladen werden:", error);
|
||||
showMessage("Fehler beim Laden der Standorte", "error");
|
||||
});
|
||||
const licence = document.getElementById("licencekey").value; // Get the licence key from the input field
|
||||
fetch("http://db.reptilfpv.de:3000/api/location/", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${licence}`, // Add Bearer token using licenkey
|
||||
},
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
|
||||
const select = document.getElementById("locationSelect");
|
||||
|
||||
// Vorhandene Optionen löschen (außer der ersten "Bitte wählen...")
|
||||
while (select.children.length > 1) {
|
||||
select.removeChild(select.lastChild);
|
||||
}
|
||||
|
||||
// Neue Optionen aus Backend-Response hinzufügen
|
||||
// Neue Optionen aus Backend-Response hinzufügen
|
||||
data.forEach((location) => {
|
||||
const option = document.createElement("option");
|
||||
option.value = location.id;
|
||||
option.textContent = location.name;
|
||||
select.appendChild(option);
|
||||
});
|
||||
|
||||
// Aktuell gespeicherten Standort laden
|
||||
loadCurrentLocation();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("Locations konnten nicht geladen werden:", error);
|
||||
showMessage("Fehler beim Laden der Locations", "error");
|
||||
});
|
||||
}
|
||||
|
||||
// Aktuell gespeicherten Standort laden
|
||||
function loadCurrentLocation() {
|
||||
fetch("/api/get-location")
|
||||
|
||||
Reference in New Issue
Block a user