diff --git a/frontend/src/components/PortCard.tsx b/frontend/src/components/PortCard.tsx new file mode 100644 index 0000000..744a68b --- /dev/null +++ b/frontend/src/components/PortCard.tsx @@ -0,0 +1,117 @@ +import React from 'react'; +import { PortStatus } from '../types'; + +interface PortCardProps { + port: PortStatus; + isSelected: boolean; + onSelect: (portIndex: number) => void; + onStartRecording: (portIndex: number) => void; + onStopRecording: (portIndex: number) => void; + onOpenConfig: (portIndex: number) => void; +} + +function formatUptime(seconds: number): string { + const hours = Math.floor(seconds / 3600); + const minutes = Math.floor((seconds % 3600) / 60); + const secs = Math.floor(seconds % 60); + return `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(secs).padStart(2, '0')}`; +} + +function truncateFilePath(path: string, maxLength: number = 50): string { + if (path.length <= maxLength) { + return path; + } + return '...' + path.slice(-(maxLength - 3)); +} + +export function PortCard({ + port, + isSelected, + onSelect, + onStartRecording, + onStopRecording, + onOpenConfig, +}: PortCardProps) { + const recordingBadgeClass = port.is_recording + ? 'bg-red-500 text-white text-xs px-2 py-1 rounded' + : 'bg-gray-500 text-white text-xs px-2 py-1 rounded'; + + const recordingStatus = port.is_recording ? 'RECORDING' : 'IDLE'; + + const cardClass = `bg-gray-800 border border-gray-700 rounded-lg p-4 cursor-pointer hover:border-blue-500 transition-colors ${ + isSelected ? 'border-blue-500 ring-2 ring-blue-500' : '' + }`; + + return ( +