From: Dominik Csapak <d.csapak@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-yew-quarantine-gui 1/1] spam list: add option menu
Date: Tue, 23 Sep 2025 15:20:08 +0200 [thread overview]
Message-ID: <20250923132013.3145698-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250923132013.3145698-1-d.csapak@proxmox.com>
this contains options to
* change the language
* switch to the desktop view (by appending mobile=0 to the url)
* logout
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/page_spam_list.rs | 81 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 78 insertions(+), 3 deletions(-)
diff --git a/src/page_spam_list.rs b/src/page_spam_list.rs
index bdea7a8..58d2541 100644
--- a/src/page_spam_list.rs
+++ b/src/page_spam_list.rs
@@ -1,6 +1,7 @@
use std::rc::Rc;
use anyhow::Error;
+use gloo_utils::document;
use js_sys::Date;
use wasm_bindgen::JsValue;
@@ -9,11 +10,12 @@ use yew::prelude::*;
use yew::virtual_dom::{VComp, VNode};
use yew_router::scope_ext::RouterScopeExt;
-use pwt::css::{ColorScheme, FlexFit, JustifyContent};
+use pwt::css::{AlignItems, ColorScheme, FlexFit, JustifyContent};
use pwt::prelude::*;
use pwt::touch::{ApplicationBar, Fab, Scaffold};
use pwt::widget::form::{Field, Form, FormContext, InputType};
-use pwt::widget::{Button, Column, Dialog, Image, Row, ThemeModeSelector};
+use pwt::widget::menu::{Menu, MenuButton, MenuItem};
+use pwt::widget::{Button, Column, Dialog, Image, LanguageSelector, Row, ThemeModeSelector};
use proxmox_subscription::{SubscriptionInfo, SubscriptionStatus};
use proxmox_yew_comp::http_get;
@@ -40,6 +42,7 @@ pub enum ViewState {
Normal,
ShowDialog,
ShowSubscriptionNotice,
+ ShowLanguageSelect,
}
pub struct PmgPageSpamList {
state: ViewState,
@@ -56,6 +59,9 @@ pub enum Msg {
CloseDialog,
ApplyDate,
SubscriptionResult(Result<SubscriptionInfo, Error>),
+ SwitchToDesktop,
+ ShowLanguageSelect,
+ Logout,
}
fn epoch_to_date_string(epoch: f64) -> String {
@@ -177,6 +183,27 @@ impl Component for PmgPageSpamList {
self.subscription_result = Some(valid);
true
}
+ Msg::SwitchToDesktop => {
+ let location = document().location().unwrap();
+ let param = match location.search() {
+ Ok(search) => web_sys::UrlSearchParams::new_with_str(&search).unwrap(),
+ Err(_) => web_sys::UrlSearchParams::new().unwrap(),
+ };
+ param.set("mobile", "0");
+ let search: String = param.to_string().into();
+ if let Err(err) = location.set_search(&search) {
+ log::error!("could not set location parameter: {err:?}");
+ }
+ false
+ }
+ Msg::ShowLanguageSelect => {
+ self.state = ViewState::ShowLanguageSelect;
+ true
+ }
+ Msg::Logout => {
+ proxmox_yew_comp::http_clear_auth();
+ true
+ }
}
}
@@ -209,6 +236,18 @@ impl Component for PmgPageSpamList {
)
.on_close(ctx.link().callback(|_| Msg::CloseDialog)),
),
+ ViewState::ShowLanguageSelect => Some(
+ Dialog::new(tr!("Select Language"))
+ .with_child(
+ Row::new()
+ .class(AlignItems::Center)
+ .padding(4)
+ .gap(2)
+ .with_child(tr!("Language"))
+ .with_child(LanguageSelector::new()),
+ )
+ .on_close(ctx.link().callback(|_| Msg::CloseDialog)),
+ ),
};
let fab = Fab::new("fa fa-calendar").on_activate(ctx.link().callback(|_| Msg::ShowDialog));
@@ -240,7 +279,43 @@ impl Component for PmgPageSpamList {
.class("pwt-navbar-brand"),
)
.title("Mail")
- .with_action(ThemeModeSelector::new()),
+ .with_action(
+ Row::new()
+ .gap(1)
+ .with_child(ThemeModeSelector::new())
+ .with_child(
+ MenuButton::new("")
+ .class("circle")
+ .icon_class("fa fa-bars")
+ .menu(
+ Menu::new()
+ .with_item(
+ MenuItem::new(tr!("Language"))
+ .icon_class("fa fa-language")
+ .on_select(
+ ctx.link()
+ .callback(|_| Msg::ShowLanguageSelect),
+ ),
+ )
+ .with_item(
+ MenuItem::new(tr!("Switch to Desktop View"))
+ .icon_class("fa fa-desktop")
+ .on_select(
+ ctx.link()
+ .callback(|_| Msg::SwitchToDesktop),
+ ),
+ )
+ .with_separator()
+ .with_item(
+ MenuItem::new(tr!("Logout"))
+ .icon_class("fa fa-sign-out")
+ .on_select(
+ ctx.link().callback(|_| Msg::Logout),
+ ),
+ ),
+ ),
+ ),
+ ),
)
.body(
Column::new()
--
2.47.3
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
next prev parent reply other threads:[~2025-09-23 13:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 13:20 [pmg-devel] [PATCH pmg-gui/pmg-yew-quarantine-gui 0/2] quarantine: allow switching between mobile and desktop ui Dominik Csapak
2025-09-23 13:20 ` [pmg-devel] [PATCH pmg-gui 1/1] quarantine view: add option to switch to mobile view Dominik Csapak
2025-09-23 15:21 ` Thomas Lamprecht
2025-09-23 13:20 ` Dominik Csapak [this message]
2025-09-23 14:46 ` [pmg-devel] applied: [PATCH pmg-yew-quarantine-gui 1/1] spam list: add option menu Thomas Lamprecht
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=20250923132013.3145698-3-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pmg-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