refactor: basePath als Umgebungsvariable eingeführt (NEXT_PUBLIC_BASE_PATH)
- alle festen "/talas5/" Pfade entfernt - dynamischer basePath für API-Links und Station öffnen - README.md und CHANGELOG.md aktualisiert - Version erhöht auf 1.1.188
This commit is contained in:
@@ -17,6 +17,8 @@ const determinePriority = (iconPath, priorityConfig) => {
|
||||
};
|
||||
|
||||
export const createAndSetDevices = async (systemId, setMarkersFunction, GisSystemStatic, priorityConfig) => {
|
||||
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
||||
try {
|
||||
const state = store.getState();
|
||||
const staticDistrictData = selectGisStationsStaticDistrict(state); // { Points: [...] }
|
||||
@@ -100,7 +102,7 @@ export const createAndSetDevices = async (systemId, setMarkersFunction, GisSyste
|
||||
const separator = map.contextmenu.addItem({ separator: true });
|
||||
|
||||
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
|
||||
const baseUrl = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80/talas5/` : `${window.location.origin}/talas5/`;
|
||||
const baseUrl = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80${basePath}/` : `${window.location.origin}${basePath}/`;
|
||||
|
||||
const detailsItem = map.contextmenu.addItem({
|
||||
text: "Station öffnen (Tab)",
|
||||
|
||||
@@ -8,6 +8,8 @@ import * as urls from "../config/urls.js";
|
||||
import * as layers from "../config/layers.js";
|
||||
|
||||
export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItemsToMapContextMenu, hasRights, setPolylineEventsDisabled) => {
|
||||
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
||||
if (!mapRef.current) {
|
||||
console.error("❌ Fehler: mapRef.current ist nicht definiert.");
|
||||
return;
|
||||
@@ -84,7 +86,7 @@ export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItems
|
||||
text: "Station öffnen (Tab)",
|
||||
icon: "/img/screen_new.png",
|
||||
callback: () => {
|
||||
const link = `http://${window.location.hostname}/talas5/devices/${selectedDevice.id}`;
|
||||
const link = `http://${window.location.hostname}${basePath}/devices/${selectedDevice.id}`;
|
||||
if (link) {
|
||||
console.log("🟢 Öffne Link in neuem Tab:", link);
|
||||
window.open(link, "_blank");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// utils/openInNewTab.js
|
||||
|
||||
export function openInNewTab(e, target) {
|
||||
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
||||
const url = new URL(window.location.origin);
|
||||
const originWithoutPort = `${url.protocol}//${url.hostname}`; // Protokoll und Hostname, ohne Port
|
||||
|
||||
@@ -16,13 +18,13 @@ export function openInNewTab(e, target) {
|
||||
}
|
||||
|
||||
if (target instanceof L.Marker && target.options.link) {
|
||||
link = `${originWithoutPort}/talas5/devices/${target.options.link}`;
|
||||
link = `${originWithoutPort}${basePath}/devices/${target.options.link}`;
|
||||
console.log("Link des Markers", link);
|
||||
} else if (target instanceof L.Polyline) {
|
||||
const idLD = target.options.idLD;
|
||||
console.log("idLD der Linie", idLD);
|
||||
if (idLD) {
|
||||
link = `${originWithoutPort}/talas5/devices/cpl.aspx?id=${idLD}`;
|
||||
link = `${originWithoutPort}${basePath}/devices/cpl.aspx?id=${idLD}`;
|
||||
} else {
|
||||
console.error("Keine gültige 'idLD' für die Linie gefunden.");
|
||||
return;
|
||||
|
||||
@@ -14,6 +14,8 @@ import { updatePolylineCoordinatesThunk } from "../../redux/thunks/database/poly
|
||||
|
||||
//--------------------------------------------
|
||||
export const setupPolylines = (map, linePositions, lineColors, tooltipContents, setNewCoords, tempMarker, currentZoom, currentCenter, polylineVisible) => {
|
||||
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
||||
if (!polylineVisible) {
|
||||
//console.warn("Polylines deaktiviert - keine Zeichnung");
|
||||
return { markers: [], polylines: [] };
|
||||
@@ -150,7 +152,7 @@ export const setupPolylines = (map, linePositions, lineColors, tooltipContents,
|
||||
callback: (e) => {
|
||||
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
|
||||
|
||||
const baseUrl = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80/talas5/` : `${window.location.origin}/talas5/`;
|
||||
const baseUrl = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80${basePath}/` : `${window.location.origin}${basePath}/`;
|
||||
|
||||
const link = `${baseUrl}cpl.aspx?ver=35&kue=24&id=${lineData.idLD}`;
|
||||
|
||||
@@ -214,7 +216,7 @@ export const setupPolylines = (map, linePositions, lineColors, tooltipContents,
|
||||
callback: (e) => {
|
||||
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
|
||||
|
||||
const baseUrl = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80/talas5/` : `${window.location.origin}/talas5/`;
|
||||
const baseUrl = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80${basePath}/` : `${window.location.origin}${basePath}/`;
|
||||
|
||||
const link = `${baseUrl}cpl.aspx?ver=35&kue=24&id=${lineData.idLD}`;
|
||||
|
||||
@@ -270,7 +272,7 @@ export const setupPolylines = (map, linePositions, lineColors, tooltipContents,
|
||||
polyline.setStyle({ weight: 14 });
|
||||
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
|
||||
|
||||
const baseUrl = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80/talas5/` : `${window.location.origin}/talas5/`;
|
||||
const baseUrl = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80${basePath}/` : `${window.location.origin}${basePath}/`;
|
||||
|
||||
const link = `${baseUrl}cpl.aspx?ver=35&kue=24&id=${lineData.idLD}`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user