import React from 'react'; import { PortForwardingType } from '../domain/models'; import { AppLogo } from './AppLogo'; // SVG Icon components from public folder const CloudIcon: React.FC<{ className?: string }> = ({ className }) => ( cloud ); const FirewallIcon: React.FC<{ className?: string }> = ({ className }) => ( firewall ); const ServerIcon: React.FC<{ className?: string }> = ({ className }) => ( server ); // Animated diagram component for port forwarding visualization interface TrafficDiagramProps { type: PortForwardingType; isAnimating?: boolean; /** Which role to highlight: 'app' | 'ssh-server' | 'target' | undefined (all visible) */ highlightRole?: 'app' | 'ssh-server' | 'target'; } // AppLogo is now imported from ./AppLogo to share accent color theming // Animated line component const AnimatedLine: React.FC<{ x1: number; y1: number; x2: number; y2: number; isAnimating: boolean; reverse?: boolean; isBlocked?: boolean; }> = ({ x1, y1, x2, y2, isAnimating, reverse = false, isBlocked = false }) => { if (isBlocked) { return ; } return ( <> {isAnimating && ( )} ); }; export const TrafficDiagram: React.FC = ({ type, isAnimating = true, highlightRole }) => { // Helper to determine opacity based on highlight role const getOpacity = (role: 'app' | 'ssh-server' | 'target' | 'firewall') => { if (!highlightRole) return 'opacity-100'; if (role === 'firewall') return 'opacity-30'; // Firewall always dimmed when highlighting return role === highlightRole ? 'opacity-100' : 'opacity-30'; }; return (
{/* ========== LOCAL FORWARDING ========== */} {type === 'local' && (
{/* App Logo - left (same line as firewall) */}
{/* Firewall - center top (same line as app) */}
{/* Target servers - right (in red border box) */}
{/* SSH Server - bottom center */}
{/* SVG Lines */} {/* App to Firewall - blocked red line (with gap) */} {/* App to SSH Server - blue animated (with gap) */} {/* SSH Server to targets - blue animated (with gap) */}
)} {/* ========== REMOTE FORWARDING ========== */} {type === 'remote' && (
{/* Left Server - the remote SSH server where port will be opened */}
{/* Firewall - center top */}
{/* Right Server - the destination where traffic will be forwarded */}
{/* App Logo - bottom center (Netcatty client) */}
{/* SVG Lines */} {/* Left server to Firewall - blocked (with gap) */} {/* Left server to App - blue animated (with gap) */} {/* Right server to App - blue animated (with gap) */}
)} {/* ========== DYNAMIC FORWARDING ========== */} {type === 'dynamic' && (
{/* App Logo - left (same line as firewall) */}
{/* Firewall - center top (same line as app) */}
{/* Cloud targets - right (in red border box) */}
{/* SSH Server - bottom center */}
{/* Cloud target - bottom right */}
{/* SVG Lines */} {/* App to Firewall - blocked (with gap) */} {/* App to SSH Server - blue animated (with gap) */} {/* SSH Server to clouds - blue animated (with gap) */}
)}
); };