From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 06A941FF137 for ; Tue, 31 Mar 2026 14:55:13 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 790FF1CF7D; Tue, 31 Mar 2026 14:55:40 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 31 Mar 2026 14:55:33 +0200 Message-Id: Subject: Re: [PATCH yew-comp 1/3] task (viewer): add task download button To: "Dominik Csapak" , "Maximiliano Sandoval" X-Mailer: aerc 0.20.0 References: <20260330125320.507302-1-d.csapak@proxmox.com> <20260330125320.507302-2-d.csapak@proxmox.com> <5cb3e221-fb33-493a-bdf5-1f8582492abb@proxmox.com> <5a9cab9e-c636-4a24-8dbc-0758c83e9aed@proxmox.com> In-Reply-To: <5a9cab9e-c636-4a24-8dbc-0758c83e9aed@proxmox.com> From: "Shannon Sterz" X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774961677459 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.375 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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: N324RT3DOSUG7NNVMJ4LGCTFA4LQAMTF X-Message-ID-Hash: N324RT3DOSUG7NNVMJ4LGCTFA4LQAMTF X-MailFrom: s.sterz@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 CC: yew-devel@lists.proxmox.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Yew framework devel list at Proxmox List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue Mar 31, 2026 at 2:14 PM CEST, Dominik Csapak wrote: > > > On 3/31/26 2:05 PM, Dominik Csapak wrote: >> >> >> On 3/31/26 1:13 PM, Maximiliano Sandoval wrote: >>> Dominik Csapak writes: >>> >>>> similar to what we already have in the ExtJS gui. Currently the defaul= t >>>> is to construct a data URL from the downloaded json in the UI, since n= ot >>>> all APIs support the 'download=3D1' parameter (and some can't be easil= y >>>> extended). >>>> >>>> The download api can be enabled with a setting though, so if at some >>>> point all consumers use that, we can drop the compatibility code path. >>>> >>>> Adds also a small helper to create a temporary 'a' element to click. >>>> >>>> Signed-off-by: Dominik Csapak >>>> --- >>>> Longer explanation which api calls do not support the 'download' >>>> parameter: on PDM, we tunnel the api call to the remote, but this is >>>> autogenerated code that expects json output. With the 'download' >>>> parameter, the content type gets set to text/plain, which confuses the >>>> client. >>>> >>>> To fix it, we'd either have to rewrite the auto-code generation to >>>> handle this case, or expose the underlying client and doit manually, o= r >>>> rewrite the remote task api call to to something similar what we do he= re >>>> in the ui, collecting json output and returning a final log txt file. >>>> >>>> Since having this download button is useful anyway, and implementing a= ny >>>> of these solutions would take way longer than doing this here, I opted >>>> for doing that now, and fixing the backend later. >>>> >>>> =C2=A0 src/lib.rs=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2= =A0 21 ++++++++ >>>> =C2=A0 src/log_view.rs=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 7 +-- >>>> =C2=A0 src/task_viewer.rs | 118 ++++++++++++++++++++++++++++++++++++++= +++---- >>>> =C2=A0 src/tasks.rs=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 = 6 +++ >>>> =C2=A0 4 files changed, 140 insertions(+), 12 deletions(-) >>>> >>>> diff --git a/src/lib.rs b/src/lib.rs >>>> index 62aa571..65dae68 100644 >>>> --- a/src/lib.rs >>>> +++ b/src/lib.rs >>>> @@ -234,6 +234,8 @@ pub mod utils; >>>> =C2=A0 mod xtermjs; >>>> =C2=A0 pub use xtermjs::{ConsoleType, ProxmoxXTermJs, XTermJs}; >>>> +use anyhow::{format_err, Error}; >>>> + >>>> =C2=A0 use pwt::gettext_noop; >>>> =C2=A0 use pwt::state::{LanguageInfo, TextDirection}; >>>> @@ -271,6 +273,25 @@ mod panic_wrapper { >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >>>> =C2=A0 } >>>> +/// Helper to download the given 'source' url via a simulated click >>>> on a hidden 'a' element. >>>> +pub fn download_as_file(source: &str, file_name: &str) -> Result<(), >>>> Error> { >>>> +=C2=A0=C2=A0=C2=A0 let el =3D gloo_utils::document() >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .create_element("a") >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .map_err(|_| format_err!("= unable to create element 'a'"))?; >>>> +=C2=A0=C2=A0=C2=A0 let html =3D el >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .dyn_into::() >>> >>> Is it possible a `use wasm_bindgen::JsCast;` >>> >>> is missing in this function or file? This does not compile. >>> >> >> yes that's possible. Not sure why, when I compile pdm with this as path >> dep override, it compiles with no issues, but a 'make deb' fails >> here... >> > > > ah found it, we do: > > --- > #[cfg(target_arch =3D "wasm32")] > use wasm_bindgen::{self, prelude::*}; > --- > > which imports this for wasm32 only and a 'make deb' seemingly builds for > x86 during the tests > > short term solution is to remove the 'cfg(target_arch)' line, but the > 'real' fix would probably for cargo to build for the correct arch here > (not sure if that can be configured somehow) adding: ``` [build] target =3D "wasm32-unknown-unknown" ``` to `.cargo/config.toml` might be what you are looking for :)