commit 5187dd9d82edb0e7b28d038217f5fa3ebb36ca56
parent 2d1d0923824ec6dbe0098c198e47fdda9e0def8f
Author: breadcat <breadcat@users.noreply.github.com>
Date: Sun, 17 May 2026 19:39:09 +0100
Include recent files list in admin thumbnail tab
Diffstat:
4 files changed, 61 insertions(+), 25 deletions(-)
diff --git a/include-admin.go b/include-admin.go
@@ -20,12 +20,29 @@ func renderAdminPage(w http.ResponseWriter, r *http.Request, data AdminPageData)
renderTemplate(w, "admin.html", pageData)
}
+func getRecentFiles() []File {
+ rows, err := db.Query("SELECT id, filename FROM files ORDER BY id DESC LIMIT 20")
+ if err != nil {
+ log.Printf("Warning: getRecentFiles: failed to query recent files: %v", err)
+ return nil
+ }
+ defer rows.Close()
+ var files []File
+ for rows.Next() {
+ var f File
+ rows.Scan(&f.ID, &f.Filename)
+ files = append(files, f)
+ }
+ return files
+}
+
func currentAdminState(r *http.Request, orphanData OrphanData, missingThumbnails []VideoFile) AdminPageData {
return AdminPageData{
Config: config,
OrphanData: orphanData,
ActiveTab: r.FormValue("active_tab"),
MissingThumbnails: missingThumbnails,
+ RecentFiles: getRecentFiles(),
}
}
diff --git a/include-types.go b/include-types.go
@@ -138,6 +138,7 @@ type AdminPageData struct {
OrphanData OrphanData
ActiveTab string
MissingThumbnails []VideoFile
+ RecentFiles []File
}
type notesAnalysis struct {
diff --git a/static/admin-tabs.js b/static/admin-tabs.js
@@ -4,7 +4,7 @@ function activateTab(contentPrefix, btnSelector, tabPrefix, tabName) {
btn.style.fontWeight = 'normal';
});
- document.querySelectorAll(`[id^="${contentPrefix}"]`).forEach(el => {
+ document.querySelectorAll('[id^="' + contentPrefix + '"]').forEach(el => {
el.style.display = 'none';
});
@@ -27,7 +27,7 @@ function showThumbnailSubTab(subTabName) {
}
document.addEventListener('DOMContentLoaded', function() {
- showAdminTab('settings');
+ showAdminTab(window.activeAdminTab || 'settings');
showThumbnailSubTab('missing');
document.querySelectorAll('.auto-hide-success').forEach(div => {
diff --git a/templates/admin.html b/templates/admin.html
@@ -293,34 +293,51 @@
<div id="thumb-content-regenerate" style="display: none;">
<h3>Regenerate Thumbnail</h3>
- <div style="margin-bottom: 20px; padding: 10px; background-color: #e7f3ff; border: 1px solid #b3d9ff; border-radius: 4px;">
- <strong>Tip:</strong> Enter a file ID to regenerate its thumbnail with a custom timestamp. You can find file IDs in the URL when viewing a file (e.g., /file/312).
- </div>
+ <div style="display: flex; gap: 30px; align-items: flex-start;">
- <form method="post" action="/thumbnails/generate" style="max-width: 500px; padding: 20px; background-color: #f8f9fa; border: 1px solid #ddd; border-radius: 5px;">
- <input type="hidden" name="action" value="generate_single">
- <input type="hidden" name="redirect" value="admin">
+ <div style="flex: 0 0 auto;">
+ <div style="margin-bottom: 20px; padding: 10px; background-color: #e7f3ff; border: 1px solid #b3d9ff; border-radius: 4px; max-width: 500px;">
+ <strong>Tip:</strong> Enter a file ID to regenerate its thumbnail with a custom timestamp. You can find file IDs in the URL when viewing a file (e.g., /file/312).
+ </div>
- <div style="margin-bottom: 20px;">
- <label for="file_id" style="display: block; font-weight: bold; margin-bottom: 5px;">File ID:</label>
- <input type="text" id="file_id" name="file_id" required
- style="width: 100%; padding: 8px; font-size: 14px; font-family: monospace;"
- placeholder="e.g., 312">
- <small style="color: #666;">Enter the ID of the video file</small>
+ <form method="post" action="/thumbnails/generate" style="max-width: 500px; padding: 20px; background-color: #f8f9fa; border: 1px solid #ddd; border-radius: 5px;">
+ <input type="hidden" name="action" value="generate_single">
+ <input type="hidden" name="redirect" value="admin">
+
+ <div style="margin-bottom: 20px;">
+ <label for="file_id" style="display: block; font-weight: bold; margin-bottom: 5px;">File ID:</label>
+ <input type="text" id="file_id" name="file_id" required
+ style="width: 100%; padding: 8px; font-size: 14px; font-family: monospace;"
+ placeholder="e.g., 312">
+ <small style="color: #666;">Enter the ID of the video file</small>
+ </div>
+
+ <div style="margin-bottom: 20px;">
+ <label for="timestamp" style="display: block; font-weight: bold; margin-bottom: 5px;">Timestamp:</label>
+ <input type="text" id="timestamp" name="timestamp" value="00:00:05" required
+ style="width: 100%; padding: 8px; font-size: 14px; font-family: monospace;"
+ placeholder="00:00:05">
+ <small style="color: #666;">Format: HH:MM:SS (e.g., 00:00:05 for 5 seconds)</small>
+ </div>
+
+ <button type="submit" style="background-color: #007bff; color: white; padding: 10px 20px; border: none; border-radius: 4px; font-size: 16px; cursor: pointer; width: 100%;">
+ Generate/Regenerate Thumbnail
+ </button>
+ </form>
</div>
- <div style="margin-bottom: 20px;">
- <label for="timestamp" style="display: block; font-weight: bold; margin-bottom: 5px;">Timestamp:</label>
- <input type="text" id="timestamp" name="timestamp" value="00:00:05" required
- style="width: 100%; padding: 8px; font-size: 14px; font-family: monospace;"
- placeholder="00:00:05">
- <small style="color: #666;">Format: HH:MM:SS (e.g., 00:00:05 for 5 seconds)</small>
+ <div style="flex: 1; min-width: 200px;">
+ <h4 style="margin-top: 0;">Recent Files (for reference)</h4>
+ {{range .Data.RecentFiles}}
+ <div class="file-item">
+ <span class="file-id">ID {{.ID}}:</span> <a href="/file/{{.ID}}" title="{{.Filename}}">{{.Filename}}</a>
+ </div>
+ {{else}}
+ <div class="file-item">No files found</div>
+ {{end}}
</div>
- <button type="submit" style="background-color: #007bff; color: white; padding: 10px 20px; border: none; border-radius: 4px; font-size: 16px; cursor: pointer; width: 100%;">
- Generate/Regenerate Thumbnail
- </button>
- </form>
+ </div>
</div>
</div>
@@ -329,7 +346,8 @@
<script>window.activeAdminTab = "{{.Data.ActiveTab}}";</script>
<script src="/static/tag-alias.js" defer></script>
<script src="/static/sed-rules.js" defer></script>
-<script src="/static/admin-tabs.js" defer></script>
+<script src="/static/admin-tabs.js"></script>
<script src="/static/common.js" defer></script>
+<script src="/static/hover-preview.js" defer></script>
{{template "_footer"}}
\ No newline at end of file