diff --git a/frontend/src/TrafficDashboard.jsx b/frontend/src/TrafficDashboard.jsx index 4c393c6..9a9db97 100644 --- a/frontend/src/TrafficDashboard.jsx +++ b/frontend/src/TrafficDashboard.jsx @@ -182,6 +182,44 @@ export default function TrafficDashboard() { fetchStats(); }, [fetchStats]); + // Суммарная статистика по всем отображаемым системам (без ошибок, с данными) + const summary = (() => { + const withData = (jumphosts || []).filter((jh) => !jh.error && Array.isArray(jh.interfaces) && jh.interfaces.length > 0); + let totalBytes = 0; + let totalRx = 0; + let totalTx = 0; + const byJumphost = []; + for (const jh of withData) { + let jhTotal = 0; + let jhRx = 0; + let jhTx = 0; + for (const i of jh.interfaces) { + jhTotal += i.totalBytes || 0; + jhRx += i.rxBytes || 0; + jhTx += i.txBytes || 0; + } + totalBytes += jhTotal; + totalRx += jhRx; + totalTx += jhTx; + if (jhTotal > 0) { + byJumphost.push({ + name: jh.name || jh.host || 'Jumphost', + value: jhTotal, + fill: CHART_COLORS[byJumphost.length % CHART_COLORS.length], + }); + } + } + return { + totalBytes, + totalRx, + totalTx, + systemsCount: withData.length, + byJumphost, + }; + })(); + + const hasSummary = summary.systemsCount > 0 && summary.totalBytes > 0; + return (