75 lines
3.9 KiB
JavaScript
75 lines
3.9 KiB
JavaScript
// /config/config.js
|
|
import * as urls from "../config/urls.js";
|
|
// Definieren der grundlegenden Umgebungseinstellungen und Konfigurationen der Karte
|
|
const standardSideMenu = true; // Einstellung, ob ein standardmäßiges Seitenmenü verwendet wird
|
|
const fullSideMenu = false; // Einstellung, ob ein vollständiges Seitenmenü verwendet wird
|
|
|
|
const serverURL = process.env.NEXT_PUBLIC_SERVER_URL;
|
|
if (!serverURL) {
|
|
throw new Error("Die Umgebungsvariable NEXT_PUBLIC_SERVER_URL ist nicht gesetzt!");
|
|
}
|
|
console.log("%c 1- serverURL in config:", "color: #006400;", serverURL);
|
|
|
|
// Initialisieren von Variablen, die später im Browserkontext gesetzt werden
|
|
let windowHeight, url_string, url, idMap, idUser;
|
|
//Online Daten
|
|
let mapGisStationsStaticDistrictUrl, mapGisStationsStatusDistrictUrl, mapGisStationsMeasurementsUrl, mapGisSystemStaticUrl, mapDataIconUrl, webserviceGisLinesStatusUrl;
|
|
|
|
// Prüfen, ob das Code im Browser ausgeführt wird
|
|
if (typeof window !== "undefined") {
|
|
// Diese Variablen werden nur im Browser-Kontext initialisiert
|
|
windowHeight = window.innerHeight; // Die Höhe des Browserfensters
|
|
url_string = window.location.href; // Die vollständige URL als String
|
|
url = new URL(url_string); // Die URL als URL-Objekt, um Teile der URL einfacher zu handhaben
|
|
console.log("%c 2- URL in config:", "color: #006400; font-size: 16px; background-color: #f0f0f0;", url);
|
|
|
|
console.log("%c 3- URL origin in config:", "color: #006400;", url.origin); //http://localhost:3000
|
|
idMap = url.searchParams.get("m"); // Ein Parameter aus der URL, Standardwert ist '10'
|
|
idUser = url.searchParams.get("u"); // Ein weiterer Parameter aus der URL, Standardwert ist '484 admin zu testen von Stationen ausblenden und einblenden in der Card'
|
|
|
|
console.log(`4- Parameter 'idMap' : ${idMap}`);
|
|
console.log(`5- Parameter 'idUser': ${idUser}`);
|
|
|
|
// Konstruktion von URLs, die auf spezifische Ressourcen auf dem Server zeigen
|
|
//http://localhost:3000/?m=10&u=485
|
|
|
|
//-----------------Von WebService------------------------------------------------
|
|
mapGisStationsStaticDistrictUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsStaticDistrict?idMap=${idMap}&idUser=${idUser}`; //idMap: 10, idUser: 484
|
|
mapGisStationsStatusDistrictUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`;
|
|
mapGisStationsMeasurementsUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisStationsMeasurements?idMap=${idMap}`;
|
|
mapGisSystemStaticUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${idMap}&idUser=${idUser}`;
|
|
mapDataIconUrl = `${serverURL}/talas5/ClientData/WebserviceMap.asmx/GetIconsStatic`;
|
|
|
|
//webserviceGisLinesStatusUrl = `http://10.10.0.13/talas5/ClientData/WebServiceMap.asmx/GisLinesStatus?idMap=${idMap}`;
|
|
|
|
// webserviceGisLinesStatusUrl = `http://localhost:3000/api/linesColorApi`;
|
|
//webserviceGisLinesStatusUrl = `http://192.168.10.14/talas5/ClientData/WebServiceMap.asmx/GisLinesStatus?idMap=${idMap}`;
|
|
webserviceGisLinesStatusUrl = `${serverURL}/talas5/ClientData/WebServiceMap.asmx/GisLinesStatus?idMap=${idMap}`;
|
|
|
|
//http://10.10.0.13/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=12&idUser=484
|
|
}
|
|
|
|
// Export der definierten Variablen und URLs, damit sie in anderen Teilen der Anwendung verwendet werden können
|
|
export {
|
|
standardSideMenu,
|
|
fullSideMenu,
|
|
serverURL,
|
|
windowHeight,
|
|
url_string,
|
|
url,
|
|
idMap,
|
|
idUser,
|
|
mapGisStationsStaticDistrictUrl,
|
|
mapGisStationsStatusDistrictUrl,
|
|
mapGisStationsMeasurementsUrl,
|
|
mapGisSystemStaticUrl,
|
|
mapDataIconUrl,
|
|
webserviceGisLinesStatusUrl,
|
|
};
|
|
|
|
/*
|
|
Access to fetch at 'http://localhost:3000/api/linesColorApi' from origin 'http://10.10.0.13:3000' has been blocked by CORS policy:
|
|
No 'Access-Control-Allow-Origin' header is present on the requested resource.
|
|
If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
|
|
*/
|