import React, { useState, useEffect } from 'react'; import { useLoaderData, useNavigate, useOutletContext, useParams } from "@remix-run/react"; import { useSocket } from "../context"; import { L33tADSPLC } from "@l33t-lib"; import { loaderPLCById } from '../loaders'; /* Importazioni originali commentate import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faSearch, faChevronRight, faChevronDown, faLink, faUnlink, faFilter } from '@fortawesome/free-solid-svg-icons'; import { Tree, NodeRendererProps } from 'react-arborist'; import ValueOscilloscope, { DataPoint } from '../components/ValueOscilloscope'; */ export const loader = loaderPLCById; export default function PlcDetail() { const navigate = useNavigate(); const { id } = useParams<{ id: string }>(); const [selectedPLC] = useState(useLoaderData()); const socket = useSocket(); // Stati originali commentati /* const [search, setSearch] = useState(''); const [treeData, setTreeData] = useState([]); const [selectedNode, setSelectedNode] = useState(null); const [varValue, setVarValue] = useState(); const [showOnlyBound, setShowOnlyBound] = useState(false); const [symbols, setSymbols] = useState(null); */ const [boundVariables, setBoundVariables] = useState( selectedPLC ? selectedPLC.boundVariables : [] ); // Navigazione con ESC useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { if (event.key === "Escape") navigate(".."); }; document.addEventListener("keydown", handleKeyDown); return () => { document.removeEventListener("keydown", handleKeyDown); }; }, [navigate]); // Handler per aggiornamenti const handleChange = (field: string, value: string) => { const updatedPLC = { ...selectedPLC, [field]: value }; if (socket) { socket.emit("l33t_plc_update", id, updatedPLC); } }; if (!id) return
Error: No PLC ID provided
; if (!selectedPLC) return
No PLC selected
; return (

PLC Details

{/* ID Field */}
handleChange('id', e.target.value)} className="w-full bg-gray-700 rounded px-3 py-2" />
{/* IP Field */}
handleChange('ip', e.target.value)} className="w-full bg-gray-700 rounded px-3 py-2" />
{/* Bound Variables List */} {boundVariables && boundVariables.length > 0 ? (

Bound Variables

    {boundVariables.map((variable, index) => (
  • {variable}
  • ))}
) : (

No bound variables

)}
); } /* Componenti originali commentati interface TreeNode { id: string; name: string; children?: TreeNode[]; type: 'program' | 'variable'; path: string; isBound?: boolean; } const Node: React.FC & { onSelect: (node: TreeNode) => void; onToggleBind: (node: TreeNode) => void; }> = ... const SymbolDisplay = ({ symbol }: { symbol: any }) => ... */