* [pmg-devel] [RFC pmg-yew-quarantine-gui 0/2] fix direct actions from spamreport links
@ 2025-10-28 16:36 Stoiko Ivanov
2025-10-28 16:36 ` [pmg-devel] [RFC pmg-yew-quarantine-gui 1/2] buildsys: initialize pwt-assets as submodule automatically Stoiko Ivanov
2025-10-28 16:36 ` [pmg-devel] [RFC pmg-yew-quarantine-gui 2/2] main view: handle optional quarantine action in spamreport links Stoiko Ivanov
0 siblings, 2 replies; 5+ messages in thread
From: Stoiko Ivanov @ 2025-10-28 16:36 UTC (permalink / raw)
To: pmg-devel
Patch 1/2 is idependent, and was added last time I tested the changes for
the disabled realm-selector (as it took me a while to figure out why my
build was failing.
Patch 2/2 is an attempt at handling the links we have in the html-version
of the verbose spamreport - where each quarantined mail has 4 links
(delete, deliver, blocklist, welcomelist) - they are currently not working
as reported in our community forum.
Sending as RFC, as it's my first stab at Yew - and as my tests had a few
glitches (POST requests with 401 responses) - so it's quite easily
possible the approach is wrong.
Feedback very much welcome!
Stoiko Ivanov (2):
buildsys: initialize pwt-assets as submodule automatically
main view: handle optional quarantine action in spamreport links
Makefile | 5 ++++-
src/main.rs | 28 +++++++++++++++++++++++++++-
2 files changed, 31 insertions(+), 2 deletions(-)
--
2.47.3
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pmg-devel] [RFC pmg-yew-quarantine-gui 1/2] buildsys: initialize pwt-assets as submodule automatically
2025-10-28 16:36 [pmg-devel] [RFC pmg-yew-quarantine-gui 0/2] fix direct actions from spamreport links Stoiko Ivanov
@ 2025-10-28 16:36 ` Stoiko Ivanov
2025-10-29 8:59 ` Dominik Csapak
2025-10-28 16:36 ` [pmg-devel] [RFC pmg-yew-quarantine-gui 2/2] main view: handle optional quarantine action in spamreport links Stoiko Ivanov
1 sibling, 1 reply; 5+ messages in thread
From: Stoiko Ivanov @ 2025-10-28 16:36 UTC (permalink / raw)
To: pmg-devel
The error-message for the missing submodule and prerequisite is clear,
but due to parallel make - it gets printed, before the rustc output -
and is thus not visible when the build fails.
inspired by our zfsonlinux git:
63bd3935c (ensure submodule gets initialized on fresh clone and build).
but instead of letting BUILDDIR depend on pwt-assets/README.md it
depends on the PHONY target (as this will evaluated anyways - and
short-circuit if the README.md exists)
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
Makefile | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index fdf046c..72937c0 100644
--- a/Makefile
+++ b/Makefile
@@ -66,8 +66,11 @@ install: $(COMPILED_OUTPUT) pmg-mobile-index.html.tt
install -m0644 dist/mobile-yew-style.css $(DESTDIR)$(UIDIR)/css
install -m0644 pmg-mobile-index.html.tt $(DESTDIR)$(UIDIR)
+.PHONY: submodule
+submodule:
+ test -f "pwt-assets/README.md" || git submodule update --init
-$(BUILDDIR):
+$(BUILDDIR): submodule
rm -rf $@ $@.tmp
mkdir -p $@.tmp
cp -a debian/ src/ pwt-assets/ images/ pmg-mobile-index.html.tt Makefile Cargo.toml $@.tmp
--
2.47.3
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pmg-devel] [RFC pmg-yew-quarantine-gui 2/2] main view: handle optional quarantine action in spamreport links
2025-10-28 16:36 [pmg-devel] [RFC pmg-yew-quarantine-gui 0/2] fix direct actions from spamreport links Stoiko Ivanov
2025-10-28 16:36 ` [pmg-devel] [RFC pmg-yew-quarantine-gui 1/2] buildsys: initialize pwt-assets as submodule automatically Stoiko Ivanov
@ 2025-10-28 16:36 ` Stoiko Ivanov
2025-10-29 9:09 ` Dominik Csapak
1 sibling, 1 reply; 5+ messages in thread
From: Stoiko Ivanov @ 2025-10-28 16:36 UTC (permalink / raw)
To: pmg-devel
Our html verbose spamreports have included links for each possible
action for each mail (delete, deliver, blocklist, welcomelist) in the
action GET parameter. Currently the yew-based mobile view does not
handle those actions.
This patch adds the functionality by issueing a POST request in the
view function if the a cselect (id) and action parameter are present.
I tried adding the same call to the update function, but it seems the
update function does not get the query-string after a login, or was not
called in my tests.
Big thanks to Dominik for walking me through our yew framework and
providing other valuable suggestions!
Reported in our community forum:
https://forum.proxmox.com/threads/.174685/
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
src/main.rs | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/src/main.rs b/src/main.rs
index 8cd8a6b..366cdc7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,7 @@
mod spam_list;
+use std::str::FromStr;
+
pub use spam_list::SpamList;
mod page_mail_view;
@@ -14,7 +16,7 @@ pub use page_not_found::PageNotFound;
mod page_login;
pub use page_login::PageLogin;
-use anyhow::Error;
+use anyhow::{format_err, Error};
use gloo_utils::{document, format::JsValueSerdeExt};
use serde::Deserialize;
use serde_json::{json, Value};
@@ -114,6 +116,15 @@ impl Component for PmgQuarantineApp {
let logged_in = self.login_info.is_some();
MaterialApp::new(move |path: &str| {
if logged_in {
+ let document = document();
+ let location = document.location().unwrap();
+ let search = location.search().unwrap();
+ let param = web_sys::UrlSearchParams::new_with_str(&search).unwrap();
+ if let (Some(id), Some(action)) = (param.get("cselect"), param.get("action")) {
+ wasm_bindgen_futures::spawn_local(async move {
+ _ = mail_action(&id, MailAction::from_str(&action).unwrap()).await
+ });
+ }
switch(path)
} else {
vec![PageLogin::new().on_login(link.callback(Msg::Login)).into()]
@@ -187,6 +198,21 @@ impl std::fmt::Display for MailAction {
}
}
+impl std::str::FromStr for MailAction {
+ type Err = anyhow::Error;
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
+ match s {
+ "deliver" => Ok(MailAction::Deliver),
+ "delete" => Ok(MailAction::Delete),
+ "welcomelist" => Ok(MailAction::Welcomelist),
+ "whitelist" => Ok(MailAction::Welcomelist),
+ "blocklist" => Ok(MailAction::Blocklist),
+ "blacklist" => Ok(MailAction::Blocklist),
+ _ => Err(format_err!("unknown quarantine action")),
+ }
+ }
+}
+
pub(crate) async fn mail_action(id: &str, action: MailAction) -> Result<Value, Error> {
let param = json!({
"action": action.to_string(),
--
2.47.3
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pmg-devel] [RFC pmg-yew-quarantine-gui 1/2] buildsys: initialize pwt-assets as submodule automatically
2025-10-28 16:36 ` [pmg-devel] [RFC pmg-yew-quarantine-gui 1/2] buildsys: initialize pwt-assets as submodule automatically Stoiko Ivanov
@ 2025-10-29 8:59 ` Dominik Csapak
0 siblings, 0 replies; 5+ messages in thread
From: Dominik Csapak @ 2025-10-29 8:59 UTC (permalink / raw)
To: Stoiko Ivanov, pmg-devel
LGTM
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
On 10/28/25 5:36 PM, Stoiko Ivanov wrote:
> The error-message for the missing submodule and prerequisite is clear,
> but due to parallel make - it gets printed, before the rustc output -
> and is thus not visible when the build fails.
>
> inspired by our zfsonlinux git:
> 63bd3935c (ensure submodule gets initialized on fresh clone and build).
>
> but instead of letting BUILDDIR depend on pwt-assets/README.md it
> depends on the PHONY target (as this will evaluated anyways - and
> short-circuit if the README.md exists)
>
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
> Makefile | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index fdf046c..72937c0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -66,8 +66,11 @@ install: $(COMPILED_OUTPUT) pmg-mobile-index.html.tt
> install -m0644 dist/mobile-yew-style.css $(DESTDIR)$(UIDIR)/css
> install -m0644 pmg-mobile-index.html.tt $(DESTDIR)$(UIDIR)
>
> +.PHONY: submodule
> +submodule:
> + test -f "pwt-assets/README.md" || git submodule update --init
>
> -$(BUILDDIR):
> +$(BUILDDIR): submodule
> rm -rf $@ $@.tmp
> mkdir -p $@.tmp
> cp -a debian/ src/ pwt-assets/ images/ pmg-mobile-index.html.tt Makefile Cargo.toml $@.tmp
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pmg-devel] [RFC pmg-yew-quarantine-gui 2/2] main view: handle optional quarantine action in spamreport links
2025-10-28 16:36 ` [pmg-devel] [RFC pmg-yew-quarantine-gui 2/2] main view: handle optional quarantine action in spamreport links Stoiko Ivanov
@ 2025-10-29 9:09 ` Dominik Csapak
0 siblings, 0 replies; 5+ messages in thread
From: Dominik Csapak @ 2025-10-29 9:09 UTC (permalink / raw)
To: Stoiko Ivanov, pmg-devel
This is not correct I'm afraid.
It works, but just "by accident"
Usually doing such things in the 'view' method is not good, since
that can trigger any amount of times, depending on what happens
to the component.
it currently triggers only once, because when we login, we replace the
url via the 'location' which causes a refresh of the page, but seemingly
only after all outstanding javascript is finished running
with that refresh, we lose all state
Also we don't have any feedback here that the action was done.
I'll have an idea how to solve this, but it's a bit more involved than
this. I'd send a patch later if you don't mind
On 10/28/25 5:36 PM, Stoiko Ivanov wrote:
> Our html verbose spamreports have included links for each possible
> action for each mail (delete, deliver, blocklist, welcomelist) in the
> action GET parameter. Currently the yew-based mobile view does not
> handle those actions.
>
> This patch adds the functionality by issueing a POST request in the
> view function if the a cselect (id) and action parameter are present.
>
> I tried adding the same call to the update function, but it seems the
> update function does not get the query-string after a login, or was not
> called in my tests.
>
> Big thanks to Dominik for walking me through our yew framework and
> providing other valuable suggestions!
>
> Reported in our community forum:
> https://forum.proxmox.com/threads/.174685/
>
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
> src/main.rs | 28 +++++++++++++++++++++++++++-
> 1 file changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/src/main.rs b/src/main.rs
> index 8cd8a6b..366cdc7 100644
> --- a/src/main.rs
> +++ b/src/main.rs
> @@ -1,5 +1,7 @@
> mod spam_list;
>
> +use std::str::FromStr;
> +
> pub use spam_list::SpamList;
>
> mod page_mail_view;
> @@ -14,7 +16,7 @@ pub use page_not_found::PageNotFound;
> mod page_login;
> pub use page_login::PageLogin;
>
> -use anyhow::Error;
> +use anyhow::{format_err, Error};
> use gloo_utils::{document, format::JsValueSerdeExt};
> use serde::Deserialize;
> use serde_json::{json, Value};
> @@ -114,6 +116,15 @@ impl Component for PmgQuarantineApp {
> let logged_in = self.login_info.is_some();
> MaterialApp::new(move |path: &str| {
> if logged_in {
> + let document = document();
> + let location = document.location().unwrap();
> + let search = location.search().unwrap();
> + let param = web_sys::UrlSearchParams::new_with_str(&search).unwrap();
> + if let (Some(id), Some(action)) = (param.get("cselect"), param.get("action")) {
> + wasm_bindgen_futures::spawn_local(async move {
> + _ = mail_action(&id, MailAction::from_str(&action).unwrap()).await
> + });
> + }
> switch(path)
> } else {
> vec![PageLogin::new().on_login(link.callback(Msg::Login)).into()]
> @@ -187,6 +198,21 @@ impl std::fmt::Display for MailAction {
> }
> }
>
> +impl std::str::FromStr for MailAction {
> + type Err = anyhow::Error;
> + fn from_str(s: &str) -> Result<Self, Self::Err> {
> + match s {
> + "deliver" => Ok(MailAction::Deliver),
> + "delete" => Ok(MailAction::Delete),
> + "welcomelist" => Ok(MailAction::Welcomelist),
> + "whitelist" => Ok(MailAction::Welcomelist),
> + "blocklist" => Ok(MailAction::Blocklist),
> + "blacklist" => Ok(MailAction::Blocklist),
> + _ => Err(format_err!("unknown quarantine action")),
> + }
> + }
> +}
> +
> pub(crate) async fn mail_action(id: &str, action: MailAction) -> Result<Value, Error> {
> let param = json!({
> "action": action.to_string(),
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-29 9:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-28 16:36 [pmg-devel] [RFC pmg-yew-quarantine-gui 0/2] fix direct actions from spamreport links Stoiko Ivanov
2025-10-28 16:36 ` [pmg-devel] [RFC pmg-yew-quarantine-gui 1/2] buildsys: initialize pwt-assets as submodule automatically Stoiko Ivanov
2025-10-29 8:59 ` Dominik Csapak
2025-10-28 16:36 ` [pmg-devel] [RFC pmg-yew-quarantine-gui 2/2] main view: handle optional quarantine action in spamreport links Stoiko Ivanov
2025-10-29 9:09 ` Dominik Csapak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox