From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager] remove 'per-node-template' from the weburl config
Date: Thu, 23 Jan 2025 14:27:54 +0100 [thread overview]
Message-ID: <20250123132754.3271555-1-d.csapak@proxmox.com> (raw)
* 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
next reply other threads:[~2025-01-23 13:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-23 13:27 Dominik Csapak [this message]
2025-01-25 17:01 ` [pdm-devel] applied: " Thomas Lamprecht
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=20250123132754.3271555-1-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.