Skip to content

Commit 0c86ab1

Browse files
committed
feat: show total uplink and downlink of bar in node stats modal
1 parent f5e5958 commit 0c86ab1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

dashboard/src/components/dialogs/NodeStatsModal.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,15 @@ const NodeStatsModal = ({ open, onClose, data, chartConfig, period, allChartData
150150
return sum + (data[key] || 0)
151151
}, 0)
152152

153+
// Calculate total uplink and downlink
154+
const totalUplink = Object.keys(data)
155+
.filter(key => key.startsWith('_uplink_'))
156+
.reduce((sum, key) => sum + (data[key] || 0), 0)
157+
158+
const totalDownlink = Object.keys(data)
159+
.filter(key => key.startsWith('_downlink_'))
160+
.reduce((sum, key) => sum + (data[key] || 0), 0)
161+
153162
// Get nodes with usage > 0
154163
const activeNodes = Object.keys(data)
155164
.filter(key => !key.startsWith('_') && key !== 'time' && key !== '_period_start' && (data[key] || 0) > 0)
@@ -214,6 +223,24 @@ const NodeStatsModal = ({ open, onClose, data, chartConfig, period, allChartData
214223
</Badge>
215224
</div>
216225

226+
{/* Total Upload/Download */}
227+
{!hideUplinkDownlink && (
228+
<div className={`flex items-center gap-2 sm:gap-3 text-xs ${isRTL ? 'flex-row-reverse justify-end' : 'flex-row justify-start'}`}>
229+
<div className={`flex items-center gap-1`}>
230+
<Upload className="h-3 w-3 text-green-500" />
231+
<span dir="ltr" className="font-mono text-muted-foreground">
232+
{formatBytes(totalUplink)}
233+
</span>
234+
</div>
235+
<div className={`flex items-center gap-1`}>
236+
<Download className="h-3 w-3 text-blue-500" />
237+
<span dir="ltr" className="font-mono text-muted-foreground">
238+
{formatBytes(totalDownlink)}
239+
</span>
240+
</div>
241+
</div>
242+
)}
243+
217244
{/* Node Statistics */}
218245
<div className="space-y-2 sm:space-y-3">
219246
<h4 className={`text-xs sm:text-sm font-semibold text-foreground`}>

0 commit comments

Comments
 (0)