feat: SAC 0.7.4 sidebar system stats block with UI toggle
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from pydantic import BaseModel, Field
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.auth.jwt_auth import get_current_user
|
||||
from app.database import get_db
|
||||
from app.services.system_stats import collect_system_stats
|
||||
from app.services.ui_settings import get_effective_ui_settings
|
||||
|
||||
router = APIRouter(prefix="/system", tags=["system"])
|
||||
|
||||
|
||||
class SystemStatsResponse(BaseModel):
|
||||
visible: bool = Field(description="Показывать блок в боковой панели (глобальная настройка)")
|
||||
collected_at: str
|
||||
cpu_percent: float | None = None
|
||||
memory: dict | None = None
|
||||
disk: dict | None = None
|
||||
database: dict
|
||||
app: dict
|
||||
|
||||
|
||||
@router.get("/stats", response_model=SystemStatsResponse)
|
||||
def get_system_stats(
|
||||
db: Session = Depends(get_db),
|
||||
_user=Depends(get_current_user),
|
||||
) -> SystemStatsResponse:
|
||||
ui = get_effective_ui_settings(db)
|
||||
payload = collect_system_stats(db)
|
||||
return SystemStatsResponse(visible=ui.show_sidebar_system_stats, **payload)
|
||||
Reference in New Issue
Block a user