From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 68A9E1FF0B7 for ; Mon, 30 Nov 2026 13:53:36 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id E30E521702; Mon, 30 Nov 2026 13:53:30 +0100 (CET) From: Dominik Csapak 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 Message-ID: <20261130125325.2392967-4-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261130125325.2392967-1-d.csapak@proxmox.com> References: <20261130125325.2392967-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.099 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_2 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_4 0.1 random spam to be learned in bayes RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 4WROHRBAOVHESKWLCOBDOCMTG3GYN5DF X-Message-ID-Hash: 4WROHRBAOVHESKWLCOBDOCMTG3GYN5DF X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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, } 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) -> Html { - let props = ctx.props(); - let url = xtermjs_url(&props.console_type, &props.node_name, props.vnc); + let url = xtermjs_url(ctx.props()); html! {