Karan Adhikari commited on
Commit
de94e0d
·
unverified ·
1 Parent(s): b2b72aa

Update styling and text in admin dashboard template

Browse files
Backend/fastapi/templates/admin_dashboard.html CHANGED
@@ -3,19 +3,18 @@
3
  {% block title %}Admin Dashboard - Telegram Stremio{% endblock %}
4
 
5
  {% block content %}
6
- <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
7
  <div class="mb-8 flex justify-between items-center">
8
  <div>
9
- <h1 class="text-3xl font-bold text-gray-900 dark:text-white">Admin Dashboard</h1>
10
- <p class="mt-2 text-sm text-gray-600 dark:text-gray-400">Monitor system health and manage flagged dead
11
- links.</p>
12
  </div>
13
  </div>
14
 
15
  <!-- System Health Section -->
16
  <div class="mb-10">
17
  <div class="flex items-center justify-between mb-4">
18
- <h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">System Health</h2>
19
  <button onclick="clearCache()"
20
  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">
21
  <i class="fas fa-trash-alt mr-2"></i> Clear File Cache
@@ -26,12 +25,12 @@
26
  <!-- Cache Card -->
27
  <div class="theme-card rounded-xl border p-6 shadow-sm">
28
  <div class="flex items-center">
29
- <div class="flex-shrink-0 bg-blue-100 dark:bg-blue-900/30 p-3 rounded-lg">
30
- <i class="fas fa-memory text-xl text-blue-600 dark:text-blue-400"></i>
31
  </div>
32
  <div class="ml-4">
33
- <h3 class="text-sm font-medium text-gray-500 dark:text-gray-400">Cached File IDs</h3>
34
- <p class="text-2xl font-bold text-gray-900 dark:text-white" id="stat-cache-size">-</p>
35
  </div>
36
  </div>
37
  </div>
@@ -39,47 +38,47 @@
39
  <!-- Active Bots Card -->
40
  <div class="theme-card rounded-xl border p-6 shadow-sm">
41
  <div class="flex items-center">
42
- <div class="flex-shrink-0 bg-green-100 dark:bg-green-900/30 p-3 rounded-lg">
43
- <i class="fas fa-robot text-xl text-green-600 dark:text-green-400"></i>
44
  </div>
45
  <div class="ml-4">
46
- <h3 class="text-sm font-medium text-gray-500 dark:text-gray-400">Connected Bots</h3>
47
- <p class="text-2xl font-bold text-gray-900 dark:text-white" id="stat-bot-count">-</p>
48
  </div>
49
  </div>
50
  </div>
51
-
52
  </div>
53
 
54
- <!-- Bot Health & Load - Full Width -->
55
  <div class="theme-card rounded-xl border shadow-sm mt-6">
56
  <div class="flex items-center justify-between px-6 py-4 border-b">
57
  <div class="flex items-center gap-3">
58
- <div class="bg-purple-100 dark:bg-purple-900/30 p-2 rounded-lg">
59
- <i class="fas fa-heartbeat text-purple-600 dark:text-purple-400"></i>
60
  </div>
61
- <h3 class="text-base font-semibold text-gray-800 dark:text-gray-200">Bot Health & Load</h3>
62
  </div>
63
  </div>
64
- <div id="stat-workloads" class="divide-y divide-gray-100 dark:divide-gray-800">
65
- <div class="px-6 py-4 text-sm text-gray-500">Loading...</div>
66
  </div>
67
  </div>
68
  </div>
69
 
70
- <!-- Stream Analytics Section -->
71
  <div class="mb-10">
72
  <div class="flex items-center justify-between mb-4">
73
- <h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">Recent Stream Analytics</h2>
74
  <button onclick="clearAnalytics()"
75
  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">
76
  <i class="fas fa-trash-alt mr-2"></i> Clear Analytics
77
  </button>
78
  </div>
 
79
  <div class="theme-card border rounded-xl overflow-hidden shadow-sm">
80
  <div class="overflow-x-auto">
81
- <table class="w-full text-sm text-left">
82
- <thead class="text-xs uppercase bg-gray-50 dark:bg-gray-800 dark:text-gray-300 border-b">
83
  <tr>
84
  <th class="px-6 py-4 font-semibold">Stream ID</th>
85
  <th class="px-6 py-4 font-semibold">Title</th>
@@ -91,10 +90,10 @@
91
  <th class="px-6 py-4 font-semibold text-right">Time</th>
92
  </tr>
93
  </thead>
94
- <tbody id="analytics-tbody" class="divide-y divide-gray-100 dark:divide-gray-800">
95
  <tr>
96
- <td colspan="8" class="px-6 py-8 text-center text-gray-500">
97
- <i class="fas fa-spinner fa-spin mr-2"></i> Loading analytics...
98
  </td>
99
  </tr>
100
  </tbody>
@@ -103,13 +102,13 @@
103
  </div>
104
  </div>
105
 
106
- <!-- Dead Links Section -->
107
  <div>
108
- <h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200 mb-4">Flagged Dead Links</h2>
109
  <div class="theme-card border rounded-xl overflow-hidden shadow-sm">
110
  <div class="overflow-x-auto">
111
- <table class="w-full text-sm text-left">
112
- <thead class="text-xs uppercase bg-gray-50 dark:bg-gray-800 dark:text-gray-300 border-b">
113
  <tr>
114
  <th class="px-6 py-4 font-semibold">Title</th>
115
  <th class="px-6 py-4 font-semibold w-24">Type</th>
@@ -118,10 +117,10 @@
118
  <th class="px-6 py-4 font-semibold w-24 text-center">Action</th>
119
  </tr>
120
  </thead>
121
- <tbody id="dead-links-tbody" class="divide-y divide-gray-100 dark:divide-gray-800">
122
  <tr>
123
- <td colspan="5" class="px-6 py-8 text-center text-gray-500">
124
- <i class="fas fa-spinner fa-spin mr-2"></i> Loading dead links...
125
  </td>
126
  </tr>
127
  </tbody>
@@ -143,35 +142,35 @@
143
  let wlHtml = '';
144
  if (data.bot_workloads && data.bot_workloads.length > 0) {
145
  data.bot_workloads.forEach(b => {
146
- let statusColor = 'bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400';
147
- if (b.status === 'degraded') statusColor = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400';
148
- if (b.status === 'failing') statusColor = 'bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400';
149
 
150
  wlHtml += `
151
- <div class="flex items-center justify-between px-6 py-4 hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors">
152
  <div class="flex items-center gap-3">
153
- <span class="font-semibold text-gray-900 dark:text-white">${b.display_name}</span>
154
  <span class="text-[10px] px-2 py-0.5 rounded-full uppercase font-bold tracking-wider ${statusColor}">${b.status}</span>
155
  </div>
156
  <div class="flex items-center gap-6 text-sm">
157
  <div class="text-center">
158
- <div class="text-xs text-gray-500 mb-0.5">Active Streams</div>
159
- <div class="font-bold text-gray-900 dark:text-white">${b.current_load}</div>
160
  </div>
161
  <div class="text-center">
162
- <div class="text-xs text-gray-500 mb-0.5">Avg Speed</div>
163
- <div class="font-bold text-gray-900 dark:text-white">${b.avg_mbps} <span class="font-normal text-xs text-gray-400">MB/s</span></div>
164
  </div>
165
  <div class="text-center">
166
- <div class="text-xs text-gray-500 mb-0.5">Recent Failures</div>
167
- <div class="font-bold ${b.failures > 0 ? 'text-red-500' : 'text-gray-400'}">${b.failures}</div>
168
  </div>
169
  </div>
170
  </div>
171
  `;
172
  });
173
  } else {
174
- wlHtml = '<div class="px-6 py-8 text-center text-gray-500">No bot data available</div>';
175
  }
176
  document.getElementById('stat-workloads').innerHTML = wlHtml;
177
  }
@@ -189,13 +188,13 @@
189
  const streams = data.data.recent;
190
 
191
  if (!streams || streams.length === 0) {
192
- tbody.innerHTML = '<tr><td colspan="8" class="px-6 py-8 text-center text-gray-500">No recent streams recorded.</td></tr>';
193
  return;
194
  }
195
 
196
  let html = '';
197
  streams.forEach(s => {
198
- const mbpsStr = `${s.avg_mbps.toFixed(1)} / <span class="text-gray-400">${s.peak_mbps.toFixed(1)}</span>`;
199
  const bytesStr = (s.total_bytes / (1024 * 1024)).toFixed(1) + ' MB';
200
  const timeStr = new Date(s.logged_at).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
201
  const durationStr = s.duration_sec ? `${s.duration_sec.toFixed(1)}s` : '—';
@@ -206,15 +205,15 @@
206
  if (s.status === 'cancelled') statusColor = 'text-yellow-500';
207
 
208
  html += `
209
- <tr class="hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors">
210
- <td class="px-6 py-3 font-mono text-xs text-gray-500 truncate max-w-[120px]" title="${s.stream_id}">${s.stream_id}</td>
211
- <td class="px-6 py-3 text-sm font-medium text-gray-800 dark:text-gray-200 max-w-[160px] truncate" title="${titleStr}">${titleStr}</td>
212
- <td class="px-6 py-3 text-center">Bot ${s.client_index + 1} <span class="text-xs text-gray-400 ml-1">(DC${s.dc_id})</span></td>
213
- <td class="px-6 py-3 text-right font-medium">${bytesStr}</td>
214
- <td class="px-6 py-3 text-right font-medium text-gray-700 dark:text-gray-300">${mbpsStr} <span class="text-xs text-gray-500">MB/s</span></td>
215
- <td class="px-6 py-3 text-center text-gray-500">${durationStr}</td>
216
  <td class="px-6 py-3 text-center capitalize text-xs font-bold ${statusColor}">${s.status}</td>
217
- <td class="px-6 py-3 text-right text-gray-500 text-xs">${timeStr}</td>
218
  </tr>
219
  `;
220
  });
@@ -234,31 +233,32 @@
234
  const links = data.data;
235
 
236
  if (links.length === 0) {
237
- tbody.innerHTML = '<tr><td colspan="5" class="px-6 py-8 text-center text-gray-500">No dead links found. All files are healthy!</td></tr>';
238
  return;
239
  }
240
 
241
  let html = '';
242
  links.forEach(l => {
243
  const typeBadge = l.type === 'movie'
244
- ? '<span class="px-2 py-1 rounded bg-blue-100 text-blue-800 text-xs font-medium">Movie</span>'
245
- : '<span class="px-2 py-1 rounded bg-purple-100 text-purple-800 text-xs font-medium">TV Series</span>';
246
 
247
  html += `
248
- <tr class="hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors">
249
  <td class="px-6 py-4">
250
- <div class="font-medium text-gray-900 dark:text-gray-100">${l.title}</div>
251
- <div class="text-xs text-gray-500">${l.year || ''}</div>
252
  </td>
253
  <td class="px-6 py-4">${typeBadge}</td>
254
  <td class="px-6 py-4">
255
- <div class="text-sm font-medium text-red-600 dark:text-red-400">${l.quality}</div>
256
- <div class="text-xs text-gray-500">${l.size || 'Unknown size'}</div>
257
  </td>
258
- <td class="px-6 py-4 text-center text-gray-500 text-xs">${l.date_added ? new Date(l.date_added).toLocaleDateString() : '—'}</td>
259
  <td class="px-6 py-4 text-center">
260
- <button onclick="deleteDeadLink(${l.tmdb_id}, ${l.db_index}, '${l.type}', '${l.quality_id}', ${l.season || -1}, ${l.episode || -1})"
261
- class="text-red-600 hover:text-red-800 bg-red-50 hover:bg-red-100 rounded p-2 transition-colors" title="Delete from Database">
 
262
  <i class="fas fa-trash"></i>
263
  </button>
264
  </td>
@@ -339,4 +339,4 @@
339
  setInterval(fetchAnalytics, 15000);
340
  });
341
  </script>
342
- {% endblock %}
 
3
  {% block title %}Admin Dashboard - Telegram Stremio{% endblock %}
4
 
5
  {% block content %}
6
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 text-text">
7
  <div class="mb-8 flex justify-between items-center">
8
  <div>
9
+ <h1 class="text-3xl font-bold text-text">Admin Dashboard</h1>
10
+ <p class="mt-2 text-sm theme-text-secondary">Monitor system health and manage flagged dead links.</p>
 
11
  </div>
12
  </div>
13
 
14
  <!-- System Health Section -->
15
  <div class="mb-10">
16
  <div class="flex items-center justify-between mb-4">
17
+ <h2 class="text-xl font-semibold text-text">System Health</h2>
18
  <button onclick="clearCache()"
19
  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">
20
  <i class="fas fa-trash-alt mr-2"></i> Clear File Cache
 
25
  <!-- Cache Card -->
26
  <div class="theme-card rounded-xl border p-6 shadow-sm">
27
  <div class="flex items-center">
28
+ <div class="flex-shrink-0 bg-primary/10 p-3 rounded-lg">
29
+ <i class="fas fa-memory text-xl text-primary"></i>
30
  </div>
31
  <div class="ml-4">
32
+ <h3 class="text-sm font-medium theme-text-secondary">Cached File IDs</h3>
33
+ <p class="text-2xl font-bold text-text" id="stat-cache-size">-</p>
34
  </div>
35
  </div>
36
  </div>
 
38
  <!-- Active Bots Card -->
39
  <div class="theme-card rounded-xl border p-6 shadow-sm">
40
  <div class="flex items-center">
41
+ <div class="flex-shrink-0 bg-primary/10 p-3 rounded-lg">
42
+ <i class="fas fa-robot text-xl text-primary"></i>
43
  </div>
44
  <div class="ml-4">
45
+ <h3 class="text-sm font-medium theme-text-secondary">Connected Bots</h3>
46
+ <p class="text-2xl font-bold text-text" id="stat-bot-count">-</p>
47
  </div>
48
  </div>
49
  </div>
 
50
  </div>
51
 
52
+ <!-- Bot Health & Load -->
53
  <div class="theme-card rounded-xl border shadow-sm mt-6">
54
  <div class="flex items-center justify-between px-6 py-4 border-b">
55
  <div class="flex items-center gap-3">
56
+ <div class="bg-primary/10 p-2 rounded-lg">
57
+ <i class="fas fa-heartbeat text-primary"></i>
58
  </div>
59
+ <h3 class="text-base font-semibold text-text">Bot Health & Load</h3>
60
  </div>
61
  </div>
62
+ <div id="stat-workloads" class="divide-y divide-white/10">
63
+ <div class="px-6 py-4 text-sm theme-text-secondary">Loading...</div>
64
  </div>
65
  </div>
66
  </div>
67
 
68
+ <!-- Stream Analytics -->
69
  <div class="mb-10">
70
  <div class="flex items-center justify-between mb-4">
71
+ <h2 class="text-xl font-semibold text-text">Recent Stream Analytics</h2>
72
  <button onclick="clearAnalytics()"
73
  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">
74
  <i class="fas fa-trash-alt mr-2"></i> Clear Analytics
75
  </button>
76
  </div>
77
+
78
  <div class="theme-card border rounded-xl overflow-hidden shadow-sm">
79
  <div class="overflow-x-auto">
80
+ <table class="w-full text-sm text-left text-text">
81
+ <thead class="text-xs uppercase theme-card border-b text-text">
82
  <tr>
83
  <th class="px-6 py-4 font-semibold">Stream ID</th>
84
  <th class="px-6 py-4 font-semibold">Title</th>
 
90
  <th class="px-6 py-4 font-semibold text-right">Time</th>
91
  </tr>
92
  </thead>
93
+ <tbody id="analytics-tbody" class="divide-y divide-white/10">
94
  <tr>
95
+ <td colspan="8" class="px-6 py-8 text-center theme-text-secondary">
96
+ <i class="fas fa-spinner fa-spin text-primary mr-2"></i> Loading analytics...
97
  </td>
98
  </tr>
99
  </tbody>
 
102
  </div>
103
  </div>
104
 
105
+ <!-- Dead Links -->
106
  <div>
107
+ <h2 class="text-xl font-semibold text-text mb-4">Flagged Dead Links</h2>
108
  <div class="theme-card border rounded-xl overflow-hidden shadow-sm">
109
  <div class="overflow-x-auto">
110
+ <table class="w-full text-sm text-left text-text">
111
+ <thead class="text-xs uppercase theme-card border-b text-text">
112
  <tr>
113
  <th class="px-6 py-4 font-semibold">Title</th>
114
  <th class="px-6 py-4 font-semibold w-24">Type</th>
 
117
  <th class="px-6 py-4 font-semibold w-24 text-center">Action</th>
118
  </tr>
119
  </thead>
120
+ <tbody id="dead-links-tbody" class="divide-y divide-white/10">
121
  <tr>
122
+ <td colspan="5" class="px-6 py-8 text-center theme-text-secondary">
123
+ <i class="fas fa-spinner fa-spin text-primary mr-2"></i> Loading dead links...
124
  </td>
125
  </tr>
126
  </tbody>
 
142
  let wlHtml = '';
143
  if (data.bot_workloads && data.bot_workloads.length > 0) {
144
  data.bot_workloads.forEach(b => {
145
+ let statusColor = 'bg-green-500/10 text-green-500';
146
+ if (b.status === 'degraded') statusColor = 'bg-yellow-500/10 text-yellow-500';
147
+ if (b.status === 'failing') statusColor = 'bg-red-500/10 text-red-500';
148
 
149
  wlHtml += `
150
+ <div class="flex items-center justify-between px-6 py-4 hover:bg-white/5 transition-colors">
151
  <div class="flex items-center gap-3">
152
+ <span class="font-semibold text-text">${b.display_name}</span>
153
  <span class="text-[10px] px-2 py-0.5 rounded-full uppercase font-bold tracking-wider ${statusColor}">${b.status}</span>
154
  </div>
155
  <div class="flex items-center gap-6 text-sm">
156
  <div class="text-center">
157
+ <div class="text-xs theme-text-secondary mb-0.5">Active Streams</div>
158
+ <div class="font-bold text-text">${b.current_load}</div>
159
  </div>
160
  <div class="text-center">
161
+ <div class="text-xs theme-text-secondary mb-0.5">Avg Speed</div>
162
+ <div class="font-bold text-text">${b.avg_mbps} <span class="font-normal text-xs theme-text-secondary">MB/s</span></div>
163
  </div>
164
  <div class="text-center">
165
+ <div class="text-xs theme-text-secondary mb-0.5">Recent Failures</div>
166
+ <div class="font-bold ${b.failures > 0 ? 'text-red-500' : 'theme-text-secondary'}">${b.failures}</div>
167
  </div>
168
  </div>
169
  </div>
170
  `;
171
  });
172
  } else {
173
+ wlHtml = '<div class="px-6 py-8 text-center theme-text-secondary">No bot data available</div>';
174
  }
175
  document.getElementById('stat-workloads').innerHTML = wlHtml;
176
  }
 
188
  const streams = data.data.recent;
189
 
190
  if (!streams || streams.length === 0) {
191
+ tbody.innerHTML = '<tr><td colspan="8" class="px-6 py-8 text-center theme-text-secondary">No recent streams recorded.</td></tr>';
192
  return;
193
  }
194
 
195
  let html = '';
196
  streams.forEach(s => {
197
+ const mbpsStr = `${s.avg_mbps.toFixed(1)} / <span class="theme-text-secondary">${s.peak_mbps.toFixed(1)}</span>`;
198
  const bytesStr = (s.total_bytes / (1024 * 1024)).toFixed(1) + ' MB';
199
  const timeStr = new Date(s.logged_at).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
200
  const durationStr = s.duration_sec ? `${s.duration_sec.toFixed(1)}s` : '—';
 
205
  if (s.status === 'cancelled') statusColor = 'text-yellow-500';
206
 
207
  html += `
208
+ <tr class="hover:bg-white/5 transition-colors">
209
+ <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>
210
+ <td class="px-6 py-3 text-sm font-medium text-text max-w-[160px] truncate" title="${titleStr}">${titleStr}</td>
211
+ <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>
212
+ <td class="px-6 py-3 text-right font-medium text-text">${bytesStr}</td>
213
+ <td class="px-6 py-3 text-right font-medium text-text">${mbpsStr} <span class="text-xs theme-text-secondary">MB/s</span></td>
214
+ <td class="px-6 py-3 text-center theme-text-secondary">${durationStr}</td>
215
  <td class="px-6 py-3 text-center capitalize text-xs font-bold ${statusColor}">${s.status}</td>
216
+ <td class="px-6 py-3 text-right theme-text-secondary text-xs">${timeStr}</td>
217
  </tr>
218
  `;
219
  });
 
233
  const links = data.data;
234
 
235
  if (links.length === 0) {
236
+ 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>';
237
  return;
238
  }
239
 
240
  let html = '';
241
  links.forEach(l => {
242
  const typeBadge = l.type === 'movie'
243
+ ? '<span class="px-2 py-1 rounded bg-primary/10 text-primary text-xs font-medium">Movie</span>'
244
+ : '<span class="px-2 py-1 rounded bg-accent/10 text-accent text-xs font-medium">TV Series</span>';
245
 
246
  html += `
247
+ <tr class="hover:bg-white/5 transition-colors">
248
  <td class="px-6 py-4">
249
+ <div class="font-medium text-text">${l.title}</div>
250
+ <div class="text-xs theme-text-secondary">${l.year || ''}</div>
251
  </td>
252
  <td class="px-6 py-4">${typeBadge}</td>
253
  <td class="px-6 py-4">
254
+ <div class="text-sm font-medium text-red-500">${l.quality}</div>
255
+ <div class="text-xs theme-text-secondary">${l.size || 'Unknown size'}</div>
256
  </td>
257
+ <td class="px-6 py-4 text-center theme-text-secondary text-xs">${l.date_added ? new Date(l.date_added).toLocaleDateString() : '—'}</td>
258
  <td class="px-6 py-4 text-center">
259
+ <button onclick="deleteDeadLink(${l.tmdb_id}, ${l.db_index}, '${l.type}', '${l.quality_id}', ${l.season || -1}, ${l.episode || -1})"
260
+ class="text-red-500 hover:text-red-600 bg-red-500/10 hover:bg-red-500/20 rounded p-2 transition-colors"
261
+ title="Delete from Database">
262
  <i class="fas fa-trash"></i>
263
  </button>
264
  </td>
 
339
  setInterval(fetchAnalytics, 15000);
340
  });
341
  </script>
342
+ {% endblock %}