public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pdm-devel] [PATCH datacenter-manager] remove 'per-node-template' from the weburl config
@ 2025-01-23 13:27 Dominik Csapak
  2025-01-25 17:01 ` [pdm-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2025-01-23 13:27 UTC (permalink / raw)
  To: pdm-devel

* remove the property from the struct
* remove the second edit field
* adapt url generation code

i left the 'node' parameter in the 'get_deep_url' since we'll want to
add it later again (does not hurt to not use it), but removed the option
from the config again, otherwise a user might set it and wonders why it
doesn't to anything.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 lib/pdm-api-types/src/remotes.rs |  4 ---
 ui/src/lib.rs                    | 50 +++++++++++++-------------------
 ui/src/remotes/edit_remote.rs    | 19 ------------
 3 files changed, 20 insertions(+), 53 deletions(-)

diff --git a/lib/pdm-api-types/src/remotes.rs b/lib/pdm-api-types/src/remotes.rs
index 01ee95a..76e42d9 100644
--- a/lib/pdm-api-types/src/remotes.rs
+++ b/lib/pdm-api-types/src/remotes.rs
@@ -44,10 +44,6 @@ pub struct WebUrl {
     /// A base URL for accessing the remote.
     #[serde(skip_serializing_if = "Option::is_none")]
     pub base_url: Option<String>,
-
-    /// A template for a per node URL. replaces {{nodename}} with the nodename.
-    #[serde(skip_serializing_if = "Option::is_none")]
-    pub per_node_template: Option<String>,
 }
 
 #[api]
diff --git a/ui/src/lib.rs b/ui/src/lib.rs
index cee7791..cf7b15e 100644
--- a/ui/src/lib.rs
+++ b/ui/src/lib.rs
@@ -82,7 +82,7 @@ pub(crate) fn get_remote<C: yew::Component>(
 pub(crate) fn get_deep_url<C: yew::Component>(
     link: &yew::html::Scope<C>,
     remote: &str,
-    node: Option<&str>,
+    _node: Option<&str>,
     id: &str,
 ) -> Option<web_sys::Url> {
     let remote = get_remote(link, remote)?;
@@ -91,37 +91,27 @@ pub(crate) fn get_deep_url<C: yew::Component>(
         (id, pdm_api_types::remotes::RemoteType::Pve) => format!("v1::={id}"),
         (id, pdm_api_types::remotes::RemoteType::Pbs) => format!("DataStore-{id}"),
     };
+    let url = remote
+        .web_url
+        .as_deref()
+        .and_then(|web_url| web_url.base_url.as_deref())
+        .and_then(|url| web_sys::Url::new(url).ok())
+        .or_else(|| {
+            let node = remote.nodes.first()?;
+            let url = web_sys::Url::new(&format!("https://{}/", node.hostname));
+            url.ok().inspect(|url| {
+                if url.port() == "" {
+                    let default_port = match remote.ty {
+                        pdm_api_types::remotes::RemoteType::Pve => "8006",
+                        pdm_api_types::remotes::RemoteType::Pbs => "8007",
+                    };
+                    url.set_port(default_port);
+                }
+            })
+        });
 
-    let url = match remote.web_url {
-        Some(web_url) => match (web_url.per_node_template.as_deref(), node) {
-            (Some(template), Some(node)) => {
-                web_sys::Url::new(&template.replace("{{nodename}}", node)).ok()
-            }
-            _ => web_url
-                .base_url
-                .as_ref()
-                .map(|url| web_sys::Url::new(url).ok())
-                .flatten(),
-        },
-        None => None,
-    }
-    .or_else(|| {
-        let node = remote.nodes.first()?;
-        let url = web_sys::Url::new(&format!("https://{}/", node.hostname));
-        url.ok().map(|url| {
-            if url.port() == "" {
-                let default_port = match remote.ty {
-                    pdm_api_types::remotes::RemoteType::Pve => "8006",
-                    pdm_api_types::remotes::RemoteType::Pbs => "8007",
-                };
-                url.set_port(default_port);
-            }
-            url
-        })
-    });
-    url.map(|url| {
+    url.inspect(|url| {
         url.set_hash(&hash);
-        url
     })
 }
 
diff --git a/ui/src/remotes/edit_remote.rs b/ui/src/remotes/edit_remote.rs
index 3c98fa1..d9c0e6f 100644
--- a/ui/src/remotes/edit_remote.rs
+++ b/ui/src/remotes/edit_remote.rs
@@ -123,25 +123,6 @@ fn edit_remote_input_panel(_form_ctx: &FormContext, remote_id: &str) -> Html {
                 .name("_web-url_base-url")
                 .placeholder(tr!("Use first endpoint.")),
         )
-        .with_field(
-            tr!("per Node URL template"),
-            Field::new()
-                .name("_web-url_per-node-template")
-                .placeholder(tr!("Same as Web Base URL.")),
-        )
-        .with_custom_child(
-            Row::new()
-                .key("hint-text")
-                .gap(2)
-                .with_child(Container::new().with_child(tr!(
-                    "Possible template values for 'per Node URL template' are:"
-                )))
-                .with_child(
-                    Container::new()
-                        .style("font-family", "monospace")
-                        .with_child("{{nodename}}"),
-                ),
-        )
         .with_custom_child(
             Container::new()
                 .key("nodes-title")
-- 
2.39.5



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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pdm-devel] applied: [PATCH datacenter-manager] remove 'per-node-template' from the weburl config
  2025-01-23 13:27 [pdm-devel] [PATCH datacenter-manager] remove 'per-node-template' from the weburl config Dominik Csapak
@ 2025-01-25 17:01 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2025-01-25 17:01 UTC (permalink / raw)
  To: Proxmox Datacenter Manager development discussion, Dominik Csapak

Am 23.01.25 um 14:27 schrieb Dominik Csapak:
> * remove the property from the struct
> * remove the second edit field
> * adapt url generation code
> 
> i left the 'node' parameter in the 'get_deep_url' since we'll want to
> add it later again (does not hurt to not use it), but removed the option
> from the config again, otherwise a user might set it and wonders why it
> doesn't to anything.

yeah, not sure about the config layout (now or final) for this, but it's
fine enough for now I think.

> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  lib/pdm-api-types/src/remotes.rs |  4 ---
>  ui/src/lib.rs                    | 50 +++++++++++++-------------------
>  ui/src/remotes/edit_remote.rs    | 19 ------------
>  3 files changed, 20 insertions(+), 53 deletions(-)
> 
>

applied, thanks!


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-25 17:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-23 13:27 [pdm-devel] [PATCH datacenter-manager] remove 'per-node-template' from the weburl config Dominik Csapak
2025-01-25 17:01 ` [pdm-devel] applied: " Thomas Lamprecht

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