From 1b324bbd58200f5d152f61b85f11f158cc0d41c1 Mon Sep 17 00:00:00 2001 From: UserIsMH Date: Sun, 8 Jun 2025 00:43:29 +0200 Subject: [PATCH] Dashboard - redundante Informationen entfernt --- JOURNAL.md | 30 +++++++++++++++++++++++++- v2_adminpanel/app.py | 11 ++++++++++ v2_adminpanel/templates/dashboard.html | 28 +++++++++++------------- 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/JOURNAL.md b/JOURNAL.md index c1e4751..a14c3c2 100644 --- a/JOURNAL.md +++ b/JOURNAL.md @@ -1120,4 +1120,32 @@ Die Session-Daten werden erst gefüllt, wenn der License Server API implementier **Status:** - ✅ Alle Lizenzen haben nun automatisch einen Erstellungszeitstempel - ✅ Batch-Generierung funktioniert wieder -- ✅ Konsistente Zeitstempel für Audit-Zwecke \ No newline at end of file +- ✅ Konsistente Zeitstempel für Audit-Zwecke + +## 2025-01-06: Status "Deaktiviert" für manuell abgeschaltete Lizenzen + +**Problem:** +- Dashboard zeigte nur "aktiv" und "abgelaufen" als Status +- Manuell deaktivierte Lizenzen (is_active = FALSE) wurden nicht korrekt angezeigt +- Filter für "inactive" existierte, aber Status wurde nicht richtig berechnet + +**Lösung:** +1. **Status-Berechnung erweitert:** + - CASE-Statement prüft zuerst `is_active = FALSE` + - Status "deaktiviert" wird vor anderen Status geprüft + - Reihenfolge: deaktiviert → abgelaufen → läuft bald ab → aktiv +2. **Dashboard-Statistik erweitert:** + - Neue Zählung für deaktivierte Lizenzen + - Variable `inactive_licenses` im stats Dictionary + +**Änderungen:** +- `app.py`: Dashboard - Status-Berechnung für letzte 5 Lizenzen +- `app.py`: Lizenzübersicht - Status-Berechnung in der Hauptabfrage +- `app.py`: Export - Status-Berechnung für CSV/Excel Export +- `app.py`: Dashboard - Neue Statistik für deaktivierte Lizenzen + +**Status:** +- ✅ "Deaktiviert" wird korrekt als Status angezeigt +- ✅ Dashboard zeigt Anzahl deaktivierter Lizenzen +- ✅ Export enthält korrekten Status +- ✅ Konsistente Status-Anzeige überall \ No newline at end of file diff --git a/v2_adminpanel/app.py b/v2_adminpanel/app.py index c434209..d1142df 100644 --- a/v2_adminpanel/app.py +++ b/v2_adminpanel/app.py @@ -877,6 +877,13 @@ def dashboard(): """) expired_licenses = cur.fetchone()[0] + # Deaktivierte Lizenzen + cur.execute(""" + SELECT COUNT(*) FROM licenses + WHERE is_active = FALSE + """) + inactive_licenses = cur.fetchone()[0] + # Lizenzen die in den nächsten 30 Tagen ablaufen cur.execute(""" SELECT COUNT(*) FROM licenses @@ -898,6 +905,7 @@ def dashboard(): cur.execute(""" SELECT l.id, l.license_key, c.name, l.valid_until, CASE + WHEN l.is_active = FALSE THEN 'deaktiviert' WHEN l.valid_until < CURRENT_DATE THEN 'abgelaufen' WHEN l.valid_until < CURRENT_DATE + INTERVAL '30 days' THEN 'läuft bald ab' ELSE 'aktiv' @@ -990,6 +998,7 @@ def dashboard(): 'total_licenses': total_licenses, 'active_licenses': active_licenses, 'expired_licenses': expired_licenses, + 'inactive_licenses': inactive_licenses, 'expiring_soon': expiring_soon, 'full_licenses': license_types.get('full', 0), 'test_licenses': license_types.get('test', 0), @@ -1319,6 +1328,7 @@ def licenses(): SELECT l.id, l.license_key, c.name, c.email, l.license_type, l.valid_from, l.valid_until, l.is_active, CASE + WHEN l.is_active = FALSE THEN 'deaktiviert' WHEN l.valid_until < CURRENT_DATE THEN 'abgelaufen' WHEN l.valid_until < CURRENT_DATE + INTERVAL '30 days' THEN 'läuft bald ab' ELSE 'aktiv' @@ -1732,6 +1742,7 @@ def export_licenses(): SELECT l.id, l.license_key, c.name as customer_name, c.email as customer_email, l.license_type, l.valid_from, l.valid_until, l.is_active, CASE + WHEN l.is_active = FALSE THEN 'Deaktiviert' WHEN l.valid_until < CURRENT_DATE THEN 'Abgelaufen' WHEN l.valid_until < CURRENT_DATE + INTERVAL '30 days' THEN 'Läuft bald ab' ELSE 'Aktiv' diff --git a/v2_adminpanel/templates/dashboard.html b/v2_adminpanel/templates/dashboard.html index 2b3046a..f4a149d 100644 --- a/v2_adminpanel/templates/dashboard.html +++ b/v2_adminpanel/templates/dashboard.html @@ -13,6 +13,7 @@ .status-aktiv { color: #28a745; } .status-ablaufend { color: #ffc107; } .status-abgelaufen { color: #dc3545; } + .status-deaktiviert { color: #6c757d; } {% endblock %} @@ -33,7 +34,7 @@
-
+
👥 Kunden
@@ -42,7 +43,7 @@
-
+
📋 Lizenzen
@@ -51,16 +52,7 @@
-
-
-
-
✅ Aktiv
-

{{ stats.active_licenses }}

-

Gültige Lizenzen

-
-
-
-
+
🟢 Sessions
@@ -95,14 +87,18 @@
Lizenzstatus
-
+

{{ stats.active_licenses }}

Aktiv

-
+

{{ stats.expired_licenses }}

Abgelaufen

+
+

{{ stats.inactive_licenses }}

+

Deaktiviert

+
@@ -273,7 +269,9 @@ {{ license[2] }} {{ license[1][:8] }}... - {% if license[4] == 'abgelaufen' %} + {% if license[4] == 'deaktiviert' %} + 🚫 Deaktiviert + {% elif license[4] == 'abgelaufen' %} ⚠️ Abgelaufen {% elif license[4] == 'läuft bald ab' %} ⏰ Läuft bald ab