all lists on 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 7/9] ui: remotes: add tasks to global remote panel
Date: Mon, 20 Jan 2025 10:30:04 +0100	[thread overview]
Message-ID: <20250120093006.927014-15-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250120093006.927014-1-d.csapak@proxmox.com>

this replaces the previous "global" remotes panel (that was just the
configuration) with a TabPanel that contains the configuration and the
tasks for all remotes.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/main_menu.rs     |   7 +-
 ui/src/remotes/mod.rs   |  35 +++++++++
 ui/src/remotes/tasks.rs | 153 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 192 insertions(+), 3 deletions(-)
 create mode 100644 ui/src/remotes/tasks.rs

diff --git a/ui/src/main_menu.rs b/ui/src/main_menu.rs
index 364ba94..4f40d2c 100644
--- a/ui/src/main_menu.rs
+++ b/ui/src/main_menu.rs
@@ -16,9 +16,10 @@ use proxmox_yew_comp::{NotesView, XTermJs};
 
 use pdm_api_types::remotes::RemoteType;
 
+use crate::remotes::RemotesPanel;
 use crate::{
-    AccessControl, CertificatesPanel, Dashboard, RemoteConfigPanel, RemoteList,
-    ServerAdministration, SystemConfiguration,
+    AccessControl, CertificatesPanel, Dashboard, RemoteList, ServerAdministration,
+    SystemConfiguration,
 };
 
 /*
@@ -279,7 +280,7 @@ impl Component for PdmMainMenu {
                 Container::new()
                     .class("pwt-content-spacer")
                     .class(pwt::css::FlexFit)
-                    .with_child(RemoteConfigPanel::new())
+                    .with_child(html! {<RemotesPanel/>})
                     .into()
             },
             remote_submenu,
diff --git a/ui/src/remotes/mod.rs b/ui/src/remotes/mod.rs
index f221777..a2f471c 100644
--- a/ui/src/remotes/mod.rs
+++ b/ui/src/remotes/mod.rs
@@ -20,3 +20,38 @@ mod edit_remote;
 
 mod config;
 pub use config::{create_remote, RemoteConfigPanel};
+
+mod tasks;
+
+use yew::{function_component, Html};
+
+use pwt::{
+    props::{ContainerBuilder, StorageLocation},
+    state::NavigationContainer,
+    widget::{MiniScrollMode, TabBarItem, TabPanel},
+};
+
+#[function_component(RemotesPanel)]
+pub fn system_configuration() -> Html {
+    let panel = TabPanel::new()
+        .state_id(StorageLocation::session("RemotesPanelState"))
+        .class(pwt::css::FlexFit)
+        .router(true)
+        .scroll_mode(MiniScrollMode::Arrow)
+        .with_item_builder(
+            TabBarItem::new()
+                .key("configuration")
+                .label("Configuration")
+                .icon_class("fa fa-cogs"),
+            |_| RemoteConfigPanel::new().into(),
+        )
+        .with_item_builder(
+            TabBarItem::new()
+                .key("tasks")
+                .label("Tasks")
+                .icon_class("fa fa-book"),
+            |_| tasks::RemoteTaskList::new().into(),
+        );
+
+    NavigationContainer::new().with_child(panel).into()
+}
diff --git a/ui/src/remotes/tasks.rs b/ui/src/remotes/tasks.rs
new file mode 100644
index 0000000..6474035
--- /dev/null
+++ b/ui/src/remotes/tasks.rs
@@ -0,0 +1,153 @@
+use std::rc::Rc;
+
+use yew::{
+    html,
+    virtual_dom::{VComp, VNode},
+    Component, Properties,
+};
+
+use pdm_api_types::RemoteUpid;
+use pdm_client::types::PveUpid;
+
+use proxmox_yew_comp::{
+    common_api_types::TaskListItem,
+    utils::{format_task_description, format_upid, render_epoch_short},
+    TaskViewer, Tasks,
+};
+use pwt::{
+    css::FlexFit,
+    props::{ContainerBuilder, WidgetBuilder},
+    tr,
+    widget::{
+        data_table::{DataTableColumn, DataTableHeader},
+        Column,
+    },
+};
+
+#[derive(PartialEq, Properties)]
+pub struct RemoteTaskList;
+impl RemoteTaskList {
+    pub fn new() -> Self {
+        yew::props!(Self {})
+    }
+}
+
+pub struct PbsRemoteTaskList {
+    columns: Rc<Vec<DataTableHeader<TaskListItem>>>,
+    upid: Option<(String, Option<i64>)>,
+}
+
+fn columns() -> Rc<Vec<DataTableHeader<TaskListItem>>> {
+    Rc::new(vec![
+        DataTableColumn::new(tr!("Start Time"))
+            .width("130px")
+            .render(|item: &TaskListItem| render_epoch_short(item.starttime).into())
+            .into(),
+        DataTableColumn::new(tr!("End Time"))
+            .width("130px")
+            .render(|item: &TaskListItem| match item.endtime {
+                Some(endtime) => render_epoch_short(endtime).into(),
+                None => html! {},
+            })
+            .into(),
+        DataTableColumn::new(tr!("User name"))
+            .width("150px")
+            .render(|item: &TaskListItem| {
+                html! {&item.user}
+            })
+            .into(),
+        DataTableColumn::new(tr!("Remote"))
+            .width("150px")
+            .render(
+                |item: &TaskListItem| match item.upid.parse::<RemoteUpid>() {
+                    Ok(remote) => html! {remote.remote()},
+                    Err(_) => html! {{"-"}},
+                },
+            )
+            .into(),
+        DataTableColumn::new(tr!("Node"))
+            .width("150px")
+            .render(|item: &TaskListItem| {
+                html! {&item.node}
+            })
+            .into(),
+        DataTableColumn::new(tr!("Description"))
+            .flex(1)
+            .render(move |item: &TaskListItem| {
+                if let Ok(remote_upid) = item.upid.parse::<RemoteUpid>() {
+                    match remote_upid.upid.parse::<PveUpid>() {
+                        Ok(upid) => {
+                            format_task_description(&upid.worker_type, upid.worker_id.as_deref())
+                        }
+                        Err(_) => format_upid(&remote_upid.upid),
+                    }
+                } else {
+                    format_upid(&item.upid)
+                }
+                .into()
+            })
+            .into(),
+        DataTableColumn::new(tr!("Status"))
+            .width("200px")
+            .render(|item: &TaskListItem| {
+                let text = item.status.as_deref().unwrap_or("");
+                html! {text}
+            })
+            .into(),
+    ])
+}
+
+impl Component for PbsRemoteTaskList {
+    type Message = Option<(String, Option<i64>)>;
+    type Properties = RemoteTaskList;
+
+    fn create(_ctx: &yew::Context<Self>) -> Self {
+        Self {
+            columns: columns(),
+            upid: None,
+        }
+    }
+
+    fn update(&mut self, _ctx: &yew::Context<Self>, msg: Self::Message) -> bool {
+        self.upid = msg;
+        true
+    }
+
+    fn view(&self, ctx: &yew::Context<Self>) -> yew::Html {
+        let task = self
+            .upid
+            .as_ref()
+            .and_then(|(upid, endtime)| upid.parse::<RemoteUpid>().ok().map(|upid| (upid, endtime)))
+            .map(|(remote_upid, endtime)| {
+                // TODO PBS
+                let base_url = format!("/pve/remotes/{}/tasks", remote_upid.remote());
+                TaskViewer::new(remote_upid.to_string())
+                    .endtime(endtime)
+                    .base_url(base_url)
+                    .on_close({
+                        let link = ctx.link().clone();
+                        move |_| link.send_message(None)
+                    })
+            });
+        Column::new()
+            .class(FlexFit)
+            .with_child(
+                Tasks::new()
+                    .base_url("/remote-tasks/list")
+                    .on_show_task({
+                        let link = ctx.link().clone();
+                        move |(upid_str, endtime)| link.send_message(Some((upid_str, endtime)))
+                    })
+                    .columns(self.columns.clone()),
+            )
+            .with_optional_child(task)
+            .into()
+    }
+}
+
+impl From<RemoteTaskList> for VNode {
+    fn from(val: RemoteTaskList) -> Self {
+        let comp = VComp::new::<PbsRemoteTaskList>(Rc::new(val), None);
+        VNode::from(comp)
+    }
+}
-- 
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-01-20  9:30 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-20  9:29 [pdm-devel] [PATCH yew-comp/datacenter-manager] ui: implement remote task list Dominik Csapak
2025-01-20  9:29 ` [pdm-devel] [PATCH yew-comp 1/7] tasks: make date filter functional Dominik Csapak
2025-01-20 11:30   ` Thomas Lamprecht
2025-01-20 12:10     ` Dominik Csapak
2025-01-21  8:33       ` Thomas Lamprecht
2025-01-21  9:46         ` Dominik Csapak
2025-01-20  9:29 ` [pdm-devel] [PATCH yew-comp 2/7] tasks: load more tasks on end of list Dominik Csapak
2025-01-20 17:29   ` Thomas Lamprecht
2025-01-21  9:43     ` Dominik Csapak
2025-01-20  9:29 ` [pdm-devel] [PATCH yew-comp 3/7] utils: factor out task description into own function Dominik Csapak
2025-01-20 17:29   ` Thomas Lamprecht
2025-01-21  9:44     ` Dominik Csapak
2025-01-20  9:29 ` [pdm-devel] [PATCH yew-comp 4/7] running tasks: make TaskListItem renderer configurable Dominik Csapak
2025-01-20  9:29 ` [pdm-devel] [PATCH yew-comp 5/7] running tasks: make buttons configurable Dominik Csapak
2025-01-20  9:29 ` [pdm-devel] [PATCH yew-comp 6/7] tasks: make columns configurable Dominik Csapak
2025-01-20 17:37   ` Thomas Lamprecht
2025-01-20  9:29 ` [pdm-devel] [PATCH yew-comp 7/7] tasks: make the 'show task' action configurable Dominik Csapak
2025-01-20  9:29 ` [pdm-devel] [PATCH datacenter-manager 1/9] server: factor out task filters into `TaskFilters` type Dominik Csapak
2025-01-20 17:42   ` Thomas Lamprecht
2025-01-20  9:29 ` [pdm-devel] [PATCH datacenter-manager 2/9] server: task cache: skip remotes with errors on fetch Dominik Csapak
2025-01-20 17:45   ` Thomas Lamprecht
2025-01-21  8:29     ` Dietmar Maurer
2025-01-20  9:30 ` [pdm-devel] [PATCH datacenter-manager 3/9] server: task cache: add filter options Dominik Csapak
2025-01-20  9:30 ` [pdm-devel] [PATCH datacenter-manager 4/9] server: task cache: reverse task order Dominik Csapak
2025-01-20  9:30 ` [pdm-devel] [PATCH datacenter-manager 5/9] pdm-client: export PveUpid Dominik Csapak
2025-01-20  9:30 ` [pdm-devel] [PATCH datacenter-manager 6/9] ui: refactor RemoteConfigPanel into own module Dominik Csapak
2025-01-20  9:30 ` Dominik Csapak [this message]
2025-01-20  9:30 ` [pdm-devel] [PATCH datacenter-manager 8/9] ui: register pve tasks Dominik Csapak
2025-01-20  9:30 ` [pdm-devel] [PATCH datacenter-manager 9/9] ui: also show running remote tasks in 'running tasks' list Dominik Csapak
2025-01-20 11:27 ` [pdm-devel] applied: [PATCH yew-comp/datacenter-manager] ui: implement remote task list Dietmar Maurer
2025-01-20 11:34   ` Thomas Lamprecht
2025-01-21  8:41 ` [pdm-devel] " 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=20250120093006.927014-15-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal