Add storage analytics page

This commit is contained in:
2026-05-18 01:09:34 +02:00
parent a91b9b36d3
commit 691041814f
9 changed files with 439 additions and 8 deletions

View File

@@ -91,7 +91,7 @@ func (h *Handler) AdminPage(c *gin.Context) {
page = 1
}
limit := 10
limit := 25
offset := (page - 1) * limit
files, totalCount, err := h.fileService.GetPaginatedFiles(limit, offset)
@@ -103,11 +103,6 @@ func (h *Handler) AdminPage(c *gin.Context) {
return
}
// Only check files on the current page.
// Status meanings:
// - green: file exists on disk
// - red: file missing
// - rainbow: stat error (something unexpected)
type AdminFileView struct {
file.FileRecord
ActualStatus string
@@ -153,4 +148,26 @@ func (h *Handler) Logout(c *gin.Context) {
func (h *Handler) ChangePasswordPage(c *gin.Context) {
c.HTML(200, "changePassword.html", nil)
}
}
func (h *Handler) AdminStatsPage(c *gin.Context) {
log := middleware.StructuredLog(c).With().
Str("event", "admin_stats_page").
Logger()
stats, err := h.fileService.GetStorageStats()
if err != nil {
log.Error().Err(err).Msg("Failed to load storage stats")
c.HTML(500, "admin_stats.html", gin.H{
"error": err.Error(),
})
return
}
log.Info().Msg("Admin stats page viewed")
c.HTML(200, "admin_stats.html", gin.H{
"Stats": stats,
})
}