Sort virtual interfaces: VLANs first by ID, then alphabetically
All checks were successful
Build and Release / build-and-release (push) Successful in 1m32s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m32s
Dashboard changes: - Sort child interfaces under physical NICs with VLANs first (by VLAN ID ascending) - Non-VLAN virtual interfaces sorted alphabetically by name - Applied same sorting to both nested children and standalone virtual interfaces Example output order: - wan (vlan 5) - lan (vlan 30) - isolan (vlan 32) - seclan (vlan 35) - br-48df2d79b46f - docker0 - tailscale0 Updated to version 0.1.171
This commit is contained in:
parent
937f4ad427
commit
8f9e9eabca
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.170"
|
version = "0.1.171"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
@ -301,7 +301,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.170"
|
version = "0.1.171"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@ -324,7 +324,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.170"
|
version = "0.1.171"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.170"
|
version = "0.1.171"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.170"
|
version = "0.1.171"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@ -629,10 +629,20 @@ impl SystemWidget {
|
|||||||
let virtual_interfaces: 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();
|
||||||
|
|
||||||
// Find standalone virtual interfaces (those without a parent)
|
// Find standalone virtual interfaces (those without a parent)
|
||||||
let standalone_virtual: Vec<_> = virtual_interfaces.iter()
|
let mut standalone_virtual: Vec<_> = virtual_interfaces.iter()
|
||||||
.filter(|i| i.parent_interface.is_none())
|
.filter(|i| i.parent_interface.is_none())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
// Sort standalone virtual: VLANs first (by VLAN ID), then others alphabetically
|
||||||
|
standalone_virtual.sort_by(|a, b| {
|
||||||
|
match (a.vlan_id, b.vlan_id) {
|
||||||
|
(Some(vlan_a), Some(vlan_b)) => vlan_a.cmp(&vlan_b),
|
||||||
|
(Some(_), None) => std::cmp::Ordering::Less,
|
||||||
|
(None, Some(_)) => std::cmp::Ordering::Greater,
|
||||||
|
(None, None) => a.name.cmp(&b.name),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Render physical interfaces with their children
|
// Render physical interfaces with their children
|
||||||
for (phy_idx, interface) in physical.iter().enumerate() {
|
for (phy_idx, interface) in physical.iter().enumerate() {
|
||||||
let is_last_physical = phy_idx == physical.len() - 1 && standalone_virtual.is_empty();
|
let is_last_physical = phy_idx == physical.len() - 1 && standalone_virtual.is_empty();
|
||||||
@ -646,7 +656,7 @@ impl SystemWidget {
|
|||||||
lines.push(Line::from(header_spans));
|
lines.push(Line::from(header_spans));
|
||||||
|
|
||||||
// Find child interfaces for this physical interface
|
// Find child interfaces for this physical interface
|
||||||
let children: Vec<_> = virtual_interfaces.iter()
|
let mut children: Vec<_> = virtual_interfaces.iter()
|
||||||
.filter(|vi| {
|
.filter(|vi| {
|
||||||
if let Some(parent) = &vi.parent_interface {
|
if let Some(parent) = &vi.parent_interface {
|
||||||
parent == &interface.name
|
parent == &interface.name
|
||||||
@ -656,6 +666,16 @@ impl SystemWidget {
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
// Sort children: VLANs first (by VLAN ID), then others alphabetically
|
||||||
|
children.sort_by(|a, b| {
|
||||||
|
match (a.vlan_id, b.vlan_id) {
|
||||||
|
(Some(vlan_a), Some(vlan_b)) => vlan_a.cmp(&vlan_b),
|
||||||
|
(Some(_), None) => std::cmp::Ordering::Less,
|
||||||
|
(None, Some(_)) => std::cmp::Ordering::Greater,
|
||||||
|
(None, None) => a.name.cmp(&b.name),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Count total items under this physical interface (IPs + children)
|
// Count total items under this physical interface (IPs + children)
|
||||||
let ip_count = interface.ipv4_addresses.len() + interface.ipv6_addresses.len();
|
let ip_count = interface.ipv4_addresses.len() + interface.ipv6_addresses.len();
|
||||||
let total_children = ip_count + children.len();
|
let total_children = ip_count + children.len();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.170"
|
version = "0.1.171"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user