* [PATCH proxmox-datacenter-manager 1/1] guests: allow sorting by cpu and memory in tree view
@ 2026-05-26 15:28 Stefan Hanreich
0 siblings, 0 replies; only message in thread
From: Stefan Hanreich @ 2026-05-26 15:28 UTC (permalink / raw)
To: pdm-devel
Can be used for showing the guests with most CPU / memory usage by
remote.
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
ui/src/guests.rs | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/ui/src/guests.rs b/ui/src/guests.rs
index c49eaff5..92930464 100644
--- a/ui/src/guests.rs
+++ b/ui/src/guests.rs
@@ -930,6 +930,19 @@ fn tree_columns(
.into(),
DataTableColumn::new(tr!("CPU usage"))
.width("90px")
+ .sorter(|a: &GuestTreeNode, b: &GuestTreeNode| {
+ let cpu_a = match a {
+ GuestTreeNode::Guest(guest) => guest.cpu(),
+ _ => f64::MIN,
+ };
+
+ let cpu_b = match b {
+ GuestTreeNode::Guest(guest) => guest.cpu(),
+ _ => f64::MIN,
+ };
+
+ cpu_a.total_cmp(&cpu_b)
+ })
.render(|node: &GuestTreeNode| match node {
GuestTreeNode::Guest(entry) => cpu_html(entry),
_ => html! {},
@@ -937,6 +950,19 @@ fn tree_columns(
.into(),
DataTableColumn::new(tr!("Memory usage"))
.width("150px")
+ .sorter(|a: &GuestTreeNode, b: &GuestTreeNode| {
+ let mem_a = match a {
+ GuestTreeNode::Guest(guest) => guest.mem(),
+ _ => u64::MIN,
+ };
+
+ let mem_b = match b {
+ GuestTreeNode::Guest(guest) => guest.mem(),
+ _ => u64::MIN,
+ };
+
+ mem_a.cmp(&mem_b)
+ })
.render(|node: &GuestTreeNode| match node {
GuestTreeNode::Guest(entry) => mem_html(entry),
_ => html! {},
--
2.47.3
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-05-26 15:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26 15:28 [PATCH proxmox-datacenter-manager 1/1] guests: allow sorting by cpu and memory in tree view Stefan Hanreich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox