refactor: complete rewrite as React+FastAPI dashboard
Replace monolithic Jinja2 template with modern stack: Backend (FastAPI): - Modular router/service architecture - Async PostgreSQL (asyncpg) for news from n8n pipeline - Live Unraid server stats (2 servers via API) - Home Assistant, Vikunja tasks, weather (wttr.in) - WebSocket broadcast for real-time updates (15s) - TTL cache per endpoint, all config via ENV vars Frontend (React + Vite + TypeScript): - Glassmorphism dark theme with Tailwind CSS - Responsive grid: mobile/tablet/desktop/ultrawide - Weather cards, hourly forecast, news with category tabs - Server stats (CPU ring, RAM bar, Docker list) - Home Assistant controls, task management - Live clock, WebSocket connection indicator Infrastructure: - Multi-stage Dockerfile (node:22-alpine + python:3.11-slim) - docker-compose with full ENV configuration - Kaniko CI/CD pipeline for GitLab registry Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4bbc125a67
commit
9f7330e217
48 changed files with 6390 additions and 1461 deletions
64
server/routers/servers.py
Normal file
64
server/routers/servers.py
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
"""Unraid servers status router."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from server.cache import cache
|
||||
from server.config import settings
|
||||
from server.services.unraid_service import ServerConfig, fetch_all_servers
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
router = APIRouter(prefix="/api", tags=["servers"])
|
||||
|
||||
CACHE_KEY = "servers"
|
||||
|
||||
|
||||
@router.get("/servers")
|
||||
async def get_servers() -> Dict[str, Any]:
|
||||
"""Return status information for all configured Unraid servers.
|
||||
|
||||
Response shape::
|
||||
|
||||
{
|
||||
"servers": [ ... server dicts ... ]
|
||||
}
|
||||
"""
|
||||
|
||||
# --- cache hit? -----------------------------------------------------------
|
||||
cached = await cache.get(CACHE_KEY)
|
||||
if cached is not None:
|
||||
return cached
|
||||
|
||||
# --- cache miss -----------------------------------------------------------
|
||||
server_configs: List[ServerConfig] = [
|
||||
ServerConfig(
|
||||
name=srv.name,
|
||||
host=srv.host,
|
||||
api_key=srv.api_key,
|
||||
port=srv.port,
|
||||
)
|
||||
for srv in settings.unraid_servers
|
||||
]
|
||||
|
||||
servers_data: List[Dict[str, Any]] = []
|
||||
try:
|
||||
servers_data = await fetch_all_servers(server_configs)
|
||||
except Exception as exc:
|
||||
logger.exception("Failed to fetch Unraid server data")
|
||||
return {
|
||||
"servers": [],
|
||||
"error": True,
|
||||
"message": str(exc),
|
||||
}
|
||||
|
||||
payload: Dict[str, Any] = {
|
||||
"servers": servers_data,
|
||||
}
|
||||
|
||||
await cache.set(CACHE_KEY, payload, settings.unraid_cache_ttl)
|
||||
return payload
|
||||
Loading…
Add table
Add a link
Reference in a new issue