Files
CPLv4.0/components/main/analogInputs/AnalogInputsView.tsx
ISA bdbdd27963 feat: Add cursor wait state to AnalogInputsTable rows during data loading
- Applied `cursor-wait` style to table rows (`<tr>`) in AnalogInputsTable when loading is true.
- Ensured consistent cursor behavior across the entire table and rows
2025-07-23 13:40:43 +02:00

64 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
// components/main/analogInputs/AnalogInputsView.tsx
import React, { useState, useEffect } from "react";
import AnalogInputsTable from "@/components/main/analogInputs/AnalogInputsTable";
import AnalogInputsChart from "@/components/main/analogInputs/AnalogInputsChart";
import AnalogInputsSettingsModal from "@/components/main/analogInputs/AnalogInputsSettingsModal";
import { getAnalogInputsThunk } from "@/redux/thunks/getAnalogInputsThunk";
import { useAppDispatch } from "@/redux/store";
import { useSelector } from "react-redux";
import { RootState } from "@/redux/store";
function AnalogInputsView() {
const [loading, setLoading] = useState(false); // Add loading state
const selectedInput = useSelector(
(state: RootState) => state.selectedAnalogInput
);
const selectedId = useSelector(
(state: RootState) => state.analogInputsHistory.selectedId
);
const dispatch = useAppDispatch();
useEffect(() => {
if (typeof window !== "undefined") {
dispatch(getAnalogInputsThunk());
const interval = setInterval(() => {
dispatch(getAnalogInputsThunk());
}, 10000);
return () => clearInterval(interval);
}
}, [dispatch]);
return (
<div
className={`flex flex-col gap-3 p-4 h-[calc(100vh-13vh-8vh)] ${
loading ? "cursor-wait" : ""
}`}
>
<div className="container mx-auto">
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div className="bg-white rounded-lg p-4">
<h2 className="text-xl font-semibold mb-4 text-gray-700">
Messwerteingänge
</h2>
<AnalogInputsTable loading={loading} />
</div>
<div className="bg-white shadow-lg rounded-lg p-4 border border-gray-200">
<h2 className="text-xl font-semibold mb-4 text-gray-700">
Messkurve Messwerteingang {selectedId ?? ""}
</h2>
<AnalogInputsChart setLoading={setLoading} loading={loading} />
</div>
</div>
</div>
{selectedInput !== null && <AnalogInputsSettingsModal />}
</div>
);
}
export default AnalogInputsView;