feat: local-cpl-sim system

This commit is contained in:
ISA
2025-09-04 12:26:06 +02:00
parent 02a0ce5891
commit 0286670b81
6 changed files with 36 additions and 9 deletions

View File

@@ -6,6 +6,6 @@ NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false
NEXT_PUBLIC_EXPORT_STATIC=false NEXT_PUBLIC_EXPORT_STATIC=false
NEXT_PUBLIC_USE_CGI=false NEXT_PUBLIC_USE_CGI=false
# App-Versionsnummer # App-Versionsnummer
NEXT_PUBLIC_APP_VERSION=1.6.836 NEXT_PUBLIC_APP_VERSION=1.6.837
NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter) NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter)

View File

@@ -5,5 +5,5 @@ NEXT_PUBLIC_CPL_API_PATH=/CPL
NEXT_PUBLIC_EXPORT_STATIC=true NEXT_PUBLIC_EXPORT_STATIC=true
NEXT_PUBLIC_USE_CGI=true NEXT_PUBLIC_USE_CGI=true
# App-Versionsnummer # App-Versionsnummer
NEXT_PUBLIC_APP_VERSION=1.6.836 NEXT_PUBLIC_APP_VERSION=1.6.837
NEXT_PUBLIC_CPL_MODE=production NEXT_PUBLIC_CPL_MODE=production

View File

@@ -1,3 +1,8 @@
## [1.6.837] 2025-09-04
- feat: local-cpl-sim meldungen/Berichte
---
## [1.6.836] 2025-09-04 ## [1.6.836] 2025-09-04
- feat: local-cpl-sim.mjs kabelueberwachung - feat: local-cpl-sim.mjs kabelueberwachung

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "cpl-v4", "name": "cpl-v4",
"version": "1.6.836", "version": "1.6.837",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "cpl-v4", "name": "cpl-v4",
"version": "1.6.836", "version": "1.6.837",
"dependencies": { "dependencies": {
"@fontsource/roboto": "^5.1.0", "@fontsource/roboto": "^5.1.0",
"@headlessui/react": "^2.2.4", "@headlessui/react": "^2.2.4",

View File

@@ -1,6 +1,6 @@
{ {
"name": "cpl-v4", "name": "cpl-v4",
"version": "1.6.836", "version": "1.6.837",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev -p 3000", "dev": "next dev -p 3000",

View File

@@ -137,14 +137,21 @@ function tryServeSpecialMocks(res, relPath) {
} }
} }
if (rp === "CPL/SERVICE/systemVoltTemp.js") { if (rp === "CPL/SERVICE/systemVoltTemp.js") {
const mockPath = path.join( const base = path.join(
process.cwd(), process.cwd(),
"mocks", "mocks",
"device-cgi-simulator", "device-cgi-simulator",
"SERVICE", "SERVICE"
"systemVoltTempMockData.js"
); );
if (exists(mockPath)) return streamRaw(res, mockPath); const preferred = path.join(base, "systemVoltTemp.js");
if (exists(preferred)) return streamRaw(res, preferred);
const mockPath = path.join(base, "systemVoltTempMockData.js");
if (exists(mockPath)) {
// Transform variable name to expected win_systemVoltTemp when streaming
return streamTransform(res, mockPath, (txt) =>
txt.replace(/win_systemVoltTempMockData/g, "win_systemVoltTemp")
);
}
} }
if (rp === "CPL/SERVICE/last20Messages.js") { if (rp === "CPL/SERVICE/last20Messages.js") {
const mockPath = path.join( const mockPath = path.join(
@@ -238,6 +245,21 @@ function streamRaw(res, filePath) {
return true; return true;
} }
function streamTransform(res, filePath, transformFn) {
const ext = path.extname(filePath).toLowerCase();
const type = contentTypeByExt(ext);
const headers = { "Content-Type": type, "Cache-Control": "no-cache" };
res.writeHead(200, headers);
try {
const txt = fs.readFileSync(filePath, "utf8");
const out = transformFn(txt);
res.end(out);
} catch {
res.end();
}
return true;
}
function resolvePlaceholders(filePath, content) { function resolvePlaceholders(filePath, content) {
const rel = getRelFromRoot(filePath); const rel = getRelFromRoot(filePath);
const serviceSystem = const serviceSystem =