public inbox for yew-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [yew-devel] [PATCH yew-comp 1/4] expose subscription_note publicly
@ 2025-07-01  8:38 Dominik Csapak
  2025-07-01  8:38 ` [yew-devel] [PATCH yew-comp 2/4] http helpers: expose ticket refresh loop controls Dominik Csapak
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Dominik Csapak @ 2025-07-01  8:38 UTC (permalink / raw)
  To: yew-devel

sometimes we only need the subscription notice text, so expose that
function which returns the correct string.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/lib.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lib.rs b/src/lib.rs
index 091cb72..42c037e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -158,7 +158,7 @@ mod subscription_panel;
 pub use subscription_panel::{ProxmoxSubscriptionPanel, SubscriptionPanel};
 
 mod subscription_info;
-pub use subscription_info::{ProxmoxSubscriptionInfo, SubscriptionInfo};
+pub use subscription_info::{subscription_note, ProxmoxSubscriptionInfo, SubscriptionInfo};
 
 mod syslog;
 pub use syslog::{ProxmoxSyslog, Syslog};
-- 
2.39.5



_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [yew-devel] [PATCH yew-comp 2/4] http helpers: expose ticket refresh loop controls
  2025-07-01  8:38 [yew-devel] [PATCH yew-comp 1/4] expose subscription_note publicly Dominik Csapak
@ 2025-07-01  8:38 ` Dominik Csapak
  2025-07-01  8:38 ` [yew-devel] [PATCH yew-comp 3/4] login panel/realm selector: make realm path configurable Dominik Csapak
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Dominik Csapak @ 2025-07-01  8:38 UTC (permalink / raw)
  To: yew-devel

by introducing a stop_ticket_refresh_loop and making both start and stop
public. This can be useful e.g. when such a ticket refresh loop is
unwanted. This is the case for example for the PMG quarantine interface
when using a PMGQUAR ticket, since that is valid as long as the
quarantine is valid and refreshing it simply yields the same ticket.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/http_helpers.rs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/http_helpers.rs b/src/http_helpers.rs
index d035b48..94cc078 100644
--- a/src/http_helpers.rs
+++ b/src/http_helpers.rs
@@ -85,13 +85,17 @@ thread_local! {
     static TICKET_REFRESH_LOOP_GUARD: RefCell<Option<AsyncAbortGuard>> = const { RefCell::new(None) };
 }
 
-fn start_ticket_refresh_loop() {
+pub fn start_ticket_refresh_loop() {
     let abort_guard = AsyncAbortGuard::spawn(ticket_refresh_loop());
 
     // Make sure there is a single loop running.
     TICKET_REFRESH_LOOP_GUARD.with_borrow_mut(|v| *v = Some(abort_guard));
 }
 
+pub fn stop_ticket_refresh_loop() {
+    TICKET_REFRESH_LOOP_GUARD.with_borrow_mut(|v| *v = None);
+}
+
 async fn ticket_refresh_loop() {
     loop {
         let sleep_time_ms = 5000;
-- 
2.39.5



_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [yew-devel] [PATCH yew-comp 3/4] login panel/realm selector: make realm path configurable
  2025-07-01  8:38 [yew-devel] [PATCH yew-comp 1/4] expose subscription_note publicly Dominik Csapak
  2025-07-01  8:38 ` [yew-devel] [PATCH yew-comp 2/4] http helpers: expose ticket refresh loop controls Dominik Csapak
@ 2025-07-01  8:38 ` Dominik Csapak
  2025-07-01  8:38 ` [yew-devel] [PATCH yew-comp 4/4] login panel: use snackbar for errors when on mobile Dominik Csapak
  2025-07-01  9:25 ` [yew-devel] applied: [PATCH yew-comp 1/4] expose subscription_note publicly Dietmar Maurer
  3 siblings, 0 replies; 5+ messages in thread
From: Dominik Csapak @ 2025-07-01  8:38 UTC (permalink / raw)
  To: yew-devel

sometimes, the path to the publicly available realm list has a different
api path, for example in PMG. To make it usable there, make the path
configurable but default to the old one

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/login_panel.rs    | 6 ++++++
 src/realm_selector.rs | 7 ++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/login_panel.rs b/src/login_panel.rs
index fabe271..3c16ed4 100644
--- a/src/login_panel.rs
+++ b/src/login_panel.rs
@@ -40,6 +40,11 @@ pub struct LoginPanel {
     #[prop_or(false)]
     #[builder]
     pub mobile: bool,
+
+    /// The path to the domain api call, default is defined in the [RealmSelector]
+    #[prop_or_default]
+    #[builder]
+    pub domain_path: Option<AttrValue>,
 }
 
 impl Default for LoginPanel {
@@ -194,6 +199,7 @@ impl ProxmoxLoginPanel {
                 RealmSelector::new()
                     .name("realm")
                     .label_id(realm_label_id)
+                    .path(props.domain_path.clone())
                     .default(default_realm),
             )
             .with_child(
diff --git a/src/realm_selector.rs b/src/realm_selector.rs
index 6522c59..fa144c4 100644
--- a/src/realm_selector.rs
+++ b/src/realm_selector.rs
@@ -42,6 +42,11 @@ pub struct RealmSelector {
     #[builder(IntoPropValue, into_prop_value)]
     #[prop_or_default]
     pub default: Option<AttrValue>,
+
+    /// The path for getting the realm list
+    #[builder]
+    #[prop_or(Some("/access/domains".into()))]
+    pub path: Option<AttrValue>,
 }
 
 impl Default for RealmSelector {
@@ -104,7 +109,7 @@ impl Component for ProxmoxRealmSelector {
             .with_input_props(&props.input_props)
             .required(true)
             .default(props.default.as_deref().unwrap_or("pam").to_string())
-            .loader("/access/domains")
+            .loader(props.path.clone())
             .validate(self.validate.clone())
             .into()
     }
-- 
2.39.5



_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [yew-devel] [PATCH yew-comp 4/4] login panel: use snackbar for errors when on mobile
  2025-07-01  8:38 [yew-devel] [PATCH yew-comp 1/4] expose subscription_note publicly Dominik Csapak
  2025-07-01  8:38 ` [yew-devel] [PATCH yew-comp 2/4] http helpers: expose ticket refresh loop controls Dominik Csapak
  2025-07-01  8:38 ` [yew-devel] [PATCH yew-comp 3/4] login panel/realm selector: make realm path configurable Dominik Csapak
@ 2025-07-01  8:38 ` Dominik Csapak
  2025-07-01  9:25 ` [yew-devel] applied: [PATCH yew-comp 1/4] expose subscription_note publicly Dietmar Maurer
  3 siblings, 0 replies; 5+ messages in thread
From: Dominik Csapak @ 2025-07-01  8:38 UTC (permalink / raw)
  To: yew-devel

when mobile is set, use the snackbar for errors if a snackbar controller
is available. Otherwise show the erros like before.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/login_panel.rs | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/login_panel.rs b/src/login_panel.rs
index 3c16ed4..11c7ade 100644
--- a/src/login_panel.rs
+++ b/src/login_panel.rs
@@ -2,6 +2,7 @@ use std::rc::Rc;
 
 use pwt::props::PwtSpace;
 use pwt::state::PersistentState;
+use pwt::touch::{SnackBar, SnackBarContextExt};
 use yew::html::IntoEventCallback;
 use yew::prelude::*;
 use yew::virtual_dom::{VComp, VNode};
@@ -34,7 +35,8 @@ pub struct LoginPanel {
 
     /// Mobile Layout
     ///
-    /// Use special layout for mobile apps.
+    /// Use special layout for mobile apps. For example shows error in a [SnackBar]
+    /// if a [SnackBarController] context is available.
     ///
     /// Note: Always use saved userid to avoid additional checkbox.
     #[prop_or(false)]
@@ -450,6 +452,9 @@ impl Component for ProxmoxLoginPanel {
                 let realm = self.form_ctx.read().get_field_text("realm");
 
                 self.send_login(ctx, username, password, realm);
+                if let (true, Some(controller)) = (props.mobile, ctx.link().snackbar_controller()) {
+                    controller.dismiss_all()
+                }
                 true
             }
             Msg::Login(info) => {
@@ -465,7 +470,14 @@ impl Component for ProxmoxLoginPanel {
             Msg::LoginError(msg) => {
                 self.loading = false;
                 self.challenge = None;
-                self.login_error = Some(msg);
+                match (props.mobile, ctx.link().snackbar_controller()) {
+                    (true, Some(controller)) => {
+                        controller.show_snackbar(SnackBar::new().message(msg));
+                    }
+                    _ => {
+                        self.login_error = Some(msg);
+                    }
+                }
                 true
             }
         }
-- 
2.39.5



_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [yew-devel] applied: [PATCH yew-comp 1/4] expose subscription_note publicly
  2025-07-01  8:38 [yew-devel] [PATCH yew-comp 1/4] expose subscription_note publicly Dominik Csapak
                   ` (2 preceding siblings ...)
  2025-07-01  8:38 ` [yew-devel] [PATCH yew-comp 4/4] login panel: use snackbar for errors when on mobile Dominik Csapak
@ 2025-07-01  9:25 ` Dietmar Maurer
  3 siblings, 0 replies; 5+ messages in thread
From: Dietmar Maurer @ 2025-07-01  9:25 UTC (permalink / raw)
  To: Yew framework devel list at Proxmox, Dominik Csapak

applied all 4 patches


_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-01  9:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-01  8:38 [yew-devel] [PATCH yew-comp 1/4] expose subscription_note publicly Dominik Csapak
2025-07-01  8:38 ` [yew-devel] [PATCH yew-comp 2/4] http helpers: expose ticket refresh loop controls Dominik Csapak
2025-07-01  8:38 ` [yew-devel] [PATCH yew-comp 3/4] login panel/realm selector: make realm path configurable Dominik Csapak
2025-07-01  8:38 ` [yew-devel] [PATCH yew-comp 4/4] login panel: use snackbar for errors when on mobile Dominik Csapak
2025-07-01  9:25 ` [yew-devel] applied: [PATCH yew-comp 1/4] expose subscription_note publicly Dietmar Maurer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal