Improve User Management GUI

This commit is contained in:
David Rodenkirchen 2026-05-07 00:21:26 +02:00
parent ead829d322
commit 3b16004f73
2 changed files with 35 additions and 11 deletions

View File

@ -1 +1 @@
0.5.1
0.5.2

View File

@ -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(
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="Konto & Sitzplatz",
text=f"Konto von ",
style=TextStyle(
fill=self.session.theme.background_color,
font_size=1.2
),
margin_top=2,
margin_bottom=2,
align_x=0.5
justify="right"
),
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(