Commit graph

1 commit

Author SHA1 Message Date
Claude
1e0cfe5270
Add embedded web UI with dark/light mode support
Features:
- Single binary deployment with embedded HTML templates
- Dark and light mode theme switcher with localStorage persistence
- Server-side rendered Go templates
- Clean, modern UI with CSS variables for theming
- Login page with default admin credentials hint
- Dashboard with statistics and quick actions
- Admin user management page
- Session management via HTTP-only cookies

Implementation:
- Created web templates in cmd/tracks/web/templates/
  - base.html: Main layout with navigation and theme toggle
  - login.html: Login form with first-time user hint
  - dashboard.html: Main dashboard with stats cards and recent todos
  - admin_users.html: User management with create user modal
- Added web_handler.go for serving web UI
  - ShowLogin: Renders login page
  - HandleLogin: Processes login form, sets cookie, redirects to dashboard
  - HandleLogout: Clears cookie, redirects to login
  - ShowDashboard: Shows personalized dashboard with stats
  - ShowAdminUsers: Admin-only user management page
  - HandleCreateUser: Processes user creation form
- Updated main.go to embed templates using //go:embed
- Added web routes before API routes:
  - GET/POST /login (public)
  - GET /logout (public)
  - GET / and /dashboard (authenticated)
  - GET/POST /admin/users (authenticated + admin)

UI Features:
- Responsive design with mobile support
- Theme persistence across sessions
- Clean card-based layout
- Statistics dashboard (active todos, projects, contexts, completed today)
- Quick action buttons
- Admin badge for admin users
- Navigation menu with conditional admin links

Security:
- HttpOnly cookies for session tokens
- Admin middleware for protected routes
- CSRF protection via form POST
- Password fields properly masked

No external dependencies - all CSS and JS inline in templates.
Everything compiles into single binary.

Tested:
- Login page renders correctly ✓
- Login form submits and creates session ✓
- Dashboard displays with user info ✓
- Theme toggle functionality included ✓
- Admin user sees admin links ✓
2025-11-05 11:56:31 +00:00