Add storage analytics page
This commit is contained in:
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ func RegisterRoutes(r *gin.Engine, h *Handler, userService *user.Service) {
|
||||
adminRoutes.Use(user.ForcePasswordChangeMiddleware(userService))
|
||||
|
||||
adminRoutes.GET("/admin", h.AdminPage)
|
||||
adminRoutes.GET("/admin/stats", h.AdminStatsPage)
|
||||
adminRoutes.GET("/config", h.ConfigPage)
|
||||
adminRoutes.POST("/config", h.ConfigSave)
|
||||
adminRoutes.GET("/logout", h.Logout)
|
||||
|
||||
Reference in New Issue
Block a user