Add UI settings API and improve context initialization
- Add /settings/ui GET and PUT endpoints for UI settings - Improve ThemeContext with better initialization and auto accent handling - Update SidebarContext with expanded state persistence - Fix context initialization in ModulesContext and ViewModeContext - Update components to use improved theme/sidebar contexts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ from app.models.user import User
|
||||
from app.core.settings_registry import (
|
||||
THEME_KEYS,
|
||||
MODULE_KEYS,
|
||||
UI_KEYS,
|
||||
SETTINGS_REGISTRY,
|
||||
get_default_value,
|
||||
)
|
||||
@@ -82,6 +83,47 @@ def get_module_settings(
|
||||
return result
|
||||
|
||||
|
||||
@router.get("/ui", response_model=dict[str, Any])
|
||||
def get_ui_settings(
|
||||
*,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user)
|
||||
) -> Any:
|
||||
"""
|
||||
Get UI settings (accessible to all authenticated users).
|
||||
|
||||
Returns UI/layout settings that apply to all users.
|
||||
"""
|
||||
result = {}
|
||||
for key in UI_KEYS:
|
||||
setting = crud.settings.get_setting(db, key=key)
|
||||
if setting:
|
||||
result[key] = setting.get_value()
|
||||
else:
|
||||
result[key] = get_default_value(key)
|
||||
return result
|
||||
|
||||
|
||||
@router.put("/ui", response_model=dict[str, Any])
|
||||
def update_ui_settings(
|
||||
*,
|
||||
db: Session = Depends(get_db),
|
||||
ui_data: dict[str, Any],
|
||||
current_user: User = Depends(get_current_superuser)
|
||||
) -> Any:
|
||||
"""
|
||||
Update UI settings (admin only).
|
||||
|
||||
Updates multiple UI/layout settings at once.
|
||||
"""
|
||||
result = {}
|
||||
for key, value in ui_data.items():
|
||||
if key in UI_KEYS:
|
||||
setting = crud.settings.update_setting(db, key=key, value=value)
|
||||
result[key] = setting.get_value()
|
||||
return result
|
||||
|
||||
|
||||
@router.put("/modules", response_model=dict[str, Any])
|
||||
def update_module_settings(
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user