From 5caa4d3e5d56a33af1a44c2f38ecd76cb4a76496 Mon Sep 17 00:00:00 2001 From: Nick Adam Date: Thu, 20 Nov 2025 18:15:54 +0100 Subject: [PATCH] added users section in stats --- backend/main.go | 18 +++++++++++++++++- frontend/src/pages/Home.jsx | 14 ++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/backend/main.go b/backend/main.go index 28c51ca..c089a11 100644 --- a/backend/main.go +++ b/backend/main.go @@ -200,6 +200,7 @@ type StatsResponse struct { FQDNs int `json:"fqdns"` CSRs int `json:"csrs"` Certificates int `json:"certificates"` + Users int `json:"users"` } type Space struct { @@ -655,7 +656,7 @@ func getStatsHandler(w http.ResponseWriter, r *http.Request) { return } - var spacesCount, fqdnsCount, csrsCount, certificatesCount int + var spacesCount, fqdnsCount, csrsCount, certificatesCount, usersCount int // Zähle Spaces err := db.QueryRow("SELECT COUNT(*) FROM spaces").Scan(&spacesCount) @@ -689,11 +690,20 @@ func getStatsHandler(w http.ResponseWriter, r *http.Request) { return } + // Zähle Benutzer + err = db.QueryRow("SELECT COUNT(*) FROM users").Scan(&usersCount) + if err != nil { + http.Error(w, "Fehler beim Abrufen der Statistiken", http.StatusInternalServerError) + log.Printf("Fehler beim Zählen der Benutzer: %v", err) + return + } + response := StatsResponse{ Spaces: spacesCount, FQDNs: fqdnsCount, CSRs: csrsCount, Certificates: certificatesCount, + Users: usersCount, } json.NewEncoder(w).Encode(response) @@ -2211,6 +2221,12 @@ components: csrs: type: integer example: 7 + certificates: + type: integer + example: 8 + users: + type: integer + example: 3 Space: type: object properties: diff --git a/frontend/src/pages/Home.jsx b/frontend/src/pages/Home.jsx index dd79380..2cef111 100644 --- a/frontend/src/pages/Home.jsx +++ b/frontend/src/pages/Home.jsx @@ -267,6 +267,20 @@ const Home = () => { + +
+
+
+

Benutzer

+

{stats.users || 0}

+
+
+ + + +
+
+
) : (

Fehler beim Laden der Statistiken