From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 827841FF191 for ; Tue, 21 Oct 2025 08:37:42 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4C734167CF; Tue, 21 Oct 2025 08:38:07 +0200 (CEST) From: Dietmar Maurer To: pdm-devel@lists.proxmox.com Date: Tue, 21 Oct 2025 08:38:01 +0200 Message-ID: <20251021063803.2046329-1-dietmar@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.583 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 KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an 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. [overview.rs, lxc.rs, mod.rs] Subject: [pdm-devel] [PATCH datacenter-manager 1/3] ui: lxc: move files into subfolder, add Tabbar on top 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 that we can add other tab panels in the future. Signed-off-by: Dietmar Maurer --- ui/src/pve/lxc/mod.rs | 81 ++++++++++++++++++++++++++ ui/src/pve/{lxc.rs => lxc/overview.rs} | 28 +++------ 2 files changed, 90 insertions(+), 19 deletions(-) create mode 100644 ui/src/pve/lxc/mod.rs rename ui/src/pve/{lxc.rs => lxc/overview.rs} (96%) diff --git a/ui/src/pve/lxc/mod.rs b/ui/src/pve/lxc/mod.rs new file mode 100644 index 0000000..b984903 --- /dev/null +++ b/ui/src/pve/lxc/mod.rs @@ -0,0 +1,81 @@ +mod overview; +use overview::LxcOverviewPanel; + +use std::rc::Rc; + +use yew::virtual_dom::{VComp, VNode}; + +use pwt::prelude::*; +use pwt::widget::{Fa, Row, TabBarItem, TabPanel}; + +use pdm_api_types::resource::PveLxcResource; + +use crate::pve::utils::render_lxc_name; + +#[derive(Clone, Debug, Properties, PartialEq)] +pub struct LxcPanel { + remote: String, + node: String, + info: PveLxcResource, + + #[prop_or(60_000)] + /// The interval for refreshing the rrd data + pub rrd_interval: u32, + + #[prop_or(10_000)] + /// The interval for refreshing the status data + pub status_interval: u32, +} + +impl LxcPanel { + pub fn new(remote: String, node: String, info: PveLxcResource) -> Self { + yew::props!(Self { remote, node, info }) + } +} + +pub struct LxcPanelComp {} + +impl yew::Component for LxcPanelComp { + type Message = (); + type Properties = LxcPanel; + + fn create(_ctx: &yew::Context) -> Self { + Self {} + } + + fn view(&self, ctx: &yew::Context) -> yew::Html { + let props = ctx.props(); + + let title: Html = Row::new() + .gap(2) + .class(pwt::css::AlignItems::Baseline) + .with_child(Fa::new("cube")) + .with_child(tr! {"CT {0}", render_lxc_name(&props.info, true)}) + .into(); + + TabPanel::new() + .class(pwt::css::FlexFit) + .title(title) + .with_item_builder( + TabBarItem::new() + .key("status_view") + .label(tr!("Overview")) + .icon_class("fa fa-tachometer"), + { + let remote = props.remote.clone(); + let node = props.node.clone(); + let info = props.info.clone(); + move |_| { + LxcOverviewPanel::new(remote.clone(), node.clone(), info.clone()).into() + } + }, + ) + .into() + } +} + +impl Into for LxcPanel { + fn into(self) -> VNode { + VComp::new::(Rc::new(self), None).into() + } +} diff --git a/ui/src/pve/lxc.rs b/ui/src/pve/lxc/overview.rs similarity index 96% rename from ui/src/pve/lxc.rs rename to ui/src/pve/lxc/overview.rs index 08380b6..ac968fd 100644 --- a/ui/src/pve/lxc.rs +++ b/ui/src/pve/lxc/overview.rs @@ -11,23 +11,20 @@ use yew::{ use proxmox_human_byte::HumanByte; use proxmox_yew_comp::{RRDGraph, RRDTimeframe, RRDTimeframeSelector, Series}; use pwt::{ - css::{AlignItems, ColorScheme, FlexFit, JustifyContent}, + css::{ColorScheme, FlexFit, JustifyContent}, prelude::*, props::WidgetBuilder, - widget::{Column, Container, Fa, Panel, Progress, Row}, + widget::{Column, Container, Panel, Progress, Row}, AsyncPool, }; use pdm_api_types::{resource::PveLxcResource, rrddata::LxcDataPoint}; use pdm_client::types::{IsRunning, LxcStatus}; -use crate::{ - pve::utils::render_lxc_name, - renderer::{separator, status_row}, -}; +use crate::renderer::{separator, status_row}; #[derive(Clone, Debug, Properties)] -pub struct LxcPanel { +pub struct LxcOverviewPanel { remote: String, node: String, info: PveLxcResource, @@ -41,7 +38,7 @@ pub struct LxcPanel { pub status_interval: u32, } -impl PartialEq for LxcPanel { +impl PartialEq for LxcOverviewPanel { fn eq(&self, other: &Self) -> bool { if self.remote == other.remote && self.node == other.node { // only check some fields, so we don't update when e.g. only the cpu changes @@ -53,15 +50,15 @@ impl PartialEq for LxcPanel { } } } -impl Eq for LxcPanel {} +impl Eq for LxcOverviewPanel {} -impl LxcPanel { +impl LxcOverviewPanel { pub fn new(remote: String, node: String, info: PveLxcResource) -> Self { yew::props!(Self { remote, node, info }) } } -impl Into for LxcPanel { +impl Into for LxcOverviewPanel { fn into(self) -> VNode { VComp::new::(Rc::new(self), None).into() } @@ -118,7 +115,7 @@ impl LxcanelComp { impl yew::Component for LxcanelComp { type Message = Msg; - type Properties = LxcPanel; + type Properties = LxcOverviewPanel; fn create(ctx: &yew::Context) -> Self { ctx.link() @@ -254,12 +251,6 @@ impl yew::Component for LxcanelComp { fn view(&self, ctx: &yew::Context) -> yew::Html { let props = ctx.props(); - let title: Html = Row::new() - .gap(2) - .class(AlignItems::Baseline) - .with_child(Fa::new("cube")) - .with_child(tr! {"VM '{0}'", render_lxc_name(&props.info, true)}) - .into(); let mut status_comp = Column::new().gap(2).padding(4); let status = match &self.status { @@ -349,7 +340,6 @@ impl yew::Component for LxcanelComp { Panel::new() .class(FlexFit) - .title(title) .class(ColorScheme::Neutral) .with_child( // FIXME: add some 'visible' or 'active' property to the progress -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel