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 v3 8/8] ui: dashboard: make task summary time range configurable
Date: Mon, 25 Aug 2025 10:08:44 +0200	[thread overview]
Message-ID: <20250825081042.797559-9-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250825081042.797559-1-d.csapak@proxmox.com>

in the browsers local storage.

We already have now an interface to configure this, so use it to store
the timeframe to check for tasks

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/dashboard/mod.rs | 34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs
index 502332a..d9b58b6 100644
--- a/ui/src/dashboard/mod.rs
+++ b/ui/src/dashboard/mod.rs
@@ -59,6 +59,9 @@ pub const DEFAULT_MAX_AGE_S: u64 = 60;
 /// The default refresh interval
 pub const DEFAULT_REFRESH_INTERVAL_S: u64 = DEFAULT_MAX_AGE_S / 2;
 
+/// The default hours to show for task summaries
+pub const DEFAULT_TASK_SUMMARY_HOURS: u32 = 24;
+
 #[derive(Properties, PartialEq)]
 pub struct Dashboard {}
 
@@ -81,6 +84,8 @@ pub struct DashboardConfig {
     refresh_interval: Option<u64>,
     #[serde(skip_serializing_if = "Option::is_none")]
     max_age: Option<u64>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    task_last_hours: Option<u32>,
 }
 
 pub type LoadingResult = (
@@ -257,6 +262,7 @@ impl PdmDashboard {
     fn reload(&mut self, ctx: &yew::Context<Self>) {
         let link = ctx.link().clone();
         let max_age = self.config.max_age.unwrap_or(DEFAULT_MAX_AGE_S);
+        let last_hours = self.statistics.hours;
 
         self.load_finished_time = None;
         self.async_pool.spawn(async move {
@@ -265,7 +271,7 @@ impl PdmDashboard {
             let top_entities_future = client.get_top_entities();
             let status_future = http_get("/resources/status", Some(json!({"max-age": max_age})));
 
-            let since = (Date::now() / 1000.0) as i64 - (24 * 60 * 60);
+            let since = (Date::now() / 1000.0) as i64 - (last_hours * 60 * 60) as i64;
             let params = Some(json!({
                 "since": since,
                 "limit": 0,
@@ -291,7 +297,8 @@ impl Component for PdmDashboard {
     type Properties = Dashboard;
 
     fn create(ctx: &yew::Context<Self>) -> Self {
-        let config = PersistentState::new(StorageLocation::local("dashboard-config"));
+        let config: PersistentState<DashboardConfig> =
+            PersistentState::new(StorageLocation::local("dashboard-config"));
         let async_pool = AsyncPool::new();
 
         let (remote_list, _context_listener) = ctx
@@ -299,9 +306,10 @@ impl Component for PdmDashboard {
             .context(ctx.link().callback(Msg::RemoteListChanged))
             .expect("No Remote list context provided");
 
-        let since = (Date::now() / 1000.0) as i64 - (24 * 60 * 60);
+        let hours = config.task_last_hours.unwrap_or(DEFAULT_TASK_SUMMARY_HOURS);
+        let since = (Date::now() / 1000.0) as i64 - (hours * 60 * 60) as i64;
         let statistics = StatisticsOptions {
-            hours: 24,
+            hours,
             since,
             data: None,
             error: None,
@@ -375,6 +383,17 @@ impl Component for PdmDashboard {
             }
             Msg::UpdateConfig(dashboard_config) => {
                 self.config.update(dashboard_config);
+                let old_hours = self.statistics.hours;
+                let new_hours = self
+                    .config
+                    .task_last_hours
+                    .unwrap_or(DEFAULT_TASK_SUMMARY_HOURS);
+
+                if old_hours != new_hours {
+                    self.statistics.hours = new_hours;
+                    self.reload(ctx);
+                }
+
                 self.show_config_window = false;
                 true
             }
@@ -592,6 +611,13 @@ impl Component for PdmDashboard {
                                     DisplayField::new()
                                         .key("max-age-explanation")
                                         .value(tr!("If a response from a remote is older than 'Max Age', it will be updated on the next refresh.")))
+                                .with_field(
+                                    tr!("Task Summary Time Range (last hours)"),
+                                    Number::new()
+                                        .name("task-last-hours")
+                                        .min(0u64)
+                                        .placeholder(DEFAULT_TASK_SUMMARY_HOURS.to_string()),
+                                )
                                 .into()
                         })
                         .on_close(ctx.link().callback(|_| Msg::ConfigWindow(false)))
-- 
2.47.2



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


  parent reply	other threads:[~2025-08-25  8:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-25  8:08 [pdm-devel] [PATCH datacenter-manager v3 0/8] add task summary panels in dashboard Dominik Csapak
2025-08-25  8:08 ` [pdm-devel] [PATCH datacenter-manager v3 1/8] server: task cache: treat a limit of 0 as unbounded Dominik Csapak
2025-08-25  9:55   ` Stefan Hanreich
2025-08-25 10:49     ` Dominik Csapak
2025-08-25 13:40       ` Stefan Hanreich
2025-08-25  8:08 ` [pdm-devel] [PATCH datacenter-manager v3 2/8] server: api: remote tasks: add 'remote' filter option Dominik Csapak
2025-08-25  8:08 ` [pdm-devel] [PATCH datacenter-manager v3 3/8] server: api: add remote-tasks statistics Dominik Csapak
2025-08-25  8:08 ` [pdm-devel] [PATCH datacenter-manager v3 4/8] ui: refactor remote upid formatter Dominik Csapak
2025-08-25 10:56   ` Stefan Hanreich
2025-08-26  9:48     ` Dominik Csapak
2025-08-25  8:08 ` [pdm-devel] [PATCH datacenter-manager v3 5/8] ui: tasks: add helper to summarize task categories Dominik Csapak
2025-08-25  9:54   ` Stefan Hanreich
2025-08-25  8:08 ` [pdm-devel] [PATCH datacenter-manager v3 6/8] ui: add dialog to show filtered tasks Dominik Csapak
2025-08-25  8:08 ` [pdm-devel] [PATCH datacenter-manager v3 7/8] ui: dashboard: add task summaries Dominik Csapak
2025-08-25 10:52   ` Stefan Hanreich
2025-08-25  8:08 ` Dominik Csapak [this message]
2025-08-25  9:54   ` [pdm-devel] [PATCH datacenter-manager v3 8/8] ui: dashboard: make task summary time range configurable Stefan Hanreich
2025-08-25 13:17 ` [pdm-devel] [PATCH datacenter-manager v3 0/8] add task summary panels in dashboard Stefan Hanreich
2025-08-26 11:22 ` [pdm-devel] superseded: " 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=20250825081042.797559-9-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