frontend: add force rescan to button and watch status display

- Send force: true in scan API request body
- Rename 'Scan Library' button to 'Rescan Library'
- Replace Settings card with Watch Status display
- Add loadWatchStatus() to fetch and display watch mode status
- Remove inline script from admin.templ (moved to admin.ts)
This commit is contained in:
2026-02-26 10:11:52 -05:00
parent a97220e654
commit abcc468024
2 changed files with 39 additions and 19 deletions
+30 -1
View File
@@ -128,7 +128,11 @@ async function scanAllLibraries(): Promise<void> {
for (const lib of libraries) {
const scanResp = await fetch(`/api/libraries/${lib.id}/scan`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${token}` }
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ force: true })
});
if (scanResp.ok) {
@@ -289,8 +293,33 @@ function hideScanProgress(): void {
if (container) container.classList.add('hidden');
}
async function loadWatchStatus(): Promise<void> {
const token = localStorage.getItem('token');
if (!token) return;
try {
const response = await fetch('/api/scanner/watch/status', {
headers: { 'Authorization': `Bearer ${token}` }
});
if (response.ok) {
const data = await response.json();
const countEl = document.getElementById('watch-count');
if (countEl) {
countEl.textContent = data.total_watching?.toString() || '0';
}
}
} catch (error) {
console.error('Failed to load watch status:', error);
}
}
document.addEventListener('DOMContentLoaded', function() {
loadWatchStatus();
});
(window as any).triggerLibraryScan = triggerLibraryScan;
(window as any).triggerQuickScan = triggerQuickScan;
(window as any).loadSystemStats = loadSystemStats;
(window as any).scanAllLibraries = scanAllLibraries;
(window as any).loadWatchStatus = loadWatchStatus;
(window as any).hideScanProgress = hideScanProgress;