public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Lukas Wagner <l.wagner@proxmox.com>,
	Proxmox Datacenter Manager development discussion
	<pdm-devel@lists.proxmox.com>
Subject: Re: [pdm-devel] [PATCH proxmox-yew-comp 2/2] task descriptions: add PBS task descriptions
Date: Thu, 18 Dec 2025 14:24:23 +0100	[thread overview]
Message-ID: <1c14b3ca-d1ad-4cf7-b8d5-ef22f95c42b3@proxmox.com> (raw)
In-Reply-To: <DF1D2LJO2KTC.29VH1XGPX988M@proxmox.com>



On 12/18/25 2:02 PM, Lukas Wagner wrote:
> On Thu Dec 18, 2025 at 1:19 PM CET, Dominik Csapak wrote:
>> Looks mostly good to me, some comments inline
>>
>>
>> On 12/18/25 10:51 AM, Lukas Wagner wrote:
>>> Tried to make these match the JS ones as closely as possible. Some of
>>> these could be improved in the future, but this should then be done in
>>> tandem with the JS definitions.
>>>
>>> Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
>>> ---
>>>    src/utils/task_descriptions.rs | 186 +++++++++++++++++++++++++++++++++
>>>    1 file changed, 186 insertions(+)
>>>
>>> diff --git a/src/utils/task_descriptions.rs b/src/utils/task_descriptions.rs
>>> index 86525a4..caeb563 100644
>>> --- a/src/utils/task_descriptions.rs
>>> +++ b/src/utils/task_descriptions.rs
>>> @@ -212,3 +212,189 @@ pub fn register_pve_tasks() {
>>>        register_task_description("zfscreate", (tr!("ZFS Storage"), tr!("Create")));
>>>        register_task_description("zfsremove", ("ZFS Pool", tr!("Remove")));
>>>    }
>>> +
>>> +/// Register PBS task descriptions.
>>> +pub fn register_pbs_tasks() {
>>> +    register_task_description("acme-deativate", |_ty, id: Option<String>| {
>>> +        let id = id.unwrap_or_else(|| "default".to_string());
>>> +        tr!("Deactivate ACME Account - {0}", id)
>>> +    });
>>> +    register_task_description("acme-register", |_ty, id: Option<String>| {
>>> +        let id = id.unwrap_or_else(|| "default".to_string());
>>> +        tr!("Register ACME Account - {0}", id)
>>> +    });
>>> +    register_task_description("acme-update", |_ty, id: Option<String>| {
>>> +        let id = id.unwrap_or_else(|| "default".to_string());
>>> +        tr!("Update ACME Account - {0}", id)
>>> +    });
>>> +    register_task_description("acme-new-cert", ("", tr!("Order Certificate")));
>>> +    register_task_description("acme-renew-cert", ("", tr!("Renew Certificate")));
>>> +    register_task_description("acme-revoke-cert", ("", tr!("Revoke Certificate")));
>>> +    register_task_description("backup", |_ty, id: Option<String>| {
>>> +        render_datastore_worker_id(id, &tr!("Backup"))
>>> +    });
>>> +    register_task_description(
>>> +        "barcode-label-media",
>>> +        (tr!("Drive"), tr!("Barcode-Label Media")),
>>> +    );
>>> +    register_task_description("catalog-media", (tr!("Drive"), tr!("Catalog Media")));
>>> +    register_task_description(
>>> +        "create-datastore",
>>> +        (tr!("Datastore"), tr!("Create Datastore")),
>>> +    );
>>> +    register_task_description(
>>> +        "delete-datastore",
>>> +        (tr!("Datastore"), tr!("Remove Datastore")),
>>> +    );
>>> +    register_task_description(
>>> +        "delete-namespace",
>>> +        (tr!("Namespace"), tr!("Remove Namespace")),
>>> +    );
>>> +    register_task_description("dircreate", (tr!("Directory Storage"), tr!("Create")));
>>> +    register_task_description("dirremove", (tr!("Directory Storage"), tr!("Remove")));
>>> +    register_task_description("eject-media", (tr!("Drive"), tr!("Eject Media")));
>>> +    register_task_description("format-media", (tr!("Drive"), tr!("Format Media")));
>>> +    register_task_description("forget-group", (tr!("Group"), tr!("Remove Group")));
>>> +    register_task_description(
>>> +        "garbage_collection",
>>> +        (tr!("Datastore"), tr!("Garbage Collect")),
>>> +    );
>>> +    register_task_description("realm-sync", ("Realm", tr!("User Sync")));
>>> +    register_task_description("inventory-update", (tr!("Drive"), tr!("Inventory Update")));
>>> +    register_task_description("label-media", (tr!("Drive"), tr!("Label Media")));
>>> +    register_task_description("load-media", |_ty, id: Option<String>| {
>>> +        render_drive_load_media_id(&id.unwrap_or_default(), &tr!("Load Media"))
>>> +    });
>>> +    register_task_description("logrotate", tr!("Log Rotation"));
>>> +    register_task_description("mount-device", (tr!("Datastore"), tr!("Mount Device")));
>>> +    register_task_description(
>>> +        "mount-sync-jobs",
>>> +        (
>>> +            tr!("Datastore"),
>>> +            tr!("sync jobs handler triggered by mount"),
>>> +        ),
>>> +    );
>>> +    register_task_description("prune", |_ty, id: Option<String>| {
>>> +        render_datastore_worker_id(id, &tr!("Prune"))
>>> +    });
>>> +    register_task_description("prunejob", |_ty, id: Option<String>| {
>>> +        render_prune_job_worker_id(id, &tr!("Prune Job"))
>>> +    });
>>> +    register_task_description("reader", |_ty, id: Option<String>| {
>>> +        render_datastore_worker_id(id, &tr!("Read Objects"))
>>> +    });
>>> +    register_task_description("rewind-media", (tr!("Drive"), tr!("Rewind Media")));
>>> +    register_task_description("s3-refresh", (tr!("Datastore"), tr!("S3 Refresh")));
>>> +    register_task_description("sync", (tr!("Datastore"), tr!("Remote Sync")));
>>> +    register_task_description("syncjob", (tr!("Sync Job"), tr!("Remote Sync")));
>>> +    register_task_description("tape-backup", |_ty, id: Option<String>| {
>>> +        render_tape_backup_id(id, &tr!("Tape Backup"))
>>> +    });
>>> +    register_task_description("tape-backup-job", |_ty, id: Option<String>| {
>>> +        render_tape_backup_id(id, &tr!("Tape Backup Job"))
>>> +    });
>>> +    register_task_description("tape-restore", (tr!("Datastore"), tr!("Tape Restore")));
>>> +    register_task_description("unload-media", (tr!("Drive"), tr!("Unload Media")));
>>> +    register_task_description("unmount-device", (tr!("Datastore"), tr!("Unmount Device")));
>>> +    register_task_description(
>>> +        "verificationjob",
>>> +        (tr!("Verify Job"), tr!("Scheduled Verification")),
>>> +    );
>>> +    register_task_description("verify", (tr!("Datastore"), tr!("Verification")));
>>> +    register_task_description("verify_group", (tr!("Group"), tr!("Verification")));
>>> +    register_task_description("verify_snapshot", (tr!("Snapshot"), tr!("Verification")));
>>> +    register_task_description("wipedisk", (tr!("Device"), tr!("Wipe Disk")));
>>> +    register_task_description("zfscreate", (tr!("ZFS Storage"), tr!("Create")));
>>> +}
>>> +
>>> +proxmox_schema::const_regex! {
>>> +    DATASTORE_WORKER_ID_REGEX = r"^(\S+?):(\S+?)/(\S+?)(/(.+))?$";
>>> +}
>>> +
>>> +fn render_datastore_worker_id(id: Option<String>, what: &str) -> String {
>>> +    let id = id.as_deref().unwrap_or("unknown");
>>> +
>>> +    if let Some(cap) = DATASTORE_WORKER_ID_REGEX.captures(id) {
>>> +        let datastore = cap.get(1).map(|m| m.as_str());
>>> +        let res2 = cap.get(2).map(|m| m.as_str());
>>> +        let res3 = cap.get(3).map(|m| m.as_str());
>>> +        let epoch = cap.get(5).map(|m| m.as_str());
>>> +
>>> +        if let (Some(datastore), Some(res2), Some(res3), Some(epoch)) =
>>> +            (datastore, res2, res3, epoch)
>>> +        {
>>> +            if let Ok(epoch) = i64::from_str_radix(epoch, 16) {
>>> +                let utctime = proxmox_time::epoch_to_rfc3339_utc(epoch).unwrap_or_default();
>>> +                return format!(
>>> +                    "{} {} {} {}/{} {}",
>>> +                    tr!("Datastore"),
>>> +                    datastore,
>>> +                    what,
>>> +                    res2,
>>> +                    res3,
>>> +                    utctime
>>> +                );
>>> +            }
>>> +        }
>>> +    }
>>> +
>>> +    format!("{} {} {}", tr!("Datastore"), id, what)
>>> +}
>>
>> this implementation differs a bit from the js one.
>> if the regex matches but the epoch is `None` we render
>>
>> 'Datastore id what' instead of
>> 'Datastore id what backupgroup'
>>
>>
>>
> 
> Ack, thanks!
> 
>>> +
>>> +proxmox_schema::const_regex! {
>>> +    PRUNE_JOB_WORKER_ID_REGEX = r"^(\S+?):(\S+)$";
>>> +}
>>> +
>>> +fn render_prune_job_worker_id(id: Option<String>, what: &str) -> String {
>>> +    let id = id.as_deref().unwrap_or("unknown");
>>> +
>>> +    if let Some(cap) = PRUNE_JOB_WORKER_ID_REGEX.captures(id) {
>>> +        let datastore = cap.get(1).map(|m| m.as_str());
>>> +        let namespace = cap.get(2).map(|m| m.as_str());
>>> +
>>> +        if let (Some(datastore), Some(namespace)) = (datastore, namespace) {
>>> +            return format!(
>>> +                "{} on {} {} {}  {}",
>>> +                what,
>>> +                tr! {"Datastore"},
>>> +                datastore,
>>> +                tr!("Namespace"),
>>> +                namespace
>>> +            );
>>> +        }
>>> +    }
>>> +    return format!("{} on {} {}", what, tr! {"Datastore"}, id);
>>> +}
> 
> As a reference for my comment down below, the JS version is
> 
>      render_prune_job_worker_id: function (id, what) {
>          const res = id.match(/^(\S+?):(\S+)$/);
>          if (!res) {
>              return `${what} on Datastore ${id}`;
>          }
>          let datastore = res[1],
>              namespace = res[2];
>          return `${what} on Datastore ${datastore} Namespace  ${namespace}`;
>      },
> 
> 
>>> +
>>> +proxmox_schema::const_regex! {
>>> +    TAPE_WORKER_ID_REGEX = r"^(\S+?):(\S+?):(\S+?)(:(.+))?$";
>>> +}
>>> +
>>> +fn render_tape_backup_id(id: Option<String>, what: &str) -> String {
>>> +    let id = id.as_deref().unwrap_or("unknown");
>>> +
>>> +    if let Some(cap) = TAPE_WORKER_ID_REGEX.captures(id) {
>>> +        let datastore = cap.get(1).map(|m| m.as_str());
>>> +        let pool = cap.get(2).map(|m| m.as_str());
>>> +        let drive = cap.get(3).map(|m| m.as_str());
>>> +
>>> +        if let (Some(datastore), Some(pool), Some(drive)) = (datastore, pool, drive) {
>>> +            return format!("{} {} (pool {}, drive {})", what, datastore, pool, drive);
>>> +        }
>>> +    }
>>> +    format!("{} {}", what, id)
>>
>>
>> this is also a bit different:
>>
>> on pbs we format them as
>>
>> '{what} on Datastore {datastore} Namespace {namespace}'
>>
> 
> The JS-impl is
> 
>      render_tape_backup_id: function (id, what) {
>          const res = id.match(/^(\S+?):(\S+?):(\S+?)(:(.+))?$/);
>          if (res) {
>              let datastore = res[1];
>              let pool = res[2];
>              let drive = res[3];
>              return `${what} ${datastore} (pool ${pool}, drive ${drive})`;
>          }
>          return `${what} ${id}`;
>      },
> 
> 
> so I think my version should be correct?
> 
> 
> Did you mean the formatting for the prune job?
> I also double checked this one, seems correct to me.
> Keep in mind that the logic is inverted in the JS code.
> 
> But maybe I'm missing something :)
> 

yeah, i looked in the wrong place when trying to find which function it
was to compare... oops and sorry for the noise

> 
>>> +}
>>> +
>>> +proxmox_schema::const_regex! {
>>> +    DRIVE_LOAD_WORKER_ID_REGEX = r"^(\S+?):(\S+?)$";
>>> +}
>>> +
>>> +fn render_drive_load_media_id(id: &str, what: &str) -> String {
>>> +    if let Some(caps) = DRIVE_LOAD_WORKER_ID_REGEX.captures(id) {
>>> +        let drive = &caps[1];
>>> +        let label = &caps[2];
>>> +        return format!("{} {drive} - {what} '{label}'", tr!("Drive"));
>>> +    }
>>> +
>>> +    format!("{what} {id}")
>>> +}
> 



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


  reply	other threads:[~2025-12-18 13:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-18  9:51 [pdm-devel] [PATCH datacenter-manager/proxmox-yew-comp 0/4] move task description table to yew-comp Lukas Wagner
2025-12-18  9:51 ` [pdm-devel] [PATCH proxmox-yew-comp 1/2] utils: move task descriptions to a submodule Lukas Wagner
2025-12-18 11:49   ` Dominik Csapak
2025-12-18 12:05     ` Lukas Wagner
2025-12-18  9:51 ` [pdm-devel] [PATCH proxmox-yew-comp 2/2] task descriptions: add PBS task descriptions Lukas Wagner
2025-12-18 12:19   ` Dominik Csapak
2025-12-18 13:02     ` Lukas Wagner
2025-12-18 13:24       ` Dominik Csapak [this message]
2025-12-18  9:51 ` [pdm-devel] [PATCH datacenter-manager 1/2] ui: register task descriptions for some native PDM tasks Lukas Wagner
2025-12-18  9:51 ` [pdm-devel] [PATCH datacenter-manager 2/2] ui: use task descriptions from yew-comp for PBS and PVE Lukas Wagner
2025-12-18 12:19 ` [pdm-devel] superseded: [PATCH datacenter-manager/proxmox-yew-comp 0/4] move task description table to yew-comp 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=1c14b3ca-d1ad-4cf7-b8d5-ef22f95c42b3@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=l.wagner@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