From: "Shannon Sterz" <s.sterz@proxmox.com>
To: "Dominik Csapak" <d.csapak@proxmox.com>
Cc: Proxmox Datacenter Manager development discussion
<pdm-devel@lists.proxmox.com>
Subject: Re: [pdm-devel] [PATCH datacenter-manager v2 06/16] ui: dashboard: refactor task summary panel creation to its own module
Date: Thu, 23 Oct 2025 13:19:22 +0200 [thread overview]
Message-ID: <DDPNSXUQ7JQP.20KJD4EM3SZ6H@proxmox.com> (raw)
In-Reply-To: <20251023083253.1038119-7-d.csapak@proxmox.com>
On Thu Oct 23, 2025 at 10:28 AM CEST, Dominik Csapak wrote:
> so we can easily reuse it outside the dashboard struct.
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> ui/src/dashboard/mod.rs | 65 +++++++++++++++------------------------
> ui/src/dashboard/tasks.rs | 30 ++++++++++++++++++
> 2 files changed, 54 insertions(+), 41 deletions(-)
>
> diff --git a/ui/src/dashboard/mod.rs b/ui/src/dashboard/mod.rs
> index fa0fe2fc..c0b20b36 100644
> --- a/ui/src/dashboard/mod.rs
> +++ b/ui/src/dashboard/mod.rs
> @@ -54,7 +54,7 @@ use status_row::DashboardStatusRow;
> mod filtered_tasks;
>
> mod tasks;
> -use tasks::TaskSummary;
> +use tasks::create_task_summary_panel;
>
> /// The initial 'max-age' parameter in seconds. The backend polls every 15 minutes, so to increase
> /// the chance of showing some data quickly use that as max age at the very first load.
> @@ -145,44 +145,6 @@ pub struct PdmDashboard {
> }
>
> impl PdmDashboard {
> - fn create_task_summary_panel(
> - &self,
> - statistics: &StatisticsOptions,
> - remotes: Option<u32>,
> - ) -> Panel {
> - let (hours, since) = Self::get_task_options(&self.config);
> - let title = match remotes {
> - Some(_count) => tr!("Task Summary Sorted by Failed Tasks (Last {0}h)", hours),
> - None => tr!("Task Summary by Category (Last {0}h)", hours),
> - };
> - Panel::new()
> - .flex(1.0)
> - .width(500)
> - .border(true)
> - .title(create_title_with_icon("list", title))
> - .with_child(
> - Container::new()
> - .class(FlexFit)
> - .padding(2)
> - .with_optional_child(
> - statistics
> - .data
> - .clone()
> - .map(|data| TaskSummary::new(data, since, remotes)),
> - )
> - .with_optional_child(
> - (statistics.error.is_none() && statistics.data.is_none())
> - .then_some(loading_column()),
> - )
> - .with_optional_child(
> - statistics
> - .error
> - .as_ref()
> - .map(|err| error_message(&err.to_string())),
> - ),
> - )
> - }
> -
> fn create_top_entities_panel(
> &self,
> icon: &str,
> @@ -383,6 +345,7 @@ impl Component for PdmDashboard {
> }
>
> fn view(&self, ctx: &yew::Context<Self>) -> yew::Html {
> + let (hours, since) = Self::get_task_options(&self.config);
> let content = Column::new()
> .class(FlexFit)
> .with_child(
> @@ -541,8 +504,28 @@ impl Component for PdmDashboard {
> .style("padding-top", "0")
> .class(pwt::css::Flex::Fill)
> .class(FlexWrap::Wrap)
> - .with_child(self.create_task_summary_panel(&self.statistics, None))
> - .with_child(self.create_task_summary_panel(&self.statistics, Some(5)))
> + .with_child(
> + create_task_summary_panel(
> + self.statistics.data.clone(),
> + self.statistics.error.as_ref(),
> + None,
> + hours,
> + since,
> + )
> + .flex(1.0)
> + .width(500),
could these be moved to the function as well here? at least the
`flex(1.0)` is probably used fairly often here?
> + )
> + .with_child(
> + create_task_summary_panel(
> + self.statistics.data.clone(),
> + self.statistics.error.as_ref(),
> + Some(5),
> + hours,
> + since,
> + )
> + .flex(1.0)
> + .width(500),
> + )
> .with_child(create_sdn_panel(self.status.clone()).flex(1.0).width(200)),
> );
>
> diff --git a/ui/src/dashboard/tasks.rs b/ui/src/dashboard/tasks.rs
> index d32cf378..cdb0d9c6 100644
> --- a/ui/src/dashboard/tasks.rs
> +++ b/ui/src/dashboard/tasks.rs
> @@ -2,6 +2,7 @@ use std::collections::BTreeMap;
> use std::collections::HashMap;
> use std::rc::Rc;
>
> +use anyhow::Error;
> use yew::html::Scope;
> use yew::virtual_dom::Key;
>
> @@ -11,11 +12,15 @@ use pwt::prelude::*;
> use pwt::props::ExtractPrimaryKey;
> use pwt::state::Store;
> use pwt::widget::data_table::{DataTable, DataTableColumn, DataTableHeader};
> +use pwt::widget::error_message;
> +use pwt::widget::Panel;
> use pwt::widget::{ActionIcon, Container, Tooltip};
> use pwt_macros::{builder, widget};
>
> use pdm_api_types::TaskStatistics;
>
> +use crate::dashboard::create_title_with_icon;
> +use crate::dashboard::loading_column;
> use crate::tasks::TaskWorkerType;
>
> use super::filtered_tasks::FilteredTasks;
> @@ -295,3 +300,28 @@ impl Component for ProxmoxTaskSummary {
> .into()
> }
> }
> +
> +pub fn create_task_summary_panel(
> + statistics: Option<TaskStatistics>,
> + error: Option<&Error>,
> + remotes: Option<u32>,
> + hours: u32,
> + since: i64,
> +) -> Panel {
> + let title = match remotes {
> + Some(_count) => tr!("Task Summary Sorted by Failed Tasks (Last {0}h)", hours),
> + None => tr!("Task Summary by Category (Last {0}h)", hours),
> + };
> + let loading = error.is_none() && statistics.is_none();
> + Panel::new()
> + .border(true)
> + .title(create_title_with_icon("list", title))
> + .with_child(
> + Container::new()
> + .class(css::FlexFit)
> + .padding(2)
> + .with_optional_child(statistics.map(|data| TaskSummary::new(data, since, remotes)))
> + .with_optional_child((loading).then_some(loading_column()))
> + .with_optional_child(error.map(|err| error_message(&err.to_string()))),
> + )
> +}
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-10-23 11:18 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 8:28 [pdm-devel] [PATCH datacenter-manager v2 00/16] prepare ui for customizable views Dominik Csapak
2025-10-23 8:28 ` [pdm-devel] [PATCH datacenter-manager v2 01/16] ui: dashboard: refactor guest panel creation to its own module Dominik Csapak
2025-10-23 11:19 ` Shannon Sterz
2025-10-23 8:28 ` [pdm-devel] [PATCH datacenter-manager v2 02/16] ui: dashboard: refactor creating the node panel into " Dominik Csapak
2025-10-23 11:19 ` Shannon Sterz
2025-10-23 8:28 ` [pdm-devel] [PATCH datacenter-manager v2 03/16] ui: dashboard: refactor remote panel creation " Dominik Csapak
2025-10-23 8:28 ` [pdm-devel] [PATCH datacenter-manager v2 04/16] ui: dashboard: remote panel: make wizard menu optional Dominik Csapak
2025-10-23 8:28 ` [pdm-devel] [PATCH datacenter-manager v2 05/16] ui: dashboard: refactor sdn panel creation into its own module Dominik Csapak
2025-10-23 8:28 ` [pdm-devel] [PATCH datacenter-manager v2 06/16] ui: dashboard: refactor task summary panel creation to " Dominik Csapak
2025-10-23 11:19 ` Shannon Sterz [this message]
2025-10-23 8:28 ` [pdm-devel] [PATCH datacenter-manager v2 07/16] ui: dashboard: task summary: disable virtual scrolling Dominik Csapak
2025-10-23 8:28 ` [pdm-devel] [PATCH datacenter-manager v2 08/16] ui: dashboard: refactor subscription panel creation to its own module Dominik Csapak
2025-10-23 8:28 ` [pdm-devel] [PATCH datacenter-manager v2 09/16] ui: dashboard: refactor top entities " Dominik Csapak
2025-10-23 8:28 ` [pdm-devel] [PATCH datacenter-manager v2 10/16] ui: dashboard: refactor DashboardConfig editing/constants to their module Dominik Csapak
2025-10-23 8:28 ` [pdm-devel] [PATCH datacenter-manager v2 11/16] ui: dashboard: factor out task parameter calculation Dominik Csapak
2025-10-23 8:28 ` [pdm-devel] [PATCH datacenter-manager v2 12/16] ui: dashboard: remove unused remote list Dominik Csapak
2025-10-23 8:28 ` [pdm-devel] [PATCH datacenter-manager v2 13/16] ui: dashboard: status row: make loading less jarring Dominik Csapak
2025-10-23 11:19 ` Shannon Sterz
2025-10-23 8:28 ` [pdm-devel] [RFC PATCH datacenter-manager v2 14/16] ui: introduce `LoadResult` helper type Dominik Csapak
2025-10-23 11:19 ` Shannon Sterz
2025-10-23 8:28 ` [pdm-devel] [RFC PATCH datacenter-manager v2 15/16] ui: dashboard: implement 'View' Dominik Csapak
2025-10-23 11:19 ` Shannon Sterz
2025-10-23 11:44 ` Dominik Csapak
2025-10-23 11:48 ` Dominik Csapak
2025-10-24 10:17 ` Shannon Sterz
2025-10-23 8:28 ` [pdm-devel] [RFC PATCH datacenter-manager v2 16/16] ui: dashboard: use 'View' instead of the Dashboard Dominik Csapak
2025-10-23 11:19 ` Shannon Sterz
2025-10-23 11:20 ` [pdm-devel] [PATCH datacenter-manager v2 00/16] prepare ui for customizable views Shannon Sterz
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=DDPNSXUQ7JQP.20KJD4EM3SZ6H@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=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