TDR Chart von Dropdown Menü Auwahl zeichnen
This commit is contained in:
@@ -5,18 +5,18 @@ export const fetchAllTDMDataFromServer = async (): Promise<any[]> => {
|
||||
|
||||
const isDev = window.location.hostname === "localhost";
|
||||
|
||||
const baseUrl = isDev
|
||||
? "/CPLmockData/TDM" // z. B. /public/CPLmockData/TDM/slot0.json usw.
|
||||
: `${window.location.origin}/CPL?Service/empty.acp&TDM`;
|
||||
const slotRequests = Array.from({ length: 32 }, (_, i) => {
|
||||
const url = isDev
|
||||
? `/CPLmockData/TDM/slot${i}.json` // ✅ korrekt für DEV (Dateien im public-Ordner)
|
||||
: `${window.location.origin}/CPL?Service/empty.acp&TDM=${i}`; // ✅ korrekt für PROD
|
||||
|
||||
const slotRequests = Array.from({ length: 32 }, (_, i) =>
|
||||
fetch(`${baseUrl}=${i}`)
|
||||
return fetch(url)
|
||||
.then((res) => (res.ok ? res.json() : null))
|
||||
.catch((err) => {
|
||||
console.error(`❌ Fehler bei Slot ${i}:`, err);
|
||||
return null;
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
return await Promise.all(slotRequests);
|
||||
};
|
||||
|
||||
22
services/fetchTDRChartDataById.ts
Normal file
22
services/fetchTDRChartDataById.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
// /services/fetchTDRChartDataById.ts
|
||||
|
||||
export const fetchTDRChartDataById = async (
|
||||
id: number
|
||||
): Promise<any[] | null> => {
|
||||
const isDev = process.env.NODE_ENV === "development";
|
||||
|
||||
const url = isDev
|
||||
? `http://localhost:3000/CPLmockData/Last100TDR/kue_01/id/${id}.json`
|
||||
: `${window.location.origin}/CPL?Service/empty.acp&TDR=${id}`;
|
||||
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
if (!response.ok)
|
||||
throw new Error(`Fehler beim Laden der TDR-Daten für ID ${id}`);
|
||||
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error("❌ Fehler in fetchTDRChartDataById:", error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user