diff --git a/config/webVersion.ts b/config/webVersion.ts index 69946d4..5c01b73 100644 --- a/config/webVersion.ts +++ b/config/webVersion.ts @@ -6,5 +6,5 @@ 2: Patch oder Hotfix (Bugfixes oder kleine Änderungen). */ -const webVersion = "1.6.303"; +const webVersion = "1.6.304"; export default webVersion; diff --git a/pages/api/cpl/fetchAnalogInputsHistory.ts b/pages/api/cpl/fetchAnalogInputsHistory.ts new file mode 100644 index 0000000..92b80ab --- /dev/null +++ b/pages/api/cpl/fetchAnalogInputsHistory.ts @@ -0,0 +1,38 @@ +// /pages/api/cpl/fetchAnalogInputsHistory.ts + +import path from "path"; +import fs from "fs/promises"; +import type { NextApiRequest, NextApiResponse } from "next"; + +export default async function handler( + req: NextApiRequest, + res: NextApiResponse +) { + try { + const result: Record = {}; + + for (let i = 1; i <= 8; i++) { + const filePath = path.join( + process.cwd(), + "apiMockData", + "analogInputsHistoryData", + `analogInput${i}.json` + ); + + try { + const fileContent = await fs.readFile(filePath, "utf-8"); + result[99 + i] = JSON.parse(fileContent); // z. B. 100 für AE1, 101 für AE2 + } catch (err) { + console.warn( + `Mock-Datei für analogInput${i} nicht gefunden oder fehlerhaft.` + ); + result[99 + i] = []; + } + } + + res.status(200).json(result); + } catch (error) { + console.error("Fehler beim Laden der analogen Eingänge (Mock):", error); + res.status(500).json({ error: "Fehler beim Laden der Mock-Daten." }); + } +} diff --git a/services/fetchAnalogInputHistory.ts b/services/fetchAnalogInputsHistoryService.ts similarity index 90% rename from services/fetchAnalogInputHistory.ts rename to services/fetchAnalogInputsHistoryService.ts index 4667e13..fcb5770 100644 --- a/services/fetchAnalogInputHistory.ts +++ b/services/fetchAnalogInputsHistoryService.ts @@ -1,6 +1,6 @@ -// services/fetchAnalogInputHistory.ts +// services/fetchAnalogInputHistoryService.ts -export async function fetchAnalogInputHistory(): Promise< +export async function fetchAnalogInputHistoryService(): Promise< Record > { const baseUrl = `${window.location.origin}/CPL?Service/empty.acp`;