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 2/3] ui: pve: lxc: add rrd time frame selector
Date: Fri,  6 Jun 2025 14:10:27 +0200	[thread overview]
Message-ID: <20250606121028.2595348-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250606121028.2595348-1-d.csapak@proxmox.com>

so the user can select the timeframe and aggregation for the rrd graphs

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/pve/lxc.rs | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/ui/src/pve/lxc.rs b/ui/src/pve/lxc.rs
index c43ac9e..92d9757 100644
--- a/ui/src/pve/lxc.rs
+++ b/ui/src/pve/lxc.rs
@@ -9,7 +9,7 @@ use yew::{
 };
 
 use proxmox_human_byte::HumanByte;
-use proxmox_yew_comp::{RRDGraph, Series};
+use proxmox_yew_comp::{RRDGraph, RRDTimeframe, RRDTimeframeSelector, Series};
 use pwt::{
     css::{AlignItems, ColorScheme, FlexFit},
     prelude::*,
@@ -69,6 +69,7 @@ pub enum Msg {
     ReloadRrd,
     StatusResult(Result<LxcStatus, proxmox_client::Error>),
     RrdResult(Result<Vec<LxcDataPoint>, proxmox_client::Error>),
+    UpdateRrdTimeframe(RRDTimeframe),
 }
 
 pub struct LxcanelComp {
@@ -79,6 +80,8 @@ pub struct LxcanelComp {
     _rrd_timeout: Option<Timeout>,
     _async_pool: AsyncPool,
 
+    rrd_time_frame: RRDTimeframe,
+
     time: Rc<Vec<i64>>,
     cpu: Rc<Series>,
     memory: Rc<Series>,
@@ -100,14 +103,10 @@ impl LxcanelComp {
     async fn reload_rrd(
         remote: &str,
         vmid: u32,
+        rrd_time_frame: RRDTimeframe,
     ) -> Result<Vec<LxcDataPoint>, proxmox_client::Error> {
         let rrd = crate::pdm_client()
-            .pve_lxc_rrddata(
-                remote,
-                vmid,
-                proxmox_rrd_api_types::RrdMode::Average,
-                proxmox_rrd_api_types::RrdTimeframe::Hour,
-            )
+            .pve_lxc_rrddata(remote, vmid, rrd_time_frame.mode, rrd_time_frame.timeframe)
             .await?;
         Ok(rrd)
     }
@@ -129,6 +128,8 @@ impl yew::Component for LxcanelComp {
             last_rrd_error: None,
             last_status_error: None,
 
+            rrd_time_frame: RRDTimeframe::load(),
+
             time: Rc::new(Vec::new()),
             cpu: Rc::new(Series::new("", Vec::new())),
             memory: Rc::new(Series::new("", Vec::new())),
@@ -153,8 +154,9 @@ impl yew::Component for LxcanelComp {
                 false
             }
             Msg::ReloadRrd => {
+                let timeframe = self.rrd_time_frame;
                 self._async_pool.send_future(link, async move {
-                    Msg::RrdResult(Self::reload_rrd(&remote, vmid).await)
+                    Msg::RrdResult(Self::reload_rrd(&remote, vmid, timeframe).await)
                 });
                 false
             }
@@ -214,6 +216,11 @@ impl yew::Component for LxcanelComp {
                 }));
                 true
             }
+            Msg::UpdateRrdTimeframe(rrd_time_frame) => {
+                self.rrd_time_frame = rrd_time_frame;
+                ctx.link().send_message(Msg::ReloadRrd);
+                false
+            }
         }
     }
 
@@ -351,6 +358,9 @@ impl yew::Component for LxcanelComp {
         Panel::new()
             .class(FlexFit)
             .title(title)
+            .with_tool(
+                RRDTimeframeSelector::new().on_change(ctx.link().callback(Msg::UpdateRrdTimeframe)),
+            )
             .class(ColorScheme::Neutral)
             .with_child(
                 // FIXME: add some 'visible' or 'active' property to the progress
-- 
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-06-06 12:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-06 12:10 [pdm-devel] [PATCH datacenter-manager 0/3] add rrd time frame selector for pve panels Dominik Csapak
2025-06-06 12:10 ` [pdm-devel] [PATCH datacenter-manager 1/3] ui: pve: qemu: add rrd time frame selector Dominik Csapak
2025-06-06 12:10 ` Dominik Csapak [this message]
2025-06-06 12:10 ` [pdm-devel] [PATCH datacenter-manager 3/3] ui: pve: nodes: " Dominik Csapak
2025-08-18 12:31 ` [pdm-devel] [PATCH datacenter-manager 0/3] add rrd time frame selector for pve panels Lukas Wagner
2025-08-19  8:10   ` Dominik Csapak
2025-08-19 12:36 ` [pdm-devel] applied: " Lukas Wagner

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=20250606121028.2595348-3-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