210726
Github Commits
Github Commit 1
-
Replaced Draft Prototypes with Full Single-Page Application (main.py): Refactored
main.py(+220 / -119 lines) to replace commented-out prototype functions with a full NiceGUI single-page application (CathWest Parking) featuring a structured view switching engine (switch_to). -
Implemented Custom Logging System (main.py & topsecret/): Built the
FireflyTerminalLoggerengine to wrapsys.stdoutandsys.stderr, automatically routing console output totopsecret/latest.logwhile rotating previous logs to date-stamped files (DD-MM-YYYY.log). -
Integrated Authentication & Navigation Flow (main.py): Implemented bcrypt password verification against stored credentials in
topsecret/<account_name>.txtwith conditional routing: routing new/unconfigured users to the Profile Configuration view and returning users directly to the Map view. -
Added Map & Interactive Reservation Features (main.py): Added a floating background audio player (
waiting-audio.mp4), an interactive Leaflet map anchored to CathWest Innovation College (Loyola Campus), constrained 28-day date pickers, time-slot selection, and an interactive Inbox dialog.
Stumbling Blocks
-
Stream Interception & Double Output: Wrapping standard IO streams (
sys.stdoutandsys.stderr) insideFireflyTerminalLoggerinitially risk creating recursive logging loops or missing stream flushes when NiceGUI's asynchronous event loop wrote output during UI updates. -
SPA Container State Visibility: Managing view transitions across five separate NiceGUI containers (
login,terms,profile,map,reservation) using a singleswitch_to()helper required careful visibility state management to ensure background map elements and dialog overlays didn't render off-screen or retain stale states. -
Profile-Based First-Run Routing: Determining user navigation during login required checking both local account files in
topsecret/and profile data insupersecretdata.jsonwithout throwing file-not-found exceptions for first-time sign-ins.
Reflective Comments
Overall, replacing the draft function placeholders with a modular single-page architecture significantly cleaned up the core UI flow. Establishing automated log rotation early makes debugging UI routing much easier as new features are added. Moving forward, isolating custom logger handlers into a separate module (like errorhandler.py) will keep main.py purely focused on UI layout and routing logic.
Resources and Code Used
-
NiceGUI & Leaflet UI Components: Utilized NiceGUI's core UI elements (
ui.element,ui.card,ui.leaflet,ui.dialog) to build a single-page view container layout with maps and floating audio controls. -
Python Standard Stream Management: Leveraged standard Python system modules (
sys,os,io,datetime) to redirect stdout/stderr streams and automate file-based log rotation. -
JSON & Bcrypt Security Layer: Applied
jsonstate persistence andbcryptpassword verification to secure local credential checking and manage user profile attributes.