feat: RSL starten in Dev mode 15 Sek. und in prod. 120 Sek.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user