mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 17:43:47 +00:00
fix: handle undefined inbounds/outbounds in traffic tab
API may return nodes without inbounds/outbounds arrays. Made fields optional in NodeRealtimeStats and added null safety guards in TrafficTab.
This commit is contained in:
@@ -174,8 +174,8 @@ export interface NodeRealtimeStats {
|
|||||||
uploadBytes: number;
|
uploadBytes: number;
|
||||||
totalBytes: number;
|
totalBytes: number;
|
||||||
usersOnline: number;
|
usersOnline: number;
|
||||||
inbounds: InboundTraffic[];
|
inbounds?: InboundTraffic[];
|
||||||
outbounds: InboundTraffic[];
|
outbounds?: InboundTraffic[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Squads
|
// Squads
|
||||||
|
|||||||
@@ -923,12 +923,12 @@ function TrafficTab({ data, isLoading, onRefresh }: TrafficTabProps) {
|
|||||||
<span className="text-sm text-dark-300">{formatBytes(node.totalBytes)}</span>
|
<span className="text-sm text-dark-300">{formatBytes(node.totalBytes)}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{node.inbounds.length > 0 && (
|
{(node.inbounds?.length ?? 0) > 0 && (
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<p className="mb-2 text-xs font-medium text-dark-400">
|
<p className="mb-2 text-xs font-medium text-dark-400">
|
||||||
{t('admin.remnawave.traffic.inbounds', 'Inbounds')}
|
{t('admin.remnawave.traffic.inbounds', 'Inbounds')}
|
||||||
</p>
|
</p>
|
||||||
{[...node.inbounds]
|
{[...(node.inbounds ?? [])]
|
||||||
.sort((a, b) => b.totalBytes - a.totalBytes)
|
.sort((a, b) => b.totalBytes - a.totalBytes)
|
||||||
.map((ib) => (
|
.map((ib) => (
|
||||||
<div
|
<div
|
||||||
@@ -948,12 +948,12 @@ function TrafficTab({ data, isLoading, onRefresh }: TrafficTabProps) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{node.outbounds.length > 0 && (
|
{(node.outbounds?.length ?? 0) > 0 && (
|
||||||
<div className="mt-3 space-y-1">
|
<div className="mt-3 space-y-1">
|
||||||
<p className="mb-2 text-xs font-medium text-dark-400">
|
<p className="mb-2 text-xs font-medium text-dark-400">
|
||||||
{t('admin.remnawave.traffic.outbounds', 'Outbounds')}
|
{t('admin.remnawave.traffic.outbounds', 'Outbounds')}
|
||||||
</p>
|
</p>
|
||||||
{[...node.outbounds]
|
{[...(node.outbounds ?? [])]
|
||||||
.sort((a, b) => b.totalBytes - a.totalBytes)
|
.sort((a, b) => b.totalBytes - a.totalBytes)
|
||||||
.map((ob) => (
|
.map((ob) => (
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in New Issue
Block a user