feat: add update service env label

This commit is contained in:
2026-01-15 11:18:54 +01:00
parent f513d46d08
commit 8c55fd4954
7 changed files with 21 additions and 4 deletions

View File

@ -81,3 +81,4 @@ class UpdateServiceStatus(BaseModel):
status_code: Optional[int] = None
error: Optional[str] = None
checked_url: str
environment: str

View File

@ -128,13 +128,13 @@
<section id="updateSection" class="panel-section hidden">
<h3><i data-lucide="download"></i> Update-Verwaltung</h3>
<div id="updateStatus" style="background: rgba(10, 14, 20, 0.6); border: 1px solid var(--color-border); border-left: 3px solid var(--color-accent); padding: 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem;">
<div id="updateStatus" style="background: var(--bg-panel); border: 1px solid var(--border-main); border-left: 3px solid var(--primary); padding: 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem;">
<div class="spinner" style="margin: 0 auto;"></div>
<p class="text-center text-muted mt-1">Lade Update-Status...</p>
</div>
<!-- Enrollment Section -->
<div id="enrollmentSection" class="hidden" style="margin-bottom: 1rem; padding: 1rem; background: rgba(255, 255, 255, 0.05); border-radius: var(--radius-sm); border: 1px dashed var(--color-border);">
<div id="enrollmentSection" class="hidden" style="margin-bottom: 1rem; padding: 1rem; background: var(--bg-panel); border-radius: var(--radius-sm); border: 1px dashed var(--border-main);">
<h4 style="margin-top: 0; margin-bottom: 0.5rem;"><i data-lucide="link"></i> Gerät registrieren (Enrollment)</h4>
<p class="text-muted" style="font-size: 0.875rem; margin-bottom: 0.5rem;">
Dieses Gerät ist noch nicht beim Update-Service registriert. Bitte geben Sie einen gültigen Enrollment-Token ein.
@ -442,6 +442,9 @@
const serviceBadge = serviceStatus.reachable
? '<span class="badge success"><i data-lucide="server"></i> Online</span>'
: '<span class="badge error"><i data-lucide="server-off"></i> Offline</span>';
const envLabel = serviceStatus.environment
? serviceStatus.environment.toUpperCase()
: 'UNKNOWN';
const serviceHint = serviceStatus.status_code
? `HTTP ${serviceStatus.status_code}`
: (serviceStatus.error || 'keine Antwort');
@ -455,6 +458,7 @@
<div>
<div class="text-muted" style="font-size: 0.75rem; text-transform: uppercase; margin-bottom: 0.25rem;">Update-Service</div>
<div>${serviceBadge}</div>
<div class="badge neutral" style="display: inline-flex; margin-top: 0.25rem;">${envLabel}</div>
<div class="text-muted" style="font-size: 0.75rem;">${serviceStatus.url} (${serviceHint})</div>
</div>
<div>

View File

@ -231,8 +231,16 @@ def get_service_status(settings: Settings) -> Dict[str, Any]:
"status_code": None,
"error": "update service url not configured",
"checked_url": "",
"environment": "unknown",
}
env = "prod"
lowered = base_url.lower()
if "://dev." in lowered or lowered.startswith("dev."):
env = "dev"
elif "://staging." in lowered or lowered.startswith("staging."):
env = "staging"
check_url = base_url
try:
with httpx.Client(timeout=3.0) as client:
@ -243,6 +251,7 @@ def get_service_status(settings: Settings) -> Dict[str, Any]:
"status_code": response.status_code,
"error": None,
"checked_url": check_url,
"environment": env,
}
except Exception as exc:
return {
@ -251,4 +260,5 @@ def get_service_status(settings: Settings) -> Dict[str, Any]:
"status_code": None,
"error": str(exc),
"checked_url": check_url,
"environment": env,
}