From 8278017459da16cdc83b9683a0526f6cef002222 Mon Sep 17 00:00:00 2001 From: shats Date: Tue, 17 Feb 2026 13:25:50 +0700 Subject: [PATCH] feat(TrafficDashboard): enhance traffic visualization with donut chart and updated color palette --- frontend/src/TrafficDashboard.jsx | 116 +++++++++++++++++++----------- 1 file changed, 73 insertions(+), 43 deletions(-) diff --git a/frontend/src/TrafficDashboard.jsx b/frontend/src/TrafficDashboard.jsx index 9cf62e9..4c393c6 100644 --- a/frontend/src/TrafficDashboard.jsx +++ b/frontend/src/TrafficDashboard.jsx @@ -11,15 +11,15 @@ import { Pie, Cell, ResponsiveContainer, - Legend, Tooltip, } from 'recharts'; import PageHeader from './components/PageHeader.jsx'; +/** Палитра в стиле UniFi: зелёные, жёлтые, оранжевые, красные, фиолетовые, серые */ const CHART_COLORS = [ - '#206bc4', '#4299e1', '#2fb344', '#5eba00', '#e64980', '#f76707', - '#fd7e14', '#fab005', '#e67700', '#20c997', '#0dcaf0', '#6f42c1', - '#6366f1', '#8b5cf6', '#a855f7', '#d63384', '#0d6efd', '#198754', + '#2fb344', '#5eba00', '#94c748', '#fab005', '#fd7e14', '#f76707', + '#e64980', '#ae3ec9', '#7950f2', '#5c7cfa', '#748cab', '#868e96', + '#adb5bd', '#ced4da', '#206bc4', '#20c997', ]; function formatBytes(bytes) { @@ -30,6 +30,10 @@ function formatBytes(bytes) { return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`; } +const DONUT_SIZE = 200; +const DONUT_OUTER = 88; +const DONUT_INNER = 52; + function JumphostCard({ jumphost }) { const { name, host, error, interfaces } = jumphost; const hasData = Array.isArray(interfaces) && interfaces.length > 0; @@ -81,47 +85,73 @@ function JumphostCard({ jumphost }) { )} {!error && chartData.length > 0 && ( - <> -
- Всего: {formatBytes(totalBytes)} (RX + TX) +
+
+ + + + {chartData.map((entry, index) => ( + + ))} + + formatBytes(value)} + contentStyle={{ fontSize: '12px' }} + labelFormatter={(name, payload) => { + const p = payload?.[0]; + if (!p) return name; + return `${name} — RX: ${formatBytes(p.rxBytes || 0)}, TX: ${formatBytes(p.txBytes || 0)}`; + }} + /> + + +
+
+ {formatBytes(totalBytes)} +
+
+ TRAFFIC +
+
- - - - percent > 0.05 ? `${name} ${(percent * 100).toFixed(0)}%` : '' - } - labelLine={false} +
+ {chartData.map((item) => ( +
- {chartData.map((entry, index) => ( - - ))} - - formatBytes(value)} - contentStyle={{ fontSize: '12px' }} - labelFormatter={(name, payload) => { - const p = payload?.[0]; - if (!p) return name; - return `${name} — RX: ${formatBytes(p.rxBytes || 0)}, TX: ${formatBytes(p.txBytes || 0)}`; - }} - /> - { - const item = chartData.find((d) => d.name === value); - return item ? `${value} (${formatBytes(item.value)})` : value; - }} - wrapperStyle={{ fontSize: '11px' }} - /> - - - + + + {item.name} - {formatBytes(item.value)} + +
+ ))} +
+
)}