Add configurable TIMEZONE for web UI display (UTC storage preserved)

This commit is contained in:
2026-07-17 12:02:58 +07:00
parent 559025d5f7
commit 513b8ede84
12 changed files with 131 additions and 7 deletions
+6 -1
View File
@@ -11,9 +11,13 @@ from auth import verify_token, require_admin
from models import Computer, Heartbeat, User, Notification, AuditLog, Setting
from notifications import check_offline_computers, get_unread_count
from settings_store import get_all_settings
from timezone_utils import localtime, localtime_iso, get_common_timezones, get_current_timezone
router = APIRouter()
templates = Jinja2Templates(directory="templates")
templates.env.filters["localtime"] = localtime
templates.env.filters["localtime_iso"] = localtime_iso
templates.env.globals["current_timezone"] = get_current_timezone
def user_or_redirect(request: Request, db: Session):
@@ -118,7 +122,7 @@ def computer_page(computer_id: int, request: Request, db: Session = Depends(get_
latest_sessions = []
for h in heartbeats:
hb_data.append({
"timestamp": h.timestamp.isoformat() if h.timestamp else None,
"timestamp": localtime_iso(h.timestamp),
"username": h.username,
"local_ip": h.local_ip,
"cpu_percent": h.cpu_percent,
@@ -223,6 +227,7 @@ def admin_settings_page(request: Request, db: Session = Depends(get_db)):
"request": request,
"user": current_user,
"settings": settings,
"timezones": get_common_timezones(),
"unread_count": get_unread_count(db),
},
)