From 0e81f362006f892f05fff6191dc0e34e4ebfbc29 Mon Sep 17 00:00:00 2001 From: Denis Shatskiy Date: Fri, 8 Aug 2025 14:55:23 +0700 Subject: [PATCH] feat: Enhance GraphView and ServerManager components with tunnel type styles and hover effects for improved visualization and user interaction --- frontend/src/GraphView.jsx | 77 ++++++++++++++++++++++++---------- frontend/src/ServerManager.jsx | 11 ++++- 2 files changed, 64 insertions(+), 24 deletions(-) diff --git a/frontend/src/GraphView.jsx b/frontend/src/GraphView.jsx index ac3e8fb..a315bd8 100644 --- a/frontend/src/GraphView.jsx +++ b/frontend/src/GraphView.jsx @@ -4,6 +4,7 @@ function GraphView({ servers, connections }) { const [nodePositions, setNodePositions] = useState({}); const [draggedNode, setDraggedNode] = useState(null); const [dragOffset, setDragOffset] = useState({ x: 0, y: 0 }); + const [hoveredLinkId, setHoveredLinkId] = useState(null); const svgRef = useRef(null); if (servers.length === 0) { @@ -98,6 +99,17 @@ function GraphView({ servers, connections }) { return colors[country] || '#6b7280'; }; + // Цвета/стили для разных типов туннелей + const getTunnelStyle = (tunnelType) => { + const map = { + GRE: { color: '#206bc4', dash: '0', width: 3 }, + IPSec: { color: '#f59f00', dash: '6,4', width: 3 }, + WireGuard: { color: '#2fb344', dash: '0', width: 4 }, + OpenVPN: { color: '#be4bdb', dash: '3,3', width: 3 }, + }; + return map[tunnelType] || { color: '#667382', dash: '5,5', width: 2 }; + }; + return (
+ + {/* Определение стрелок под цвет канала */} + {Array.from(new Set(connections.map(c => c.tunnelType))).map((t) => { + const style = getTunnelStyle(t); + return ( + + + + ); + })} + {/* Свечение для выделения */} + + + + + + + + {/* Связи */} {connections.map((connection, index) => { const fromServer = servers.find(s => s.ip === connection.from); @@ -119,19 +157,27 @@ function GraphView({ servers, connections }) { const fromPos = getNodePosition(connection.from); const toPos = getNodePosition(connection.to); + const style = getTunnelStyle(connection.tunnelType); + const id = `${connection.from}-${connection.to}-${index}`; + const isHovered = hoveredLinkId === id; return ( - + setHoveredLinkId(id)} + onMouseLeave={() => setHoveredLinkId(null)} + > {/* Линия связи */} {/* Подпись связи */} @@ -141,8 +187,8 @@ function GraphView({ servers, connections }) { width="80" height="30" rx="15" - fill="white" - stroke="#e5e7eb" + fill="#ffffff" + stroke={style.color} strokeWidth="1" /> - - - - + {/* Доп. определения добавлены выше */}
); diff --git a/frontend/src/ServerManager.jsx b/frontend/src/ServerManager.jsx index d8338c5..92efb80 100644 --- a/frontend/src/ServerManager.jsx +++ b/frontend/src/ServerManager.jsx @@ -700,11 +700,20 @@ function ServerManager() { />
-
+

Граф связей между серверами

+
Поддержка: GRE, IPSec, WireGuard, OpenVPN
+
+
+
GRE
+
IPSec
+
WireGuard
+
OpenVPN
+
+