diff --git a/internal/web/handler.go b/internal/web/handler.go index 483e3e0..8372eff 100644 --- a/internal/web/handler.go +++ b/internal/web/handler.go @@ -2,6 +2,7 @@ package web import ( "ResendIt/internal/file" + "os" "strconv" "github.com/gin-gonic/gin" @@ -70,10 +71,35 @@ 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 + } + + adminFiles := make([]AdminFileView, 0, len(files)) + for _, f := range files { + status := "red" + if f.Path != "" { + if _, err := os.Stat(f.Path); err == nil { + status = "green" + } else if os.IsNotExist(err) { + status = "red" + } else { + status = "rainbow" + } + } + adminFiles = append(adminFiles, AdminFileView{FileRecord: f, ActualStatus: status}) + } + totalPages := (totalCount + limit - 1) / limit c.HTML(200, "admin.html", gin.H{ - "Files": files, + "Files": adminFiles, "Page": page, "TotalPages": totalPages, }) diff --git a/templates/admin.html b/templates/admin.html index 6a12f01..88caf63 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -16,6 +16,24 @@ td { border: 1px solid #000; padding: 10px; font-size: 13px; font-weight: 500; } tr:hover { background: #ffff00; } + /* Actual file status dot */ + .dot { width: 12px; height: 12px; border: 2px solid #000; display: inline-block; } + .dot-green { background: #00ff00; } + .dot-red { background: #ff0000; } + .dot-rainbow { + animation: rainbow 0.8s linear infinite; + background: red; + } + @keyframes rainbow { + 0% { background: #ff0000; } + 16% { background: #ff9900; } + 33% { background: #ffff00; } + 50% { background: #00ff00; } + 66% { background: #00ccff; } + 83% { background: #9900ff; } + 100% { background: #ff0000; } + } + /* Harsh Status Tags */ .status-tag { font-weight: 900; font-size: 11px; padding: 3px 6px; border: 2px solid #000; display: inline-block; text-transform: uppercase; } .status-deleted { background: #000; color: #ff0000; } @@ -109,12 +127,13 @@ Hits Burn Status + Actual System_Actions {{if not .Files}} - Zero files in buffer + Zero files in buffer {{end}} {{range .Files}} @@ -147,6 +166,16 @@ {{end}} + + {{if eq .ActualStatus "green"}} + + {{else if eq .ActualStatus "red"}} + + {{else}} + + {{end}} + +
{{if not .Deleted}}