- Externe Webservices von TALAS V5 integriert und geprüft (Statuscode + Antwortstruktur) - Eigene API-Endpunkte wie /api/talas_v5_DB/getDevices hinzugefügt und validiert - Prüfung von NEXT_PUBLIC_USE_MOCKS zur Vermeidung von Mockdaten in Produktion - Validierung der Umgebungsvariablen wie DB_HOST, DB_NAME und NODE_ENV ergänzt - Response-Status 200 bei vollständigem Erfolg, 207 bei Teilfehlern - Verbesserung der JSON-Antwortstruktur zur einfacheren Analyse
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
// utils/openInNewTab.js
|
|
|
|
export function openInNewTab(e, target) {
|
|
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
|
const url = new URL(window.location.origin);
|
|
const originWithoutPort = `${url.protocol}//${url.hostname}`; // ohne Port!
|
|
|
|
let link;
|
|
|
|
if (target instanceof L.Marker && target.options.link) {
|
|
link = `${originWithoutPort}${basePath}/devices/${target.options.link}`;
|
|
} else if (target instanceof L.Polyline) {
|
|
const idLD = target.options.idLD;
|
|
if (idLD) {
|
|
link = `${originWithoutPort}${basePath}/devices/cpl.aspx?id=${idLD}`;
|
|
} else {
|
|
console.error("Keine gültige 'idLD' für die Linie gefunden.");
|
|
return;
|
|
}
|
|
} else {
|
|
const lastElementType = localStorage.getItem("lastElementType");
|
|
if (lastElementType === "polyline") {
|
|
const savedLink = localStorage.getItem("polylineLink");
|
|
if (savedLink) {
|
|
link = `${originWithoutPort}${basePath}/devices/${savedLink}`;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (link) {
|
|
if (process.env.NEXT_PUBLIC_DEBUG_LOG === "true") {
|
|
console.log("🟢 Öffne Link:", link);
|
|
}
|
|
window.open(link, "_blank");
|
|
} else {
|
|
console.error("❌ Kein gültiger Link gefunden.");
|
|
}
|
|
}
|