From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH proxmox-yew-comp v3 3/8] xtermjs: allow setting the noVNC scaling mode
Date: Mon, 30 Nov 2026 13:52:37 +0100 [thread overview]
Message-ID: <20261130125325.2392967-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261130125325.2392967-1-d.csapak@proxmox.com>
by adding a 'resize' property that is passed on to noVNC, like the web
interface of PVE does. If it is not set, noVNC uses its default.
To also use it when opening the console in its own window, add an
`open_viewer` method that does so for an existing `XTermJs`.
`open_xterm_js_viewer` keeps its parameters, so that its users do not
have to change.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/xtermjs.rs | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/src/xtermjs.rs b/src/xtermjs.rs
index fb91ded..d1329e1 100644
--- a/src/xtermjs.rs
+++ b/src/xtermjs.rs
@@ -30,6 +30,13 @@ pub struct XTermJs {
#[prop_or_default]
#[builder]
pub vnc: bool,
+
+ /// The scaling mode of noVNC ('scale', 'remote' or 'off'), if not set, noVNC uses its default.
+ ///
+ /// It is passed to noVNC as 'resize' parameter and has no effect for xterm.js.
+ #[prop_or_default]
+ #[builder(IntoPropValue, into_prop_value)]
+ pub resize: Option<AttrValue>,
}
impl Default for XTermJs {
@@ -47,7 +54,16 @@ impl XTermJs {
// FIXME: separate noVNC and xterm.js, this is not a nice interface!
/// Open a new terminal window.
pub fn open_xterm_js_viewer(console_type: ConsoleType, node_name: &str, vnc: bool) {
- let url = xtermjs_url(&console_type, node_name, vnc);
+ Self::new()
+ .console_type(console_type)
+ .node_name(node_name.to_string())
+ .vnc(vnc)
+ .open_viewer();
+ }
+
+ /// Open this terminal in a new window, instead of using it as panel.
+ pub fn open_viewer(&self) {
+ let url = xtermjs_url(self);
let target = "_blank";
let features =
"toolbar=no,location=no,status=no,menubar=no,resizable=yes,width=800,height=420";
@@ -78,19 +94,21 @@ pub enum ConsoleType {
RemotePveKVM(String, u64),
}
-fn xtermjs_url(console_type: &ConsoleType, node_name: &str, vnc: bool) -> String {
+fn xtermjs_url(props: &XTermJs) -> String {
let mut param = json!({
- "node": node_name,
+ "node": props.node_name.as_str(),
});
- if vnc {
+ if props.vnc {
param["novnc"] = 1.into();
- //param["resize"] = "scale".into();
+ if let Some(resize) = &props.resize {
+ param["resize"] = resize.as_str().into();
+ }
} else {
param["xtermjs"] = 1.into();
}
- match console_type {
+ match &props.console_type {
ConsoleType::KVM(vmid) => {
param["console"] = "kvm".into();
param["vmid"] = (*vmid).into();
@@ -146,8 +164,7 @@ impl Component for ProxmoxXTermJs {
}
fn view(&self, ctx: &Context<Self>) -> Html {
- let props = ctx.props();
- let url = xtermjs_url(&props.console_type, &props.node_name, props.vnc);
+ let url = xtermjs_url(ctx.props());
html! {<iframe class="pwt-flex-fit" src={format!("/{url}")}/>}
}
}
--
2.47.3
next prev parent reply other threads:[~2026-11-30 12:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 12:52 [PATCH datacenter-manager/proxmox-yew-comp/yew-widget-toolkit v3 0/8] ui: make the default dashboard configurable and add "My Settings" dialog Dominik Csapak
2026-11-30 12:52 ` [PATCH yew-widget-toolkit v3 1/8] state: event: add helper to dispatch custom DOM events Dominik Csapak
2026-11-30 12:52 ` [PATCH yew-widget-toolkit v3 2/8] state: persistent state: allow listening for updates Dominik Csapak
2026-11-30 12:52 ` Dominik Csapak [this message]
2026-11-30 12:52 ` [PATCH datacenter-manager v3 4/8] ui: view selector: use a placeholder that can't conflict with a view Dominik Csapak
2026-11-30 12:52 ` [PATCH datacenter-manager v3 5/8] ui: add 'My Settings' dialog with xterm.js and noVNC settings Dominik Csapak
2026-11-30 12:52 ` [PATCH datacenter-manager v3 6/8] ui: views: use the view name as key of the component Dominik Csapak
2026-11-30 12:52 ` [PATCH datacenter-manager v3 7/8] ui: make the default dashboard page configurable Dominik Csapak
2026-11-30 12:52 ` [PATCH datacenter-manager v3 8/8] docs: web ui: describe the 'My Settings' dialog Dominik Csapak
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=20261130125325.2392967-4-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox