From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 192361FF137 for ; Tue, 31 Mar 2026 09:39:25 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 572451179E; Tue, 31 Mar 2026 09:39:52 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 31 Mar 2026 09:39:46 +0200 Subject: Re: [PATCH yew-comp 1/3] task (viewer): add task download button To: "Dominik Csapak" Message-Id: X-Mailer: aerc 0.20.0 References: <20260330125320.507302-1-d.csapak@proxmox.com> <20260330125320.507302-2-d.csapak@proxmox.com> <66064577-9ace-4443-b9bc-cb1a70a68043@proxmox.com> <059e96c0-1b42-4c94-979a-6dfcf6ff5860@proxmox.com> <6e6fa075-2b27-4635-8fcf-ebdcdfdad3d8@proxmox.com> In-Reply-To: <6e6fa075-2b27-4635-8fcf-ebdcdfdad3d8@proxmox.com> From: "Shannon Sterz" X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774942731439 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.377 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: CFUGA7CQWQAJRLZLIW7WKSOEUVOAREEH X-Message-ID-Hash: CFUGA7CQWQAJRLZLIW7WKSOEUVOAREEH 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 Mon Mar 30, 2026 at 4:44 PM CEST, Dominik Csapak wrote: > > > On 3/30/26 4:39 PM, Shannon Sterz wrote: >> On Mon Mar 30, 2026 at 4:23 PM CEST, Dominik Csapak wrote: >>> >>> >>> On 3/30/26 4:17 PM, Shannon Sterz wrote: >>>> On Mon Mar 30, 2026 at 3:48 PM CEST, Dominik Csapak wrote: >>>>> >>>>> >>>>> On 3/30/26 3:35 PM, Shannon Sterz wrote: >>>>>> On Mon Mar 30, 2026 at 2:53 PM CEST, Dominik Csapak wrote: >>>>> [snip] >>>>>>> @@ -273,18 +297,94 @@ impl PwtTaskViewer { >>>>>>> let active =3D self.active; >>>>>>> let link =3D ctx.link(); >>>>>>> >>>>>>> - let toolbar =3D Toolbar::new().class("pwt-border-bottom").= with_child( >>>>>>> - Button::new(tr!("Stop")) >>>>>>> - .disabled(!active) >>>>>>> - .onclick(link.callback(|_| Msg::StopTask)), >>>>>>> - ); >>>>>>> - >>>>>>> let url =3D format!( >>>>>>> "{}/{}/log", >>>>>>> props.base_url, >>>>>>> percent_encode_component(&task_id), >>>>>>> ); >>>>>>> >>>>>>> + let filename =3D match props.task_id.parse::(= ) { >>>>>>> + Ok(upid) =3D> { >>>>>>> + format!( >>>>>>> + "task-{}-{}-{}.log", >>>>>>> + upid.node, >>>>>>> + upid.worker_type, >>>>>>> + epoch_to_rfc3339_utc(upid.starttime).unwrap_or= (upid.starttime.to_string()) >>>>>>> + ) >>>>>>> + } >>>>>>> + Err(_) =3D> format!("task-{}.log", props.task_id), >>>>>>> + }; >>>>>>> + >>>>>>> + let download_btn: Html =3D if props.download_api { >>>>>>> + Container::from_tag("a") >>>>>>> + .attribute("disabled", active.then_some("")) >>>>>>> + .attribute("target", "_blank") >>>>>>> + .attribute("href", format!("/api2/extjs{url}?downl= oad=3D1")) >>>>>>> + .attribute("filename", filename) >>>>>>> + .with_child( >>>>>>> + Button::new(tr!("Download")) >>>>>>> + .disabled(active) >>>>>>> + .icon_class("fa fa-download"), >>>>>>> + ) >>>>>>> + .into() >>>>>> >>>>>> is there a reason you construct a new `` element as a container h= ere >>>>>> instead of using the `download_as_file` helper in an `on_activate` >>>>>> callback for the button? >>>>>> >>>>> >>>>> if we have a static link, there is no need to create an 'a' element >>>>> on the fly and clicking it programmatically. Since browsers use >>>>> heuristics to detect 'user-initiated' actions to determine if things >>>>> are allowed (e.g. auto-clicking on links) such helpers should be used >>>>> sparingly. >>>>> >>>>> a static link is better expressed with native browser methods such as >>>>> an a element that the user clicks. (the button inside is just for >>>>> cosmetics in this case) >>>>> >>>>> e.g. if one would send a message in on_activate and call the helper i= n >>>>> the update method, this might not work as intended since the browser >>>>> can't detect that it was user-initiated. >>>> >>>> you could just call the helper directly instead of going through a >>>> message though, no? however, im not sure if that is picked up as >>>> user-initiated in all browsers either. >>>> >>>>> so my intent was to only use it when absolutely necessary. >>>>> >>>>> it's also what we do in PDM to download the report (though there we >>>>> use a data url) >>>>> >>>>> the idea here was also that once all task log endpoints support the >>>>> download api parameter, we can remove the button below again, >>>>> and the helper too. >>>>> >>>>> do you see any advantage with using the helper in the first case too? >>>> >>>> my thinking was mostly about being able to re-use certain code paths >>>> here. >>>> >>>> more importantly, though, from what i can tell the html 5 spec does no= t >>>> allow interactive elements, like