feat: RSL starten in Dev mode 15 Sek. und in prod. 120 Sek.
This commit is contained in:
@@ -6,6 +6,6 @@ NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false
|
||||
NEXT_PUBLIC_EXPORT_STATIC=false
|
||||
NEXT_PUBLIC_USE_CGI=false
|
||||
# App-Versionsnummer
|
||||
NEXT_PUBLIC_APP_VERSION=1.6.691
|
||||
NEXT_PUBLIC_APP_VERSION=1.6.692
|
||||
NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter)
|
||||
|
||||
|
||||
@@ -5,5 +5,5 @@ NEXT_PUBLIC_CPL_API_PATH=/CPL
|
||||
NEXT_PUBLIC_EXPORT_STATIC=true
|
||||
NEXT_PUBLIC_USE_CGI=true
|
||||
# App-Versionsnummer
|
||||
NEXT_PUBLIC_APP_VERSION=1.6.691
|
||||
NEXT_PUBLIC_APP_VERSION=1.6.692
|
||||
NEXT_PUBLIC_CPL_MODE=production
|
||||
@@ -1,3 +1,8 @@
|
||||
## [1.6.692] – 2025-08-12
|
||||
|
||||
- PlayWright Test
|
||||
|
||||
---
|
||||
## [1.6.691] – 2025-08-12
|
||||
|
||||
- RSL-Progress (120s Overlay mit Balken + Blockierung) ist implementiert: Button zeigt RSL läuft…, Daten laden ist gesperrt, Overlay mit Restsekunden und Fortschritt. Countdown endet automatisch.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
// /components/main/kabelueberwachung/kue705FO/Charts/LoopMeasurementChart/LoopChartActionBar.tsx
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { RSL_DURATION_SECONDS, NODE_ENV } from "@/utils/env";
|
||||
import DateRangePicker from "@/components/common/DateRangePicker";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { RootState } from "@/redux/store";
|
||||
@@ -93,8 +94,8 @@ export const useLoopChartLoader = () => {
|
||||
//-----------------------------------------------------------------------------------LoopChartActionBar
|
||||
const LoopChartActionBar: React.FC = () => {
|
||||
const dispatch = useDispatch();
|
||||
// RSL Progress State (120s künstlicher Countdown)
|
||||
const TOTAL_DURATION = 120; // Sekunden
|
||||
// RSL Progress State – Dauer konfigurierbar über NEXT_PUBLIC_RSL_DURATION_SECONDS
|
||||
const TOTAL_DURATION = RSL_DURATION_SECONDS;
|
||||
const [rslRunning, setRslRunning] = useState(false);
|
||||
const [rslProgress, setRslProgress] = useState(0);
|
||||
|
||||
@@ -115,7 +116,7 @@ const LoopChartActionBar: React.FC = () => {
|
||||
}
|
||||
}, 1000);
|
||||
return () => clearInterval(interval);
|
||||
}, [rslRunning]);
|
||||
}, [rslRunning, TOTAL_DURATION]);
|
||||
|
||||
const startRslProgress = () => {
|
||||
setRslRunning(true);
|
||||
@@ -168,14 +169,17 @@ const LoopChartActionBar: React.FC = () => {
|
||||
console.log("🚀 Starte RSL Messung für Slot:", slotNumber);
|
||||
console.log("📡 CGI URL:", cgiUrl);
|
||||
|
||||
const response = await fetch(cgiUrl);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`CGI-Fehler: ${response.status}`);
|
||||
if (NODE_ENV === "development") {
|
||||
// DEV: externes Gerät mocken – sofort Erfolg simulieren
|
||||
await new Promise((r) => setTimeout(r, 200));
|
||||
console.log("✅ [DEV] RSL Mock-Start ok für Slot", slotNumber);
|
||||
startRslProgress();
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await fetch(cgiUrl);
|
||||
if (!response.ok) throw new Error(`CGI-Fehler: ${response.status}`);
|
||||
console.log("✅ RSL Messung gestartet für Slot", slotNumber);
|
||||
// Start der lokalen Progress-Anzeige (ca. 120s)
|
||||
startRslProgress();
|
||||
} catch (err) {
|
||||
console.error("❌ Fehler beim Starten der RSL Messung:", err);
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "cpl-v4",
|
||||
"version": "1.6.691",
|
||||
"version": "1.6.692",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "cpl-v4",
|
||||
"version": "1.6.691",
|
||||
"version": "1.6.692",
|
||||
"dependencies": {
|
||||
"@fontsource/roboto": "^5.1.0",
|
||||
"@headlessui/react": "^2.2.4",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cpl-v4",
|
||||
"version": "1.6.691",
|
||||
"version": "1.6.692",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
17
utils/env.ts
Normal file
17
utils/env.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
// Centralized, typed access to public environment variables
|
||||
// NEXT_PUBLIC_* variables are exposed to the browser by Next.js at build time.
|
||||
|
||||
export const NODE_ENV = process.env.NODE_ENV;
|
||||
|
||||
const toNumber = (val: string | undefined): number | undefined => {
|
||||
if (val === undefined) return undefined;
|
||||
const n = Number(val);
|
||||
return Number.isFinite(n) ? n : undefined;
|
||||
};
|
||||
|
||||
// RSL measurement duration in seconds. Default: 15s in dev, 120s otherwise.
|
||||
export const RSL_DURATION_SECONDS: number = (() => {
|
||||
const fromEnv = toNumber(process.env.NEXT_PUBLIC_RSL_DURATION_SECONDS);
|
||||
if (fromEnv !== undefined) return fromEnv;
|
||||
return NODE_ENV === "development" ? 15 : 120;
|
||||
})();
|
||||
Reference in New Issue
Block a user