Compare commits

...

2 Commits

2 changed files with 31 additions and 1 deletions

View File

@@ -200,6 +200,7 @@ type StatsResponse struct {
FQDNs int `json:"fqdns"` FQDNs int `json:"fqdns"`
CSRs int `json:"csrs"` CSRs int `json:"csrs"`
Certificates int `json:"certificates"` Certificates int `json:"certificates"`
Users int `json:"users"`
} }
type Space struct { type Space struct {
@@ -655,7 +656,7 @@ func getStatsHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
var spacesCount, fqdnsCount, csrsCount, certificatesCount int var spacesCount, fqdnsCount, csrsCount, certificatesCount, usersCount int
// Zähle Spaces // Zähle Spaces
err := db.QueryRow("SELECT COUNT(*) FROM spaces").Scan(&spacesCount) err := db.QueryRow("SELECT COUNT(*) FROM spaces").Scan(&spacesCount)
@@ -689,11 +690,20 @@ func getStatsHandler(w http.ResponseWriter, r *http.Request) {
return 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{ response := StatsResponse{
Spaces: spacesCount, Spaces: spacesCount,
FQDNs: fqdnsCount, FQDNs: fqdnsCount,
CSRs: csrsCount, CSRs: csrsCount,
Certificates: certificatesCount, Certificates: certificatesCount,
Users: usersCount,
} }
json.NewEncoder(w).Encode(response) json.NewEncoder(w).Encode(response)
@@ -2211,6 +2221,12 @@ components:
csrs: csrs:
type: integer type: integer
example: 7 example: 7
certificates:
type: integer
example: 8
users:
type: integer
example: 3
Space: Space:
type: object type: object
properties: properties:

View File

@@ -267,6 +267,20 @@ const Home = () => {
</div> </div>
</div> </div>
</div> </div>
<div className="bg-gradient-to-br from-cyan-500/20 to-cyan-600/20 rounded-lg p-4 border border-cyan-500/30">
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-slate-300 mb-1">Benutzer</p>
<p className="text-3xl font-bold text-white">{stats.users || 0}</p>
</div>
<div className="w-12 h-12 bg-cyan-500/20 rounded-full flex items-center justify-center">
<svg className="w-6 h-6 text-cyan-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z" />
</svg>
</div>
</div>
</div>
</div> </div>
) : ( ) : (
<p className="text-slate-400">Fehler beim Laden der Statistiken</p> <p className="text-slate-400">Fehler beim Laden der Statistiken</p>