public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager v2 5/7] ui: tasks: add helper to summarize task categories
Date: Wed, 19 Feb 2025 13:28:22 +0100	[thread overview]
Message-ID: <20250219122824.2043990-6-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250219122824.2043990-1-d.csapak@proxmox.com>

one for mapping UPID worker types to shortahnds that can be used for
pre-filtering via the api (have to filter on the client side a bit more
since we'll return more than what we want with the current filtering
api)

and one for creating a title for each type

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/tasks.rs | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/ui/src/tasks.rs b/ui/src/tasks.rs
index 0e7899c..a94cc9a 100644
--- a/ui/src/tasks.rs
+++ b/ui/src/tasks.rs
@@ -120,3 +120,32 @@ pub fn format_optional_remote_upid(upid: &str, include_remote: bool) -> String {
         format_upid(&upid)
     }
 }
+
+/// Map worker types to sensible categories (that can also be used as filter for the api)
+///
+/// Note: if using as filter for the api, the result has to be filtered with this again, since
+/// more records will be returned. E.g. using 'vz' will also return 'vzdump' tasks which are
+/// not desired.
+pub fn map_worker_type(worker_type: &str) -> &str {
+    match worker_type {
+        task_type if task_type.contains("migrate") => "migrate",
+        task_type if task_type.starts_with("qm") => "qm",
+        task_type if task_type.starts_with("vz") && task_type != "vzdump" => "vz",
+        task_type if task_type.starts_with("ceph") => "ceph",
+        task_type if task_type.starts_with("ha") => "ha",
+        other => other,
+    }
+}
+
+/// Map a category from [`map_worker_type`] to a title text.
+pub fn get_type_title(task_type: &str) -> String {
+    match task_type {
+        "migrate" => tr!("Guest Migrations"),
+        "qm" => tr!("Virtual Machine related Tasks"),
+        "vz" => tr!("Container related Tasks"),
+        "ceph" => tr!("Ceph related Tasks"),
+        "vzdump" => tr!("Backup Tasks"),
+        "ha" => tr!("HA related Tasks"),
+        other => other.to_string(),
+    }
+}
-- 
2.39.5



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


  parent reply	other threads:[~2025-02-19 12:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-19 12:28 [pdm-devel] [PATCH datacenter-manager v2 0/7] add task summary panels in dashboard Dominik Csapak
2025-02-19 12:28 ` [pdm-devel] [PATCH datacenter-manager v2 1/7] server: task cache: treat a limit of 0 as unbounded Dominik Csapak
2025-02-19 12:28 ` [pdm-devel] [PATCH datacenter-manager v2 2/7] server: api: remote tasks: add 'remote' filter option Dominik Csapak
2025-02-19 12:28 ` [pdm-devel] [PATCH datacenter-manager v2 3/7] server: api: add remote-tasks statistics Dominik Csapak
2025-02-19 12:28 ` [pdm-devel] [PATCH datacenter-manager v2 4/7] ui: refactor remote upid formatter Dominik Csapak
2025-02-19 12:28 ` Dominik Csapak [this message]
2025-02-19 12:28 ` [pdm-devel] [PATCH datacenter-manager v2 6/7] ui: add dialog to show filtered tasks Dominik Csapak
2025-02-19 12:28 ` [pdm-devel] [PATCH datacenter-manager v2 7/7] ui: dashboard: add task summaries Dominik Csapak

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=20250219122824.2043990-6-d.csapak@proxmox.com \
    --to=d.csapak@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