608b0b7fe8
- 4 built-in themes (Default, Pastel, High Contrast, Ocean Blue) seeded as JSON files in /config/themes/ on startup; custom themes can be created, edited, and deleted via the new admin Appearance page - All theme tokens applied via JS inline CSS properties (no hardcoded CSS blocks) - New `color_mode` column on users table (migration dd6ad2f2c211); users can override the admin-set global default in Settings - Backend: GET/PATCH /settings/appearance, full CRUD on /settings/themes - Frontend: AdminAppearancePage with theme grid + colour pickers, SettingsPage replaces placeholder with mode selector, useTheme rewritten to fetch from API Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
from fastapi import APIRouter, Depends, HTTPException
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.database import get_db
|
|
from app.deps import get_current_user
|
|
from app.models.user import User
|
|
from app.schemas.user import ColorModeUpdate, DashboardPrefsOut, DashboardPrefsUpdate, UserOut
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/me", response_model=UserOut)
|
|
async def get_me(current_user: User = Depends(get_current_user)):
|
|
return current_user
|
|
|
|
|
|
@router.get("/me/preferences", response_model=DashboardPrefsOut)
|
|
async def get_preferences(current_user: User = Depends(get_current_user)):
|
|
return DashboardPrefsOut(app_ids=current_user.dashboard_app_ids or [])
|
|
|
|
|
|
@router.patch("/me/preferences", response_model=DashboardPrefsOut)
|
|
async def update_preferences(
|
|
body: DashboardPrefsUpdate,
|
|
current_user: User = Depends(get_current_user),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
current_user.dashboard_app_ids = body.app_ids
|
|
await db.commit()
|
|
await db.refresh(current_user)
|
|
return DashboardPrefsOut(app_ids=current_user.dashboard_app_ids or [])
|
|
|
|
|
|
@router.patch("/me/color-mode", response_model=UserOut)
|
|
async def update_color_mode(
|
|
body: ColorModeUpdate,
|
|
current_user: User = Depends(get_current_user),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
current_user.color_mode = body.color_mode
|
|
await db.commit()
|
|
await db.refresh(current_user)
|
|
return current_user
|