From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id CAC361FF164 for ; Fri, 6 Jun 2025 14:10:10 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B26B9C0FD; Fri, 6 Jun 2025 14:10:31 +0200 (CEST) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Fri, 6 Jun 2025 14:10:26 +0200 Message-Id: <20250606121028.2595348-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250606121028.2595348-1-d.csapak@proxmox.com> References: <20250606121028.2595348-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.022 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [qemu.rs] Subject: [pdm-devel] [PATCH datacenter-manager 1/3] ui: pve: qemu: add rrd time frame selector X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" so the user can select the timeframe and aggregation for the rrd graphs Signed-off-by: Dominik Csapak --- ui/src/pve/qemu.rs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/ui/src/pve/qemu.rs b/ui/src/pve/qemu.rs index 57e5e74..f6b4d1f 100644 --- a/ui/src/pve/qemu.rs +++ b/ui/src/pve/qemu.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), RrdResult(Result, proxmox_client::Error>), + UpdateRrdTimeframe(RRDTimeframe), } pub struct QemuPanelComp { @@ -79,6 +80,8 @@ pub struct QemuPanelComp { _rrd_timeout: Option, _async_pool: AsyncPool, + rrd_time_frame: RRDTimeframe, + time: Rc>, cpu: Rc, memory: Rc, @@ -100,14 +103,10 @@ impl QemuPanelComp { async fn reload_rrd( remote: &str, vmid: u32, + rrd_time_frame: RRDTimeframe, ) -> Result, proxmox_client::Error> { let rrd = crate::pdm_client() - .pve_qemu_rrddata( - remote, - vmid, - proxmox_rrd_api_types::RrdMode::Average, - proxmox_rrd_api_types::RrdTimeframe::Hour, - ) + .pve_qemu_rrddata(remote, vmid, rrd_time_frame.mode, rrd_time_frame.timeframe) .await?; Ok(rrd) } @@ -129,6 +128,8 @@ impl yew::Component for QemuPanelComp { 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 QemuPanelComp { false } Msg::ReloadRrd => { + let time_frame = 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, time_frame).await) }); false } @@ -214,6 +216,11 @@ impl yew::Component for QemuPanelComp { })); true } + Msg::UpdateRrdTimeframe(rrd_time_frame) => { + self.rrd_time_frame = rrd_time_frame; + ctx.link().send_message(Msg::ReloadRrd); + false + } } } @@ -360,6 +367,9 @@ impl yew::Component for QemuPanelComp { 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