From 3b16004f737c682feda1a6134fd4213210fba9cf Mon Sep 17 00:00:00 2001 From: David Rodenkirchen Date: Thu, 7 May 2026 00:21:26 +0200 Subject: [PATCH] Improve User Management GUI --- VERSION | 2 +- src/ezgg_lan_manager/pages/ManageUsersPage.py | 44 ++++++++++++++----- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/VERSION b/VERSION index 5d4294b..2411653 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.1 \ No newline at end of file +0.5.2 \ No newline at end of file diff --git a/src/ezgg_lan_manager/pages/ManageUsersPage.py b/src/ezgg_lan_manager/pages/ManageUsersPage.py index 6632739..c27d6ab 100644 --- a/src/ezgg_lan_manager/pages/ManageUsersPage.py +++ b/src/ezgg_lan_manager/pages/ManageUsersPage.py @@ -4,7 +4,7 @@ from typing import Optional from rio import Column, Component, event, TextStyle, Text, TextInput, ThemeContextSwitcher, Grid, \ PointerEventListener, PointerEvent, Rectangle, Color, TextInputChangeEvent, Spacer, Row, Switch, \ - SwitchChangeEvent, EventHandler + SwitchChangeEvent, EventHandler, Icon from src.ezgg_lan_manager import ConfigurationService, UserService, AccountingService, SeatingService, MailingService from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox @@ -73,12 +73,18 @@ class ManageUsersPage(Component): seat = await self.session[SeatingService].get_user_seat(self.selected_user.user_id) self.user_seat = seat.seat_id if seat else "-" self.is_user_account_locked = not self.selected_user.is_active + await self.on_search_parameters_changed(TextInputChangeEvent(self.selected_user.user_name)) async def on_search_parameters_changed(self, e: TextInputChangeEvent) -> None: self.search_results = list( filter(lambda user: (e.text.lower() in user.user_name.lower()) or e.text.lower() in str(user.user_id), self.all_users)) + async def reset_view(self, _: PointerEvent) -> None: + self.selected_user = None + self.search_results = self.all_users + await self.on_search_parameters_changed(TextInputChangeEvent("")) + async def change_account_active(self, _: SwitchChangeEvent) -> None: self.selected_user.is_active = not self.is_user_account_locked await self.session[UserService].update_user(self.selected_user) @@ -98,7 +104,7 @@ class ManageUsersPage(Component): if transaction.is_debit: try: - await self.session[AccountingService].remove_balance( + new_total_balance = await self.session[AccountingService].remove_balance( transaction.user_id, transaction.value, transaction.reference @@ -122,6 +128,7 @@ class ManageUsersPage(Component): self.accounting_section_result_text = f"Guthaben {'entfernt' if transaction.is_debit else 'hinzugefügt'}!" self.accounting_section_result_success = True + self.user_account_balance = self.session[AccountingService].make_euro_string_from_decimal(new_total_balance) def build(self) -> Component: return Column( @@ -164,15 +171,32 @@ class ManageUsersPage(Component): ), MainViewContentBox( Column( - Text( - text="Konto & Sitzplatz", - style=TextStyle( - fill=self.session.theme.background_color, - font_size=1.2 + Row( + Spacer(), + PointerEventListener( + content=Icon("material/cancel", fill="background", min_width=2.5, margin_top=1, margin_right=1), + on_press=self.reset_view + ) + ), + Row( + Text( + text=f"Konto von ", + style=TextStyle( + fill=self.session.theme.background_color, + font_size=1.2 + ), + justify="right" ), - margin_top=2, - margin_bottom=2, - align_x=0.5 + Text( + text=self.selected_user.user_name, + style=TextStyle( + fill=self.session.theme.hud_color, + font_size=1.2 + ), + justify="left" + ), + margin_top=0.5, + margin_bottom=2 ), Row( Text(