Skip to content

Client#4

Draft
csboo wants to merge 82 commits intomainfrom
client
Draft

Client#4
csboo wants to merge 82 commits intomainfrom
client

Conversation

@csboo
Copy link
Copy Markdown
Owner

@csboo csboo commented Dec 5, 2025

fixes #21

  • desktop support
  • mobile support
  • communicate set_admin_password endpoint
  • table width based on puzzle_value
  • scale everything dynamically
  • adjust theme and colors
  • handle adminuser better
  • properly flexing input boxes
  • logout, superlogout popup alerts
  • table order based on team points
  • always sort server data
  • puzzle_id dropdown select
  • handle way more errors and dont unwrap (likely done already)
  • make event title actually optional
  • messages and error messages should be handled differently
  • modularise and clean up code
  • fix fullscreen hover thing

@csboo
Copy link
Copy Markdown
Owner Author

csboo commented Dec 5, 2025

this is quite a WIP branch, but it works at this point, and i dont want to lose my local changes (for the 3rd time), hence the upload :D

testers are welcome!

Base automatically changed from backend to main January 13, 2026 18:24
@jarjk jarjk mentioned this pull request Jan 18, 2026
@jarjk jarjk force-pushed the client branch 2 times, most recently from b6c200c to 84bb86e Compare March 3, 2026 11:55
@jarjk
Copy link
Copy Markdown
Collaborator

jarjk commented Mar 16, 2026

as DioxusLabs/dioxus#5089 has been fixed, it's time to see how it works!

hasn't been released yet though, but here's the diff/patch to apply so you can try this out.

don't forget to run cargo update once you've applied the patch

diff --git a/src/app/home/actions.rs b/src/app/home/actions.rs
--- a/src/app/home/actions.rs
+++ b/src/app/home/actions.rs
@@ -30,19 +30,16 @@ pub fn handle_user_join(
                 return;
             }
 
-            let _ok_none = crate::backend::endpoints::join(u.clone()).await;
-            match crate::backend::endpoints::auth_state().await {
-                Ok(uname) => {
-                    popup_normal(toast_api, format!("Üdv, {}", uname));
+            match crate::backend::endpoints::join(u.clone()).await {
+                Ok(_) => {
+                    popup_normal(toast_api, format!("Üdv, {u}"));
                     auth.write().joined = true; // TODO auth.reset(_somefield)
                     auth.write().password = String::new();
                     auth.write().show_password_prompt = false;
                 }
-                Err(e) => {
-                    popup_error(
-                        toast_api,
-                        format!("Hiba: {}", e.message.unwrap_or("ismeretlen hiba".into())),
-                    );
+                Err(http_err) => {
+                    error!("couldn't join: {http_err}");
+                    popup_error(toast_api, format!("Hiba: {http_err}"));
                 }
             }
         }); // spawn async move
@@ -216,11 +213,8 @@ pub fn handle_logout(
                     popup_normal(toast_api, format!("Viszlát, {}", auth.read().username));
                     auth.set(AuthState::default());
                 }
-                Err(e) => {
-                    popup_error(
-                        toast_api,
-                        format!("Hiba: {}", e.message.unwrap_or("ismeretlen hiba".into())),
-                    );
+                Err(http_err) => {
+                    popup_error(toast_api, format!("Hiba: {http_err}"));
                 }
             }
         });

@jarjk
Copy link
Copy Markdown
Collaborator

jarjk commented Apr 13, 2026

better toasts with proc macro to generate fn-s for them:

diff --git a/src/app/home/actions.rs b/src/app/home/actions.rs
index fd2a772..dd5ee1a 100644
--- a/src/app/home/actions.rs
+++ b/src/app/home/actions.rs
@@ -5,7 +5,7 @@ use crate::{
     app::home::{
         models::AuthState,
         utils::{
-            parse_puzzle_csv, popup_error, popup_normal, validate_puzzle_id,
+            parse_puzzle_csv, popup_error, popup_normal, popup_success, validate_puzzle_id,
             validate_puzzle_solution, validate_puzzle_value,
         },
     },
@@ -33,17 +33,12 @@ pub fn handle_user_join(
             let _ok_none = crate::backend::endpoints::join(u.clone()).await;
             match crate::backend::endpoints::auth_state().await {
                 Ok(uname) => {
-                    popup_normal(toast_api, format!("Üdv, {}", uname));
+                    popup_success(toast_api, format!("Üdv, {}", uname));
                     auth.write().joined = true; // TODO auth.reset(_somefield)
                     auth.write().password = String::new();
                     auth.write().show_password_prompt = false;
                 }
-                Err(e) => {
-                    popup_error(
-                        toast_api,
-                        format!("Hiba: {}", e.message.unwrap_or("ismeretlen hiba".into())),
-                    );
-                }
+                Err(e) => popup_error(toast_api, e),
             }
         }); // spawn async move
     } // move
@@ -70,10 +65,7 @@ pub fn handle_admin_join(
                         auth.write().joined = true;
                         popup_normal(toast_api, msg);
                     }
-                    Err(e) => popup_error(
-                        toast_api,
-                        format!("Hiba: {}", e.message.unwrap_or("ismeretlen hiba".into())),
-                    ),
+                    Err(e) => popup_error(toast_api, e),
                 }
             }
         }); // spawn async move
@@ -104,7 +96,7 @@ pub fn handle_user_submit(
                     puzzle_solution.set(String::new());
                 }
                 Err(e) => {
-                    popup_error(toast_api, format!("Hiba: {}", e));
+                    popup_error(toast_api, e);
                 }
             }
         });
@@ -160,10 +152,7 @@ pub fn handle_admin_submit(
                     // password.set(String::new()); NOTE should remember password?
                 }
                 Err(e) => {
-                    popup_error(
-                        toast_api,
-                        format!("Hiba: {}", e.message.unwrap_or("ismeretlen hiba".into())),
-                    );
+                    popup_error(toast_api, e);
                 }
             }
         });
@@ -217,10 +206,7 @@ pub fn handle_logout(
                     auth.set(AuthState::default());
                 }
                 Err(e) => {
-                    popup_error(
-                        toast_api,
-                        format!("Hiba: {}", e.message.unwrap_or("ismeretlen hiba".into())),
-                    );
+                    popup_error(toast_api, e);
                 }
             }
         });
diff --git a/src/app/home/utils.rs b/src/app/home/utils.rs
index 48525ad..48498e0 100644
--- a/src/app/home/utils.rs
+++ b/src/app/home/utils.rs
@@ -65,25 +65,23 @@ pub fn parse_puzzle_csv(csv_text: &str, toast_api: Toasts) -> PuzzleSolutions {
     puzzles
 }
 
-pub fn popup_error(toast_api: Toasts, text: impl std::fmt::Display) {
-    toast_api.error(
-        "".to_string(),
-        ToastOptions::new()
-            .description(text)
-            .duration(Duration::from_secs(3))
-            .permanent(false),
-    );
+macro_rules! gen_toast {
+    ($func_name:ident, $kind:ident, title: $title:literal, timeout: $timeout:expr) => {
+        pub fn $func_name(toast_api: Toasts, text: impl std::fmt::Display) {
+            toast_api.$kind(
+                $title.to_string(),
+                ToastOptions::new()
+                    .description(text)
+                    .duration(Duration::from_secs($timeout))
+                    .permanent(false),
+            );
+        }
+    };
 }
 
-pub fn popup_normal(toast_api: Toasts, text: impl std::fmt::Display) {
-    toast_api.info(
-        "".to_string(),
-        ToastOptions::new()
-            .description(text)
-            .duration(Duration::from_secs(3))
-            .permanent(false),
-    );
-}
+gen_toast!(popup_normal, info, title: "Info", timeout: 5);
+gen_toast!(popup_success, success, title: "Siker", timeout: 6);
+gen_toast!(popup_error, error, title: "Hiba", timeout: 12);
 
 pub fn get_points_of(team: &(String, SolvedPuzzles), puzzles: Vec<(PuzzleId, PuzzleValue)>) -> u32 {
     puzzles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gui client

2 participants