Download Backend/fastapi/templates/admin_dashboard.html from DevDoCode/stremio: direct link, hf CLI and curl.
- Browser
- Download file 17.3 kB
-
https://huggingface.co/spaces/DevDoCode/stremio/resolve/e581a8cc505fdc9406c4d06d05c669c8b71f8dc8/Backend/fastapi/templates/admin_dashboard.html
- Command line
-
hf download hf://spaces/DevDoCode/stremio@e581a8cc505fdc9406c4d06d05c669c8b71f8dc8/Backend/fastapi/templates/admin_dashboard.html
-
curl -L -o admin_dashboard.html https://huggingface.co/spaces/DevDoCode/stremio/resolve/e581a8cc505fdc9406c4d06d05c669c8b71f8dc8/Backend/fastapi/templates/admin_dashboard.html
17.3 kB
| {% extends "base.html" %} | |
| {% block title %}Admin Dashboard - Telegram Stremio{% endblock %} | |
| {% block content %} | |
| <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 text-text"> | |
| <div class="mb-8 flex justify-between items-center"> | |
| <div> | |
| <h1 class="text-3xl font-bold text-text">Admin Dashboard</h1> | |
| <p class="mt-2 text-sm theme-text-secondary">Monitor system health and manage flagged dead links.</p> | |
| </div> | |
| </div> | |
| <!-- System Health Section --> | |
| <div class="mb-10"> | |
| <div class="flex items-center justify-between mb-4"> | |
| <h2 class="text-xl font-semibold text-text">System Health</h2> | |
| <button onclick="clearCache()" | |
| class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-md text-sm font-medium transition-colors shadow-sm flex items-center justify-center"> | |
| <i class="fas fa-trash-alt mr-2"></i> Clear File Cache | |
| </button> | |
| </div> | |
| <div class="grid grid-cols-1 md:grid-cols-3 gap-6" id="stats-container"> | |
| <!-- Cache Card --> | |
| <div class="theme-card rounded-xl border p-6 shadow-sm"> | |
| <div class="flex items-center"> | |
| <div class="flex-shrink-0 bg-primary/10 p-3 rounded-lg"> | |
| <i class="fas fa-memory text-xl text-primary"></i> | |
| </div> | |
| <div class="ml-4"> | |
| <h3 class="text-sm font-medium theme-text-secondary">Cached File IDs</h3> | |
| <p class="text-2xl font-bold text-text" id="stat-cache-size">-</p> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Active Bots Card --> | |
| <div class="theme-card rounded-xl border p-6 shadow-sm"> | |
| <div class="flex items-center"> | |
| <div class="flex-shrink-0 bg-primary/10 p-3 rounded-lg"> | |
| <i class="fas fa-robot text-xl text-primary"></i> | |
| </div> | |
| <div class="ml-4"> | |
| <h3 class="text-sm font-medium theme-text-secondary">Connected Bots</h3> | |
| <p class="text-2xl font-bold text-text" id="stat-bot-count">-</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Bot Health & Load --> | |
| <div class="theme-card rounded-xl border shadow-sm mt-6"> | |
| <div class="flex items-center justify-between px-6 py-4 border-b"> | |
| <div class="flex items-center gap-3"> | |
| <div class="bg-primary/10 p-2 rounded-lg"> | |
| <i class="fas fa-heartbeat text-primary"></i> | |
| </div> | |
| <h3 class="text-base font-semibold text-text">Bot Health & Load</h3> | |
| </div> | |
| </div> | |
| <div id="stat-workloads" class="divide-y divide-white/10"> | |
| <div class="px-6 py-4 text-sm theme-text-secondary">Loading...</div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Stream Analytics --> | |
| <div class="mb-10"> | |
| <div class="flex items-center justify-between mb-4"> | |
| <h2 class="text-xl font-semibold text-text">Recent Stream Analytics</h2> | |
| <button onclick="clearAnalytics()" | |
| class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-md text-sm font-medium transition-colors shadow-sm flex items-center"> | |
| <i class="fas fa-trash-alt mr-2"></i> Clear Analytics | |
| </button> | |
| </div> | |
| <div class="theme-card border rounded-xl overflow-hidden shadow-sm"> | |
| <div class="overflow-x-auto"> | |
| <table class="w-full text-sm text-left text-text"> | |
| <thead class="text-xs uppercase theme-card border-b text-text"> | |
| <tr> | |
| <th class="px-6 py-4 font-semibold">Stream ID</th> | |
| <th class="px-6 py-4 font-semibold">Title</th> | |
| <th class="px-6 py-4 font-semibold text-center">Bot (DC)</th> | |
| <th class="px-6 py-4 font-semibold text-right">Data Transferred</th> | |
| <th class="px-6 py-4 font-semibold text-right">Avg / Peak Speed</th> | |
| <th class="px-6 py-4 font-semibold text-center">Duration</th> | |
| <th class="px-6 py-4 font-semibold text-center">Status</th> | |
| <th class="px-6 py-4 font-semibold text-right">Time</th> | |
| </tr> | |
| </thead> | |
| <tbody id="analytics-tbody" class="divide-y divide-white/10"> | |
| <tr> | |
| <td colspan="8" class="px-6 py-8 text-center theme-text-secondary"> | |
| <i class="fas fa-spinner fa-spin text-primary mr-2"></i> Loading analytics... | |
| </td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Dead Links --> | |
| <div> | |
| <h2 class="text-xl font-semibold text-text mb-4">Flagged Dead Links</h2> | |
| <div class="theme-card border rounded-xl overflow-hidden shadow-sm"> | |
| <div class="overflow-x-auto"> | |
| <table class="w-full text-sm text-left text-text"> | |
| <thead class="text-xs uppercase theme-card border-b text-text"> | |
| <tr> | |
| <th class="px-6 py-4 font-semibold">Title</th> | |
| <th class="px-6 py-4 font-semibold w-24">Type</th> | |
| <th class="px-6 py-4 font-semibold">Quality Details</th> | |
| <th class="px-6 py-4 font-semibold w-32 text-center">Date Added</th> | |
| <th class="px-6 py-4 font-semibold w-24 text-center">Action</th> | |
| </tr> | |
| </thead> | |
| <tbody id="dead-links-tbody" class="divide-y divide-white/10"> | |
| <tr> | |
| <td colspan="5" class="px-6 py-8 text-center theme-text-secondary"> | |
| <i class="fas fa-spinner fa-spin text-primary mr-2"></i> Loading dead links... | |
| </td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| async function fetchStats() { | |
| try { | |
| const res = await fetch('/api/admin/system-stats'); | |
| if (res.ok) { | |
| const data = await res.json(); | |
| document.getElementById('stat-cache-size').textContent = data.cache_size; | |
| document.getElementById('stat-bot-count').textContent = data.total_bots; | |
| let wlHtml = ''; | |
| if (data.bot_workloads && data.bot_workloads.length > 0) { | |
| data.bot_workloads.forEach(b => { | |
| let statusColor = 'bg-green-500/10 text-green-500'; | |
| if (b.status === 'degraded') statusColor = 'bg-yellow-500/10 text-yellow-500'; | |
| if (b.status === 'failing') statusColor = 'bg-red-500/10 text-red-500'; | |
| wlHtml += ` | |
| <div class="flex items-center justify-between px-6 py-4 hover:bg-white/5 transition-colors"> | |
| <div class="flex items-center gap-3"> | |
| <span class="font-semibold text-text">${b.display_name}</span> | |
| <span class="text-[10px] px-2 py-0.5 rounded-full uppercase font-bold tracking-wider ${statusColor}">${b.status}</span> | |
| </div> | |
| <div class="flex items-center gap-6 text-sm"> | |
| <div class="text-center"> | |
| <div class="text-xs theme-text-secondary mb-0.5">Active Streams</div> | |
| <div class="font-bold text-text">${b.current_load}</div> | |
| </div> | |
| <div class="text-center"> | |
| <div class="text-xs theme-text-secondary mb-0.5">Avg Speed</div> | |
| <div class="font-bold text-text">${b.avg_mbps} <span class="font-normal text-xs theme-text-secondary">MB/s</span></div> | |
| </div> | |
| <div class="text-center"> | |
| <div class="text-xs theme-text-secondary mb-0.5">Recent Failures</div> | |
| <div class="font-bold ${b.failures > 0 ? 'text-red-500' : 'theme-text-secondary'}">${b.failures}</div> | |
| </div> | |
| </div> | |
| </div> | |
| `; | |
| }); | |
| } else { | |
| wlHtml = '<div class="px-6 py-8 text-center theme-text-secondary">No bot data available</div>'; | |
| } | |
| document.getElementById('stat-workloads').innerHTML = wlHtml; | |
| } | |
| } catch (err) { | |
| console.error(err); | |
| } | |
| } | |
| async function fetchAnalytics() { | |
| try { | |
| const res = await fetch('/api/admin/stream-analytics'); | |
| const tbody = document.getElementById('analytics-tbody'); | |
| if (res.ok) { | |
| const data = await res.json(); | |
| const streams = data.data.recent; | |
| if (!streams || streams.length === 0) { | |
| tbody.innerHTML = '<tr><td colspan="8" class="px-6 py-8 text-center theme-text-secondary">No recent streams recorded.</td></tr>'; | |
| return; | |
| } | |
| let html = ''; | |
| streams.forEach(s => { | |
| const mbpsStr = `${s.avg_mbps.toFixed(1)} / <span class="theme-text-secondary">${s.peak_mbps.toFixed(1)}</span>`; | |
| const bytesStr = (s.total_bytes / (1024 * 1024)).toFixed(1) + ' MB'; | |
| const timeStr = new Date(s.logged_at).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); | |
| const durationStr = s.duration_sec ? `${s.duration_sec.toFixed(1)}s` : '—'; | |
| const titleStr = s.title || s.meta?.title || '—'; | |
| let statusColor = 'text-green-500'; | |
| if (s.status === 'error') statusColor = 'text-red-500'; | |
| if (s.status === 'cancelled') statusColor = 'text-yellow-500'; | |
| html += ` | |
| <tr class="hover:bg-white/5 transition-colors"> | |
| <td class="px-6 py-3 font-mono text-xs theme-text-secondary truncate max-w-[120px]" title="${s.stream_id}">${s.stream_id}</td> | |
| <td class="px-6 py-3 text-sm font-medium text-text max-w-[160px] truncate" title="${titleStr}">${titleStr}</td> | |
| <td class="px-6 py-3 text-center">Bot ${s.client_index + 1} <span class="text-xs theme-text-secondary ml-1">(DC${s.dc_id})</span></td> | |
| <td class="px-6 py-3 text-right font-medium text-text">${bytesStr}</td> | |
| <td class="px-6 py-3 text-right font-medium text-text">${mbpsStr} <span class="text-xs theme-text-secondary">MB/s</span></td> | |
| <td class="px-6 py-3 text-center theme-text-secondary">${durationStr}</td> | |
| <td class="px-6 py-3 text-center capitalize text-xs font-bold ${statusColor}">${s.status}</td> | |
| <td class="px-6 py-3 text-right theme-text-secondary text-xs">${timeStr}</td> | |
| </tr> | |
| `; | |
| }); | |
| tbody.innerHTML = html; | |
| } | |
| } catch (err) { | |
| console.error(err); | |
| } | |
| } | |
| async function fetchDeadLinks() { | |
| try { | |
| const res = await fetch('/api/admin/dead-links'); | |
| const tbody = document.getElementById('dead-links-tbody'); | |
| if (res.ok) { | |
| const data = await res.json(); | |
| const links = data.data; | |
| if (links.length === 0) { | |
| tbody.innerHTML = '<tr><td colspan="5" class="px-6 py-8 text-center theme-text-secondary">No dead links found. All files are healthy!</td></tr>'; | |
| return; | |
| } | |
| let html = ''; | |
| links.forEach(l => { | |
| const typeBadge = l.type === 'movie' | |
| ? '<span class="px-2 py-1 rounded bg-primary/10 text-primary text-xs font-medium">Movie</span>' | |
| : '<span class="px-2 py-1 rounded bg-accent/10 text-accent text-xs font-medium">TV Series</span>'; | |
| html += ` | |
| <tr class="hover:bg-white/5 transition-colors"> | |
| <td class="px-6 py-4"> | |
| <div class="font-medium text-text">${l.title}</div> | |
| <div class="text-xs theme-text-secondary">${l.year || ''}</div> | |
| </td> | |
| <td class="px-6 py-4">${typeBadge}</td> | |
| <td class="px-6 py-4"> | |
| <div class="text-sm font-medium text-red-500">${l.quality}</div> | |
| <div class="text-xs theme-text-secondary">${l.size || 'Unknown size'}</div> | |
| </td> | |
| <td class="px-6 py-4 text-center theme-text-secondary text-xs">${l.date_added ? new Date(l.date_added).toLocaleDateString() : '—'}</td> | |
| <td class="px-6 py-4 text-center"> | |
| <button onclick="deleteDeadLink(${l.tmdb_id}, ${l.db_index}, '${l.type}', '${l.quality_id}', ${l.season || -1}, ${l.episode || -1})" | |
| class="text-red-500 hover:text-red-600 bg-red-500/10 hover:bg-red-500/20 rounded p-2 transition-colors" | |
| title="Delete from Database"> | |
| <i class="fas fa-trash"></i> | |
| </button> | |
| </td> | |
| </tr> | |
| `; | |
| }); | |
| tbody.innerHTML = html; | |
| } | |
| } catch (err) { | |
| console.error(err); | |
| } | |
| } | |
| async function clearCache() { | |
| if (!confirm("Are you sure you want to clear the Telegram FileId cache? This will force bots to re-fetch metadata on the next stream.")) return; | |
| try { | |
| const res = await fetch('/api/admin/clear-cache', { method: 'POST' }); | |
| if (res.ok) { | |
| const data = await res.json(); | |
| alert(data.message); | |
| fetchStats(); | |
| } else { | |
| alert("Failed to clear cache."); | |
| } | |
| } catch (err) { | |
| alert("Error clearing cache."); | |
| } | |
| } | |
| async function clearAnalytics() { | |
| if (!confirm("Are you sure you want to clear all stream analytics history? This cannot be undone.")) return; | |
| try { | |
| const res = await fetch('/api/admin/clear-analytics', { method: 'POST' }); | |
| if (res.ok) { | |
| const data = await res.json(); | |
| alert(data.message || 'Analytics cleared successfully.'); | |
| fetchAnalytics(); | |
| } else { | |
| const err = await res.json().catch(() => ({})); | |
| alert(err.detail || 'Failed to clear analytics.'); | |
| } | |
| } catch (err) { | |
| alert('Error clearing analytics.'); | |
| } | |
| } | |
| async function deleteDeadLink(tmdb_id, db_index, type, quality_id, season, episode) { | |
| if (!confirm("Are you sure you want to purge this dead link from the database? Users will no longer see this quality in Stremio.")) return; | |
| try { | |
| let endpoint = ''; | |
| if (type === 'movie') { | |
| endpoint = `/api/media/delete-quality?tmdb_id=${tmdb_id}&db_index=${db_index}&id=${quality_id}`; | |
| } else { | |
| endpoint = `/api/media/delete-tv-quality?tmdb_id=${tmdb_id}&db_index=${db_index}&season=${season}&episode=${episode}&id=${quality_id}`; | |
| } | |
| const res = await fetch(endpoint, { method: 'DELETE' }); | |
| if (res.ok) { | |
| fetchDeadLinks(); // Refresh table | |
| } else { | |
| alert("Failed to delete the dead link."); | |
| } | |
| } catch (err) { | |
| alert("Error communicating with server."); | |
| } | |
| } | |
| // Initial fetch on load | |
| document.addEventListener('DOMContentLoaded', () => { | |
| fetchStats(); | |
| fetchAnalytics(); | |
| fetchDeadLinks(); | |
| // Refresh dynamic stats | |
| setInterval(fetchStats, 10000); | |
| setInterval(fetchAnalytics, 15000); | |
| }); | |
| </script> | |
| {% endblock %} | |