public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH proxmox-datacenter-manager 1/1] guests: allow sorting by cpu and memory in tree view
Date: Tue, 26 May 2026 17:28:09 +0200	[thread overview]
Message-ID: <20260526152811.464626-1-s.hanreich@proxmox.com> (raw)

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





                 reply	other threads:[~2026-05-26 15:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260526152811.464626-1-s.hanreich@proxmox.com \
    --to=s.hanreich@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal