- FDN-02: Rollback-fähige Down-Migrationen (024-026), archivdms seed dev CLI - FDN-03: internal/objectstore Interface + lokaler WORM-Treiber, signierte Download-URLs - FDN-07: go.mod/go.sum vervollständigt (fehlender go-ldap/v3-Eintrag), CI-Pipeline (.gitea/workflows/ci.yml, bereits in FDN-01 committet) damit lauffähig - FDN-08: Request-ID-Middleware, /metrics-Endpoint, Panic-Recovery, Login/Logout/Me technisches Logging inkl. Access-Log je Anfrage
30 lines
995 B
Go
30 lines
995 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"archivdms/internal/storage"
|
|
)
|
|
|
|
// handleDashboard returns aggregated, tenant-scoped key figures for the
|
|
// dashboard (GET /api/dashboard). Any authenticated user may view their own
|
|
// tenant's stats — no admin role required. Read-only, so no audit-log entry.
|
|
// Superadmin accounts have no tenant_id (by design, see auth.Manager.issueToken);
|
|
// they get an empty/zeroed snapshot instead of a 403, since there is no
|
|
// single tenant to scope the query to.
|
|
func (s *Server) handleDashboard(w http.ResponseWriter, r *http.Request) {
|
|
sess := sessionFromCtx(r.Context())
|
|
if sess.TenantID == nil {
|
|
writeJSON(w, http.StatusOK, &storage.DashboardStats{})
|
|
return
|
|
}
|
|
|
|
stats, err := s.store.GetDashboardStats(r.Context(), *sess.TenantID, sess.UserID)
|
|
if err != nil {
|
|
s.reqLog(r.Context()).Error("dashboard stats failed", "err", err)
|
|
writeError(w, http.StatusInternalServerError, "dashboard stats failed")
|
|
return
|
|
}
|
|
writeJSON(w, http.StatusOK, stats)
|
|
}
|