feat: Umgebungsspezifisches Laden von Datenquellen implementiert

- Alle fetch-Services (TDM, TDR, analoge/digitale Eingänge/Ausgänge, SystemSettings usw.) angepasst,
  um `NEXT_PUBLIC_NODE_ENV` zu verwenden.
- Entwicklungsumgebung lädt Daten aus /CPLmockData/...
- Produktionsumgebung verwendet echte Endpunkte mit /CPL?/CPL/...
- .env.production und .env.development korrekt berücksichtigt
- loadWindowVariables, WindowVariablesInitializer und verwandte Dateien bereinigt
- Mockdaten erscheinen nicht mehr versehentlich in Produktionsumgebung
This commit is contained in:
ISA
2025-03-27 11:03:23 +01:00
parent 0bec3fb148
commit c55f0e7fe5
21 changed files with 170 additions and 104 deletions

View File

@@ -1,16 +1,12 @@
// /services/fetchAllTDRChartData.ts
const getTDRBasePath = () => {
if (typeof window !== "undefined") {
return window.location.hostname === "localhost"
? "/CPLmockData/LastTDR/jsonDatei"
: "/CPL?/CPL/LastTDR";
}
return "";
};
export const fetchAllTDRChartDataFromServer = async (): Promise<any[]> => {
const basePath = getTDRBasePath();
const isDev = process.env.NEXT_PUBLIC_NODE_ENV === "development";
const basePath = isDev
? "/CPLmockData/LastTDR/jsonDatei"
: "/CPL?/CPL/LastTDR";
const fileNames = Array.from({ length: 32 }, (_, i) => `slot${i}.json`);
const fetchPromises = fileNames.map(async (fileName) => {
@@ -20,7 +16,7 @@ export const fetchAllTDRChartDataFromServer = async (): Promise<any[]> => {
throw new Error(`Fehler bei ${fileName}: ${response.statusText}`);
return await response.json();
} catch (error) {
console.error(`Fehler beim Laden von ${fileName}:`, error);
console.error(`Fehler beim Laden von ${fileName}:`, error);
return null;
}
});