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 543D01FF191 for ; Tue, 23 Sep 2025 15:20:17 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 47DB2FA73; Tue, 23 Sep 2025 15:20:47 +0200 (CEST) From: Dominik Csapak To: pmg-devel@lists.proxmox.com Date: Tue, 23 Sep 2025 15:20:08 +0200 Message-ID: <20250923132013.3145698-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250923132013.3145698-1-d.csapak@proxmox.com> References: <20250923132013.3145698-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 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 0.001 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 0.001 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 0.001 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 Subject: [pmg-devel] [PATCH pmg-yew-quarantine-gui 1/1] spam list: add option menu X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pmg-devel-bounces@lists.proxmox.com Sender: "pmg-devel" 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 --- 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), + 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