diff --git a/FRONTEND/src/components/CardLine.tsx b/FRONTEND/src/components/CardLine.tsx index bc6ff2a..8a22305 100644 --- a/FRONTEND/src/components/CardLine.tsx +++ b/FRONTEND/src/components/CardLine.tsx @@ -10,6 +10,7 @@ import { notifications } from "@mantine/notifications"; import { listBaudDefault } from "../untils/constanst"; import { IconCaretRight } from "@tabler/icons-react"; import { motion } from "motion/react"; +import CopyIcon from "./CopyIcon"; const CardLine = ({ line, @@ -220,14 +221,17 @@ const CardLine = ({ onClick={(e) => { e.preventDefault(); e.stopPropagation(); + if (!line?.inventory?.pid) return; navigator.clipboard.writeText( - `PID: ${line?.inventory?.pid || ""} | SN: ${ - line?.inventory?.sn || "" - }` + line?.inventory?.pid || "" ); }} className={`${classes.info_line} ${classes.buttonCopy}`} fs={"italic"} + style={{ + opacity: line?.inventory?.pid ? 1 : 0.5, + cursor: line?.inventory?.pid ? "pointer" : "default", + }} > {line?.inventory?.pid || ""} @@ -238,6 +242,14 @@ const CardLine = ({ ) : ( "" )} + {line?.inventory?.pid && ( + + )}
{ e.preventDefault(); e.stopPropagation(); + if (!line?.inventory?.sn) return; navigator.clipboard.writeText( - `PID: ${line?.inventory?.pid || ""} | SN: ${ - line?.inventory?.sn || "" - }` + line?.inventory?.sn || "" ); }} className={`${classes.info_line} ${classes.buttonCopy}`} fs={"italic"} + style={{ + opacity: line?.inventory?.sn ? 1 : 0.5, + cursor: line?.inventory?.sn ? "pointer" : "default", + }} > {line?.inventory?.sn || ""} + {line?.inventory?.sn && ( + + )} + {line?.inventory?.pid && line?.inventory?.sn && ( + + )}
{line?.connecting && ( { + const [copied, setCopied] = useState(false); + + if (!value) return null; + + const handleClick = (e: React.MouseEvent) => { + e.preventDefault(); + e.stopPropagation(); + navigator.clipboard.writeText(value); + setCopied(true); + setTimeout(() => setCopied(false), 1000); + }; + + const tooltipText = copied ? copiedLabel || label.replace("Copy", "Copied") : label; + + return ( + + + {copied ? : } + + + ); +}; + +export default CopyIcon; + + diff --git a/FRONTEND/src/components/DragTabs.tsx b/FRONTEND/src/components/DragTabs.tsx index 2222164..07ab364 100644 --- a/FRONTEND/src/components/DragTabs.tsx +++ b/FRONTEND/src/components/DragTabs.tsx @@ -240,7 +240,7 @@ export default function DraggableTabs({ > - + - {line?.baud || ""} - + PID: - {line?.inventory?.pid || ""} + { + e.preventDefault(); + e.stopPropagation(); + if (!line?.inventory?.pid) return; + navigator.clipboard.writeText(line.inventory?.pid || ""); + }} + > + {line?.inventory?.pid || ""} + {line?.inventory?.vid ? ( {line?.inventory?.vid} @@ -491,12 +506,48 @@ const ModalTerminal = ({ ) : ( "" )} + - + SN: - {line?.inventory?.sn || ""} + { + e.preventDefault(); + e.stopPropagation(); + if (!line?.inventory?.sn) return; + navigator.clipboard.writeText(line.inventory?.sn || ""); + }} + > + {line?.inventory?.sn || ""} + + +