Compare commits
1 Commits
csrf-token
...
50fa003842
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50fa003842 |
@@ -2,6 +2,7 @@ package web
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"ResendIt/internal/file"
|
"ResendIt/internal/file"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -70,10 +71,35 @@ func (h *Handler) AdminPage(c *gin.Context) {
|
|||||||
return
|
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
|
totalPages := (totalCount + limit - 1) / limit
|
||||||
|
|
||||||
c.HTML(200, "admin.html", gin.H{
|
c.HTML(200, "admin.html", gin.H{
|
||||||
"Files": files,
|
"Files": adminFiles,
|
||||||
"Page": page,
|
"Page": page,
|
||||||
"TotalPages": totalPages,
|
"TotalPages": totalPages,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -16,6 +16,24 @@
|
|||||||
td { border: 1px solid #000; padding: 10px; font-size: 13px; font-weight: 500; }
|
td { border: 1px solid #000; padding: 10px; font-size: 13px; font-weight: 500; }
|
||||||
tr:hover { background: #ffff00; }
|
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 */
|
/* 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-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; }
|
.status-deleted { background: #000; color: #ff0000; }
|
||||||
@@ -109,12 +127,13 @@
|
|||||||
<th>Hits</th>
|
<th>Hits</th>
|
||||||
<th>Burn</th>
|
<th>Burn</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
|
<th>Actual</th>
|
||||||
<th>System_Actions</th>
|
<th>System_Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{if not .Files}}
|
{{if not .Files}}
|
||||||
<tr><td colspan="7" class="text-center py-10 font-bold uppercase italic">Zero files in buffer</td></tr>
|
<tr><td colspan="8" class="text-center py-10 font-bold uppercase italic">Zero files in buffer</td></tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{range .Files}}
|
{{range .Files}}
|
||||||
<tr>
|
<tr>
|
||||||
@@ -147,6 +166,16 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<td class="text-center">
|
||||||
|
{{if eq .ActualStatus "green"}}
|
||||||
|
<span class="dot dot-green" title="File exists"></span>
|
||||||
|
{{else if eq .ActualStatus "red"}}
|
||||||
|
<span class="dot dot-red" title="File missing"></span>
|
||||||
|
{{else}}
|
||||||
|
<span class="dot dot-rainbow" title="Stat error"></span>
|
||||||
|
{{end}}
|
||||||
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
{{if not .Deleted}}
|
{{if not .Deleted}}
|
||||||
|
|||||||
Reference in New Issue
Block a user