feat: DetailModal um Min/Max/Durchschnitt ergänzt

- Chart zeigt jetzt zusätzlich zu Messwert auch Minimal-, Maximal- und Durchschnittswerte an
- Datenstruktur an Redux angepasst (i, a, g)
- Darstellung entspricht jetzt LoopMeasurementChart
This commit is contained in:
Ismail Ali
2025-07-10 19:11:38 +02:00
parent 3a1d85dbe2
commit 420989dc9f
13 changed files with 77 additions and 470 deletions

View File

@@ -15,51 +15,20 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
return res.status(400).json({ error: "Missing or invalid updates array" });
}
if (mode === "json") {
const filePath = path.join(
process.cwd(),
"mocks/api/SERVICE/analogInputsMockData.json"
);
const content = fs.readFileSync(filePath, "utf-8");
const data = JSON.parse(content);
const filePath = path.join(
process.cwd(),
"mocks/device-cgi-simulator/SERVICE/analogInputsMockData.json"
);
const content = fs.readFileSync(filePath, "utf-8");
const data = JSON.parse(content);
for (const update of updates) {
const { key, index, value } = update;
if (Array.isArray(data[key]) && index < data[key].length) {
data[key][index] = value;
}
for (const update of updates) {
const { key, index, value } = update;
if (Array.isArray(data[key]) && index < data[key].length) {
data[key][index] = value;
}
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), "utf-8");
return res.status(200).json({ success: true });
}
if (mode === "jsSimulatedProd") {
const filePath = path.join(
process.cwd(),
"mocks/device-cgi-simulator/SERVICE/analogInputsMockData.js"
);
let content = fs.readFileSync(filePath, "utf-8");
for (const update of updates) {
const { key, index, value } = update;
const regex = new RegExp(`var\\s+${key}\\s*=\\s*\\[([\\s\\S]*?)\\];`);
const match = content.match(regex);
if (!match) continue;
const items = match[1].split(",").map((s) => s.trim());
if (index >= items.length) continue;
const isString = typeof value === "string";
items[index] = isString ? `"${value}"` : `${value}`;
const updatedLine = `var ${key} = [${items.join(", ")}];`;
content = content.replace(regex, updatedLine);
}
fs.writeFileSync(filePath, content, "utf-8");
return res.status(200).json({ success: true });
}
return res.status(400).json({ error: "Unsupported mode" });
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), "utf-8");
return res.status(200).json({ success: true });
}