Fix network interface display for VLANs and physical NICs
All checks were successful
Build and Release / build-and-release (push) Successful in 1m11s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m11s
Agent changes: - Filter out ifb* interfaces from network display - Parse @parent notation for VLAN interfaces (e.g., lan@enp0s31f6) - Show physical interfaces even without IP addresses - Only filter virtual interfaces that have no IPs - Extract parent interface relationships for proper nesting Dashboard changes: - Nest VLAN/child interfaces under their physical parent - Show physical NICs with status icons even when down - Display child interfaces grouped under parent interface - Keep standalone virtual interfaces at root level Updated to version 0.1.169
This commit is contained in:
@@ -628,9 +628,14 @@ impl SystemWidget {
|
||||
let physical: Vec<_> = self.network_interfaces.iter().filter(|i| i.is_physical).collect();
|
||||
let virtual_interfaces: Vec<_> = self.network_interfaces.iter().filter(|i| !i.is_physical).collect();
|
||||
|
||||
// Render physical interfaces
|
||||
// Find standalone virtual interfaces (those without a parent)
|
||||
let standalone_virtual: Vec<_> = virtual_interfaces.iter()
|
||||
.filter(|i| i.parent_interface.is_none())
|
||||
.collect();
|
||||
|
||||
// Render physical interfaces with their children
|
||||
for (phy_idx, interface) in physical.iter().enumerate() {
|
||||
let is_last_physical = phy_idx == physical.len() - 1 && virtual_interfaces.is_empty();
|
||||
let is_last_physical = phy_idx == physical.len() - 1 && standalone_virtual.is_empty();
|
||||
|
||||
// Physical interface header with status icon
|
||||
let mut header_spans = vec![];
|
||||
@@ -640,36 +645,74 @@ impl SystemWidget {
|
||||
));
|
||||
lines.push(Line::from(header_spans));
|
||||
|
||||
// Show IPs nested under the interface
|
||||
let ip_count = interface.ipv4_addresses.len() + interface.ipv6_addresses.len();
|
||||
let mut ip_index = 0;
|
||||
// Find child interfaces for this physical interface
|
||||
let children: Vec<_> = virtual_interfaces.iter()
|
||||
.filter(|vi| {
|
||||
if let Some(parent) = &vi.parent_interface {
|
||||
parent == &interface.name
|
||||
} else {
|
||||
false
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
// IPv4 addresses
|
||||
// Count total items under this physical interface (IPs + children)
|
||||
let ip_count = interface.ipv4_addresses.len() + interface.ipv6_addresses.len();
|
||||
let total_children = ip_count + children.len();
|
||||
let mut child_index = 0;
|
||||
|
||||
// IPv4 addresses on the physical interface itself
|
||||
for ipv4 in &interface.ipv4_addresses {
|
||||
ip_index += 1;
|
||||
let is_last_ip = ip_index == ip_count && is_last_physical;
|
||||
let tree_symbol = if is_last_ip { " └─ " } else { " ├─ " };
|
||||
child_index += 1;
|
||||
let is_last = child_index == total_children && is_last_physical;
|
||||
let tree_symbol = if is_last { " └─ " } else { " ├─ " };
|
||||
lines.push(Line::from(vec![
|
||||
Span::styled(tree_symbol, Typography::tree()),
|
||||
Span::styled(format!("ip: {}", ipv4), Typography::secondary()),
|
||||
]));
|
||||
}
|
||||
|
||||
// IPv6 addresses
|
||||
// IPv6 addresses on the physical interface itself
|
||||
for ipv6 in &interface.ipv6_addresses {
|
||||
ip_index += 1;
|
||||
let is_last_ip = ip_index == ip_count && is_last_physical;
|
||||
let tree_symbol = if is_last_ip { " └─ " } else { " ├─ " };
|
||||
child_index += 1;
|
||||
let is_last = child_index == total_children && is_last_physical;
|
||||
let tree_symbol = if is_last { " └─ " } else { " ├─ " };
|
||||
lines.push(Line::from(vec![
|
||||
Span::styled(tree_symbol, Typography::tree()),
|
||||
Span::styled(format!("ip: {}", ipv6), Typography::secondary()),
|
||||
]));
|
||||
}
|
||||
|
||||
// Child virtual interfaces (VLANs, etc.)
|
||||
for child in children {
|
||||
child_index += 1;
|
||||
let is_last = child_index == total_children && is_last_physical;
|
||||
let tree_symbol = if is_last { " └─ " } else { " ├─ " };
|
||||
|
||||
let ip_text = if !child.ipv4_addresses.is_empty() {
|
||||
Self::compress_ipv4_addresses(&child.ipv4_addresses)
|
||||
} else if !child.ipv6_addresses.is_empty() {
|
||||
child.ipv6_addresses.join(", ")
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
|
||||
let child_text = if !ip_text.is_empty() {
|
||||
format!("{}: {}", child.name, ip_text)
|
||||
} else {
|
||||
format!("{}:", child.name)
|
||||
};
|
||||
|
||||
lines.push(Line::from(vec![
|
||||
Span::styled(tree_symbol, Typography::tree()),
|
||||
Span::styled(child_text, Typography::secondary()),
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
// Render standalone virtual interfaces (those without a parent)
|
||||
for (virt_idx, interface) in virtual_interfaces.iter().enumerate() {
|
||||
let is_last = virt_idx == virtual_interfaces.len() - 1;
|
||||
for (virt_idx, interface) in standalone_virtual.iter().enumerate() {
|
||||
let is_last = virt_idx == standalone_virtual.len() - 1;
|
||||
let tree_symbol = if is_last { " └─ " } else { " ├─ " };
|
||||
|
||||
// Virtual interface with IPs
|
||||
|
||||
Reference in New Issue
Block a user