Karan Adhikari commited on
Revert "Revamp frontend templates and admin dashboard UI; improve admin JS ro…" (#38)
Browse filesThis reverts commit f946b58a1cfa122a7b7e9af74128e38970e049d1.
- Backend/config.py +1 -1
- Backend/fastapi/templates/access_manage.html +216 -299
- Backend/fastapi/templates/admin_dashboard.html +310 -196
- Backend/fastapi/templates/base.html +91 -152
- Backend/fastapi/templates/dashboard.html +853 -234
- Backend/fastapi/templates/login.html +26 -52
- Backend/fastapi/templates/media_edit.html +877 -176
- Backend/fastapi/templates/media_management.html +415 -99
- Backend/fastapi/templates/public_status.html +47 -85
- Backend/fastapi/templates/stremio_guide.html +74 -99
- Backend/fastapi/templates/subscriptions_manage.html +258 -201
- Backend/fastapi/themes.py +142 -50
- docker-compose.yaml +1 -1
- sample_config.env +1 -1
Backend/config.py
CHANGED
|
@@ -10,7 +10,7 @@ class Telegram:
|
|
| 10 |
HELPER_BOT_TOKEN = getenv("HELPER_BOT_TOKEN", "")
|
| 11 |
|
| 12 |
BASE_URL = getenv("BASE_URL", "").rstrip('/')
|
| 13 |
-
PORT = int(getenv("PORT", "
|
| 14 |
|
| 15 |
PARALLEL = int(getenv("PARALLEL", "1"))
|
| 16 |
PRE_FETCH = int(getenv("PRE_FETCH", "1"))
|
|
|
|
| 10 |
HELPER_BOT_TOKEN = getenv("HELPER_BOT_TOKEN", "")
|
| 11 |
|
| 12 |
BASE_URL = getenv("BASE_URL", "").rstrip('/')
|
| 13 |
+
PORT = int(getenv("PORT", "8000"))
|
| 14 |
|
| 15 |
PARALLEL = int(getenv("PARALLEL", "1"))
|
| 16 |
PRE_FETCH = int(getenv("PRE_FETCH", "1"))
|
Backend/fastapi/templates/access_manage.html
CHANGED
|
@@ -1,216 +1,125 @@
|
|
| 1 |
{% extends "base.html" %}
|
| 2 |
{% block title %}Access Management{% endblock %}
|
| 3 |
{% block content %}
|
|
|
|
| 4 |
|
| 5 |
-
<
|
| 6 |
-
|
| 7 |
-
.admin-glass-panel {
|
| 8 |
-
background: color-mix(in srgb, var(--card) 40%, transparent);
|
| 9 |
-
backdrop-filter: blur(16px);
|
| 10 |
-
-webkit-backdrop-filter: blur(16px);
|
| 11 |
-
border: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
|
| 12 |
-
box-shadow: 0 10px 40px -10px rgba(0,0,0,0.3);
|
| 13 |
-
}
|
| 14 |
-
|
| 15 |
-
.admin-glass-input {
|
| 16 |
-
background: color-mix(in srgb, var(--bg) 50%, transparent);
|
| 17 |
-
border: 1px solid color-mix(in srgb, var(--text) 15%, transparent);
|
| 18 |
-
color: var(--text);
|
| 19 |
-
transition: all 0.3s ease;
|
| 20 |
-
}
|
| 21 |
-
.admin-glass-input::placeholder { color: var(--text-sec); opacity: 0.7; }
|
| 22 |
-
.admin-glass-input:focus {
|
| 23 |
-
outline: none;
|
| 24 |
-
border-color: var(--primary);
|
| 25 |
-
box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
|
| 26 |
-
background: color-mix(in srgb, var(--bg) 80%, transparent);
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
/* Table styling to fit the glass theme */
|
| 30 |
-
.glass-table th {
|
| 31 |
-
background: color-mix(in srgb, var(--card) 40%, transparent);
|
| 32 |
-
text-transform: uppercase;
|
| 33 |
-
letter-spacing: 0.05em;
|
| 34 |
-
font-size: 0.75rem;
|
| 35 |
-
}
|
| 36 |
-
.glass-table tr {
|
| 37 |
-
border-bottom: 1px solid color-mix(in srgb, var(--text) 5%, transparent);
|
| 38 |
-
transition: background 0.2s ease;
|
| 39 |
-
}
|
| 40 |
-
.glass-table tr:hover {
|
| 41 |
-
background: color-mix(in srgb, var(--text) 3%, transparent);
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
/* Scrollbar for the table container */
|
| 45 |
-
.custom-scrollbar::-webkit-scrollbar { height: 8px; }
|
| 46 |
-
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
|
| 47 |
-
.custom-scrollbar::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text) 20%, transparent); border-radius: 10px; }
|
| 48 |
-
</style>
|
| 49 |
-
|
| 50 |
-
<div class="w-full space-y-6 animate-[fadeIn_0.5s_ease-out]">
|
| 51 |
-
|
| 52 |
-
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4 glass-panel rounded-3xl p-6">
|
| 53 |
<div>
|
| 54 |
-
<h2 class="text-
|
| 55 |
-
|
| 56 |
-
<i class="fa-solid fa-key text-primary"></i>
|
| 57 |
-
</div>
|
| 58 |
-
<span class="text-transparent bg-clip-text bg-gradient-to-r from-primary to-accent">Access Management</span>
|
| 59 |
-
</h2>
|
| 60 |
-
<p class="text-sm text-text-sec mt-2 ml-1">Manage API tokens and user access for the Stremio addon</p>
|
| 61 |
</div>
|
| 62 |
-
<button onclick="loadTokens()"
|
| 63 |
-
|
|
|
|
| 64 |
</button>
|
| 65 |
</div>
|
| 66 |
|
| 67 |
-
<
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
<div class="text-
|
| 71 |
-
<div class="text-
|
| 72 |
-
<i class="fa-solid fa-users text-primary"></i> Total Tokens
|
| 73 |
-
</div>
|
| 74 |
</div>
|
| 75 |
-
<div class="
|
| 76 |
-
<div class="
|
| 77 |
-
<div class="text-
|
| 78 |
-
<div class="text-sm text-text-sec font-medium mt-1 flex items-center gap-2">
|
| 79 |
-
<i class="fa-solid fa-circle-check text-green-400"></i> Active Subscriptions
|
| 80 |
-
</div>
|
| 81 |
</div>
|
| 82 |
-
<div class="
|
| 83 |
-
<div class="
|
| 84 |
-
<div class="text-
|
| 85 |
-
<div class="text-sm text-text-sec font-medium mt-1 flex items-center gap-2">
|
| 86 |
-
<i class="fa-solid fa-circle-xmark text-red-400"></i> Expired / No Sub
|
| 87 |
-
</div>
|
| 88 |
</div>
|
| 89 |
</div>
|
| 90 |
|
| 91 |
-
<
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
<option value="all"
|
| 100 |
-
<option value="active"
|
| 101 |
-
<option value="expired"
|
| 102 |
</select>
|
| 103 |
-
<select id="page-size"
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
<option value="
|
|
|
|
|
|
|
| 107 |
</select>
|
| 108 |
</div>
|
| 109 |
|
| 110 |
-
<
|
| 111 |
-
|
| 112 |
-
|
|
|
|
| 113 |
<thead>
|
| 114 |
-
<tr>
|
| 115 |
-
<th class="px-
|
| 116 |
-
<th class="px-
|
| 117 |
-
<th class="px-
|
| 118 |
-
<th class="px-
|
| 119 |
-
<th class="px-
|
| 120 |
-
<th class="px-
|
| 121 |
</tr>
|
| 122 |
</thead>
|
| 123 |
<tbody id="token-table-body">
|
| 124 |
<tr>
|
| 125 |
-
<td colspan="6" class="text-center py-
|
| 126 |
-
<i class="fa-solid fa-circle-notch fa-spin text-2xl mb-3 text-primary"></i>
|
| 127 |
-
<p>Loading access data...</p>
|
| 128 |
-
</td>
|
| 129 |
</tr>
|
| 130 |
</tbody>
|
| 131 |
</table>
|
| 132 |
</div>
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
<
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
|
|
|
| 145 |
</div>
|
| 146 |
</div>
|
| 147 |
</div>
|
| 148 |
|
| 149 |
-
<
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
<h3 class="text-xl font-bold text-text">Assign Plan</h3>
|
| 156 |
-
</div>
|
| 157 |
-
<p class="text-sm text-text-sec mb-6 ml-1" id="assign-user-label">User: –</p>
|
| 158 |
-
|
| 159 |
<input type="hidden" id="assign-user-id">
|
| 160 |
|
| 161 |
-
<div class="
|
| 162 |
-
<
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
</div>
|
| 168 |
-
|
| 169 |
-
<div class="relative flex items-center py-2">
|
| 170 |
-
<div class="flex-grow border-t border-white/10"></div>
|
| 171 |
-
<span class="flex-shrink-0 mx-4 text-text-sec text-xs font-medium">OR</span>
|
| 172 |
-
<div class="flex-grow border-t border-white/10"></div>
|
| 173 |
-
</div>
|
| 174 |
-
|
| 175 |
-
<div>
|
| 176 |
-
<label class="block text-xs font-bold text-text-sec uppercase tracking-wider mb-2">Custom Days</label>
|
| 177 |
-
<div class="relative">
|
| 178 |
-
<input type="number" id="assign-custom-days" placeholder="e.g. 30" min="1" class="w-full admin-glass-input rounded-xl pl-4 pr-12 py-3 text-sm">
|
| 179 |
-
<span class="absolute right-4 top-1/2 transform -translate-y-1/2 text-text-sec text-sm">days</span>
|
| 180 |
-
</div>
|
| 181 |
-
</div>
|
| 182 |
</div>
|
| 183 |
|
| 184 |
-
<div class="
|
| 185 |
-
<
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
|
|
|
| 189 |
</div>
|
| 190 |
-
</div>
|
| 191 |
-
</div>
|
| 192 |
|
| 193 |
-
<div
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
<
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
<h3 class="text-xl font-bold text-text" id="sub-action-title">Manage Sub</h3>
|
| 200 |
-
</div>
|
| 201 |
-
<p class="text-sm text-text-sec mb-6 ml-1" id="sub-action-desc"></p>
|
| 202 |
-
|
| 203 |
-
<input type="hidden" id="sub-action-user-id">
|
| 204 |
-
<input type="hidden" id="sub-action-action">
|
| 205 |
-
|
| 206 |
-
<div id="sub-action-days-group" class="mb-6">
|
| 207 |
-
<label class="block text-xs font-bold text-text-sec uppercase tracking-wider mb-2">Number of Days</label>
|
| 208 |
-
<input type="number" id="sub-action-days" value="30" min="1" class="w-full admin-glass-input rounded-xl px-4 py-3 text-sm">
|
| 209 |
-
</div>
|
| 210 |
-
|
| 211 |
-
<div class="flex justify-end gap-3 mt-4">
|
| 212 |
-
<button onclick="closeSubModal()" class="px-5 py-2.5 text-text-sec hover:text-text hover:bg-white/10 rounded-full transition-all text-sm font-semibold">Cancel</button>
|
| 213 |
-
<button id="sub-action-btn" onclick="submitSubAction()" class="px-5 py-2.5 text-white rounded-full shadow-lg transition-all text-sm font-bold">Confirm</button>
|
| 214 |
</div>
|
| 215 |
</div>
|
| 216 |
</div>
|
|
@@ -223,10 +132,9 @@
|
|
| 223 |
const q = document.getElementById('search-input').value.toLowerCase();
|
| 224 |
const status = document.getElementById('filter-status').value;
|
| 225 |
return allTokens.filter(t => {
|
| 226 |
-
const matchQ = !q ||
|
| 227 |
-
(t.user_name && t.user_name.toLowerCase().includes(q)) ||
|
| 228 |
-
(t.user_id && String(t.user_id).includes(q))
|
| 229 |
-
(t.token && String(t.token).toLowerCase().includes(q));
|
| 230 |
const matchStatus = status === 'all' || (status === 'active' && !t.is_expired) || (status === 'expired' && t.is_expired);
|
| 231 |
return matchQ && matchStatus;
|
| 232 |
});
|
|
@@ -241,84 +149,96 @@
|
|
| 241 |
const start = (currentPage - 1) * pageSize;
|
| 242 |
const slice = filtered.slice(start, start + pageSize);
|
| 243 |
|
| 244 |
-
document.getElementById('page-info').
|
| 245 |
-
document.getElementById('page-num').textContent = `Page ${currentPage}
|
| 246 |
document.getElementById('btn-prev').disabled = currentPage <= 1;
|
| 247 |
document.getElementById('btn-next').disabled = currentPage >= totalPages;
|
| 248 |
|
| 249 |
const tbody = document.getElementById('token-table-body');
|
| 250 |
if (!slice.length) {
|
| 251 |
-
tbody.innerHTML = '<tr><td colspan="6" class="text-center py-
|
| 252 |
return;
|
| 253 |
}
|
| 254 |
tbody.innerHTML = slice.map(renderRow).join('');
|
| 255 |
}
|
| 256 |
|
| 257 |
function renderRow(t) {
|
| 258 |
-
const statusBadge = t.is_expired
|
| 259 |
-
? '<span class="px-
|
| 260 |
-
: '<span class="px-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
const
|
| 264 |
-
const
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
const safeName = escHtml(t.user_name || String(t.user_id || ''));
|
| 280 |
|
|
|
|
| 281 |
let actionBtns = '';
|
| 282 |
if (t.user_id) {
|
|
|
|
| 283 |
actionBtns = `
|
| 284 |
-
<button onclick="openAssignModal(${t.user_id}, '${safeName}')"
|
| 285 |
-
|
|
|
|
| 286 |
</button>
|
| 287 |
-
<button onclick="openSubModal(${t.user_id}, '${safeName}', 'extend')"
|
| 288 |
-
|
|
|
|
| 289 |
</button>
|
| 290 |
-
<button onclick="openSubModal(${t.user_id}, '${safeName}', 'reduce')"
|
| 291 |
-
|
|
|
|
| 292 |
</button>
|
| 293 |
-
<button onclick="openSubModal(${t.user_id}, '${safeName}', 'delete')"
|
| 294 |
-
|
|
|
|
| 295 |
</button>`;
|
| 296 |
} else if (t.token) {
|
|
|
|
| 297 |
actionBtns = `
|
| 298 |
-
<button onclick="linkUser('${escHtml(t.token)}')"
|
| 299 |
-
|
| 300 |
-
|
|
|
|
|
|
|
| 301 |
}
|
| 302 |
|
| 303 |
const revokeTokenBtn = t.token ? `
|
| 304 |
-
<button onclick="revokeToken('${escHtml(t.token)}')"
|
| 305 |
-
|
|
|
|
| 306 |
</button>` : '';
|
| 307 |
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
<td class="px-6 py-4">
|
| 319 |
-
<div class="flex flex-wrap items-center justify-center gap-1.5">${actionBtns}${revokeTokenBtn}</div>
|
| 320 |
-
</td>
|
| 321 |
-
</tr>`;
|
| 322 |
}
|
| 323 |
|
| 324 |
function changePage(dir) {
|
|
@@ -328,7 +248,7 @@
|
|
| 328 |
|
| 329 |
async function loadTokens() {
|
| 330 |
const tbody = document.getElementById('token-table-body');
|
| 331 |
-
tbody.innerHTML = '<tr><td colspan="6" class="text-center py-
|
| 332 |
try {
|
| 333 |
const resp = await fetch('/api/admin/access/tokens');
|
| 334 |
const data = await resp.json();
|
|
@@ -341,7 +261,7 @@
|
|
| 341 |
currentPage = 1;
|
| 342 |
renderPage();
|
| 343 |
} catch (err) {
|
| 344 |
-
tbody.innerHTML = `<tr><td colspan="6" class="text-center py-10 text-red-
|
| 345 |
}
|
| 346 |
}
|
| 347 |
|
|
@@ -351,17 +271,18 @@
|
|
| 351 |
const data = await resp.json();
|
| 352 |
const plans = data.plans || data || [];
|
| 353 |
const sel = document.getElementById('assign-plan-select');
|
| 354 |
-
sel.innerHTML = '<option value=""
|
| 355 |
-
plans.map(p => `<option value="${p.days}"
|
| 356 |
} catch (e) { console.warn('Could not load plans', e); }
|
| 357 |
}
|
| 358 |
|
| 359 |
function openAssignModal(userId, userName) {
|
| 360 |
document.getElementById('assign-user-id').value = userId;
|
| 361 |
-
document.getElementById('assign-user-label').
|
| 362 |
document.getElementById('assign-custom-days').value = '';
|
| 363 |
document.getElementById('assign-plan-select').value = '';
|
| 364 |
-
document.getElementById('assign-modal')
|
|
|
|
| 365 |
}
|
| 366 |
|
| 367 |
function closeAssignModal() {
|
|
@@ -374,7 +295,7 @@
|
|
| 374 |
const planDays = parseInt(document.getElementById('assign-plan-select').value) || 0;
|
| 375 |
const days = customDays || planDays;
|
| 376 |
|
| 377 |
-
if (!days || days < 1) { showToast('Please select a plan or enter custom days.', '
|
| 378 |
|
| 379 |
try {
|
| 380 |
const resp = await fetch(`/api/admin/access/users/${userId}/assign-plan`, {
|
|
@@ -384,13 +305,13 @@
|
|
| 384 |
});
|
| 385 |
const data = await resp.json();
|
| 386 |
if (resp.ok) {
|
| 387 |
-
showToast(`Assigned ${days} days to user
|
| 388 |
closeAssignModal();
|
| 389 |
loadTokens();
|
| 390 |
} else {
|
| 391 |
-
showToast(data.detail || 'Failed to assign plan.', '
|
| 392 |
}
|
| 393 |
-
} catch (err) { showToast('Error: ' + err.message, '
|
| 394 |
}
|
| 395 |
|
| 396 |
async function revokeToken(token) {
|
|
@@ -398,14 +319,14 @@
|
|
| 398 |
try {
|
| 399 |
const resp = await fetch(`/api/admin/access/tokens/${encodeURIComponent(token)}`, { method: 'DELETE' });
|
| 400 |
const data = await resp.json();
|
| 401 |
-
if (resp.ok) { showToast('Token
|
| 402 |
-
else showToast(data.detail || 'Failed
|
| 403 |
-
} catch (err) { showToast('Error: ' + err.message, '
|
| 404 |
}
|
| 405 |
|
| 406 |
async function linkUser(token) {
|
| 407 |
const userId = prompt('Enter the Telegram User ID to link this token to:');
|
| 408 |
-
if (!userId || isNaN(parseInt(userId))) { showToast('Invalid user ID
|
| 409 |
try {
|
| 410 |
const resp = await fetch(`/api/admin/access/tokens/${encodeURIComponent(token)}/link-user`, {
|
| 411 |
method: 'PATCH',
|
|
@@ -414,37 +335,28 @@
|
|
| 414 |
});
|
| 415 |
const data = await resp.json();
|
| 416 |
if (resp.ok) {
|
| 417 |
-
showToast(`Token
|
| 418 |
loadTokens();
|
| 419 |
-
} else { showToast(data.detail || 'Failed to link
|
| 420 |
-
} catch (err) { showToast('Error: ' + err.message, '
|
| 421 |
}
|
| 422 |
|
|
|
|
| 423 |
function openSubModal(userId, userName, action) {
|
| 424 |
document.getElementById('sub-action-user-id').value = userId;
|
| 425 |
document.getElementById('sub-action-action').value = action;
|
| 426 |
-
|
| 427 |
-
const
|
| 428 |
-
extend:
|
| 429 |
-
reduce:
|
| 430 |
-
delete:
|
| 431 |
};
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
document.getElementById('sub-action-
|
| 435 |
-
document.getElementById('sub-action-desc').innerHTML = cfg.desc;
|
| 436 |
-
|
| 437 |
-
const iconContainer = document.getElementById('sub-action-icon-bg');
|
| 438 |
-
iconContainer.className = `w-10 h-10 rounded-full flex items-center justify-center border bg-${cfg.color}-500/20 border-${cfg.color}-500/30`;
|
| 439 |
-
document.getElementById('sub-action-icon').className = `fa-solid ${cfg.icon} text-${cfg.color}-400`;
|
| 440 |
-
|
| 441 |
-
document.getElementById('sub-action-days-group').style.display = action === 'delete' ? 'none' : 'block';
|
| 442 |
document.getElementById('sub-action-days').value = 30;
|
| 443 |
-
|
| 444 |
const btn = document.getElementById('sub-action-btn');
|
| 445 |
-
btn.className = `px-
|
| 446 |
-
btn.innerHTML = action === 'delete' ? '<i class="fa-solid fa-triangle-exclamation"></i> Revoke' : '<i class="fa-solid fa-check"></i> Confirm';
|
| 447 |
-
|
| 448 |
document.getElementById('sub-action-modal').style.display = 'flex';
|
| 449 |
}
|
| 450 |
|
|
@@ -462,61 +374,66 @@
|
|
| 462 |
});
|
| 463 |
const data = await resp.json();
|
| 464 |
if (resp.ok) {
|
| 465 |
-
showToast(`${action.charAt(0).toUpperCase() + action.slice(1)}
|
| 466 |
closeSubModal();
|
| 467 |
loadTokens();
|
| 468 |
-
} else { showToast(data.detail || '
|
| 469 |
-
} catch (err) { showToast('Error: ' + err.message, '
|
| 470 |
}
|
| 471 |
|
| 472 |
async function copyLink(url) {
|
| 473 |
-
try { await navigator.clipboard.writeText(url); showToast('Link copied
|
| 474 |
catch { prompt('Copy this link:', url); }
|
| 475 |
}
|
| 476 |
|
| 477 |
function fmtDate(iso) {
|
| 478 |
-
if (!iso) return
|
| 479 |
const d = new Date(iso);
|
| 480 |
-
return {
|
| 481 |
-
|
| 482 |
-
time: d.toLocaleTimeString('en-IN', { timeZone: 'Asia/Kolkata', hour: '2-digit', minute: '2-digit' })
|
| 483 |
-
};
|
| 484 |
}
|
| 485 |
|
| 486 |
function escHtml(s) {
|
| 487 |
return String(s || '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
| 488 |
}
|
| 489 |
|
| 490 |
-
function showToast(msg,
|
| 491 |
const t = document.createElement('div');
|
| 492 |
-
|
| 493 |
-
t.className = `fixed bottom-
|
| 494 |
-
${isError ? 'bg-red-500/80 border-red-400 text-white' : 'bg-green-500/80 border-green-400 text-white'}`;
|
| 495 |
-
t.innerHTML = `<i class="fa-solid ${isError ? 'fa-circle-exclamation' : 'fa-circle-check'} text-lg"></i><span class="font-medium text-sm">${msg}</span>`;
|
| 496 |
document.body.appendChild(t);
|
| 497 |
-
setTimeout(() =>
|
| 498 |
-
t.classList.add('opacity-0', 'translate-y-4');
|
| 499 |
-
setTimeout(() => t.remove(), 300);
|
| 500 |
-
}, 3500);
|
| 501 |
}
|
| 502 |
|
| 503 |
-
//
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
|
| 507 |
-
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
| 508 |
-
`;
|
| 509 |
-
document.head.appendChild(style);
|
| 510 |
-
|
| 511 |
-
// Close modals on backdrop click
|
| 512 |
-
['assign-modal', 'sub-action-modal'].forEach(id => {
|
| 513 |
-
document.getElementById(id).addEventListener('click', function(e) {
|
| 514 |
-
if (e.target === this) this.style.display = 'none';
|
| 515 |
-
});
|
| 516 |
});
|
| 517 |
|
| 518 |
loadPlans();
|
| 519 |
loadTokens();
|
| 520 |
</script>
|
| 521 |
|
| 522 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
{% extends "base.html" %}
|
| 2 |
{% block title %}Access Management{% endblock %}
|
| 3 |
{% block content %}
|
| 4 |
+
<div class="container mx-auto px-4 py-8 max-w-7xl">
|
| 5 |
|
| 6 |
+
<!-- Header -->
|
| 7 |
+
<div class="flex items-center justify-between mb-6">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
<div>
|
| 9 |
+
<h2 class="text-3xl font-bold text-primary">🔑 Access Management</h2>
|
| 10 |
+
<p class="text-sm text-text opacity-60 mt-1">Manage API tokens for Stremio addon access</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
</div>
|
| 12 |
+
<button onclick="loadTokens()"
|
| 13 |
+
class="bg-primary text-white px-4 py-2 rounded-lg hover:opacity-80 transition text-sm font-medium">
|
| 14 |
+
🔄 Refresh
|
| 15 |
</button>
|
| 16 |
</div>
|
| 17 |
|
| 18 |
+
<!-- Stats -->
|
| 19 |
+
<div class="grid grid-cols-3 gap-4 mb-6">
|
| 20 |
+
<div class="theme-card rounded-xl p-4 text-center">
|
| 21 |
+
<div class="text-2xl font-bold text-primary" id="stat-total">–</div>
|
| 22 |
+
<div class="text-xs text-text opacity-60 mt-1">Total Tokens</div>
|
|
|
|
|
|
|
| 23 |
</div>
|
| 24 |
+
<div class="theme-card rounded-xl p-4 text-center">
|
| 25 |
+
<div class="text-2xl font-bold text-green-500" id="stat-active">–</div>
|
| 26 |
+
<div class="text-xs text-text opacity-60 mt-1">Active</div>
|
|
|
|
|
|
|
|
|
|
| 27 |
</div>
|
| 28 |
+
<div class="theme-card rounded-xl p-4 text-center">
|
| 29 |
+
<div class="text-2xl font-bold text-red-400" id="stat-expired">–</div>
|
| 30 |
+
<div class="text-xs text-text opacity-60 mt-1">Expired / No Sub</div>
|
|
|
|
|
|
|
|
|
|
| 31 |
</div>
|
| 32 |
</div>
|
| 33 |
|
| 34 |
+
<!-- Search & Filter bar -->
|
| 35 |
+
<div class="flex flex-wrap gap-3 mb-4 items-center">
|
| 36 |
+
<input id="search-input" type="text" placeholder="🔍 Search by name or user ID…"
|
| 37 |
+
class="flex-1 min-w-[200px] border border-gray-300 dark:border-gray-600 rounded-lg px-4 py-2 text-sm focus:outline-none focus:border-primary bg-white dark:bg-gray-800 text-text"
|
| 38 |
+
oninput="renderPage()">
|
| 39 |
+
<select id="filter-status"
|
| 40 |
+
class="border border-gray-300 dark:border-gray-600 rounded-lg px-3 py-2 text-sm focus:outline-none bg-white dark:bg-gray-800 text-text"
|
| 41 |
+
onchange="renderPage()">
|
| 42 |
+
<option value="all">All Status</option>
|
| 43 |
+
<option value="active">🟢 Active</option>
|
| 44 |
+
<option value="expired">🔴 Expired</option>
|
| 45 |
</select>
|
| 46 |
+
<select id="page-size"
|
| 47 |
+
class="border border-gray-300 dark:border-gray-600 rounded-lg px-3 py-2 text-sm focus:outline-none bg-white dark:bg-gray-800 text-text"
|
| 48 |
+
onchange="currentPage=1; renderPage()">
|
| 49 |
+
<option value="10">10 / page</option>
|
| 50 |
+
<option value="25">25 / page</option>
|
| 51 |
+
<option value="50">50 / page</option>
|
| 52 |
</select>
|
| 53 |
</div>
|
| 54 |
|
| 55 |
+
<!-- Token Table -->
|
| 56 |
+
<div class="theme-card rounded-2xl shadow overflow-hidden">
|
| 57 |
+
<div class="overflow-x-auto">
|
| 58 |
+
<table class="w-full text-sm">
|
| 59 |
<thead>
|
| 60 |
+
<tr class="border-b border-gray-200 dark:border-gray-700">
|
| 61 |
+
<th class="px-4 py-3 text-left text-text opacity-70 font-semibold">Status</th>
|
| 62 |
+
<th class="px-4 py-3 text-left text-text opacity-70 font-semibold">User</th>
|
| 63 |
+
<th class="px-4 py-3 text-left text-text opacity-70 font-semibold">Addon Link</th>
|
| 64 |
+
<th class="px-4 py-3 text-left text-text opacity-70 font-semibold">Created</th>
|
| 65 |
+
<th class="px-4 py-3 text-left text-text opacity-70 font-semibold">Expires</th>
|
| 66 |
+
<th class="px-4 py-3 text-center text-text opacity-70 font-semibold">Actions</th>
|
| 67 |
</tr>
|
| 68 |
</thead>
|
| 69 |
<tbody id="token-table-body">
|
| 70 |
<tr>
|
| 71 |
+
<td colspan="6" class="text-center py-10 text-text opacity-40">Loading tokens…</td>
|
|
|
|
|
|
|
|
|
|
| 72 |
</tr>
|
| 73 |
</tbody>
|
| 74 |
</table>
|
| 75 |
</div>
|
| 76 |
+
</div>
|
| 77 |
+
|
| 78 |
+
<!-- Pagination -->
|
| 79 |
+
<div class="flex items-center justify-between mt-4 text-sm text-text opacity-70" id="pagination-bar">
|
| 80 |
+
<span id="page-info"></span>
|
| 81 |
+
<div class="flex gap-2">
|
| 82 |
+
<button id="btn-prev" onclick="changePage(-1)"
|
| 83 |
+
class="px-3 py-1 rounded border border-gray-300 hover:bg-gray-100 disabled:opacity-30 transition">‹
|
| 84 |
+
Prev</button>
|
| 85 |
+
<span id="page-num" class="px-3 py-1 font-semibold"></span>
|
| 86 |
+
<button id="btn-next" onclick="changePage(1)"
|
| 87 |
+
class="px-3 py-1 rounded border border-gray-300 hover:bg-gray-100 disabled:opacity-30 transition">Next
|
| 88 |
+
›</button>
|
| 89 |
</div>
|
| 90 |
</div>
|
| 91 |
</div>
|
| 92 |
|
| 93 |
+
<!-- Assign Plan Modal -->
|
| 94 |
+
<div id="assign-modal" class="fixed inset-0 bg-black bg-opacity-60 hidden items-center justify-center z-50"
|
| 95 |
+
style="display:none">
|
| 96 |
+
<div class="bg-white dark:bg-gray-800 rounded-2xl p-6 w-full max-w-md shadow-2xl mx-4">
|
| 97 |
+
<h3 class="text-lg font-bold mb-1 text-gray-800 dark:text-white">📋 Assign Subscription Plan</h3>
|
| 98 |
+
<p class="text-sm text-gray-500 mb-4" id="assign-user-label">User: –</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
<input type="hidden" id="assign-user-id">
|
| 100 |
|
| 101 |
+
<div class="mb-4">
|
| 102 |
+
<label class="block text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2">Select a Plan</label>
|
| 103 |
+
<select id="assign-plan-select"
|
| 104 |
+
class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:outline-none focus:border-primary dark:bg-gray-700 dark:border-gray-600 dark:text-white">
|
| 105 |
+
<option value="">— Select plan —</option>
|
| 106 |
+
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
</div>
|
| 108 |
|
| 109 |
+
<div class="mb-4">
|
| 110 |
+
<label class="block text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2">Or enter custom
|
| 111 |
+
days</label>
|
| 112 |
+
<input type="number" id="assign-custom-days" placeholder="e.g. 30" min="1"
|
| 113 |
+
class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:outline-none focus:border-primary dark:bg-gray-700 dark:border-gray-600 dark:text-white">
|
| 114 |
+
<p class="text-xs text-gray-400 mt-1">Custom days override plan selection above.</p>
|
| 115 |
</div>
|
|
|
|
|
|
|
| 116 |
|
| 117 |
+
<div class="flex justify-end gap-3 mt-6">
|
| 118 |
+
<button onclick="closeAssignModal()"
|
| 119 |
+
class="px-4 py-2 text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition text-sm">Cancel</button>
|
| 120 |
+
<button onclick="assignPlan()"
|
| 121 |
+
class="px-4 py-2 bg-primary text-white rounded-lg hover:opacity-80 transition text-sm font-semibold">✅
|
| 122 |
+
Assign & Activate</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
</div>
|
| 124 |
</div>
|
| 125 |
</div>
|
|
|
|
| 132 |
const q = document.getElementById('search-input').value.toLowerCase();
|
| 133 |
const status = document.getElementById('filter-status').value;
|
| 134 |
return allTokens.filter(t => {
|
| 135 |
+
const matchQ = !q ||
|
| 136 |
+
(t.user_name && t.user_name.toLowerCase().includes(q)) ||
|
| 137 |
+
(t.user_id && String(t.user_id).includes(q));
|
|
|
|
| 138 |
const matchStatus = status === 'all' || (status === 'active' && !t.is_expired) || (status === 'expired' && t.is_expired);
|
| 139 |
return matchQ && matchStatus;
|
| 140 |
});
|
|
|
|
| 149 |
const start = (currentPage - 1) * pageSize;
|
| 150 |
const slice = filtered.slice(start, start + pageSize);
|
| 151 |
|
| 152 |
+
document.getElementById('page-info').textContent = `Showing ${start + 1}–${Math.min(start + pageSize, filtered.length)} of ${filtered.length}`;
|
| 153 |
+
document.getElementById('page-num').textContent = `Page ${currentPage} / ${totalPages}`;
|
| 154 |
document.getElementById('btn-prev').disabled = currentPage <= 1;
|
| 155 |
document.getElementById('btn-next').disabled = currentPage >= totalPages;
|
| 156 |
|
| 157 |
const tbody = document.getElementById('token-table-body');
|
| 158 |
if (!slice.length) {
|
| 159 |
+
tbody.innerHTML = '<tr><td colspan="6" class="text-center py-10 text-text opacity-40">No tokens match your search.</td></tr>';
|
| 160 |
return;
|
| 161 |
}
|
| 162 |
tbody.innerHTML = slice.map(renderRow).join('');
|
| 163 |
}
|
| 164 |
|
| 165 |
function renderRow(t) {
|
| 166 |
+
const statusBadge = t.is_expired
|
| 167 |
+
? '<span class="px-2 py-1 rounded-full text-xs font-semibold bg-red-100 text-red-600">🔴 Expired</span>'
|
| 168 |
+
: '<span class="px-2 py-1 rounded-full text-xs font-semibold bg-green-100 text-green-700">🟢 Active</span>';
|
| 169 |
+
|
| 170 |
+
// User column — show name or fallback to Telegram User (ID: X)
|
| 171 |
+
const displayName = t.user_name || (t.user_id ? `Telegram User` : 'Unknown');
|
| 172 |
+
const nameHtml = `<div class="font-medium text-text">${escHtml(displayName)}</div>`;
|
| 173 |
+
const idHtml = t.user_id ? `<div class="text-xs text-text opacity-50">ID: ${t.user_id}</div>` : '';
|
| 174 |
+
|
| 175 |
+
const addonLink = !t.has_token
|
| 176 |
+
? `<span class="px-2 py-1 rounded-full text-xs font-semibold bg-yellow-100 text-yellow-700">⚠️ No Token Yet</span>
|
| 177 |
+
<div class="text-xs text-text opacity-40 italic mt-1">User hasn't generated addon token via bot.</div>`
|
| 178 |
+
: t.is_expired
|
| 179 |
+
? `<div>
|
| 180 |
+
<span class="px-2 py-1 rounded-full text-xs font-semibold bg-red-100 text-red-600">🔴 Subscription Expired</span>
|
| 181 |
+
<div class="text-xs text-text opacity-40 italic mt-1">${t.user_found ? 'Subscription inactive/expired' : 'No subscription record'}</div>
|
| 182 |
+
${t.addon_url ? `<button onclick="copyLink('${escHtml(t.addon_url)}')" class="text-xs text-text opacity-30 hover:opacity-60 underline mt-0.5">Copy URL (admin)</button>` : ''}
|
| 183 |
+
</div>`
|
| 184 |
+
: (t.addon_url
|
| 185 |
+
? `<button onclick="copyLink('${escHtml(t.addon_url)}')" class="text-primary hover:underline text-xs">📋 Copy Install Link</button>`
|
| 186 |
+
: '—');
|
| 187 |
+
|
| 188 |
+
const expires = t.expires_at
|
| 189 |
+
? `<span class="${t.is_expired ? 'text-red-500 font-semibold' : ''}">${fmtDate(t.expires_at)}</span>`
|
| 190 |
+
: '<span class="text-red-400 text-xs italic">No expiry</span>';
|
| 191 |
+
|
| 192 |
+
const rowCls = t.is_expired ? 'bg-red-50 dark:bg-red-900/10' : '';
|
| 193 |
const safeName = escHtml(t.user_name || String(t.user_id || ''));
|
| 194 |
|
| 195 |
+
// --- Action buttons ---
|
| 196 |
let actionBtns = '';
|
| 197 |
if (t.user_id) {
|
| 198 |
+
// Full actions for linked tokens/subscribers
|
| 199 |
actionBtns = `
|
| 200 |
+
<button onclick="openAssignModal(${t.user_id}, '${safeName}')"
|
| 201 |
+
class="text-blue-500 hover:text-blue-700 text-xs px-2 py-1 rounded border border-blue-300 hover:bg-blue-50 transition mb-1 mr-1">
|
| 202 |
+
📅 Assign
|
| 203 |
</button>
|
| 204 |
+
<button onclick="openSubModal(${t.user_id}, '${safeName}', 'extend')"
|
| 205 |
+
class="text-green-600 hover:text-green-800 text-xs px-2 py-1 rounded border border-green-300 hover:bg-green-50 transition mb-1 mr-1">
|
| 206 |
+
➕ Extend
|
| 207 |
</button>
|
| 208 |
+
<button onclick="openSubModal(${t.user_id}, '${safeName}', 'reduce')"
|
| 209 |
+
class="text-yellow-600 hover:text-yellow-800 text-xs px-2 py-1 rounded border border-yellow-300 hover:bg-yellow-50 transition mb-1 mr-1">
|
| 210 |
+
➖ Reduce
|
| 211 |
</button>
|
| 212 |
+
<button onclick="openSubModal(${t.user_id}, '${safeName}', 'delete')"
|
| 213 |
+
class="text-red-500 hover:text-red-700 text-xs px-2 py-1 rounded border border-red-300 hover:bg-red-50 transition mb-1 mr-1">
|
| 214 |
+
🚫 Revoke
|
| 215 |
</button>`;
|
| 216 |
} else if (t.token) {
|
| 217 |
+
// Orphan token — show Link User button
|
| 218 |
actionBtns = `
|
| 219 |
+
<button onclick="linkUser('${escHtml(t.token)}')"
|
| 220 |
+
class="text-purple-600 hover:text-purple-800 text-xs px-3 py-1 rounded border border-purple-300 hover:bg-purple-50 transition mb-1 font-semibold">
|
| 221 |
+
🔗 Link User ID
|
| 222 |
+
</button>
|
| 223 |
+
<div class="text-xs text-text opacity-40 italic mt-0.5 w-full">Enter Telegram user_id to enable management</div>`;
|
| 224 |
}
|
| 225 |
|
| 226 |
const revokeTokenBtn = t.token ? `
|
| 227 |
+
<button onclick="revokeToken('${escHtml(t.token)}')"
|
| 228 |
+
class="text-gray-500 hover:text-red-700 text-xs px-2 py-1 rounded border border-gray-300 hover:bg-red-50 transition mb-1">
|
| 229 |
+
🗑 Del Token
|
| 230 |
</button>` : '';
|
| 231 |
|
| 232 |
+
return `<tr class="border-b border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/30 transition ${rowCls}">
|
| 233 |
+
<td class="px-4 py-3">${statusBadge}</td>
|
| 234 |
+
<td class="px-4 py-3">${nameHtml}${idHtml}</td>
|
| 235 |
+
<td class="px-4 py-3">${addonLink}</td>
|
| 236 |
+
<td class="px-4 py-3 text-text opacity-70 text-xs">${t.created_at ? fmtDate(t.created_at) : '—'}</td>
|
| 237 |
+
<td class="px-4 py-3 text-xs">${expires}</td>
|
| 238 |
+
<td class="px-4 py-3">
|
| 239 |
+
<div class="flex flex-wrap gap-1">${actionBtns}${revokeTokenBtn}</div>
|
| 240 |
+
</td>
|
| 241 |
+
</tr>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
}
|
| 243 |
|
| 244 |
function changePage(dir) {
|
|
|
|
| 248 |
|
| 249 |
async function loadTokens() {
|
| 250 |
const tbody = document.getElementById('token-table-body');
|
| 251 |
+
tbody.innerHTML = '<tr><td colspan="6" class="text-center py-10 text-text opacity-40">Loading…</td></tr>';
|
| 252 |
try {
|
| 253 |
const resp = await fetch('/api/admin/access/tokens');
|
| 254 |
const data = await resp.json();
|
|
|
|
| 261 |
currentPage = 1;
|
| 262 |
renderPage();
|
| 263 |
} catch (err) {
|
| 264 |
+
tbody.innerHTML = `<tr><td colspan="6" class="text-center py-10 text-red-500">Error: ${err.message}</td></tr>`;
|
| 265 |
}
|
| 266 |
}
|
| 267 |
|
|
|
|
| 271 |
const data = await resp.json();
|
| 272 |
const plans = data.plans || data || [];
|
| 273 |
const sel = document.getElementById('assign-plan-select');
|
| 274 |
+
sel.innerHTML = '<option value="">— Select a plan —</option>' +
|
| 275 |
+
plans.map(p => `<option value="${p.days}">${p.days} days${p.price ? ' — ₹' + p.price : ''}</option>`).join('');
|
| 276 |
} catch (e) { console.warn('Could not load plans', e); }
|
| 277 |
}
|
| 278 |
|
| 279 |
function openAssignModal(userId, userName) {
|
| 280 |
document.getElementById('assign-user-id').value = userId;
|
| 281 |
+
document.getElementById('assign-user-label').textContent = `User: ${userName} (ID: ${userId})`;
|
| 282 |
document.getElementById('assign-custom-days').value = '';
|
| 283 |
document.getElementById('assign-plan-select').value = '';
|
| 284 |
+
const modal = document.getElementById('assign-modal');
|
| 285 |
+
modal.style.display = 'flex';
|
| 286 |
}
|
| 287 |
|
| 288 |
function closeAssignModal() {
|
|
|
|
| 295 |
const planDays = parseInt(document.getElementById('assign-plan-select').value) || 0;
|
| 296 |
const days = customDays || planDays;
|
| 297 |
|
| 298 |
+
if (!days || days < 1) { showToast('Please select a plan or enter custom days.', 'red'); return; }
|
| 299 |
|
| 300 |
try {
|
| 301 |
const resp = await fetch(`/api/admin/access/users/${userId}/assign-plan`, {
|
|
|
|
| 305 |
});
|
| 306 |
const data = await resp.json();
|
| 307 |
if (resp.ok) {
|
| 308 |
+
showToast(`✅ Assigned ${days} days to user ${userId}`, 'green');
|
| 309 |
closeAssignModal();
|
| 310 |
loadTokens();
|
| 311 |
} else {
|
| 312 |
+
showToast(data.detail || 'Failed to assign plan.', 'red');
|
| 313 |
}
|
| 314 |
+
} catch (err) { showToast('Error: ' + err.message, 'red'); }
|
| 315 |
}
|
| 316 |
|
| 317 |
async function revokeToken(token) {
|
|
|
|
| 319 |
try {
|
| 320 |
const resp = await fetch(`/api/admin/access/tokens/${encodeURIComponent(token)}`, { method: 'DELETE' });
|
| 321 |
const data = await resp.json();
|
| 322 |
+
if (resp.ok) { showToast('Token deleted.', 'green'); loadTokens(); }
|
| 323 |
+
else showToast(data.detail || 'Failed.', 'red');
|
| 324 |
+
} catch (err) { showToast('Error: ' + err.message, 'red'); }
|
| 325 |
}
|
| 326 |
|
| 327 |
async function linkUser(token) {
|
| 328 |
const userId = prompt('Enter the Telegram User ID to link this token to:');
|
| 329 |
+
if (!userId || isNaN(parseInt(userId))) { showToast('Invalid user ID.', 'red'); return; }
|
| 330 |
try {
|
| 331 |
const resp = await fetch(`/api/admin/access/tokens/${encodeURIComponent(token)}/link-user`, {
|
| 332 |
method: 'PATCH',
|
|
|
|
| 335 |
});
|
| 336 |
const data = await resp.json();
|
| 337 |
if (resp.ok) {
|
| 338 |
+
showToast(`✅ Token linked to user ${userId}. Refreshing…`, 'green');
|
| 339 |
loadTokens();
|
| 340 |
+
} else { showToast(data.detail || 'Failed to link.', 'red'); }
|
| 341 |
+
} catch (err) { showToast('Error: ' + err.message, 'red'); }
|
| 342 |
}
|
| 343 |
|
| 344 |
+
// Sub action modal (Extend / Reduce / Revoke)
|
| 345 |
function openSubModal(userId, userName, action) {
|
| 346 |
document.getElementById('sub-action-user-id').value = userId;
|
| 347 |
document.getElementById('sub-action-action').value = action;
|
| 348 |
+
const titles = { extend: '➕ Extend Subscription', reduce: '➖ Reduce Subscription', delete: '🚫 Revoke Subscription' };
|
| 349 |
+
const descs = {
|
| 350 |
+
extend: `Add days to <b>${userName}</b>'s subscription.`,
|
| 351 |
+
reduce: `Remove days from <b>${userName}</b>'s subscription.`,
|
| 352 |
+
delete: `<b>Warning:</b> Revoke <b>${userName}</b>'s subscription entirely.`
|
| 353 |
};
|
| 354 |
+
document.getElementById('sub-action-title').textContent = titles[action];
|
| 355 |
+
document.getElementById('sub-action-desc').innerHTML = descs[action];
|
| 356 |
+
document.getElementById('sub-action-days-group').className = action === 'delete' ? 'hidden' : 'mb-4';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 357 |
document.getElementById('sub-action-days').value = 30;
|
|
|
|
| 358 |
const btn = document.getElementById('sub-action-btn');
|
| 359 |
+
btn.className = `px-4 py-2 rounded-lg text-white text-sm font-semibold transition hover:opacity-80 ${action === 'delete' ? 'bg-red-500' : action === 'reduce' ? 'bg-yellow-500' : 'bg-green-600'}`;
|
|
|
|
|
|
|
| 360 |
document.getElementById('sub-action-modal').style.display = 'flex';
|
| 361 |
}
|
| 362 |
|
|
|
|
| 374 |
});
|
| 375 |
const data = await resp.json();
|
| 376 |
if (resp.ok) {
|
| 377 |
+
showToast(`✅ ${action.charAt(0).toUpperCase() + action.slice(1)}d subscription for user ${userId}`, 'green');
|
| 378 |
closeSubModal();
|
| 379 |
loadTokens();
|
| 380 |
+
} else { showToast(data.detail || 'Failed.', 'red'); }
|
| 381 |
+
} catch (err) { showToast('Error: ' + err.message, 'red'); }
|
| 382 |
}
|
| 383 |
|
| 384 |
async function copyLink(url) {
|
| 385 |
+
try { await navigator.clipboard.writeText(url); showToast('Link copied!', 'green'); }
|
| 386 |
catch { prompt('Copy this link:', url); }
|
| 387 |
}
|
| 388 |
|
| 389 |
function fmtDate(iso) {
|
| 390 |
+
if (!iso) return '—';
|
| 391 |
const d = new Date(iso);
|
| 392 |
+
return d.toLocaleDateString('en-IN', { timeZone: 'Asia/Kolkata', day: '2-digit', month: 'short', year: 'numeric' })
|
| 393 |
+
+ ' ' + d.toLocaleTimeString('en-IN', { timeZone: 'Asia/Kolkata', hour: '2-digit', minute: '2-digit' });
|
|
|
|
|
|
|
| 394 |
}
|
| 395 |
|
| 396 |
function escHtml(s) {
|
| 397 |
return String(s || '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
| 398 |
}
|
| 399 |
|
| 400 |
+
function showToast(msg, color) {
|
| 401 |
const t = document.createElement('div');
|
| 402 |
+
t.textContent = msg;
|
| 403 |
+
t.className = `fixed bottom-6 right-6 px-4 py-3 rounded-xl shadow-lg text-white text-sm z-[200] bg-${color}-500 transition-all`;
|
|
|
|
|
|
|
| 404 |
document.body.appendChild(t);
|
| 405 |
+
setTimeout(() => t.remove(), 3000);
|
|
|
|
|
|
|
|
|
|
| 406 |
}
|
| 407 |
|
| 408 |
+
// Close modal on backdrop click
|
| 409 |
+
document.getElementById('assign-modal').addEventListener('click', function (e) {
|
| 410 |
+
if (e.target === this) closeAssignModal();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
});
|
| 412 |
|
| 413 |
loadPlans();
|
| 414 |
loadTokens();
|
| 415 |
</script>
|
| 416 |
|
| 417 |
+
<!-- Sub Action Modal (Extend / Reduce / Revoke) -->
|
| 418 |
+
<div id="sub-action-modal" class="fixed inset-0 bg-black bg-opacity-60 items-center justify-center z-50 mx-4"
|
| 419 |
+
style="display:none">
|
| 420 |
+
<div class="bg-white dark:bg-gray-800 rounded-2xl p-6 w-full max-w-md shadow-2xl mx-auto mt-24">
|
| 421 |
+
<h3 class="text-lg font-bold mb-1 text-gray-800 dark:text-white" id="sub-action-title">Manage Subscription</h3>
|
| 422 |
+
<p class="text-sm text-gray-500 mb-4" id="sub-action-desc"></p>
|
| 423 |
+
<input type="hidden" id="sub-action-user-id">
|
| 424 |
+
<input type="hidden" id="sub-action-action">
|
| 425 |
+
<div id="sub-action-days-group" class="mb-4">
|
| 426 |
+
<label class="block text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2">Number of Days</label>
|
| 427 |
+
<input type="number" id="sub-action-days" value="30" min="1"
|
| 428 |
+
class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:outline-none focus:border-primary dark:bg-gray-700 dark:border-gray-600 dark:text-white">
|
| 429 |
+
</div>
|
| 430 |
+
<div class="flex justify-end gap-3 mt-4">
|
| 431 |
+
<button onclick="closeSubModal()"
|
| 432 |
+
class="px-4 py-2 text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition text-sm">Cancel</button>
|
| 433 |
+
<button id="sub-action-btn" onclick="submitSubAction()"
|
| 434 |
+
class="px-4 py-2 bg-green-600 text-white rounded-lg hover:opacity-80 transition text-sm font-semibold">Confirm</button>
|
| 435 |
+
</div>
|
| 436 |
+
</div>
|
| 437 |
+
</div>
|
| 438 |
+
|
| 439 |
+
{% endblock %}
|
Backend/fastapi/templates/admin_dashboard.html
CHANGED
|
@@ -3,226 +3,340 @@
|
|
| 3 |
{% block title %}Admin Dashboard - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
-
<
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
}
|
| 14 |
-
|
| 15 |
-
.admin-panel-card:hover {
|
| 16 |
-
border-color: rgba(59, 130, 246, 0.3);
|
| 17 |
-
}
|
| 18 |
-
|
| 19 |
-
.status-pill {
|
| 20 |
-
padding: 2px 10px;
|
| 21 |
-
border-radius: 9999px;
|
| 22 |
-
font-size: 0.7rem;
|
| 23 |
-
font-weight: 700;
|
| 24 |
-
text-transform: uppercase;
|
| 25 |
-
letter-spacing: 0.025em;
|
| 26 |
-
}
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
}
|
| 40 |
-
</style>
|
| 41 |
-
|
| 42 |
-
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 space-y-8">
|
| 43 |
-
<header class="admin-panel-card rounded-3xl overflow-hidden shadow-2xl">
|
| 44 |
-
<div class="bg-gradient-to-br from-primary/10 via-transparent to-accent/5 p-8">
|
| 45 |
-
<div class="flex flex-col lg:flex-row justify-between items-start lg:items-center gap-6">
|
| 46 |
-
<div>
|
| 47 |
-
<div class="flex items-center gap-2 mb-2">
|
| 48 |
-
<span class="flex h-2 w-2 rounded-full bg-green-500 animate-pulse"></span>
|
| 49 |
-
<p class="text-xs font-bold uppercase tracking-widest text-primary/80">Operations Command</p>
|
| 50 |
</div>
|
| 51 |
-
<
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
</p>
|
| 55 |
-
<div class="flex flex-wrap gap-3 mt-5">
|
| 56 |
-
<span class="px-3 py-1 rounded-lg bg-white/5 border border-white/10 text-[11px] font-medium text-slate-300" id="last-updated-pill">
|
| 57 |
-
<i class="fas fa-sync-alt mr-1.5 opacity-50"></i> Syncing...
|
| 58 |
-
</span>
|
| 59 |
-
<span class="px-3 py-1 rounded-lg bg-primary/10 border border-primary/20 text-[11px] font-bold text-primary">
|
| 60 |
-
Refresh: 10s
|
| 61 |
-
</span>
|
| 62 |
</div>
|
| 63 |
</div>
|
| 64 |
-
|
| 65 |
-
<div class="flex flex-wrap gap-3">
|
| 66 |
-
<button onclick="clearCache()" class="group flex items-center gap-2 bg-red-500/10 hover:bg-red-500 border border-red-500/20 text-red-500 hover:text-white px-5 py-2.5 rounded-xl text-sm font-bold transition-all duration-300">
|
| 67 |
-
<i class="fas fa-eraser opacity-70 group-hover:scale-110 transition-transform"></i>
|
| 68 |
-
Clear Cache
|
| 69 |
-
</button>
|
| 70 |
-
<button onclick="clearAnalytics()" class="group flex items-center gap-2 bg-white/5 hover:bg-white/10 border border-white/10 px-5 py-2.5 rounded-xl text-sm font-bold text-white transition-all duration-300">
|
| 71 |
-
<i class="fas fa-history opacity-70 group-hover:rotate-[-45deg] transition-transform"></i>
|
| 72 |
-
Reset Logs
|
| 73 |
-
</button>
|
| 74 |
-
</div>
|
| 75 |
</div>
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
<div class="flex items-center justify-between mb-4">
|
| 89 |
-
<span class="text-[10px] font-black uppercase tracking-widest text-slate-500">{{ stat.label }}</span>
|
| 90 |
-
<i class="fas {{ stat.icon }} text-primary/30 text-lg"></i>
|
| 91 |
</div>
|
| 92 |
-
<p class="text-3xl font-black text-white tracking-tighter" id="{{ stat.id }}">-</p>
|
| 93 |
</div>
|
| 94 |
-
{% endfor %}
|
| 95 |
-
</div>
|
| 96 |
|
| 97 |
-
|
| 98 |
-
<div class="
|
| 99 |
-
<div class="
|
| 100 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
</div>
|
| 102 |
-
<h2 class="text-lg font-bold text-white">Bot Distribution & Load</h2>
|
| 103 |
-
</div>
|
| 104 |
-
<div id="stat-workloads" class="divide-y divide-white/[0.05]">
|
| 105 |
-
<div class="p-12 text-center text-slate-500 italic text-sm">Initializing telemetry...</div>
|
| 106 |
</div>
|
| 107 |
-
</
|
| 108 |
|
| 109 |
-
<
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
<i class="fas fa-sync mr-2"></i>Refresh Table
|
| 117 |
</button>
|
| 118 |
</div>
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
<
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
</
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
<div class="flex flex-col lg:flex-row justify-between items-start lg:items-end gap-6">
|
| 144 |
-
<div>
|
| 145 |
-
<h2 class="text-lg font-bold text-white flex items-center gap-2">
|
| 146 |
-
<i class="fas fa-skull-crossbones text-red-500/50"></i>
|
| 147 |
-
Dead Link Purge
|
| 148 |
-
</h2>
|
| 149 |
-
<p class="text-xs text-slate-500 mt-1">Directly remove broken content from user search results</p>
|
| 150 |
-
</div>
|
| 151 |
-
<div class="flex flex-col sm:flex-row gap-3 w-full lg:w-auto">
|
| 152 |
-
<input id="dead-links-search" type="text" placeholder="Filter by title..."
|
| 153 |
-
class="bg-white/5 border border-white/10 rounded-xl px-4 py-2 text-sm text-white focus:outline-none focus:border-primary/50 w-full sm:w-64 transition-all">
|
| 154 |
-
<select id="dead-links-type-filter" class="bg-white/5 border border-white/10 rounded-xl px-4 py-2 text-sm text-white focus:outline-none focus:border-primary/50">
|
| 155 |
-
<option value="all">All Content</option>
|
| 156 |
-
<option value="movie">Movies</option>
|
| 157 |
-
<option value="tv">TV Shows</option>
|
| 158 |
-
</select>
|
| 159 |
-
</div>
|
| 160 |
</div>
|
| 161 |
</div>
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
<
|
| 171 |
-
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
</tbody>
|
| 174 |
-
|
|
|
|
| 175 |
</div>
|
| 176 |
-
</
|
| 177 |
</div>
|
| 178 |
|
| 179 |
<script>
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
}
|
| 188 |
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
<
|
| 202 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
</div>
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
<div class="
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
}
|
| 225 |
|
| 226 |
-
/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
</script>
|
| 228 |
{% 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
|
| 21 |
+
</button>
|
| 22 |
+
</div>
|
| 23 |
|
| 24 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-6" id="stats-container">
|
| 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>
|
| 37 |
+
|
| 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>
|
| 85 |
+
<th class="px-6 py-4 font-semibold text-center">Bot (DC)</th>
|
| 86 |
+
<th class="px-6 py-4 font-semibold text-right">Data Transferred</th>
|
| 87 |
+
<th class="px-6 py-4 font-semibold text-right">Avg / Peak Speed</th>
|
| 88 |
+
<th class="px-6 py-4 font-semibold text-center">Duration</th>
|
| 89 |
+
<th class="px-6 py-4 font-semibold text-center">Status</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>
|
| 100 |
+
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
</div>
|
| 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>
|
| 115 |
+
<th class="px-6 py-4 font-semibold">Quality Details</th>
|
| 116 |
+
<th class="px-6 py-4 font-semibold w-32 text-center">Date Added</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>
|
| 127 |
+
</table>
|
| 128 |
+
</div>
|
| 129 |
</div>
|
| 130 |
+
</div>
|
| 131 |
</div>
|
| 132 |
|
| 133 |
<script>
|
| 134 |
+
async function fetchStats() {
|
| 135 |
+
try {
|
| 136 |
+
const res = await fetch('/api/admin/system-stats');
|
| 137 |
+
if (res.ok) {
|
| 138 |
+
const data = await res.json();
|
| 139 |
+
document.getElementById('stat-cache-size').textContent = data.cache_size;
|
| 140 |
+
document.getElementById('stat-bot-count').textContent = data.total_bots;
|
|
|
|
| 141 |
|
| 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 |
+
}
|
| 177 |
+
} catch (err) {
|
| 178 |
+
console.error(err);
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
async function fetchAnalytics() {
|
| 183 |
+
try {
|
| 184 |
+
const res = await fetch('/api/admin/stream-analytics');
|
| 185 |
+
const tbody = document.getElementById('analytics-tbody');
|
| 186 |
+
if (res.ok) {
|
| 187 |
+
const data = await res.json();
|
| 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` : '—';
|
| 201 |
+
const titleStr = s.title || s.meta?.title || '—';
|
| 202 |
+
|
| 203 |
+
let statusColor = 'text-green-500';
|
| 204 |
+
if (s.status === 'error') statusColor = 'text-red-500';
|
| 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 |
+
});
|
| 220 |
+
tbody.innerHTML = html;
|
| 221 |
+
}
|
| 222 |
+
} catch (err) {
|
| 223 |
+
console.error(err);
|
| 224 |
+
}
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
async function fetchDeadLinks() {
|
| 228 |
+
try {
|
| 229 |
+
const res = await fetch('/api/admin/dead-links');
|
| 230 |
+
const tbody = document.getElementById('dead-links-tbody');
|
| 231 |
+
if (res.ok) {
|
| 232 |
+
const data = await res.json();
|
| 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>
|
| 265 |
+
</tr>
|
| 266 |
+
`;
|
| 267 |
+
});
|
| 268 |
+
tbody.innerHTML = html;
|
| 269 |
+
}
|
| 270 |
+
} catch (err) {
|
| 271 |
+
console.error(err);
|
| 272 |
+
}
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
async function clearCache() {
|
| 276 |
+
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;
|
| 277 |
+
|
| 278 |
+
try {
|
| 279 |
+
const res = await fetch('/api/admin/clear-cache', { method: 'POST' });
|
| 280 |
+
if (res.ok) {
|
| 281 |
+
const data = await res.json();
|
| 282 |
+
alert(data.message);
|
| 283 |
+
fetchStats();
|
| 284 |
+
} else {
|
| 285 |
+
alert("Failed to clear cache.");
|
| 286 |
+
}
|
| 287 |
+
} catch (err) {
|
| 288 |
+
alert("Error clearing cache.");
|
| 289 |
+
}
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
async function clearAnalytics() {
|
| 293 |
+
if (!confirm("Are you sure you want to clear all stream analytics history? This cannot be undone.")) return;
|
| 294 |
+
|
| 295 |
+
try {
|
| 296 |
+
const res = await fetch('/api/admin/clear-analytics', { method: 'POST' });
|
| 297 |
+
if (res.ok) {
|
| 298 |
+
const data = await res.json();
|
| 299 |
+
alert(data.message || 'Analytics cleared successfully.');
|
| 300 |
+
fetchAnalytics();
|
| 301 |
+
} else {
|
| 302 |
+
const err = await res.json().catch(() => ({}));
|
| 303 |
+
alert(err.detail || 'Failed to clear analytics.');
|
| 304 |
+
}
|
| 305 |
+
} catch (err) {
|
| 306 |
+
alert('Error clearing analytics.');
|
| 307 |
+
}
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
async function deleteDeadLink(tmdb_id, db_index, type, quality_id, season, episode) {
|
| 311 |
+
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;
|
| 312 |
+
|
| 313 |
+
try {
|
| 314 |
+
let endpoint = '';
|
| 315 |
+
if (type === 'movie') {
|
| 316 |
+
endpoint = `/api/media/delete-quality?tmdb_id=${tmdb_id}&db_index=${db_index}&id=${quality_id}`;
|
| 317 |
+
} else {
|
| 318 |
+
endpoint = `/api/media/delete-tv-quality?tmdb_id=${tmdb_id}&db_index=${db_index}&season=${season}&episode=${episode}&id=${quality_id}`;
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
const res = await fetch(endpoint, { method: 'DELETE' });
|
| 322 |
+
if (res.ok) {
|
| 323 |
+
fetchDeadLinks(); // Refresh table
|
| 324 |
+
} else {
|
| 325 |
+
alert("Failed to delete the dead link.");
|
| 326 |
+
}
|
| 327 |
+
} catch (err) {
|
| 328 |
+
alert("Error communicating with server.");
|
| 329 |
+
}
|
| 330 |
}
|
| 331 |
|
| 332 |
+
// Initial fetch on load
|
| 333 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 334 |
+
fetchStats();
|
| 335 |
+
fetchAnalytics();
|
| 336 |
+
fetchDeadLinks();
|
| 337 |
+
// Refresh dynamic stats
|
| 338 |
+
setInterval(fetchStats, 10000);
|
| 339 |
+
setInterval(fetchAnalytics, 15000);
|
| 340 |
+
});
|
| 341 |
</script>
|
| 342 |
{% endblock %}
|
Backend/fastapi/templates/base.html
CHANGED
|
@@ -8,187 +8,126 @@
|
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"/>
|
| 10 |
|
| 11 |
-
<
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
}
|
|
|
|
| 22 |
|
|
|
|
| 23 |
body {
|
| 24 |
-
background-color:
|
| 25 |
-
color:
|
| 26 |
-
/* Creating a smoother, ambient, floating orb background */
|
| 27 |
-
background-image:
|
| 28 |
-
radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 40%),
|
| 29 |
-
radial-gradient(circle at 85% 80%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 40%),
|
| 30 |
-
radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--card) 40%, transparent), transparent 60%);
|
| 31 |
-
background-attachment: fixed;
|
| 32 |
-
min-height: 100vh;
|
| 33 |
-
display: flex;
|
| 34 |
-
flex-direction: column;
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
/* Glassmorphism utilities */
|
| 38 |
-
.glass-panel {
|
| 39 |
-
background: color-mix(in srgb, var(--card) 45%, transparent);
|
| 40 |
-
backdrop-filter: blur(20px);
|
| 41 |
-
-webkit-backdrop-filter: blur(20px);
|
| 42 |
-
border: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
|
| 43 |
-
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
.glass-pill {
|
| 47 |
-
border-radius: 9999px; /* Fully rounded */
|
| 48 |
}
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
background: color-mix(in srgb, var(--bg) 60%, transparent);
|
| 54 |
-
color: var(--text);
|
| 55 |
-
border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
|
| 56 |
-
border-radius: 999px;
|
| 57 |
-
padding: 0.5rem 2rem 0.5rem 1rem;
|
| 58 |
-
font-size: 0.875rem;
|
| 59 |
-
cursor: pointer;
|
| 60 |
-
transition: all 0.3s ease;
|
| 61 |
}
|
| 62 |
|
| 63 |
-
.theme-
|
| 64 |
-
|
| 65 |
-
outline: none;
|
| 66 |
-
box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
|
| 67 |
}
|
| 68 |
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
color: var(--text-sec);
|
| 72 |
-
transition: all 0.2s ease-in-out;
|
| 73 |
-
position: relative;
|
| 74 |
}
|
| 75 |
|
| 76 |
-
.
|
| 77 |
-
color:
|
| 78 |
-
background: color-mix(in srgb, var(--primary) 15%, transparent);
|
| 79 |
}
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
background: color-mix(in srgb, var(--card) 65%, transparent);
|
| 84 |
-
backdrop-filter: blur(12px);
|
| 85 |
-
border: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
|
| 86 |
-
border-radius: 20px;
|
| 87 |
-
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
|
| 88 |
}
|
| 89 |
</style>
|
| 90 |
-
|
| 91 |
-
<script>
|
| 92 |
-
/* Tell Tailwind to use our CSS variables */
|
| 93 |
-
tailwind.config = {
|
| 94 |
-
darkMode: 'class',
|
| 95 |
-
theme: {
|
| 96 |
-
extend: {
|
| 97 |
-
colors: {
|
| 98 |
-
primary: 'var(--primary)',
|
| 99 |
-
secondary: 'var(--secondary)',
|
| 100 |
-
accent: 'var(--accent)',
|
| 101 |
-
background: 'var(--bg)',
|
| 102 |
-
card: 'var(--card)',
|
| 103 |
-
text: 'var(--text)',
|
| 104 |
-
'text-secondary': 'var(--text-sec)'
|
| 105 |
-
}
|
| 106 |
-
}
|
| 107 |
-
}
|
| 108 |
-
}
|
| 109 |
-
</script>
|
| 110 |
</head>
|
| 111 |
|
| 112 |
-
<body class="
|
| 113 |
-
|
| 114 |
-
<nav class="
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
<a href="/admin/access" class="nav-link px-4 py-2 rounded-full text-sm font-medium"><i class="fa-solid fa-shield-halved mr-2"></i>Access</a>
|
| 132 |
-
</div>
|
| 133 |
-
{% endif %}
|
| 134 |
-
|
| 135 |
-
<div class="flex items-center gap-4">
|
| 136 |
-
<div class="relative hidden sm:block">
|
| 137 |
-
<form method="post" action="/set-theme" id="theme-form" class="m-0">
|
| 138 |
-
<select name="theme" onchange="document.getElementById('theme-form').submit()" class="theme-select">
|
| 139 |
-
{% for theme_key, theme_data in themes.items() %}
|
| 140 |
-
<option value="{{ theme_key }}" {% if current_theme==theme_key %}selected{% endif %}>
|
| 141 |
-
{{ theme_data.name }}
|
| 142 |
-
</option>
|
| 143 |
-
{% endfor %}
|
| 144 |
-
</select>
|
| 145 |
-
<div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-3 text-text-secondary">
|
| 146 |
-
<i class="fa-solid fa-chevron-down text-xs"></i>
|
| 147 |
</div>
|
| 148 |
-
|
| 149 |
-
|
| 150 |
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
</div>
|
| 159 |
-
<a href="/logout" class="bg-red-500/10 hover:bg-red-500 text-red-500 hover:text-white border border-red-500/20 px-4 py-2 rounded-full text-sm font-semibold transition-all duration-300">
|
| 160 |
-
<i class="fa-solid fa-arrow-right-from-bracket md:mr-2"></i><span class="hidden md:inline">Logout</span>
|
| 161 |
-
</a>
|
| 162 |
</div>
|
| 163 |
-
{% else %}
|
| 164 |
-
<a href="/login" class="bg-primary hover:bg-primary/80 text-white shadow-lg shadow-primary/30 px-6 py-2 rounded-full text-sm font-semibold transition-all duration-300">
|
| 165 |
-
Login <i class="fa-solid fa-arrow-right-to-bracket ml-2"></i>
|
| 166 |
-
</a>
|
| 167 |
-
{% endif %}
|
| 168 |
</div>
|
| 169 |
</nav>
|
| 170 |
|
| 171 |
-
<
|
|
|
|
| 172 |
{% block content %}{% endblock %}
|
| 173 |
</main>
|
| 174 |
|
| 175 |
-
<
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
<p class="
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
</
|
| 186 |
-
<a href="/stremio" class="text-sm font-medium text-text-secondary hover:text-primary transition-colors">
|
| 187 |
-
<i class="fa-solid fa-book-open mr-1"></i> Guide
|
| 188 |
-
</a>
|
| 189 |
</div>
|
| 190 |
</div>
|
| 191 |
</footer>
|
| 192 |
-
|
| 193 |
</body>
|
| 194 |
-
|
|
|
|
|
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"/>
|
| 10 |
|
| 11 |
+
<script>
|
| 12 |
+
tailwind.config = {
|
| 13 |
+
darkMode: 'class',
|
| 14 |
+
theme: {
|
| 15 |
+
extend: {
|
| 16 |
+
colors: {
|
| 17 |
+
primary: '{{ theme.colors.primary }}',
|
| 18 |
+
secondary: '{{ theme.colors.secondary }}',
|
| 19 |
+
accent: '{{ theme.colors.accent }}',
|
| 20 |
+
background: '{{ theme.colors.background }}',
|
| 21 |
+
card: '{{ theme.colors.card }}',
|
| 22 |
+
text: '{{ theme.colors.text }}',
|
| 23 |
+
'text-secondary': '{{ theme.colors.text_secondary }}'
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
}
|
| 28 |
+
</script>
|
| 29 |
|
| 30 |
+
<style>
|
| 31 |
body {
|
| 32 |
+
background-color: {{ theme.colors.background }};
|
| 33 |
+
color: {{ theme.colors.text }};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
}
|
| 35 |
|
| 36 |
+
.theme-card {
|
| 37 |
+
background-color: {{ theme.colors.card }};
|
| 38 |
+
color: {{ theme.colors.text }};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
}
|
| 40 |
|
| 41 |
+
.theme-primary {
|
| 42 |
+
background-color: {{ theme.colors.primary }};
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
+
.theme-secondary {
|
| 46 |
+
background-color: {{ theme.colors.secondary }};
|
|
|
|
|
|
|
|
|
|
| 47 |
}
|
| 48 |
|
| 49 |
+
.theme-accent {
|
| 50 |
+
background-color: {{ theme.colors.accent }};
|
|
|
|
| 51 |
}
|
| 52 |
|
| 53 |
+
.theme-text-secondary {
|
| 54 |
+
color: {{ theme.colors.text_secondary }};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
}
|
| 56 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
</head>
|
| 58 |
|
| 59 |
+
<body class="min-h-screen flex flex-col">
|
| 60 |
+
<!-- Navigation -->
|
| 61 |
+
<nav class="theme-card shadow-lg border-b text-text">
|
| 62 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
| 63 |
+
<div class="flex justify-between items-center h-16">
|
| 64 |
+
<div class="flex items-center space-x-4">
|
| 65 |
+
<h1 class="text-2xl font-bold text-primary">Telegram Stremio</h1>
|
| 66 |
+
{% if current_user %}
|
| 67 |
+
<div class="hidden md:flex space-x-4">
|
| 68 |
+
<a href="/"
|
| 69 |
+
class="text-text hover:text-primary px-3 py-2 rounded-md transition-colors">Dashboard</a>
|
| 70 |
+
<a href="/media/manage"
|
| 71 |
+
class="text-text hover:text-primary px-3 py-2 rounded-md transition-colors">Media</a>
|
| 72 |
+
<a href="/admin/dashboard"
|
| 73 |
+
class="text-text hover:text-primary px-3 py-2 rounded-md transition-colors">Admin</a>
|
| 74 |
+
<a href="/admin/subscriptions"
|
| 75 |
+
class="text-text hover:text-primary px-3 py-2 rounded-md transition-colors">Sub Manage</a>
|
| 76 |
+
<a href="/admin/access"
|
| 77 |
+
class="text-text hover:text-primary px-3 py-2 rounded-md transition-colors">Access</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
</div>
|
| 79 |
+
{% endif %}
|
| 80 |
+
</div>
|
| 81 |
|
| 82 |
+
<div class="flex items-center space-x-4">
|
| 83 |
+
<!-- Theme Selector -->
|
| 84 |
+
<div class="relative">
|
| 85 |
+
<form method="post" action="/set-theme" id="theme-form">
|
| 86 |
+
<select name="theme" onchange="document.getElementById('theme-form').submit()"
|
| 87 |
+
class="theme-card border border-gray-300 rounded-md px-3 py-2 text-sm">
|
| 88 |
+
{% for theme_key, theme_data in themes.items() %}
|
| 89 |
+
<option value="{{ theme_key }}" {% if current_theme==theme_key %}selected{% endif %}>
|
| 90 |
+
{{ theme_data.name }}
|
| 91 |
+
</option>
|
| 92 |
+
{% endfor %}
|
| 93 |
+
</select>
|
| 94 |
+
</form>
|
| 95 |
+
</div>
|
| 96 |
|
| 97 |
+
{% if current_user %}
|
| 98 |
+
<div class="flex items-center space-x-4">
|
| 99 |
+
<span class="text-sm theme-text-secondary">{{ current_user }}</span>
|
| 100 |
+
<a href="/logout"
|
| 101 |
+
class="bg-red-600 text-white px-4 py-2 rounded-md hover:bg-red-700 transition-colors">Logout</a>
|
| 102 |
+
</div>
|
| 103 |
+
{% else %}
|
| 104 |
+
<a href="/login"
|
| 105 |
+
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-md transition-colors">Login</a>
|
| 106 |
+
{% endif %}
|
| 107 |
</div>
|
|
|
|
|
|
|
|
|
|
| 108 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
</div>
|
| 110 |
</nav>
|
| 111 |
|
| 112 |
+
<!-- Main Content -->
|
| 113 |
+
<main class="flex-1">
|
| 114 |
{% block content %}{% endblock %}
|
| 115 |
</main>
|
| 116 |
|
| 117 |
+
<!-- Footer -->
|
| 118 |
+
<footer class="theme-card border-t mt-auto text-text">
|
| 119 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
|
| 120 |
+
<div class="flex justify-between items-center">
|
| 121 |
+
<p class="theme-text-secondary text-sm">© 2025 Telegram Stremio. All rights reserved.</p>
|
| 122 |
+
<div class="flex space-x-4">
|
| 123 |
+
<a href="/status"
|
| 124 |
+
class="theme-text-secondary hover:text-primary text-sm transition-colors">Status</a>
|
| 125 |
+
<a href="/stremio" class="theme-text-secondary hover:text-primary text-sm transition-colors">Stremio
|
| 126 |
+
Guide</a>
|
| 127 |
+
</div>
|
|
|
|
|
|
|
|
|
|
| 128 |
</div>
|
| 129 |
</div>
|
| 130 |
</footer>
|
|
|
|
| 131 |
</body>
|
| 132 |
+
|
| 133 |
+
</html>
|
Backend/fastapi/templates/dashboard.html
CHANGED
|
@@ -3,310 +3,929 @@
|
|
| 3 |
{% block title %}Dashboard - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
-
<
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
}
|
| 26 |
-
.admin-local-input {
|
| 27 |
-
background: rgba(255, 255, 255, 0.05) !important;
|
| 28 |
-
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
| 29 |
-
color: white !important;
|
| 30 |
-
}
|
| 31 |
-
.admin-local-input:focus {
|
| 32 |
-
border-color: var(--color-primary) !important;
|
| 33 |
-
ring: 2px var(--color-primary);
|
| 34 |
-
}
|
| 35 |
-
.stream-active { border-left: 4px solid #10b981; }
|
| 36 |
-
.stream-cancelled { border-left: 4px solid #f59e0b; }
|
| 37 |
-
.stream-error { border-left: 4px solid #ef4444; }
|
| 38 |
-
</style>
|
| 39 |
-
|
| 40 |
-
<div class="min-h-screen pb-12">
|
| 41 |
-
<header class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pt-8 mb-8">
|
| 42 |
-
<div class="admin-local-panel p-6 flex flex-col md:flex-row md:items-center md:justify-between gap-4">
|
| 43 |
-
<div>
|
| 44 |
-
<h1 class="text-3xl font-extrabold tracking-tight text-white">System Dashboard</h1>
|
| 45 |
-
<p class="text-slate-400 mt-1">Live telemetry, node status, and resource monitoring.</p>
|
| 46 |
</div>
|
| 47 |
-
<button onclick="refreshSystemStats()"
|
| 48 |
-
class="flex items-center justify-center space-x-2 px-5 py-2.5 rounded-xl bg-primary hover:bg-opacity-90 text-white transition-all shadow-lg active:scale-95 group">
|
| 49 |
-
<svg id="refresh-icon" xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 group-hover:rotate-180 transition-transform duration-700" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 50 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
|
| 51 |
-
</svg>
|
| 52 |
-
<span class="font-bold uppercase tracking-wider text-xs">Refresh Stats</span>
|
| 53 |
-
</button>
|
| 54 |
</div>
|
| 55 |
</header>
|
| 56 |
|
| 57 |
-
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
| 58 |
-
<
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
</div>
|
| 66 |
-
<h3 class="text-xl font-bold text-white">System Health</h3>
|
| 67 |
-
</div>
|
| 68 |
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
<
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
<
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
</div>
|
| 86 |
</div>
|
| 87 |
-
</div>
|
| 88 |
|
| 89 |
-
|
| 90 |
-
<
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
</div>
|
| 98 |
-
<h3 class="text-xl font-bold text-white">Live Streams</h3>
|
| 99 |
-
</div>
|
| 100 |
-
<span class="px-3 py-1 bg-red-500/20 text-red-400 border border-red-500/30 rounded-full text-xs font-bold uppercase tracking-tighter">
|
| 101 |
-
{{ system_stats.total_active_streams }} Monitor
|
| 102 |
-
</span>
|
| 103 |
-
</div>
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
<div class="
|
| 111 |
-
<
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
</div>
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
</div>
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
<div class="text-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
</div>
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
</div>
|
|
|
|
| 129 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
</div>
|
| 131 |
-
|
| 132 |
-
{% else %}
|
| 133 |
-
<div class="flex-1 flex flex-col items-center justify-center py-10 opacity-40">
|
| 134 |
-
<svg class="w-12 h-12 mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/><path d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/></svg>
|
| 135 |
-
<p class="text-sm font-medium">No activity detected</p>
|
| 136 |
-
</div>
|
| 137 |
-
{% endif %}
|
| 138 |
</div>
|
| 139 |
</div>
|
| 140 |
</div>
|
| 141 |
|
| 142 |
-
<
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
{% for db_stat in system_stats.databases %}
|
| 148 |
-
<div class="
|
| 149 |
-
<div class="flex justify-between
|
| 150 |
-
<h3 class="text-
|
| 151 |
-
<div
|
| 152 |
-
|
| 153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
</svg>
|
| 155 |
</div>
|
| 156 |
</div>
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
<span class="
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
<span class="text-[10px] uppercase text-slate-500 font-bold block mb-1">TV Shows</span>
|
| 164 |
-
<span class="text-xl font-mono font-bold text-white">{{ "{:,}".format(db_stat.tv_count) }}</span>
|
| 165 |
</div>
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
<span class="text-primary">{{ "%.1f"|format(db_stat.storageSize / 1024 / 1024) }} MB</span>
|
| 171 |
</div>
|
| 172 |
-
|
| 173 |
-
<div class="
|
| 174 |
-
<div class="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
</div>
|
| 176 |
</div>
|
| 177 |
</div>
|
| 178 |
{% endfor %}
|
| 179 |
-
|
|
|
|
|
|
|
|
|
|
| 180 |
</div>
|
| 181 |
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
<
|
| 188 |
-
|
| 189 |
-
<
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
</div>
|
| 202 |
|
| 203 |
-
<
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
<
|
| 209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
</div>
|
| 211 |
-
<
|
| 212 |
-
|
| 213 |
-
New Token
|
| 214 |
-
</button>
|
| 215 |
</div>
|
| 216 |
|
| 217 |
-
<
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
</div>
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
</div>
|
| 236 |
|
|
|
|
| 237 |
<div class="overflow-x-auto">
|
| 238 |
-
<table class="w-full text-left">
|
| 239 |
<thead>
|
| 240 |
-
<tr class="
|
| 241 |
-
<th class="
|
| 242 |
-
<th class="
|
| 243 |
-
<th class="
|
| 244 |
-
<th class="
|
| 245 |
-
<th class="
|
| 246 |
</tr>
|
| 247 |
</thead>
|
| 248 |
-
<tbody
|
| 249 |
{% for token in api_tokens %}
|
| 250 |
-
<tr class="hover:bg-
|
| 251 |
-
<td class="py-
|
| 252 |
-
|
| 253 |
-
<span class="text-
|
|
|
|
| 254 |
</td>
|
| 255 |
-
<td class="py-
|
| 256 |
-
<
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
</td>
|
| 261 |
-
<td class="py-
|
| 262 |
-
<div class="text-
|
| 263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
</td>
|
| 265 |
-
<td class="py-
|
| 266 |
-
<div class="flex items-
|
| 267 |
-
<code
|
| 268 |
-
|
|
|
|
| 269 |
</code>
|
| 270 |
-
<button
|
| 271 |
-
|
| 272 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
</button>
|
| 274 |
</div>
|
| 275 |
</td>
|
| 276 |
-
<td class="py-
|
| 277 |
-
<button
|
| 278 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
</button>
|
| 280 |
</td>
|
| 281 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
{% endfor %}
|
| 283 |
</tbody>
|
| 284 |
</table>
|
| 285 |
</div>
|
| 286 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
</main>
|
| 288 |
</div>
|
| 289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
<script>
|
| 291 |
-
function
|
| 292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
const k = 1024;
|
| 294 |
-
const
|
|
|
|
| 295 |
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
| 296 |
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(
|
| 297 |
}
|
| 298 |
|
| 299 |
-
|
|
|
|
| 300 |
document.querySelectorAll('[data-bytes]').forEach(el => {
|
| 301 |
-
el.
|
| 302 |
});
|
| 303 |
-
});
|
| 304 |
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
|
|
|
|
|
|
| 311 |
</script>
|
| 312 |
-
{% endblock %}
|
|
|
|
| 3 |
{% block title %}Dashboard - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
+
<div class="min-h-screen">
|
| 7 |
+
<!-- Header with just status pill -->
|
| 8 |
+
<header class="theme-card shadow-lg mb-8">
|
| 9 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
|
| 10 |
+
<div class="flex items-center justify-between">
|
| 11 |
+
<div class="flex items-center space-x-4">
|
| 12 |
+
<h1 class="text-3xl font-bold text-primary">Dashboard</h1>
|
| 13 |
+
</div>
|
| 14 |
+
<button onclick="refreshSystemStats()"
|
| 15 |
+
class="flex items-center space-x-2 px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 text-white transition-all shadow-md active:scale-95 group focus:outline-none"
|
| 16 |
+
title="Refresh System Stats">
|
| 17 |
+
<svg id="refresh-icon" xmlns="http://www.w3.org/2000/svg"
|
| 18 |
+
class="w-5 h-5 group-hover:rotate-180 transition-transform duration-500" fill="none"
|
| 19 |
+
viewBox="0 0 24 24" stroke="currentColor">
|
| 20 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 21 |
+
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
|
| 22 |
+
</svg>
|
| 23 |
+
<span class="font-medium">Refresh Data</span>
|
| 24 |
+
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
</div>
|
| 27 |
</header>
|
| 28 |
|
| 29 |
+
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pb-12">
|
| 30 |
+
<!-- System Status Section -->
|
| 31 |
+
<div class="mb-8">
|
| 32 |
+
<div class="grid lg:grid-cols-2 gap-8">
|
| 33 |
+
<!-- System Status Card -->
|
| 34 |
+
<div class="theme-card rounded-xl p-8 shadow-xl">
|
| 35 |
+
<div class="flex items-center mb-6">
|
| 36 |
+
<div
|
| 37 |
+
class="w-12 h-12 theme-primary rounded-lg flex items-center justify-center mr-4 bg-opacity-20 text-primary">
|
| 38 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24"
|
| 39 |
+
stroke="white">
|
| 40 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 41 |
+
d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z">
|
| 42 |
+
</path>
|
| 43 |
+
</svg>
|
| 44 |
+
</div>
|
| 45 |
+
<h3 class="text-2xl font-semibold">System Status</h3>
|
| 46 |
</div>
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
<div class="space-y-4">
|
| 49 |
+
<div class="flex justify-between items-center py-3 px-4 bg-gray-50 rounded-lg">
|
| 50 |
+
<span class="font-medium theme-text-secondary">Uptime</span>
|
| 51 |
+
<span id="sys-uptime" class="text-primary font-semibold">{{ system_stats.uptime or 'N/A'
|
| 52 |
+
}}</span>
|
| 53 |
+
</div>
|
| 54 |
+
<div class="flex justify-between items-center py-3 px-4 bg-gray-50 rounded-lg">
|
| 55 |
+
<span class="font-medium theme-text-secondary">Telegram Bot</span>
|
| 56 |
+
<span id="sys-bot-name" class="text-primary font-semibold">{{ system_stats.telegram_bot or
|
| 57 |
+
'@StreamBot'
|
| 58 |
+
}}</span>
|
| 59 |
+
</div>
|
| 60 |
+
<div class="flex justify-between items-center py-3 px-4 bg-gray-50 rounded-lg">
|
| 61 |
+
<span class="font-medium theme-text-secondary">Connected Bots</span>
|
| 62 |
+
<span id="sys-bots-count" class="text-primary font-semibold">{{
|
| 63 |
+
system_stats.connected_bots|default(0) }}</span>
|
| 64 |
+
</div>
|
| 65 |
+
<div class="flex justify-between items-center py-3 px-4 bg-gray-50 rounded-lg">
|
| 66 |
+
<span class="font-medium theme-text-secondary">Backend Version</span>
|
| 67 |
+
<span id="sys-version" class="text-primary font-semibold">v{{ system_stats.version or
|
| 68 |
+
'1.0.0' }}</span>
|
| 69 |
+
</div>
|
| 70 |
</div>
|
| 71 |
</div>
|
|
|
|
| 72 |
|
| 73 |
+
<!-- Bot Workload Section -->
|
| 74 |
+
<!-- Live Streaming Status Card -->
|
| 75 |
+
<div class="streams-container">
|
| 76 |
+
<div class="theme-card rounded-xl p-8 shadow-xl">
|
| 77 |
+
<div class="flex items-center mb-6">
|
| 78 |
+
<div
|
| 79 |
+
class="w-12 h-12 theme-primary rounded-lg flex items-center justify-center mr-4 bg-opacity-20 text-primary">
|
| 80 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24"
|
| 81 |
+
stroke="white">
|
| 82 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 83 |
+
d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z">
|
| 84 |
+
</path>
|
| 85 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 86 |
+
d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
| 87 |
+
</svg>
|
| 88 |
+
</div>
|
| 89 |
+
<div class="flex-1">
|
| 90 |
+
<h3 class="text-2xl font-semibold">Live Streaming Status</h3>
|
| 91 |
+
</div>
|
| 92 |
+
<span class="px-3 py-1 bg-red-500 text-white rounded-full text-sm font-semibold">
|
| 93 |
+
{{ system_stats.total_active_streams }} Active
|
| 94 |
+
</span>
|
| 95 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
+
<div class="space-y-4">
|
| 98 |
+
{% if system_stats.active_streams and system_stats.active_streams|length > 0 %}
|
| 99 |
+
{% for stream in system_stats.active_streams %}
|
| 100 |
+
<div
|
| 101 |
+
class="p-4 bg-gray-50 rounded-lg border-l-4 {% if stream.status == 'active' %}border-green-500{% elif stream.status == 'cancelled' %}border-yellow-500{% else %}border-red-500{% endif %}">
|
| 102 |
+
<div class="flex justify-between items-start mb-3">
|
| 103 |
+
<div class="flex items-center gap-2 max-w-[70%]">
|
| 104 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4 text-primary shrink-0"
|
| 105 |
+
fill="currentColor" viewBox="0 0 24 24">
|
| 106 |
+
<path d="M8 5v14l11-7z" />
|
| 107 |
+
</svg>
|
| 108 |
+
<div class="truncate">
|
| 109 |
+
<span class="font-semibold"
|
| 110 |
+
title="{{ stream.meta.get('title') or stream.stream_id }}">{{
|
| 111 |
+
stream.meta.get('title') or
|
| 112 |
+
'Unknown Stream' }}</span>
|
| 113 |
+
<div class="text-[10px] text-gray-500 font-mono mt-0.5"
|
| 114 |
+
title="{{ stream.stream_id }}">
|
| 115 |
+
ID: {{ stream.stream_id[:8] }}...
|
| 116 |
+
</div>
|
| 117 |
+
</div>
|
| 118 |
+
</div>
|
| 119 |
+
<span
|
| 120 |
+
class="px-2 py-1 rounded text-xs font-semibold shrink-0 {% if stream.status == 'active' %}bg-green-100 text-green-800{% elif stream.status == 'cancelled' %}bg-yellow-100 text-yellow-800{% else %}bg-red-100 text-red-800{% endif %}">
|
| 121 |
+
{{ stream.status|upper }}
|
| 122 |
+
</span>
|
| 123 |
</div>
|
| 124 |
+
|
| 125 |
+
<div class="grid grid-cols-2 gap-3 mb-3">
|
| 126 |
+
<div class="flex justify-between py-2 px-3 bg-white rounded">
|
| 127 |
+
<span class="text-sm theme-text-secondary">Bot:</span>
|
| 128 |
+
<span class="text-sm font-semibold">Bot{{ stream.client_index + 1 }} </span>
|
| 129 |
+
</div>
|
| 130 |
+
<div class="flex justify-between py-2 px-3 bg-white rounded">
|
| 131 |
+
<span class="text-sm theme-text-secondary">File:</span>
|
| 132 |
+
<span class="text-sm font-semibold">DC{{ stream.dc_id }}</span>
|
| 133 |
+
</div>
|
| 134 |
+
<div class="flex justify-between py-2 px-3 bg-white rounded col-span-2">
|
| 135 |
+
<span class="text-sm theme-text-secondary">Duration:</span>
|
| 136 |
+
<span class="text-sm font-semibold">{{ stream.duration }}s</span>
|
| 137 |
+
</div>
|
| 138 |
+
|
| 139 |
+
<div class="flex justify-between py-2 px-3 bg-white rounded col-span-2">
|
| 140 |
+
<span class="text-sm theme-text-secondary">Data Transferred:</span>
|
| 141 |
+
<span class="text-sm font-semibold">{{ "%.2f"|format(stream.total_bytes / 1024 /
|
| 142 |
+
1024) }} MB</span>
|
| 143 |
+
</div>
|
| 144 |
</div>
|
| 145 |
+
|
| 146 |
+
<div class="grid grid-cols-3 gap-3">
|
| 147 |
+
<div class="text-center py-3 bg-white rounded">
|
| 148 |
+
<div class="text-xs theme-text-secondary mb-1">Instant</div>
|
| 149 |
+
<div class="text-sm font-bold text-primary">{{ stream.instant_mbps }} MB/s</div>
|
| 150 |
+
</div>
|
| 151 |
+
<div class="text-center py-3 bg-white rounded">
|
| 152 |
+
<div class="text-xs theme-text-secondary mb-1">Average</div>
|
| 153 |
+
<div class="text-sm font-bold text-primary">{{ stream.avg_mbps }} MB/s</div>
|
| 154 |
+
</div>
|
| 155 |
+
<div class="text-center py-3 bg-white rounded">
|
| 156 |
+
<div class="text-xs theme-text-secondary mb-1">Peak</div>
|
| 157 |
+
<div class="text-sm font-bold text-primary">{{ stream.peak_mbps }} MB/s</div>
|
| 158 |
+
</div>
|
| 159 |
</div>
|
| 160 |
+
|
| 161 |
+
{% if stream.meta and (stream.meta.client_host or stream.meta.user_name) %}
|
| 162 |
+
<div class="mt-3 pt-3 border-t border-gray-200">
|
| 163 |
+
<div class="flex flex-col gap-1">
|
| 164 |
+
{% if stream.meta.client_host %}
|
| 165 |
+
<div class="flex justify-between items-center text-sm">
|
| 166 |
+
<div class="flex items-center gap-2">
|
| 167 |
+
<svg xmlns="http://www.w3.org/2000/svg"
|
| 168 |
+
class="w-4 h-4 theme-text-secondary" fill="none" viewBox="0 0 24 24"
|
| 169 |
+
stroke="currentColor">
|
| 170 |
+
<path stroke-linecap="round" stroke-linejoin="round"
|
| 171 |
+
stroke-width="2"
|
| 172 |
+
d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9">
|
| 173 |
+
</path>
|
| 174 |
+
</svg>
|
| 175 |
+
<span class="theme-text-secondary">Client IPv4:</span>
|
| 176 |
+
</div>
|
| 177 |
+
<span class="font-mono text-xs">{{ stream.meta.client_host }}</span>
|
| 178 |
+
</div>
|
| 179 |
+
{% endif %}
|
| 180 |
+
{% if stream.meta.user_name %}
|
| 181 |
+
<div class="flex justify-between items-center text-sm">
|
| 182 |
+
<div class="flex items-center gap-2">
|
| 183 |
+
<svg xmlns="http://www.w3.org/2000/svg"
|
| 184 |
+
class="w-4 h-4 theme-text-secondary" fill="none" viewBox="0 0 24 24"
|
| 185 |
+
stroke="currentColor">
|
| 186 |
+
<path stroke-linecap="round" stroke-linejoin="round"
|
| 187 |
+
stroke-width="2"
|
| 188 |
+
d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z">
|
| 189 |
+
</path>
|
| 190 |
+
</svg>
|
| 191 |
+
<span class="theme-text-secondary">User:</span>
|
| 192 |
+
</div>
|
| 193 |
+
<span class="font-mono text-xs font-semibold">{{ stream.meta.user_name
|
| 194 |
+
}}</span>
|
| 195 |
+
</div>
|
| 196 |
+
{% endif %}
|
| 197 |
+
</div>
|
| 198 |
</div>
|
| 199 |
+
{% endif %}
|
| 200 |
</div>
|
| 201 |
+
{% endfor %}
|
| 202 |
+
{% else %}
|
| 203 |
+
<div class="text-center py-12">
|
| 204 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="w-16 h-16 mx-auto mb-4 text-gray-300"
|
| 205 |
+
fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 206 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 207 |
+
d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z">
|
| 208 |
+
</path>
|
| 209 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 210 |
+
d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
| 211 |
+
</svg>
|
| 212 |
+
<p class="text-gray-500 font-medium mb-1">No active streams</p>
|
| 213 |
+
<p class="text-gray-400 text-sm">Streams will appear here when users start watching
|
| 214 |
+
content</p>
|
| 215 |
+
</div>
|
| 216 |
+
{% endif %}
|
| 217 |
</div>
|
| 218 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
</div>
|
| 220 |
</div>
|
| 221 |
</div>
|
| 222 |
|
| 223 |
+
<!-- Database Statistics Section -->
|
| 224 |
+
<div class="mb-8 mt-4">
|
| 225 |
+
<h2 class="text-2xl font-bold mb-6 text-center">Database and Commands</h2>
|
| 226 |
+
<div class="grid lg:grid-cols-2 gap-6">
|
| 227 |
+
{% if system_stats.databases %}
|
| 228 |
{% for db_stat in system_stats.databases %}
|
| 229 |
+
<div class="theme-card rounded-xl p-8 shadow-xl w-full flex flex-col h-full">
|
| 230 |
+
<div class="flex items-center justify-between mb-6">
|
| 231 |
+
<h3 class="text-xl font-semibold">{{ db_stat.db_name.replace("storage_", "Database ") }}</h3>
|
| 232 |
+
<div
|
| 233 |
+
class="w-12 h-12 theme-primary rounded-lg flex items-center justify-center bg-opacity-20 text-primary">
|
| 234 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24"
|
| 235 |
+
stroke="white">
|
| 236 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 237 |
+
d="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4">
|
| 238 |
+
</path>
|
| 239 |
</svg>
|
| 240 |
</div>
|
| 241 |
</div>
|
| 242 |
+
|
| 243 |
+
<div class="space-y-4 flex-grow">
|
| 244 |
+
<div class="flex justify-between items-center py-3 px-4 bg-gray-50 rounded-lg">
|
| 245 |
+
<span class="font-medium theme-text-secondary">Movies</span>
|
| 246 |
+
<span id="db-movies-{{ loop.index0 }}" class="text-primary font-semibold">{{
|
| 247 |
+
"{:,}".format(db_stat.movie_count) }}</span>
|
|
|
|
|
|
|
| 248 |
</div>
|
| 249 |
+
<div class="flex justify-between items-center py-3 px-4 bg-gray-50 rounded-lg">
|
| 250 |
+
<span class="font-medium theme-text-secondary">TV Shows</span>
|
| 251 |
+
<span id="db-tv-{{ loop.index0 }}" class="text-primary font-semibold">{{
|
| 252 |
+
"{:,}".format(db_stat.tv_count) }}</span>
|
|
|
|
| 253 |
</div>
|
| 254 |
+
|
| 255 |
+
<div class="py-3 px-4 bg-gray-50 rounded-lg">
|
| 256 |
+
<div class="flex justify-between items-center mb-2">
|
| 257 |
+
<span class="font-medium theme-text-secondary">Storage Used</span>
|
| 258 |
+
<span id="db-storage-{{ loop.index0 }}" class="text-primary font-semibold text-sm">{{
|
| 259 |
+
"%.1f"|format(db_stat.storageSize /
|
| 260 |
+
1024 / 1024) }} MB</span>
|
| 261 |
+
</div>
|
| 262 |
+
{% set storage_percent = (db_stat.storageSize / (500 * 1024 * 1024) * 100) | round %}
|
| 263 |
+
<div class="w-full bg-gray-200 rounded-full h-2.5">
|
| 264 |
+
<div class="theme-primary h-2.5 rounded-full" style="width: {{ storage_percent }}%">
|
| 265 |
+
</div>
|
| 266 |
+
</div>
|
| 267 |
</div>
|
| 268 |
</div>
|
| 269 |
</div>
|
| 270 |
{% endfor %}
|
| 271 |
+
{% else %}
|
| 272 |
+
<div class="col-span-full text-center theme-text-secondary py-8">No database statistics available</div>
|
| 273 |
+
{% endif %} <!-- Add this closing tag -->
|
| 274 |
+
</div>
|
| 275 |
</div>
|
| 276 |
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
<!-- Media Management Section -->
|
| 280 |
+
<div class="mb-8">
|
| 281 |
+
<div class="grid lg:grid-cols-2 gap-6">
|
| 282 |
+
<a href="/media/manage?media_type=movie"
|
| 283 |
+
class="block theme-card rounded-xl p-8 shadow-xl hover:shadow-2xl transition-all group w-full">
|
| 284 |
+
<div class="flex items-center">
|
| 285 |
+
<div
|
| 286 |
+
class="w-16 h-16 theme-primary rounded-lg flex items-center justify-center mr-6 group-hover:scale-110 transition-transform bg-opacity-20 text-primary">
|
| 287 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="w-8 h-8" fill="none" viewBox="0 0 24 24"
|
| 288 |
+
stroke="white">
|
| 289 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 290 |
+
d="M7 4V2a1 1 0 011-1h8a1 1 0 011 1v2h4a1 1 0 110 2h-1v12a2 2 0 01-2-2V6H3a1 1 0 110-2h4zM9 6v10h6V6H9z">
|
| 291 |
+
</path>
|
| 292 |
+
</svg>
|
| 293 |
+
</div>
|
| 294 |
+
<div>
|
| 295 |
+
<h3 class="text-xl font-semibold mb-2">Manage Movies</h3>
|
| 296 |
+
<p class="theme-text-secondary">Edit and organize movie collections</p>
|
| 297 |
+
<div class="mt-2 text-primary font-semibold text-sm">{{ system_stats.movies|default(0) }}
|
| 298 |
+
movies</div>
|
| 299 |
+
</div>
|
| 300 |
+
</div>
|
| 301 |
+
</a>
|
| 302 |
+
|
| 303 |
+
<a href="/media/manage?media_type=tv"
|
| 304 |
+
class="block theme-card rounded-xl p-8 shadow-xl hover:shadow-2xl transition-all group w-full">
|
| 305 |
+
<div class="flex items-center">
|
| 306 |
+
<div
|
| 307 |
+
class="w-16 h-16 theme-primary rounded-lg flex items-center justify-center mr-6 group-hover:scale-110 transition-transform bg-opacity-20 text-primary">
|
| 308 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="w-8 h-8" fill="none" viewBox="0 0 24 24"
|
| 309 |
+
stroke="white">
|
| 310 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 311 |
+
d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z">
|
| 312 |
+
</path>
|
| 313 |
+
</svg>
|
| 314 |
+
</div>
|
| 315 |
+
<div>
|
| 316 |
+
<h3 class="text-xl font-semibold mb-2">Manage TV Shows</h3>
|
| 317 |
+
<p class="theme-text-secondary">Edit and organize TV series</p>
|
| 318 |
+
<div class="mt-2 text-primary font-semibold text-sm">{{ system_stats.tv_shows|default(0) }}
|
| 319 |
+
shows</div>
|
| 320 |
+
</div>
|
| 321 |
+
</div>
|
| 322 |
+
</a>
|
| 323 |
+
</div>
|
| 324 |
</div>
|
| 325 |
|
| 326 |
+
<!-- Access Management Section -->
|
| 327 |
+
<div class="theme-card rounded-xl p-8 shadow-xl mb-8">
|
| 328 |
+
<div class="text-center mb-8">
|
| 329 |
+
<div
|
| 330 |
+
class="w-16 h-16 theme-primary rounded-full flex items-center justify-center mx-auto mb-4 bg-opacity-20 text-primary">
|
| 331 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="w-8 h-8" fill="none" viewBox="0 0 24 24"
|
| 332 |
+
stroke="white">
|
| 333 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 334 |
+
d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11.536 16.464l-4.786 1.768a3 3 0 01-3.951-3.951l1.768-4.786L14.464 11.536A6 6 0 0121 9z">
|
| 335 |
+
</path>
|
| 336 |
+
</svg>
|
| 337 |
</div>
|
| 338 |
+
<h3 class="text-2xl font-bold mb-2">Access Management</h3>
|
| 339 |
+
<p class="theme-text-secondary">Manage API tokens for Stremio addon access</p>
|
|
|
|
|
|
|
| 340 |
</div>
|
| 341 |
|
| 342 |
+
<!-- Create Token Form -->
|
| 343 |
+
<div class="mb-8">
|
| 344 |
+
<div id="create-btn-container">
|
| 345 |
+
<button onclick="toggleCreateForm()"
|
| 346 |
+
class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-lg font-semibold transition-colors duration-200 flex items-center shadow-md">
|
| 347 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 mr-2" fill="none" viewBox="0 0 24 24"
|
| 348 |
+
stroke="currentColor">
|
| 349 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 350 |
+
d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
|
| 351 |
+
</svg>
|
| 352 |
+
New Token
|
| 353 |
+
</button>
|
| 354 |
+
</div>
|
| 355 |
+
|
| 356 |
+
<div id="create-form-container"
|
| 357 |
+
class="hidden mt-4 bg-gray-50 p-6 rounded-xl border border-gray-200 transition-all duration-300">
|
| 358 |
+
<form onsubmit="createToken(event)" class="flex flex-col md:flex-row gap-4 items-end">
|
| 359 |
+
<div class="flex-1 w-full">
|
| 360 |
+
<label class="block text-sm font-medium theme-text-secondary mb-1">Token Name</label>
|
| 361 |
+
<input type="text" id="token-name" placeholder="E.g., Family iPad" required
|
| 362 |
+
class="w-full theme-card border border-gray-300 rounded-lg px-4 py-3 focus:outline-none focus:border-primary">
|
| 363 |
</div>
|
| 364 |
+
|
| 365 |
+
<div class="w-full md:w-32">
|
| 366 |
+
<label class="block text-sm font-medium theme-text-secondary mb-1">Daily Limit</label>
|
| 367 |
+
<div class="relative">
|
| 368 |
+
<input type="number" id="daily-limit" placeholder="0" step="0.1" min="0"
|
| 369 |
+
class="w-full theme-card border border-gray-300 rounded-lg pl-4 pr-12 py-3 focus:outline-none focus:border-primary">
|
| 370 |
+
<span class="absolute right-4 top-3 text-gray-400 text-sm pointer-events-none">GB</span>
|
| 371 |
+
</div>
|
| 372 |
+
</div>
|
| 373 |
+
|
| 374 |
+
<div class="w-full md:w-32">
|
| 375 |
+
<label class="block text-sm font-medium theme-text-secondary mb-1">Monthly Limit</label>
|
| 376 |
+
<div class="relative">
|
| 377 |
+
<input type="number" id="monthly-limit" placeholder="0" step="0.1" min="0"
|
| 378 |
+
class="w-full theme-card border border-gray-300 rounded-lg pl-4 pr-12 py-3 focus:outline-none focus:border-primary">
|
| 379 |
+
<span class="absolute right-4 top-3 text-gray-400 text-sm pointer-events-none">GB</span>
|
| 380 |
+
</div>
|
| 381 |
+
</div>
|
| 382 |
+
|
| 383 |
+
<div class="flex gap-2 w-full md:w-auto">
|
| 384 |
+
<button type="button" onclick="toggleCreateForm()"
|
| 385 |
+
class="w-full md:w-auto bg-gray-200 text-gray-700 px-6 py-3 rounded-lg font-semibold hover:bg-gray-300 transition-colors duration-200">
|
| 386 |
+
Cancel
|
| 387 |
+
</button>
|
| 388 |
+
<button type="submit"
|
| 389 |
+
class="w-full md:w-auto bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-lg font-semibold transition-colors duration-200 flex items-center justify-center">
|
| 390 |
+
Create
|
| 391 |
+
</button>
|
| 392 |
+
</div>
|
| 393 |
+
</form>
|
| 394 |
+
</div>
|
| 395 |
</div>
|
| 396 |
|
| 397 |
+
<!-- Token List -->
|
| 398 |
<div class="overflow-x-auto">
|
| 399 |
+
<table class="w-full text-left border-collapse">
|
| 400 |
<thead>
|
| 401 |
+
<tr class="border-b border-gray-200">
|
| 402 |
+
<th class="py-4 px-4 font-semibold theme-text-secondary">Name</th>
|
| 403 |
+
<th class="py-4 px-4 font-semibold theme-text-secondary">Usage (Today / Month)</th>
|
| 404 |
+
<th class="py-4 px-4 font-semibold theme-text-secondary">Limits (GB)</th>
|
| 405 |
+
<th class="py-4 px-4 font-semibold theme-text-secondary">Manifest URL</th>
|
| 406 |
+
<th class="py-4 px-4 font-semibold theme-text-secondary text-right">Actions</th>
|
| 407 |
</tr>
|
| 408 |
</thead>
|
| 409 |
+
<tbody>
|
| 410 |
{% for token in api_tokens %}
|
| 411 |
+
<tr class="border-b border-gray-100 hover:bg-gray-50 transition-colors">
|
| 412 |
+
<td class="py-4 px-4 font-medium">
|
| 413 |
+
{{ token.name }}<br>
|
| 414 |
+
<span class="text-xs theme-text-secondary">{{ token.created_at.strftime('%Y-%m-%d')
|
| 415 |
+
}}</span>
|
| 416 |
</td>
|
| 417 |
+
<td class="py-4 px-4 text-sm">
|
| 418 |
+
<span class="block">Today: <span class="font-semibold text-primary"
|
| 419 |
+
data-bytes="{{ token.usage.daily.bytes|default(0) }}"></span></span>
|
| 420 |
+
<span class="block text-gray-500">Month: <span
|
| 421 |
+
data-bytes="{{ token.usage.monthly.bytes|default(0) }}"></span></span>
|
| 422 |
</td>
|
| 423 |
+
<td class="py-4 px-4 text-sm">
|
| 424 |
+
<div class="text-gray-600">
|
| 425 |
+
<div class="flex items-center gap-1">
|
| 426 |
+
<span class="w-4 text-gray-400">D:</span>
|
| 427 |
+
{% if token.limits.daily_limit_gb %}
|
| 428 |
+
<span
|
| 429 |
+
data-bytes="{{ (token.limits.daily_limit_gb * 1024 * 1024 * 1024)|int }}"></span>
|
| 430 |
+
{% else %}
|
| 431 |
+
<span>∞</span>
|
| 432 |
+
{% endif %}
|
| 433 |
+
</div>
|
| 434 |
+
<div class="flex items-center gap-1">
|
| 435 |
+
<span class="w-4 text-gray-400">M:</span>
|
| 436 |
+
{% if token.limits.monthly_limit_gb %}
|
| 437 |
+
<span
|
| 438 |
+
data-bytes="{{ (token.limits.monthly_limit_gb * 1024 * 1024 * 1024)|int }}"></span>
|
| 439 |
+
{% else %}
|
| 440 |
+
<span>∞</span>
|
| 441 |
+
{% endif %}
|
| 442 |
+
</div>
|
| 443 |
+
</div>
|
| 444 |
</td>
|
| 445 |
+
<td class="py-4 px-4">
|
| 446 |
+
<div class="flex flex-col items-start space-y-1">
|
| 447 |
+
<code
|
| 448 |
+
class="text-xs bg-gray-100 text-gray-600 px-2 py-1 rounded select-all border border-gray-200">
|
| 449 |
+
API={{ token.token[:3] }}.......{{ token.token[-3:] }}
|
| 450 |
</code>
|
| 451 |
+
<button
|
| 452 |
+
onclick="copyUrl('{{ (request.base_url|string).replace('http:', 'https:') }}stremio/{{ token.token }}/manifest.json')"
|
| 453 |
+
class="text-primary hover:text-opacity-80 flex items-center space-x-1 text-sm font-medium"
|
| 454 |
+
title="Copy URL">
|
| 455 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none"
|
| 456 |
+
viewBox="0 0 24 24" stroke="currentColor">
|
| 457 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 458 |
+
d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" />
|
| 459 |
+
</svg>
|
| 460 |
+
<span class="underline">Copy Link</span>
|
| 461 |
</button>
|
| 462 |
</div>
|
| 463 |
</td>
|
| 464 |
+
<td class="py-4 px-4 text-right">
|
| 465 |
+
<button
|
| 466 |
+
onclick="openEditModal('{{ token.token }}', '{{ token.limits.daily_limit_gb|default(0) }}', '{{ token.limits.monthly_limit_gb|default(0) }}')"
|
| 467 |
+
class="text-blue-500 hover:text-blue-700 font-medium text-sm px-3 py-1 mr-2 rounded border border-blue-200 hover:bg-blue-50 transition-colors">
|
| 468 |
+
Edit
|
| 469 |
+
</button>
|
| 470 |
+
<button onclick="revokeToken('{{ token.token }}')"
|
| 471 |
+
class="text-red-500 hover:text-red-700 font-medium text-sm px-3 py-1 rounded border border-red-200 hover:bg-red-50 transition-colors">
|
| 472 |
+
Revoke
|
| 473 |
</button>
|
| 474 |
</td>
|
| 475 |
</tr>
|
| 476 |
+
{% else %}
|
| 477 |
+
<tr>
|
| 478 |
+
<td colspan="5" class="py-8 text-center theme-text-secondary">No tokens found. Create one to
|
| 479 |
+
get started.</td>
|
| 480 |
+
</tr>
|
| 481 |
{% endfor %}
|
| 482 |
</tbody>
|
| 483 |
</table>
|
| 484 |
</div>
|
| 485 |
</div>
|
| 486 |
+
|
| 487 |
+
<!-- Edit Limit Modal -->
|
| 488 |
+
<div id="edit-modal" class="fixed inset-0 bg-black bg-opacity-50 hidden flex items-center justify-center z-50">
|
| 489 |
+
<div class="bg-white rounded-lg p-6 w-full max-w-md shadow-xl transform transition-all">
|
| 490 |
+
<h3 class="text-lg font-bold mb-4 theme-text-primary">Edit Token Limits</h3>
|
| 491 |
+
<input type="hidden" id="edit-token-id">
|
| 492 |
+
|
| 493 |
+
<div class="space-y-4">
|
| 494 |
+
<div>
|
| 495 |
+
<label class="block text-sm font-medium theme-text-secondary mb-1">Daily Limit (GB)</label>
|
| 496 |
+
<input type="number" id="edit-daily" placeholder="0 for unlimited" step="0.1" min="0"
|
| 497 |
+
class="w-full theme-card border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:border-primary">
|
| 498 |
+
</div>
|
| 499 |
+
<div>
|
| 500 |
+
<label class="block text-sm font-medium theme-text-secondary mb-1">Monthly Limit (GB)</label>
|
| 501 |
+
<input type="number" id="edit-monthly" placeholder="0 for unlimited" step="0.1" min="0"
|
| 502 |
+
class="w-full theme-card border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:border-primary">
|
| 503 |
+
</div>
|
| 504 |
+
</div>
|
| 505 |
+
|
| 506 |
+
<div class="mt-6 flex justify-end space-x-3">
|
| 507 |
+
<button onclick="closeEditModal()"
|
| 508 |
+
class="px-4 py-2 text-gray-600 hover:bg-gray-100 rounded-lg transition-colors">Cancel</button>
|
| 509 |
+
<button onclick="saveTokenLimits()"
|
| 510 |
+
class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors">Save
|
| 511 |
+
Changes</button>
|
| 512 |
+
</div>
|
| 513 |
+
</div>
|
| 514 |
+
</div>
|
| 515 |
+
|
| 516 |
+
|
| 517 |
</main>
|
| 518 |
</div>
|
| 519 |
|
| 520 |
+
<!-- JS for Workload Updates -->
|
| 521 |
+
<script>
|
| 522 |
+
function toggleCreateForm() {
|
| 523 |
+
const formContainer = document.getElementById('create-form-container');
|
| 524 |
+
const btnContainer = document.getElementById('create-btn-container');
|
| 525 |
+
|
| 526 |
+
if (formContainer.classList.contains('hidden')) {
|
| 527 |
+
formContainer.classList.remove('hidden');
|
| 528 |
+
btnContainer.classList.add('hidden');
|
| 529 |
+
} else {
|
| 530 |
+
formContainer.classList.add('hidden');
|
| 531 |
+
btnContainer.classList.remove('hidden');
|
| 532 |
+
}
|
| 533 |
+
}
|
| 534 |
+
|
| 535 |
+
let currentEditToken = null;
|
| 536 |
+
|
| 537 |
+
function openEditModal(token, daily, monthly) {
|
| 538 |
+
currentEditToken = token;
|
| 539 |
+
document.getElementById('edit-token-id').value = token;
|
| 540 |
+
document.getElementById('edit-daily').value = daily == 'None' ? 0 : daily;
|
| 541 |
+
document.getElementById('edit-monthly').value = monthly == 'None' ? 0 : monthly;
|
| 542 |
+
|
| 543 |
+
document.getElementById('edit-modal').classList.remove('hidden');
|
| 544 |
+
}
|
| 545 |
+
|
| 546 |
+
function closeEditModal() {
|
| 547 |
+
document.getElementById('edit-modal').classList.add('hidden');
|
| 548 |
+
currentEditToken = null;
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
+
async function saveTokenLimits() {
|
| 552 |
+
if (!currentEditToken) return;
|
| 553 |
+
|
| 554 |
+
const daily = document.getElementById('edit-daily').value;
|
| 555 |
+
const monthly = document.getElementById('edit-monthly').value;
|
| 556 |
+
|
| 557 |
+
try {
|
| 558 |
+
const response = await fetch('/api/tokens/' + currentEditToken, {
|
| 559 |
+
method: 'PUT',
|
| 560 |
+
headers: { 'Content-Type': 'application/json' },
|
| 561 |
+
body: JSON.stringify({
|
| 562 |
+
daily_limit_gb: daily,
|
| 563 |
+
monthly_limit_gb: monthly
|
| 564 |
+
})
|
| 565 |
+
});
|
| 566 |
+
|
| 567 |
+
if (response.ok) {
|
| 568 |
+
closeEditModal();
|
| 569 |
+
// Refresh page to show new limits (or update DOM dynamically if we want)
|
| 570 |
+
window.location.reload();
|
| 571 |
+
} else {
|
| 572 |
+
alert("Failed to update limits");
|
| 573 |
+
}
|
| 574 |
+
} catch (error) {
|
| 575 |
+
console.error(error);
|
| 576 |
+
alert("Error updating limits");
|
| 577 |
+
}
|
| 578 |
+
}
|
| 579 |
+
</script>
|
| 580 |
+
|
| 581 |
+
<!-- System Stats Auto-Refresh -->
|
| 582 |
+
<script>
|
| 583 |
+
async function refreshSystemStats() {
|
| 584 |
+
const icon = document.getElementById('refresh-icon');
|
| 585 |
+
if (icon) icon.classList.add('animate-spin'); // Add tailwind spin class
|
| 586 |
+
|
| 587 |
+
try {
|
| 588 |
+
const response = await fetch('/api/system/stats');
|
| 589 |
+
if (response.ok) {
|
| 590 |
+
const stats = await response.json();
|
| 591 |
+
|
| 592 |
+
// Update Static Elements
|
| 593 |
+
const elUptime = document.getElementById('sys-uptime');
|
| 594 |
+
if (elUptime) elUptime.innerText = stats.uptime;
|
| 595 |
+
|
| 596 |
+
const elBotName = document.getElementById('sys-bot-name');
|
| 597 |
+
if (elBotName) elBotName.innerText = stats.telegram_bot;
|
| 598 |
+
|
| 599 |
+
const elBotCount = document.getElementById('sys-bots-count');
|
| 600 |
+
if (elBotCount) elBotCount.innerText = stats.connected_bots;
|
| 601 |
+
|
| 602 |
+
const elVersion = document.getElementById('sys-version');
|
| 603 |
+
if (elVersion) elVersion.innerText = 'v' + stats.version;
|
| 604 |
+
|
| 605 |
+
// Update Database Stats
|
| 606 |
+
if (stats.databases && Array.isArray(stats.databases)) {
|
| 607 |
+
stats.databases.forEach((db, index) => {
|
| 608 |
+
const elMovies = document.getElementById(`db-movies-${index}`);
|
| 609 |
+
if (elMovies) elMovies.innerText = db.movie_count.toLocaleString();
|
| 610 |
+
|
| 611 |
+
const elTv = document.getElementById(`db-tv-${index}`);
|
| 612 |
+
if (elTv) elTv.innerText = db.tv_count.toLocaleString();
|
| 613 |
+
|
| 614 |
+
const elStorage = document.getElementById(`db-storage-${index}`);
|
| 615 |
+
if (elStorage) {
|
| 616 |
+
const mb = db.storageSize / (1024 * 1024);
|
| 617 |
+
elStorage.innerText = mb.toFixed(1) + ' MB';
|
| 618 |
+
}
|
| 619 |
+
});
|
| 620 |
+
}
|
| 621 |
+
|
| 622 |
+
// Update API Token Usage Data
|
| 623 |
+
if (stats.api_tokens && Array.isArray(stats.api_tokens)) {
|
| 624 |
+
stats.api_tokens.forEach((token, index) => {
|
| 625 |
+
// Find all elements with data-bytes attributes for this token
|
| 626 |
+
const tokenRows = document.querySelectorAll('tbody tr');
|
| 627 |
+
|
| 628 |
+
// Get the token's row (skip the "No tokens found" row)
|
| 629 |
+
if (tokenRows.length > index && !tokenRows[index].querySelector('[colspan]')) {
|
| 630 |
+
const row = tokenRows[index];
|
| 631 |
+
|
| 632 |
+
// Update daily usage
|
| 633 |
+
const dailyUsageSpan = row.querySelector('td:nth-child(2) span.font-semibold');
|
| 634 |
+
if (dailyUsageSpan && token.usage && token.usage.daily) {
|
| 635 |
+
const dailyBytes = token.usage.daily.bytes || 0;
|
| 636 |
+
dailyUsageSpan.setAttribute('data-bytes', dailyBytes);
|
| 637 |
+
dailyUsageSpan.textContent = formatBytes(dailyBytes);
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
// Update monthly usage
|
| 641 |
+
const monthlyUsageSpan = row.querySelector('td:nth-child(2) span.text-gray-500 span');
|
| 642 |
+
if (monthlyUsageSpan && token.usage && token.usage.monthly) {
|
| 643 |
+
const monthlyBytes = token.usage.monthly.bytes || 0;
|
| 644 |
+
monthlyUsageSpan.setAttribute('data-bytes', monthlyBytes);
|
| 645 |
+
monthlyUsageSpan.textContent = formatBytes(monthlyBytes);
|
| 646 |
+
}
|
| 647 |
+
}
|
| 648 |
+
});
|
| 649 |
+
}
|
| 650 |
+
|
| 651 |
+
// Update Bot Workloads
|
| 652 |
+
await updateBotWorkloads();
|
| 653 |
+
|
| 654 |
+
// Update Active Streams
|
| 655 |
+
await updateActiveStreams();
|
| 656 |
+
}
|
| 657 |
+
} catch (error) {
|
| 658 |
+
console.error("Failed to refresh system stats:", error);
|
| 659 |
+
} finally {
|
| 660 |
+
// Remove spin after short delay to make it visible
|
| 661 |
+
setTimeout(() => {
|
| 662 |
+
if (icon) icon.classList.remove('animate-spin');
|
| 663 |
+
}, 500);
|
| 664 |
+
}
|
| 665 |
+
}
|
| 666 |
+
|
| 667 |
+
async function updateActiveStreams() {
|
| 668 |
+
try {
|
| 669 |
+
const response = await fetch('/stream/stats');
|
| 670 |
+
if (response.ok) {
|
| 671 |
+
const data = await response.json();
|
| 672 |
+
const allStreams = data.active_streams || [];
|
| 673 |
+
const container = document.getElementById('active-streams-container');
|
| 674 |
+
// Only show streams that are actively sending data
|
| 675 |
+
const liveStreams = allStreams.filter(s => s.status === 'active' && (s.total_bytes || 0) > 0);
|
| 676 |
+
|
| 677 |
+
if (liveStreams.length === 0) {
|
| 678 |
+
container.innerHTML = `<div class="p-8 text-center bg-gray-50 border border-dashed rounded-lg">
|
| 679 |
+
<i class="fas fa-video-slash text-gray-300 text-3xl mb-3"></i>
|
| 680 |
+
<p class="text-gray-500 font-medium">No active streams at the moment</p>
|
| 681 |
+
<p class="text-xs text-gray-400 mt-1">Users are not currently watching any media.</p>
|
| 682 |
+
</div>`;
|
| 683 |
+
} else {
|
| 684 |
+
const escapeHtml = (unsafe) => {
|
| 685 |
+
if (!unsafe) return '';
|
| 686 |
+
return unsafe
|
| 687 |
+
.toString()
|
| 688 |
+
.replace(/&/g, "&")
|
| 689 |
+
.replace(/</g, "<")
|
| 690 |
+
.replace(/>/g, ">")
|
| 691 |
+
.replace(/"/g, """)
|
| 692 |
+
.replace(/'/g, "'");
|
| 693 |
+
};
|
| 694 |
+
|
| 695 |
+
const formatBytesStr = (bytes) => {
|
| 696 |
+
if (bytes === 0) return '0 B';
|
| 697 |
+
const k = 1024;
|
| 698 |
+
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
| 699 |
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
| 700 |
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
| 701 |
+
};
|
| 702 |
+
|
| 703 |
+
container.innerHTML = liveStreams.map(stream => {
|
| 704 |
+
let statusColor = 'bg-red-100 text-red-800';
|
| 705 |
+
let statusPulse = 'hidden';
|
| 706 |
+
if (stream.status === 'active') {
|
| 707 |
+
statusColor = 'bg-green-100 text-green-800';
|
| 708 |
+
statusPulse = '';
|
| 709 |
+
} else if (stream.status === 'cancelled') {
|
| 710 |
+
statusColor = 'bg-yellow-100 text-yellow-800';
|
| 711 |
+
}
|
| 712 |
+
|
| 713 |
+
const streamIdStr = stream.stream_id ? stream.stream_id.substring(0, 8) + '...' : 'Unknown';
|
| 714 |
+
const titleStr = (stream.meta && stream.meta.title) ? stream.meta.title : (stream.title || 'Unknown Stream');
|
| 715 |
+
|
| 716 |
+
return `
|
| 717 |
+
<div class="p-4 bg-gray-50 rounded-lg border-l-4 border-green-500">
|
| 718 |
+
<div class="flex justify-between items-start mb-3">
|
| 719 |
+
<div class="flex items-center gap-2 max-w-[70%]">
|
| 720 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4 text-primary shrink-0" fill="currentColor" viewBox="0 0 24 24">
|
| 721 |
+
<path d="M8 5v14l11-7z" />
|
| 722 |
+
</svg>
|
| 723 |
+
<div class="truncate">
|
| 724 |
+
<span class="font-semibold" title="${escapeHtml(stream.title || stream.stream_id)}">${escapeHtml(titleStr)}</span>
|
| 725 |
+
<div class="text-[10px] text-gray-500 font-mono mt-0.5" title="${escapeHtml(stream.stream_id)}">
|
| 726 |
+
ID: ${escapeHtml(streamIdStr)}
|
| 727 |
+
</div>
|
| 728 |
+
</div>
|
| 729 |
+
</div>
|
| 730 |
+
<span class="px-2 py-1 rounded text-xs font-semibold shrink-0 uppercase ${statusColor}">
|
| 731 |
+
${escapeHtml(stream.status)}
|
| 732 |
+
</span>
|
| 733 |
+
</div>
|
| 734 |
+
|
| 735 |
+
<div class="grid grid-cols-2 gap-3 mb-3">
|
| 736 |
+
<div class="flex justify-between py-2 px-3 bg-white rounded">
|
| 737 |
+
<span class="text-sm theme-text-secondary">Bot:</span>
|
| 738 |
+
<span class="text-sm font-semibold">Bot${(stream.client_index || 0) + 1} </span>
|
| 739 |
+
</div>
|
| 740 |
+
<div class="flex justify-between py-2 px-3 bg-white rounded">
|
| 741 |
+
<span class="text-sm theme-text-secondary">File:</span>
|
| 742 |
+
<span class="text-sm font-semibold">DC${stream.dc_id || '-'}</span>
|
| 743 |
+
</div>
|
| 744 |
+
<div class="flex justify-between py-2 px-3 bg-white rounded col-span-2">
|
| 745 |
+
<span class="text-sm theme-text-secondary">Duration:</span>
|
| 746 |
+
<span class="text-sm font-semibold">${stream.duration || 0}s</span>
|
| 747 |
+
</div>
|
| 748 |
+
|
| 749 |
+
<div class="flex justify-between py-2 px-3 bg-white rounded col-span-2">
|
| 750 |
+
<span class="text-sm theme-text-secondary">Data Transferred:</span>
|
| 751 |
+
<span class="text-sm font-semibold">${formatBytesStr(stream.total_bytes)}</span>
|
| 752 |
+
</div>
|
| 753 |
+
</div>
|
| 754 |
+
|
| 755 |
+
<div class="grid grid-cols-3 gap-3">
|
| 756 |
+
<div class="text-center py-3 bg-white rounded">
|
| 757 |
+
<div class="text-xs theme-text-secondary mb-1">Instant</div>
|
| 758 |
+
<div class="text-sm font-bold text-primary">${stream.instant_mbps || 0} MB/s</div>
|
| 759 |
+
</div>
|
| 760 |
+
<div class="text-center py-3 bg-white rounded">
|
| 761 |
+
<div class="text-xs theme-text-secondary mb-1">Average</div>
|
| 762 |
+
<div class="text-sm font-bold text-primary">${stream.avg_mbps || 0} MB/s</div>
|
| 763 |
+
</div>
|
| 764 |
+
<div class="text-center py-3 bg-white rounded">
|
| 765 |
+
<div class="text-xs theme-text-secondary mb-1">Peak</div>
|
| 766 |
+
<div class="text-sm font-bold text-primary">${stream.peak_mbps || 0} MB/s</div>
|
| 767 |
+
</div>
|
| 768 |
+
</div>
|
| 769 |
+
</div>
|
| 770 |
+
|
| 771 |
+
${stream.meta && (stream.meta.client_host || stream.meta.user_name) ? `
|
| 772 |
+
<div class="mt-3 pt-3 border-t border-gray-200">
|
| 773 |
+
<div class="flex flex-col gap-1">
|
| 774 |
+
${stream.meta.client_host ? `
|
| 775 |
+
<div class="flex justify-between items-center text-sm">
|
| 776 |
+
<div class="flex items-center gap-2">
|
| 777 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4 theme-text-secondary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 778 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"></path>
|
| 779 |
+
</svg>
|
| 780 |
+
<span class="theme-text-secondary">Client IPv4:</span>
|
| 781 |
+
</div>
|
| 782 |
+
<span class="font-mono text-xs">${escapeHtml(stream.meta.client_host)}</span>
|
| 783 |
+
</div>
|
| 784 |
+
` : ''}
|
| 785 |
+
${stream.meta.user_name ? `
|
| 786 |
+
<div class="flex justify-between items-center text-sm">
|
| 787 |
+
<div class="flex items-center gap-2">
|
| 788 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4 theme-text-secondary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 789 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"></path>
|
| 790 |
+
</svg>
|
| 791 |
+
<span class="theme-text-secondary">User:</span>
|
| 792 |
+
</div>
|
| 793 |
+
<span class="font-mono text-xs font-semibold">${escapeHtml(stream.meta.user_name)}</span>
|
| 794 |
+
</div>
|
| 795 |
+
` : ''}
|
| 796 |
+
</div>
|
| 797 |
+
</div>
|
| 798 |
+
` : ''}
|
| 799 |
+
</div>
|
| 800 |
+
`;
|
| 801 |
+
}).join('');
|
| 802 |
+
}
|
| 803 |
+
}
|
| 804 |
+
}
|
| 805 |
+
} catch (error) {
|
| 806 |
+
console.error("Failed to update active streams:", error);
|
| 807 |
+
}
|
| 808 |
+
}
|
| 809 |
+
|
| 810 |
+
// Auto-refresh every 2 minutes
|
| 811 |
+
const statsInterval = setInterval(refreshSystemStats, 120000);
|
| 812 |
+
</script>
|
| 813 |
+
<script>
|
| 814 |
+
async function createToken(event) {
|
| 815 |
+
event.preventDefault();
|
| 816 |
+
const nameInput = document.getElementById('token-name');
|
| 817 |
+
const dailyInput = document.getElementById('daily-limit');
|
| 818 |
+
const monthlyInput = document.getElementById('monthly-limit');
|
| 819 |
+
|
| 820 |
+
const payload = {
|
| 821 |
+
name: nameInput.value,
|
| 822 |
+
daily_limit_gb: dailyInput.value,
|
| 823 |
+
monthly_limit_gb: monthlyInput.value
|
| 824 |
+
};
|
| 825 |
+
|
| 826 |
+
try {
|
| 827 |
+
const response = await fetch('/api/tokens', {
|
| 828 |
+
method: 'POST',
|
| 829 |
+
headers: { 'Content-Type': 'application/json' },
|
| 830 |
+
body: JSON.stringify(payload)
|
| 831 |
+
});
|
| 832 |
+
|
| 833 |
+
if (response.ok) {
|
| 834 |
+
showToast('Token created successfully!');
|
| 835 |
+
setTimeout(() => window.location.reload(), 1000);
|
| 836 |
+
} else {
|
| 837 |
+
const data = await response.json();
|
| 838 |
+
showToast('Error: ' + data.detail);
|
| 839 |
+
}
|
| 840 |
+
} catch (error) {
|
| 841 |
+
showToast('Error creating token');
|
| 842 |
+
}
|
| 843 |
+
}
|
| 844 |
+
|
| 845 |
+
async function revokeToken(token) {
|
| 846 |
+
if (!confirm('Are you sure you want to revoke this token? The user will lose access immediately.')) return;
|
| 847 |
+
|
| 848 |
+
try {
|
| 849 |
+
const response = await fetch('/api/tokens/' + token, {
|
| 850 |
+
method: 'DELETE'
|
| 851 |
+
});
|
| 852 |
+
|
| 853 |
+
if (response.ok) {
|
| 854 |
+
showToast('Token revoked successfully!');
|
| 855 |
+
setTimeout(() => window.location.reload(), 1000);
|
| 856 |
+
} else {
|
| 857 |
+
showToast('Error revoking token');
|
| 858 |
+
}
|
| 859 |
+
} catch (error) {
|
| 860 |
+
showToast('Error revoking token');
|
| 861 |
+
}
|
| 862 |
+
}
|
| 863 |
+
|
| 864 |
+
function copyUrl(url) {
|
| 865 |
+
navigator.clipboard.writeText(url).then(function () {
|
| 866 |
+
showToast('Manifest URL copied to clipboard!');
|
| 867 |
+
});
|
| 868 |
+
}
|
| 869 |
+
</script>
|
| 870 |
+
</main>
|
| 871 |
+
</div>
|
| 872 |
+
|
| 873 |
<script>
|
| 874 |
+
function copyToClipboard() {
|
| 875 |
+
const manifestUrl = document.getElementById('manifest-url').value;
|
| 876 |
+
navigator.clipboard.writeText(manifestUrl).then(function () {
|
| 877 |
+
showToast('Manifest URL copied to clipboard!');
|
| 878 |
+
});
|
| 879 |
+
}
|
| 880 |
+
|
| 881 |
+
function showToast(message, duration = 3000) {
|
| 882 |
+
const toast = document.createElement('div');
|
| 883 |
+
toast.className = 'fixed top-4 right-4 bg-blue-600 text-white px-6 py-3 rounded-lg shadow-lg z-50 transform transition-all duration-300 translate-x-full';
|
| 884 |
+
toast.textContent = message;
|
| 885 |
+
document.body.appendChild(toast);
|
| 886 |
+
|
| 887 |
+
setTimeout(() => toast.classList.remove('translate-x-full'), 100);
|
| 888 |
+
setTimeout(() => {
|
| 889 |
+
toast.classList.add('translate-x-full');
|
| 890 |
+
setTimeout(() => document.body.removeChild(toast), 300);
|
| 891 |
+
}, duration);
|
| 892 |
+
}
|
| 893 |
+
|
| 894 |
+
function toggleAccordion(id) {
|
| 895 |
+
const content = document.getElementById(id);
|
| 896 |
+
const icon = document.getElementById(id + '-icon');
|
| 897 |
+
|
| 898 |
+
if (content.classList.contains('hidden')) {
|
| 899 |
+
content.classList.remove('hidden');
|
| 900 |
+
icon.classList.add('rotate-180');
|
| 901 |
+
} else {
|
| 902 |
+
content.classList.add('hidden');
|
| 903 |
+
icon.classList.remove('rotate-180');
|
| 904 |
+
}
|
| 905 |
+
}
|
| 906 |
+
|
| 907 |
+
function formatBytes(bytes, decimals = 2) {
|
| 908 |
+
if (!+bytes) return '0 B';
|
| 909 |
const k = 1024;
|
| 910 |
+
const dm = decimals < 0 ? 0 : decimals;
|
| 911 |
+
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
| 912 |
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
| 913 |
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
| 914 |
}
|
| 915 |
|
| 916 |
+
// Auto-format bytes on load
|
| 917 |
+
document.addEventListener("DOMContentLoaded", () => {
|
| 918 |
document.querySelectorAll('[data-bytes]').forEach(el => {
|
| 919 |
+
el.textContent = formatBytes(el.getAttribute('data-bytes'));
|
| 920 |
});
|
|
|
|
| 921 |
|
| 922 |
+
// Store the first API token in localStorage so other pages (e.g. media edit) can build stream links
|
| 923 |
+
{% if api_tokens %}
|
| 924 |
+
const firstToken = '{{ api_tokens[0].token }}';
|
| 925 |
+
if (firstToken) {
|
| 926 |
+
localStorage.setItem('api_token', firstToken);
|
| 927 |
+
}
|
| 928 |
+
{% endif %}
|
| 929 |
+
});
|
| 930 |
</script>
|
| 931 |
+
{% endblock %}
|
Backend/fastapi/templates/login.html
CHANGED
|
@@ -3,71 +3,45 @@
|
|
| 3 |
{% block title %}Login - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
-
<div class="min-h-
|
| 7 |
<div class="max-w-md w-full space-y-8">
|
| 8 |
-
<div class="text-center
|
| 9 |
-
<
|
| 10 |
-
|
| 11 |
-
</div>
|
| 12 |
-
<h2 class="text-3xl font-extrabold tracking-tight">Admin Login</h2>
|
| 13 |
-
<p class="theme-text-secondary text-sm">Access the Telegram Stremio management console</p>
|
| 14 |
</div>
|
| 15 |
|
| 16 |
{% if error %}
|
| 17 |
-
<div class="
|
| 18 |
-
|
| 19 |
-
<p class="text-sm font-medium">{{ error }}</p>
|
| 20 |
</div>
|
| 21 |
{% endif %}
|
| 22 |
|
| 23 |
-
<form method="post" class="
|
| 24 |
-
<div
|
| 25 |
-
<
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
<i data-lucide="user" class="w-4 h-4"></i>
|
| 30 |
-
</div>
|
| 31 |
-
<input type="text" id="username" name="username" required
|
| 32 |
-
class="theme-input w-full pl-10 pr-4 py-2.5 rounded-xl border-white/10 focus:ring-2 focus:ring-primary/50 transition-all outline-none"
|
| 33 |
-
placeholder="Enter admin username">
|
| 34 |
-
</div>
|
| 35 |
-
</div>
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
<i data-lucide="lock" class="w-4 h-4"></i>
|
| 42 |
-
</div>
|
| 43 |
-
<input type="password" id="password" name="password" required
|
| 44 |
-
class="theme-input w-full pl-10 pr-4 py-2.5 rounded-xl border-white/10 focus:ring-2 focus:ring-primary/50 transition-all outline-none"
|
| 45 |
-
placeholder="••••••••">
|
| 46 |
-
</div>
|
| 47 |
-
</div>
|
| 48 |
</div>
|
| 49 |
|
| 50 |
-
<button type="submit"
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
</span>
|
| 54 |
-
Sign In to Dashboard
|
| 55 |
</button>
|
| 56 |
</form>
|
| 57 |
|
| 58 |
-
<div class="
|
| 59 |
-
<
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
<
|
| 64 |
-
<i data-lucide="book-open" class="w-3 h-3"></i> Setup Guide
|
| 65 |
-
</a>
|
| 66 |
</div>
|
| 67 |
</div>
|
| 68 |
</div>
|
| 69 |
-
|
| 70 |
-
<script>
|
| 71 |
-
lucide.createIcons();
|
| 72 |
-
</script>
|
| 73 |
-
{% endblock %}
|
|
|
|
| 3 |
{% block title %}Login - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
+
<div class="min-h-screen flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
|
| 7 |
<div class="max-w-md w-full space-y-8">
|
| 8 |
+
<div class="text-center">
|
| 9 |
+
<h2 class="text-3xl font-bold">Admin Login</h2>
|
| 10 |
+
<p class="mt-2 theme-text-secondary">Sign in to access the admin panel</p>
|
|
|
|
|
|
|
|
|
|
| 11 |
</div>
|
| 12 |
|
| 13 |
{% if error %}
|
| 14 |
+
<div class="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-md">
|
| 15 |
+
{{ error }}
|
|
|
|
| 16 |
</div>
|
| 17 |
{% endif %}
|
| 18 |
|
| 19 |
+
<form method="post" class="theme-card p-8 rounded-lg shadow-lg space-y-6">
|
| 20 |
+
<div>
|
| 21 |
+
<label for="username" class="block text-sm font-medium mb-2">Username</label>
|
| 22 |
+
<input type="text" id="username" name="username" required
|
| 23 |
+
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
|
| 24 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
<div>
|
| 27 |
+
<label for="password" class="block text-sm font-medium mb-2">Password</label>
|
| 28 |
+
<input type="password" id="password" name="password" required
|
| 29 |
+
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
</div>
|
| 31 |
|
| 32 |
+
<button type="submit"
|
| 33 |
+
class="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-md transition-colors font-medium shadow-sm">
|
| 34 |
+
Sign In
|
|
|
|
|
|
|
| 35 |
</button>
|
| 36 |
</form>
|
| 37 |
|
| 38 |
+
<div class="text-center">
|
| 39 |
+
<p class="theme-text-secondary text-sm">
|
| 40 |
+
Public pages:
|
| 41 |
+
<a href="/status" class="text-primary hover:underline">System Status</a> |
|
| 42 |
+
<a href="/stremio" class="text-primary hover:underline">Stremio Guide</a>
|
| 43 |
+
</p>
|
|
|
|
|
|
|
| 44 |
</div>
|
| 45 |
</div>
|
| 46 |
</div>
|
| 47 |
+
{% endblock %}
|
|
|
|
|
|
|
|
|
|
|
|
Backend/fastapi/templates/media_edit.html
CHANGED
|
@@ -3,245 +3,946 @@
|
|
| 3 |
{% block title %}Edit {{ media_type|title }} - Fyvio Backend{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
-
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-
|
| 7 |
-
<
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
<
|
| 16 |
-
|
| 17 |
-
<
|
| 18 |
-
<i data-lucide="database" class="w-4 h-4 theme-text-secondary"></i>
|
| 19 |
-
<span class="text-xs font-mono theme-text-secondary uppercase">TMDB: {{ tmdb_id }} <span class="mx-1">•</span> DB: {{ db_index }}</span>
|
| 20 |
-
</div>
|
| 21 |
</div>
|
|
|
|
|
|
|
|
|
|
| 22 |
</div>
|
| 23 |
|
|
|
|
| 24 |
{% if media_details %}
|
| 25 |
-
<div class="
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
{% if media_details.backdrop %}
|
| 28 |
-
<div class="
|
| 29 |
-
<img src="{{ media_details.backdrop }}"
|
| 30 |
-
|
|
|
|
| 31 |
</div>
|
| 32 |
{% endif %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
<i data-lucide="star" class="w-3 h-3 fill-current"></i> {{ media_details.rating }}
|
| 43 |
</div>
|
| 44 |
-
{% endif %}
|
| 45 |
</div>
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
</div>
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
| 59 |
</div>
|
| 60 |
-
|
| 61 |
-
{% if media_details.description %}
|
| 62 |
-
<p class="text-zinc-400 text-sm md:text-base leading-relaxed max-w-3xl line-clamp-3 md:line-clamp-none">
|
| 63 |
-
{{ media_details.description }}
|
| 64 |
-
</p>
|
| 65 |
-
{% endif %}
|
| 66 |
</div>
|
| 67 |
</div>
|
|
|
|
| 68 |
</div>
|
| 69 |
-
</div>
|
| 70 |
-
{% endif %}
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
</
|
| 77 |
-
<h3 class="text-xl font-bold">Metadata Details</h3>
|
| 78 |
</div>
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
</div>
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
<
|
| 90 |
-
|
| 91 |
-
class="
|
|
|
|
| 92 |
</div>
|
| 93 |
-
<div
|
| 94 |
-
<label class="text-sm font-
|
| 95 |
-
<input type="number" step="0.1" min="0" max="10" id="rating" name="rating"
|
| 96 |
-
|
|
|
|
| 97 |
</div>
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
<
|
| 101 |
-
|
| 102 |
-
<i data-lucide="image" class="w-4 h-4"></i> Poster URL
|
| 103 |
-
</label>
|
| 104 |
-
<input type="url" id="poster" name="poster" value="{{ media_details.poster if media_details else '' }}"
|
| 105 |
-
class="theme-input w-full px-4 py-3 rounded-xl focus:ring-2 focus:ring-primary/50 transition-all outline-none border-white/10 font-mono text-xs">
|
| 106 |
-
</div>
|
| 107 |
-
<div class="space-y-2">
|
| 108 |
-
<label class="text-sm font-semibold theme-text-secondary ml-1 flex items-center gap-2">
|
| 109 |
-
<i data-lucide="monitor" class="w-4 h-4"></i> Backdrop URL
|
| 110 |
-
</label>
|
| 111 |
-
<input type="url" id="backdrop" name="backdrop" value="{{ media_details.backdrop if media_details else '' }}"
|
| 112 |
-
class="theme-input w-full px-4 py-3 rounded-xl focus:ring-2 focus:ring-primary/50 transition-all outline-none border-white/10 font-mono text-xs">
|
| 113 |
-
</div>
|
| 114 |
</div>
|
| 115 |
|
| 116 |
-
<div class="
|
| 117 |
-
<label class="text-sm font-
|
| 118 |
-
<
|
| 119 |
-
|
|
|
|
| 120 |
</div>
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
<
|
| 124 |
-
|
| 125 |
-
class="
|
| 126 |
</div>
|
| 127 |
</div>
|
| 128 |
|
| 129 |
-
<div class="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
<button type="button" onclick="window.history.back()"
|
| 131 |
-
class="px-
|
| 132 |
Cancel
|
| 133 |
</button>
|
| 134 |
<button type="submit"
|
| 135 |
-
class="
|
| 136 |
-
|
| 137 |
</button>
|
| 138 |
</div>
|
| 139 |
</form>
|
| 140 |
</div>
|
| 141 |
|
|
|
|
| 142 |
{% if media_details %}
|
| 143 |
-
<div class="
|
| 144 |
-
<
|
| 145 |
-
<div class="flex items-center gap-3">
|
| 146 |
-
<div class="p-2 rounded-lg bg-green-500/10 text-green-500">
|
| 147 |
-
<i data-lucide="layers" class="w-6 h-6"></i>
|
| 148 |
-
</div>
|
| 149 |
-
<h3 class="text-xl font-bold">Storage & Streams</h3>
|
| 150 |
-
</div>
|
| 151 |
-
</div>
|
| 152 |
|
| 153 |
{% if media_type == 'movie' and media_details.telegram %}
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
{{ quality.quality }}
|
| 160 |
-
</
|
| 161 |
-
<
|
| 162 |
-
<p class="font-bold text-sm break-all">{{ quality.name }}</p>
|
| 163 |
-
<p class="text-xs theme-text-secondary">{{ quality.size }} • Direct Stream ID: {{ quality.id[:8] }}...</p>
|
| 164 |
-
</div>
|
| 165 |
-
</div>
|
| 166 |
-
<div class="flex items-center gap-2 w-full sm:w-auto">
|
| 167 |
-
<button onclick="copyStreamLink('{{ quality.id }}', '{{ quality.name }}')"
|
| 168 |
-
class="flex-1 sm:flex-none flex items-center justify-center gap-1 px-3 py-2 rounded-lg bg-green-500/10 text-green-500 hover:bg-green-500/20 transition-all text-xs font-bold uppercase tracking-wider">
|
| 169 |
-
<i data-lucide="copy" class="w-3.5 h-3.5"></i> Link
|
| 170 |
-
</button>
|
| 171 |
-
<button onclick="deleteQuality('{{ quality.id }}')"
|
| 172 |
-
class="p-2 rounded-lg bg-red-500/10 text-red-500 hover:bg-red-500/20 transition-all">
|
| 173 |
-
<i data-lucide="trash-2" class="w-4 h-4"></i>
|
| 174 |
-
</button>
|
| 175 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
</div>
|
| 177 |
-
{% endfor %}
|
| 178 |
</div>
|
|
|
|
|
|
|
| 179 |
|
| 180 |
{% elif media_type == 'tv' and media_details.seasons %}
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
</div>
|
| 190 |
-
|
| 191 |
-
|
| 192 |
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
</div>
|
| 204 |
-
|
| 205 |
-
<
|
| 206 |
-
|
| 207 |
-
<
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
</div>
|
|
|
|
| 216 |
</div>
|
| 217 |
-
{%
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
</div>
|
| 219 |
-
</div>
|
| 220 |
-
{% endfor %}
|
| 221 |
-
|
| 222 |
-
<div class="pt-4 mt-2 border-t border-white/5 text-right">
|
| 223 |
-
<button onclick="deleteTVSeason({{ season.season_number }})" class="text-xs font-bold text-red-500/70 hover:text-red-500 uppercase tracking-widest">
|
| 224 |
-
Delete Entire Season {{ season.season_number }}
|
| 225 |
-
</button>
|
| 226 |
</div>
|
| 227 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
</div>
|
| 229 |
</div>
|
| 230 |
-
{% endfor %}
|
| 231 |
</div>
|
|
|
|
|
|
|
| 232 |
{% else %}
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
<
|
| 236 |
-
|
|
|
|
|
|
|
|
|
|
| 237 |
{% endif %}
|
| 238 |
</div>
|
| 239 |
{% endif %}
|
| 240 |
</div>
|
| 241 |
|
| 242 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
document.addEventListener('DOMContentLoaded', () => {
|
| 244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
</script>
|
| 247 |
-
|
|
|
|
|
|
| 3 |
{% block title %}Edit {{ media_type|title }} - Fyvio Backend{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4 sm:py-8">
|
| 7 |
+
<!-- Header -->
|
| 8 |
+
<div class="mb-6 sm:mb-8">
|
| 9 |
+
<div class="flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4">
|
| 10 |
+
<a href="/media/manage?media_type={{ media_type }}"
|
| 11 |
+
class="text-primary hover:underline flex items-center text-sm sm:text-base">
|
| 12 |
+
<svg class="w-4 h-4 sm:w-5 sm:h-5 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 13 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 14 |
+
d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
|
| 15 |
+
</svg>
|
| 16 |
+
Back to {{ media_type|title }}s
|
| 17 |
+
</a>
|
|
|
|
|
|
|
|
|
|
| 18 |
</div>
|
| 19 |
+
<h1 class="text-2xl sm:text-3xl font-bold mt-2">Edit {{ media_type|title }}</h1>
|
| 20 |
+
<p class="theme-text-secondary text-sm sm:text-base mt-1 sm:mt-2">TMDB ID: {{ tmdb_id }} | DB Index: {{ db_index
|
| 21 |
+
}}</p>
|
| 22 |
</div>
|
| 23 |
|
| 24 |
+
<!-- Media Preview -->
|
| 25 |
{% if media_details %}
|
| 26 |
+
<div class="theme-card rounded-lg shadow mb-6 sm:mb-8 overflow-hidden">
|
| 27 |
+
|
| 28 |
+
<!-- Mobile Layout (Stack vertically) -->
|
| 29 |
+
<div class="block sm:hidden">
|
| 30 |
+
<!-- Poster Section -->
|
| 31 |
+
<div class="bg-gradient-to-br from-gray-800 to-gray-900 p-6">
|
| 32 |
+
<div class="flex flex-col items-center text-center">
|
| 33 |
+
<img src="{{ media_details.poster or '/static/placeholder.jpg' }}" alt="{{ media_details.title }}"
|
| 34 |
+
class="w-32 h-48 object-cover rounded-lg shadow-xl border-4 border-white mb-4"
|
| 35 |
+
onerror="this.src='https://via.placeholder.com/300x450/e5e7eb/9ca3af?text=No+Image'">
|
| 36 |
+
<h2 class="text-xl font-bold text-white mb-2">{{ media_details.title }}</h2>
|
| 37 |
+
<div class="flex flex-wrap justify-center items-center gap-2 mb-3">
|
| 38 |
+
{% if media_details.rating %}
|
| 39 |
+
<span class="bg-yellow-500 text-black px-2 py-1 rounded text-sm font-bold">
|
| 40 |
+
⭐ {{ media_details.rating }}
|
| 41 |
+
</span>
|
| 42 |
+
{% endif %}
|
| 43 |
+
<span class="text-white text-sm bg-white/20 px-2 py-1 rounded">{{ media_details.release_year
|
| 44 |
+
}}</span>
|
| 45 |
+
</div>
|
| 46 |
+
<div class="flex flex-wrap justify-center gap-1">
|
| 47 |
+
{% for genre in media_details.genres[:4] %}
|
| 48 |
+
<span class="bg-white/20 text-white px-2 py-1 rounded-full text-xs">{{ genre }}</span>
|
| 49 |
+
{% endfor %}
|
| 50 |
+
</div>
|
| 51 |
+
</div>
|
| 52 |
+
</div>
|
| 53 |
+
|
| 54 |
+
<!-- Backdrop Section -->
|
| 55 |
{% if media_details.backdrop %}
|
| 56 |
+
<div class="relative h-48 overflow-hidden">
|
| 57 |
+
<img src="{{ media_details.backdrop }}" alt="{{ media_details.title }} backdrop"
|
| 58 |
+
class="w-full h-full object-cover" onerror="this.style.display='none'">
|
| 59 |
+
<div class="absolute inset-0 bg-black/30"></div>
|
| 60 |
</div>
|
| 61 |
{% endif %}
|
| 62 |
+
</div>
|
| 63 |
+
|
| 64 |
+
<!-- Desktop Layout (Original backdrop style) -->
|
| 65 |
+
<div class="hidden sm:block">
|
| 66 |
+
{% if media_details.backdrop %}
|
| 67 |
+
<div class="relative h-64 md:h-80 bg-gradient-to-r from-gray-900 to-gray-700">
|
| 68 |
+
<img src="{{ media_details.backdrop }}" alt="{{ media_details.title }} backdrop"
|
| 69 |
+
class="w-full h-full object-cover opacity-60" onerror="this.style.display='none'">
|
| 70 |
+
<div class="absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent"></div>
|
| 71 |
+
<div class="absolute bottom-0 left-0 right-0 p-6">
|
| 72 |
+
<div class="flex items-end gap-6">
|
| 73 |
+
<img src="{{ media_details.poster or '/static/placeholder.jpg' }}"
|
| 74 |
+
alt="{{ media_details.title }}"
|
| 75 |
+
class="w-32 md:w-48 h-48 md:h-72 object-cover rounded-lg shadow-2xl border-4 border-white"
|
| 76 |
+
onerror="this.src='https://via.placeholder.com/300x450/e5e7eb/9ca3af?text=No+Image'">
|
| 77 |
+
<div class="text-white flex-1">
|
| 78 |
+
<h2 class="text-2xl md:text-4xl font-bold mb-2">{{ media_details.title }}</h2>
|
| 79 |
+
<div class="flex flex-wrap items-center gap-4 mb-4">
|
| 80 |
+
{% if media_details.rating %}
|
| 81 |
+
<span class="bg-yellow-500 text-black px-2 py-1 rounded text-sm font-bold">
|
| 82 |
+
⭐ {{ media_details.rating }}
|
| 83 |
+
</span>
|
| 84 |
+
{% endif %}
|
| 85 |
+
<span class="text-lg">{{ media_details.release_year }}</span>
|
| 86 |
|
| 87 |
+
</div>
|
| 88 |
+
<div class="flex flex-wrap gap-2">
|
| 89 |
+
{% for genre in media_details.genres[:6] %}
|
| 90 |
+
<span class="bg-white/20 backdrop-blur-sm text-white px-3 py-1 rounded-full text-sm">{{
|
| 91 |
+
genre }}</span>
|
| 92 |
+
{% endfor %}
|
| 93 |
+
</div>
|
| 94 |
+
</div>
|
|
|
|
| 95 |
</div>
|
|
|
|
| 96 |
</div>
|
| 97 |
+
</div>
|
| 98 |
+
{% else %}
|
| 99 |
+
<!-- Fallback without backdrop for desktop -->
|
| 100 |
+
<div class="p-6">
|
| 101 |
+
<div class="flex items-start gap-6">
|
| 102 |
+
<div class="flex-shrink-0">
|
| 103 |
+
<img src="{{ media_details.poster or '/static/placeholder.jpg' }}"
|
| 104 |
+
alt="{{ media_details.title }}" class="w-48 h-72 object-cover rounded-lg shadow-lg"
|
| 105 |
+
onerror="this.src='https://via.placeholder.com/300x450/e5e7eb/9ca3af?text=No+Image'">
|
| 106 |
</div>
|
| 107 |
+
<div class="flex-1">
|
| 108 |
+
<h2 class="text-2xl font-bold mb-2">{{ media_details.title }}</h2>
|
| 109 |
+
<p class="theme-text-secondary mb-4">{{ media_details.release_year }} • Rating: {{
|
| 110 |
+
media_details.rating or 'N/A' }}</p>
|
| 111 |
+
<div class="flex flex-wrap gap-2 mb-4">
|
| 112 |
+
{% for genre in media_details.genres[:6] %}
|
| 113 |
+
<span class="bg-gray-200 text-gray-700 px-2 py-1 rounded-full text-sm">{{ genre }}</span>
|
| 114 |
+
{% endfor %}
|
| 115 |
+
</div>
|
| 116 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
</div>
|
| 118 |
</div>
|
| 119 |
+
{% endif %}
|
| 120 |
</div>
|
|
|
|
|
|
|
| 121 |
|
| 122 |
+
<!-- Description (common for both layouts) -->
|
| 123 |
+
{% if media_details.description %}
|
| 124 |
+
<div class="px-4 sm:px-6 pb-4 sm:pb-6">
|
| 125 |
+
<h3 class="text-base sm:text-lg font-semibold mb-2">Overview</h3>
|
| 126 |
+
<p class="theme-text-secondary leading-relaxed text-sm sm:text-base">{{ media_details.description }}</p>
|
|
|
|
| 127 |
</div>
|
| 128 |
+
{% endif %}
|
| 129 |
+
</div>
|
| 130 |
+
{% endif %}
|
| 131 |
|
| 132 |
+
<!-- Edit Form -->
|
| 133 |
+
<div class="theme-card p-4 sm:p-6 rounded-lg shadow mb-6 sm:mb-8">
|
| 134 |
+
<h3 class="text-lg sm:text-xl font-semibold mb-4 sm:mb-6">Edit Details</h3>
|
| 135 |
+
<form onsubmit="updateMedia(event)" id="edit-form">
|
| 136 |
+
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 sm:gap-6 mb-6">
|
| 137 |
+
<div class="sm:col-span-2">
|
| 138 |
+
<label class="block text-sm font-medium mb-2">Title *</label>
|
| 139 |
+
<input type="text" id="title" name="title"
|
| 140 |
+
value="{{ media_details.title if media_details else '' }}"
|
| 141 |
+
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary"
|
| 142 |
+
required>
|
| 143 |
</div>
|
| 144 |
+
<div>
|
| 145 |
+
<label class="block text-sm font-medium mb-2">Release Year *</label>
|
| 146 |
+
<input type="number" id="release_year" name="release_year"
|
| 147 |
+
value="{{ media_details.release_year if media_details else '' }}"
|
| 148 |
+
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary"
|
| 149 |
+
required>
|
| 150 |
</div>
|
| 151 |
+
<div>
|
| 152 |
+
<label class="block text-sm font-medium mb-2">Rating (0-10)</label>
|
| 153 |
+
<input type="number" step="0.1" min="0" max="10" id="rating" name="rating"
|
| 154 |
+
value="{{ media_details.rating if media_details else '' }}"
|
| 155 |
+
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary">
|
| 156 |
</div>
|
| 157 |
+
<div class="sm:col-span-2">
|
| 158 |
+
<label class="block text-sm font-medium mb-2">Logo URL</label>
|
| 159 |
+
<input type="url" id="logo" name="logo" value="{{ media_details.logo if media_details else '' }}"
|
| 160 |
+
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
</div>
|
| 162 |
|
| 163 |
+
<div class="sm:col-span-2">
|
| 164 |
+
<label class="block text-sm font-medium mb-2">Poster URL</label>
|
| 165 |
+
<input type="url" id="poster" name="poster"
|
| 166 |
+
value="{{ media_details.poster if media_details else '' }}"
|
| 167 |
+
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary">
|
| 168 |
</div>
|
| 169 |
+
<div class="sm:col-span-2">
|
| 170 |
+
<label class="block text-sm font-medium mb-2">Backdrop URL</label>
|
| 171 |
+
<input type="url" id="backdrop" name="backdrop"
|
| 172 |
+
value="{{ media_details.backdrop if media_details else '' }}"
|
| 173 |
+
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary">
|
| 174 |
</div>
|
| 175 |
</div>
|
| 176 |
|
| 177 |
+
<div class="mb-6">
|
| 178 |
+
<label class="block text-sm font-medium mb-2">Description</label>
|
| 179 |
+
<textarea id="description" name="description" rows="3"
|
| 180 |
+
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary">{{ media_details.description if media_details else '' }}</textarea>
|
| 181 |
+
</div>
|
| 182 |
+
|
| 183 |
+
<div class="mb-6">
|
| 184 |
+
<label class="block text-sm font-medium mb-2">Genres (comma-separated)</label>
|
| 185 |
+
<input type="text" id="genres" name="genres"
|
| 186 |
+
value="{% if media_details and media_details.genres %}{{ media_details.genres|join(', ') }}{% endif %}"
|
| 187 |
+
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary"
|
| 188 |
+
placeholder="Action, Comedy, Drama">
|
| 189 |
+
</div>
|
| 190 |
+
|
| 191 |
+
<div class="flex flex-col sm:flex-row justify-end gap-2 sm:gap-4">
|
| 192 |
<button type="button" onclick="window.history.back()"
|
| 193 |
+
class="w-full sm:w-auto px-6 py-2 border border-gray-300 rounded-md hover:bg-gray-50 transition-colors text-sm">
|
| 194 |
Cancel
|
| 195 |
</button>
|
| 196 |
<button type="submit"
|
| 197 |
+
class="w-full sm:w-auto bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-md transition-colors text-sm shadow-sm">
|
| 198 |
+
Save Changes
|
| 199 |
</button>
|
| 200 |
</div>
|
| 201 |
</form>
|
| 202 |
</div>
|
| 203 |
|
| 204 |
+
<!-- Quality Management -->
|
| 205 |
{% if media_details %}
|
| 206 |
+
<div class="theme-card p-4 sm:p-6 rounded-lg shadow">
|
| 207 |
+
<h3 class="text-lg sm:text-xl font-semibold mb-4 sm:mb-6">Available Content</h3>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
|
| 209 |
{% if media_type == 'movie' and media_details.telegram %}
|
| 210 |
+
<!-- Movie Qualities (sorted by quality) -->
|
| 211 |
+
<div class="space-y-3">
|
| 212 |
+
{% set sorted_qualities = media_details.telegram|sort(attribute='quality') %}
|
| 213 |
+
{% for quality in sorted_qualities %}
|
| 214 |
+
<div
|
| 215 |
+
class="flex flex-col sm:flex-row sm:items-center justify-between p-3 sm:p-4 bg-gray-50 rounded-lg border gap-3 sm:gap-0">
|
| 216 |
+
<div class="flex-1">
|
| 217 |
+
<div class="flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4">
|
| 218 |
+
<span
|
| 219 |
+
class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-blue-100 text-blue-800 w-fit">
|
| 220 |
{{ quality.quality }}
|
| 221 |
+
</span>
|
| 222 |
+
<span class="text-sm text-gray-600">{{ quality.size }}</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
</div>
|
| 224 |
+
<p class="text-sm text-gray-500 mt-2 sm:mt-1 break-all">{{ quality.name }}</p>
|
| 225 |
+
</div>
|
| 226 |
+
<div class="flex gap-2">
|
| 227 |
+
<button onclick="copyStreamLink('{{ quality.id }}', '{{ quality.name }}')"
|
| 228 |
+
class="self-start sm:self-center text-green-600 hover:text-green-800 hover:bg-green-50 px-3 py-1 rounded transition-colors text-sm"
|
| 229 |
+
title="Copy direct stream link">
|
| 230 |
+
📋 Copy Link
|
| 231 |
+
</button>
|
| 232 |
+
<button onclick="runSpeedTest('{{ quality.id }}', 'movie', '{{ quality.quality }}')"
|
| 233 |
+
class="self-start sm:self-center text-blue-600 hover:text-blue-800 hover:bg-blue-50 px-3 py-1 rounded transition-colors text-sm">
|
| 234 |
+
🚀 Speed Test
|
| 235 |
+
</button>
|
| 236 |
+
<button onclick="deleteQuality('{{ quality.id }}')"
|
| 237 |
+
class="self-start sm:self-center text-red-600 hover:text-red-800 hover:bg-red-50 px-3 py-1 rounded transition-colors text-sm">
|
| 238 |
+
Delete
|
| 239 |
+
</button>
|
| 240 |
</div>
|
|
|
|
| 241 |
</div>
|
| 242 |
+
{% endfor %}
|
| 243 |
+
</div>
|
| 244 |
|
| 245 |
{% elif media_type == 'tv' and media_details.seasons %}
|
| 246 |
+
<!-- TV Show Seasons and Episodes (sorted) -->
|
| 247 |
+
<div class="space-y-4 sm:space-y-6">
|
| 248 |
+
{% for season in media_details.seasons|sort(attribute='season_number') %}
|
| 249 |
+
<div class="border border-gray-200 rounded-lg overflow-hidden">
|
| 250 |
+
<!-- Season Header -->
|
| 251 |
+
<div
|
| 252 |
+
class="bg-gradient-to-r from-blue-50 to-indigo-50 px-4 sm:px-6 py-3 sm:py-4 border-b border-gray-200">
|
| 253 |
+
<div class="flex items-center justify-between">
|
| 254 |
+
<h4 class="text-base sm:text-lg font-semibold text-gray-900">Season {{ season.season_number }}
|
| 255 |
+
</h4>
|
| 256 |
+
<div class="flex items-center gap-2 sm:gap-4">
|
| 257 |
+
<span class="text-xs sm:text-sm text-gray-600">{{ season.episodes|length }} episode{{ 's' if
|
| 258 |
+
season.episodes|length != 1 else '' }}</span>
|
| 259 |
+
<button onclick="toggleSeason({{ loop.index0 }})"
|
| 260 |
+
class="text-blue-600 hover:text-blue-800 transition-colors p-1">
|
| 261 |
+
<svg id="season-arrow-{{ loop.index0 }}"
|
| 262 |
+
class="w-4 h-4 sm:w-5 sm:h-5 transform transition-transform" fill="none"
|
| 263 |
+
stroke="currentColor" viewBox="0 0 24 24">
|
| 264 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 265 |
+
d="M19 9l-7 7-7-7"></path>
|
| 266 |
+
</svg>
|
| 267 |
+
</button>
|
| 268 |
</div>
|
| 269 |
+
</div>
|
| 270 |
+
</div>
|
| 271 |
|
| 272 |
+
<!-- Episodes List (sorted by episode number) -->
|
| 273 |
+
<div id="season-content-{{ loop.index0 }}" class="season-content">
|
| 274 |
+
<div class="divide-y divide-gray-100">
|
| 275 |
+
{% for episode in season.episodes|sort(attribute='episode_number') %}
|
| 276 |
+
<div class="p-3 sm:p-4 hover:bg-gray-50 transition-colors">
|
| 277 |
+
<div class="flex flex-col sm:flex-row sm:items-start gap-3 sm:gap-4">
|
| 278 |
+
<!-- Episode Number -->
|
| 279 |
+
<div
|
| 280 |
+
class="flex-shrink-0 w-10 h-10 sm:w-12 sm:h-12 bg-blue-100 rounded-lg flex items-center justify-center mx-auto sm:mx-0">
|
| 281 |
+
<span class="text-sm font-bold text-blue-800">{{ episode.episode_number }}</span>
|
| 282 |
</div>
|
| 283 |
+
|
| 284 |
+
<!-- Episode Info -->
|
| 285 |
+
<div class="flex-1 min-w-0">
|
| 286 |
+
<h5 class="text-sm font-medium text-gray-900 mb-2 text-center sm:text-left">{{
|
| 287 |
+
episode.title }}</h5>
|
| 288 |
+
|
| 289 |
+
<!-- Episode Qualities (sorted by quality) -->
|
| 290 |
+
{% if episode.telegram %}
|
| 291 |
+
<div class="space-y-2">
|
| 292 |
+
{% set sorted_episode_qualities = episode.telegram|sort(attribute='quality') %}
|
| 293 |
+
{% for quality in sorted_episode_qualities %}
|
| 294 |
+
<div
|
| 295 |
+
class="flex flex-col sm:flex-row sm:items-center justify-between bg-white border border-gray-200 rounded-md p-3 gap-2 sm:gap-0">
|
| 296 |
+
<div class="flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3">
|
| 297 |
+
<span
|
| 298 |
+
class="inline-flex items-center px-2 py-1 rounded text-xs font-medium bg-green-100 text-green-800 w-fit">
|
| 299 |
+
{{ quality.quality }}
|
| 300 |
+
</span>
|
| 301 |
+
<span class="text-xs text-gray-500">{{ quality.size }}</span>
|
| 302 |
+
<span class="text-xs text-gray-400 break-all">{{ quality.name }}</span>
|
| 303 |
+
</div>
|
| 304 |
+
<div class="flex gap-2">
|
| 305 |
+
<button
|
| 306 |
+
onclick="copyStreamLink('{{ quality.id }}', '{{ quality.name }}')"
|
| 307 |
+
class="self-start sm:self-center text-green-600 hover:text-green-800 hover:bg-green-50 px-2 py-1 rounded transition-colors text-xs"
|
| 308 |
+
title="Copy direct stream link">
|
| 309 |
+
📋 Copy
|
| 310 |
+
</button>
|
| 311 |
+
<button
|
| 312 |
+
onclick="runSpeedTest('{{ quality.id }}', 'tv', '{{ quality.quality }}')"
|
| 313 |
+
class="self-start sm:self-center text-blue-600 hover:text-blue-800 hover:bg-blue-50 px-2 py-1 rounded transition-colors text-xs">
|
| 314 |
+
🚀 Speed Test
|
| 315 |
+
</button>
|
| 316 |
+
<button
|
| 317 |
+
onclick="deleteTVQuality({{ season.season_number }}, {{ episode.episode_number }}, '{{ quality.id }}')"
|
| 318 |
+
class="self-start sm:self-center text-red-600 hover:text-red-800 hover:bg-red-50 px-2 py-1 rounded transition-colors text-xs">
|
| 319 |
+
Delete
|
| 320 |
+
</button>
|
| 321 |
+
</div>
|
| 322 |
</div>
|
| 323 |
+
{% endfor %}
|
| 324 |
</div>
|
| 325 |
+
{% else %}
|
| 326 |
+
<p class="text-xs text-gray-400 text-center sm:text-left">No qualities available</p>
|
| 327 |
+
{% endif %}
|
| 328 |
+
</div>
|
| 329 |
+
|
| 330 |
+
<!-- Episode Actions -->
|
| 331 |
+
<div class="flex-shrink-0 flex justify-center sm:justify-start">
|
| 332 |
+
<button
|
| 333 |
+
onclick="deleteTVEpisode({{ season.season_number }}, {{ episode.episode_number }})"
|
| 334 |
+
class="text-red-600 hover:text-red-800 hover:bg-red-50 px-2 py-1 rounded text-xs transition-colors">
|
| 335 |
+
Delete Episode
|
| 336 |
+
</button>
|
| 337 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
</div>
|
| 339 |
</div>
|
| 340 |
+
{% endfor %}
|
| 341 |
+
</div>
|
| 342 |
+
|
| 343 |
+
<!-- Season Actions -->
|
| 344 |
+
<div class="px-3 sm:px-4 py-3 bg-gray-50 border-t border-gray-200 text-center sm:text-left">
|
| 345 |
+
<button onclick="deleteTVSeason({{ season.season_number }})"
|
| 346 |
+
class="text-red-600 hover:text-red-800 hover:bg-red-100 px-3 py-1 rounded text-sm transition-colors">
|
| 347 |
+
Delete Entire Season
|
| 348 |
+
</button>
|
| 349 |
</div>
|
| 350 |
</div>
|
|
|
|
| 351 |
</div>
|
| 352 |
+
{% endfor %}
|
| 353 |
+
</div>
|
| 354 |
{% else %}
|
| 355 |
+
<div class="text-center py-8">
|
| 356 |
+
<svg class="mx-auto h-12 w-12 text-gray-300 mb-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 357 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 358 |
+
d="M7 4V2a1 1 0 011-1h8a1 1 0 011 1v2h4a1 1 0 110 2h-1v12a2 2 0 01-2-2V6H3a1 1 0 110-2h4zM9 6v10h6V6H9z" />
|
| 359 |
+
</svg>
|
| 360 |
+
<p class="theme-text-secondary text-sm sm:text-base">No content available</p>
|
| 361 |
+
</div>
|
| 362 |
{% endif %}
|
| 363 |
</div>
|
| 364 |
{% endif %}
|
| 365 |
</div>
|
| 366 |
|
| 367 |
<script>
|
| 368 |
+
const tmdbId = {{ tmdb_id }};
|
| 369 |
+
const dbIndex = {{ db_index }};
|
| 370 |
+
const mediaType = '{{ media_type }}';
|
| 371 |
+
|
| 372 |
+
// Toggle season visibility
|
| 373 |
+
function toggleSeason(seasonIndex) {
|
| 374 |
+
const content = document.getElementById(`season-content-${seasonIndex}`);
|
| 375 |
+
const arrow = document.getElementById(`season-arrow-${seasonIndex}`);
|
| 376 |
+
|
| 377 |
+
if (content.style.display === 'none') {
|
| 378 |
+
content.style.display = 'block';
|
| 379 |
+
arrow.style.transform = 'rotate(0deg)';
|
| 380 |
+
} else {
|
| 381 |
+
content.style.display = 'none';
|
| 382 |
+
arrow.style.transform = 'rotate(-90deg)';
|
| 383 |
+
}
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
// Update media
|
| 387 |
+
async function updateMedia(event) {
|
| 388 |
+
event.preventDefault();
|
| 389 |
+
|
| 390 |
+
const formData = new FormData(event.target);
|
| 391 |
+
const updateData = {};
|
| 392 |
+
|
| 393 |
+
// Convert form data to object
|
| 394 |
+
for (let [key, value] of formData.entries()) {
|
| 395 |
+
if (key === 'genres') {
|
| 396 |
+
updateData[key] = value.split(',').map(g => g.trim()).filter(g => g);
|
| 397 |
+
} else if (key === 'rating' || key === 'release_year' || key === 'runtime') {
|
| 398 |
+
updateData[key] = value ? parseFloat(value) : null;
|
| 399 |
+
} else {
|
| 400 |
+
updateData[key] = value || null;
|
| 401 |
+
}
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
try {
|
| 405 |
+
const response = await fetch(`/api/media/update?tmdb_id=${tmdbId}&db_index=${dbIndex}&media_type=${mediaType}`, {
|
| 406 |
+
method: 'PUT',
|
| 407 |
+
headers: {
|
| 408 |
+
'Content-Type': 'application/json'
|
| 409 |
+
},
|
| 410 |
+
body: JSON.stringify(updateData)
|
| 411 |
+
});
|
| 412 |
+
|
| 413 |
+
if (response.ok) {
|
| 414 |
+
showSuccessMessage('Media updated successfully');
|
| 415 |
+
setTimeout(() => location.reload(), 1000);
|
| 416 |
+
} else {
|
| 417 |
+
const error = await response.json();
|
| 418 |
+
showErrorMessage(`Error updating media: ${error.detail || 'Unknown error'}`);
|
| 419 |
+
}
|
| 420 |
+
} catch (error) {
|
| 421 |
+
console.error('Error updating media:', error);
|
| 422 |
+
showErrorMessage('Error updating media. Please try again.');
|
| 423 |
+
}
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
// Delete name from movie
|
| 427 |
+
async function deleteQuality(id) {
|
| 428 |
+
if (!confirm(`Are you sure you want to delete the ${id} ?`)) return;
|
| 429 |
+
|
| 430 |
+
try {
|
| 431 |
+
const response = await fetch(`/api/media/delete-quality?tmdb_id=${tmdbId}&db_index=${dbIndex}&id=${encodeURIComponent(id)}`, {
|
| 432 |
+
method: 'DELETE'
|
| 433 |
+
});
|
| 434 |
+
|
| 435 |
+
if (response.ok) {
|
| 436 |
+
showSuccessMessage(`${id} deleted successfully`);
|
| 437 |
+
setTimeout(() => location.reload(), 1000);
|
| 438 |
+
} else {
|
| 439 |
+
const error = await response.json();
|
| 440 |
+
showErrorMessage(`Error deleting : ${error.detail || 'Unknown error'}`);
|
| 441 |
+
}
|
| 442 |
+
} catch (error) {
|
| 443 |
+
console.error('Error deleting :', error);
|
| 444 |
+
showErrorMessage('Error deleting . Please try again.');
|
| 445 |
+
}
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
// Delete TV quality
|
| 449 |
+
async function deleteTVQuality(season, episode, id) {
|
| 450 |
+
if (!confirm(`Are you sure you want to delete the ${id} from Season ${season} Episode ${episode}?`)) return;
|
| 451 |
+
|
| 452 |
+
try {
|
| 453 |
+
const response = await fetch(`/api/media/delete-tv-quality?tmdb_id=${tmdbId}&db_index=${dbIndex}&season=${season}&episode=${episode}&id=${encodeURIComponent(id)}`, {
|
| 454 |
+
method: 'DELETE'
|
| 455 |
+
});
|
| 456 |
+
|
| 457 |
+
if (response.ok) {
|
| 458 |
+
showSuccessMessage(`${id} deleted successfully`);
|
| 459 |
+
setTimeout(() => location.reload(), 1000);
|
| 460 |
+
} else {
|
| 461 |
+
const error = await response.json();
|
| 462 |
+
showErrorMessage(`Error deleting : ${error.detail || 'Unknown error'}`);
|
| 463 |
+
}
|
| 464 |
+
} catch (error) {
|
| 465 |
+
console.error('Error deleting :', error);
|
| 466 |
+
showErrorMessage('Error deleting. Please try again.');
|
| 467 |
+
}
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
+
// Delete TV episode
|
| 471 |
+
async function deleteTVEpisode(season, episode) {
|
| 472 |
+
if (!confirm(`Are you sure you want to delete Season ${season} Episode ${episode}?\n\nThis will remove the entire episode and all its qualities.`)) return;
|
| 473 |
+
|
| 474 |
+
try {
|
| 475 |
+
const response = await fetch(`/api/media/delete-tv-episode?tmdb_id=${tmdbId}&db_index=${dbIndex}&season=${season}&episode=${episode}`, {
|
| 476 |
+
method: 'DELETE'
|
| 477 |
+
});
|
| 478 |
+
|
| 479 |
+
if (response.ok) {
|
| 480 |
+
showSuccessMessage(`Episode ${episode} deleted successfully`);
|
| 481 |
+
setTimeout(() => location.reload(), 1000);
|
| 482 |
+
} else {
|
| 483 |
+
const error = await response.json();
|
| 484 |
+
showErrorMessage(`Error deleting episode: ${error.detail || 'Unknown error'}`);
|
| 485 |
+
}
|
| 486 |
+
} catch (error) {
|
| 487 |
+
console.error('Error deleting episode:', error);
|
| 488 |
+
showErrorMessage('Error deleting episode. Please try again.');
|
| 489 |
+
}
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
// Delete TV season
|
| 493 |
+
async function deleteTVSeason(season) {
|
| 494 |
+
if (!confirm(`Are you sure you want to delete the entire Season ${season}?\n\nThis will remove all episodes and qualities in this season. This action cannot be undone.`)) return;
|
| 495 |
+
|
| 496 |
+
try {
|
| 497 |
+
const response = await fetch(`/api/media/delete-tv-season?tmdb_id=${tmdbId}&db_index=${dbIndex}&season=${season}`, {
|
| 498 |
+
method: 'DELETE'
|
| 499 |
+
});
|
| 500 |
+
|
| 501 |
+
if (response.ok) {
|
| 502 |
+
showSuccessMessage(`Season ${season} deleted successfully`);
|
| 503 |
+
setTimeout(() => location.reload(), 1000);
|
| 504 |
+
} else {
|
| 505 |
+
const error = await response.json();
|
| 506 |
+
showErrorMessage(`Error deleting season: ${error.detail || 'Unknown error'}`);
|
| 507 |
+
}
|
| 508 |
+
} catch (error) {
|
| 509 |
+
console.error('Error deleting season:', error);
|
| 510 |
+
showErrorMessage('Error deleting season. Please try again.');
|
| 511 |
+
}
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
// Show success message
|
| 515 |
+
function showSuccessMessage(message) {
|
| 516 |
+
const msg = document.createElement('div');
|
| 517 |
+
msg.className = 'fixed top-4 right-4 bg-green-500 text-white px-4 sm:px-6 py-3 rounded-lg shadow-lg z-50 flex items-center max-w-sm';
|
| 518 |
+
msg.innerHTML = `
|
| 519 |
+
<svg class="w-4 h-4 sm:w-5 sm:h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 520 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
|
| 521 |
+
</svg>
|
| 522 |
+
<span class="text-sm">${message}</span>
|
| 523 |
+
`;
|
| 524 |
+
document.body.appendChild(msg);
|
| 525 |
+
setTimeout(() => {
|
| 526 |
+
if (document.body.contains(msg)) {
|
| 527 |
+
document.body.removeChild(msg);
|
| 528 |
+
}
|
| 529 |
+
}, 4000);
|
| 530 |
+
}
|
| 531 |
+
|
| 532 |
+
// Show error message
|
| 533 |
+
function showErrorMessage(message) {
|
| 534 |
+
const msg = document.createElement('div');
|
| 535 |
+
msg.className = 'fixed top-4 right-4 bg-red-500 text-white px-4 sm:px-6 py-3 rounded-lg shadow-lg z-50 flex items-center max-w-sm';
|
| 536 |
+
msg.innerHTML = `
|
| 537 |
+
<svg class="w-4 h-4 sm:w-5 sm:h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 538 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
|
| 539 |
+
</svg>
|
| 540 |
+
<span class="text-sm">${message}</span>
|
| 541 |
+
`;
|
| 542 |
+
document.body.appendChild(msg);
|
| 543 |
+
setTimeout(() => {
|
| 544 |
+
if (document.body.contains(msg)) {
|
| 545 |
+
document.body.removeChild(msg);
|
| 546 |
+
}
|
| 547 |
+
}, 5000);
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
+
// Initialize page
|
| 551 |
document.addEventListener('DOMContentLoaded', () => {
|
| 552 |
+
// Initialize all seasons as collapsed except the first one
|
| 553 |
+
document.querySelectorAll('.season-content').forEach((content, index) => {
|
| 554 |
+
if (index > 0) {
|
| 555 |
+
content.style.display = 'none';
|
| 556 |
+
document.getElementById(`season-arrow-${index}`).style.transform = 'rotate(-90deg)';
|
| 557 |
+
}
|
| 558 |
+
});
|
| 559 |
});
|
| 560 |
+
|
| 561 |
+
// Copy direct stream link to clipboard
|
| 562 |
+
function copyStreamLink(qualityId, fileName) {
|
| 563 |
+
// Try to find token from existing manifest URLs on the dashboard,
|
| 564 |
+
// fall back to prompting the user.
|
| 565 |
+
const base = window.location.origin;
|
| 566 |
+
|
| 567 |
+
// Ask user which token to use (pulled from cookies or prompt)
|
| 568 |
+
const token = getCopylinkToken();
|
| 569 |
+
if (!token) {
|
| 570 |
+
showErrorMessage('No API token found. Please copy the link from the Dashboard page.');
|
| 571 |
+
return;
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
const encodedName = encodeURIComponent(fileName || 'stream');
|
| 575 |
+
const url = `${base}/dl/${token}/${qualityId}/${encodedName}`;
|
| 576 |
+
navigator.clipboard.writeText(url).then(() => {
|
| 577 |
+
showSuccessMessage('Stream link copied to clipboard!');
|
| 578 |
+
}).catch(() => {
|
| 579 |
+
// Fallback: show the URL in a prompt
|
| 580 |
+
prompt('Copy this stream link:', url);
|
| 581 |
+
});
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
function getCopylinkToken() {
|
| 585 |
+
// Check sessionStorage / localStorage for a cached token
|
| 586 |
+
return sessionStorage.getItem('api_token') || localStorage.getItem('api_token') || null;
|
| 587 |
+
}
|
| 588 |
+
</script>
|
| 589 |
+
|
| 590 |
+
<style>
|
| 591 |
+
.season-content {
|
| 592 |
+
transition: all 0.3s ease;
|
| 593 |
+
}
|
| 594 |
+
|
| 595 |
+
.break-all {
|
| 596 |
+
word-break: break-all;
|
| 597 |
+
overflow-wrap: break-word;
|
| 598 |
+
}
|
| 599 |
+
|
| 600 |
+
@keyframes spin {
|
| 601 |
+
to {
|
| 602 |
+
transform: rotate(360deg);
|
| 603 |
+
}
|
| 604 |
+
}
|
| 605 |
+
|
| 606 |
+
.st-spin {
|
| 607 |
+
animation: spin 1s linear infinite;
|
| 608 |
+
}
|
| 609 |
+
</style>
|
| 610 |
+
|
| 611 |
+
<!-- ===== SPEED TEST MODAL ===== -->
|
| 612 |
+
<div id="speed-test-modal" class="fixed inset-0 z-50 hidden" aria-modal="true" role="dialog">
|
| 613 |
+
<!-- Backdrop -->
|
| 614 |
+
<div class="absolute inset-0 bg-black/60" style="backdrop-filter:blur(4px)" onclick="closeSpeedTest()"></div>
|
| 615 |
+
|
| 616 |
+
<!-- Panel -->
|
| 617 |
+
<div class="absolute left-1/2 top-1/2 w-full max-w-2xl mx-4 bg-white rounded-2xl shadow-2xl overflow-hidden"
|
| 618 |
+
style="transform:translate(-50%,-50%)">
|
| 619 |
+
|
| 620 |
+
<!-- Header -->
|
| 621 |
+
<div
|
| 622 |
+
class="flex items-center justify-between px-6 py-4 border-b border-gray-200 bg-gradient-to-r from-blue-600 to-indigo-600">
|
| 623 |
+
<div>
|
| 624 |
+
<h2 class="text-lg font-bold text-white">🚀 DC Speed Test</h2>
|
| 625 |
+
<p id="st-label" class="text-xs text-blue-100 mt-0.5"></p>
|
| 626 |
+
</div>
|
| 627 |
+
<button onclick="closeSpeedTest()"
|
| 628 |
+
class="text-white/70 hover:text-white text-3xl leading-none transition-colors">×</button>
|
| 629 |
+
</div>
|
| 630 |
+
|
| 631 |
+
<!-- Body -->
|
| 632 |
+
<div class="px-6 py-6 min-h-[200px]">
|
| 633 |
+
<!-- Spinner -->
|
| 634 |
+
<div id="st-spinner" class="flex flex-col items-center gap-4 py-10">
|
| 635 |
+
<div class="w-14 h-14 rounded-full border-4 border-blue-100 border-t-blue-600 st-spin"></div>
|
| 636 |
+
<p class="text-sm text-gray-500">Testing all DC clients simultaneously…</p>
|
| 637 |
+
<p class="text-xs text-gray-400">Downloading 100 MB from each bot client</p>
|
| 638 |
+
</div>
|
| 639 |
+
|
| 640 |
+
<!-- Results table -->
|
| 641 |
+
<div id="st-results" class="hidden">
|
| 642 |
+
<div class="overflow-x-auto rounded-xl border border-gray-200">
|
| 643 |
+
<table class="w-full text-sm">
|
| 644 |
+
<thead class="bg-gray-50 text-left">
|
| 645 |
+
<tr>
|
| 646 |
+
<th class="px-4 py-3 font-semibold text-gray-600 text-xs uppercase tracking-wider">Bot /
|
| 647 |
+
DC</th>
|
| 648 |
+
<th class="px-4 py-3 font-semibold text-gray-600 text-xs uppercase tracking-wider">Ping
|
| 649 |
+
</th>
|
| 650 |
+
<th class="px-4 py-3 font-semibold text-gray-600 text-xs uppercase tracking-wider">Speed
|
| 651 |
+
</th>
|
| 652 |
+
<th class="px-4 py-3 font-semibold text-gray-600 text-xs uppercase tracking-wider">Time
|
| 653 |
+
</th>
|
| 654 |
+
<th class="px-4 py-3 font-semibold text-gray-600 text-xs uppercase tracking-wider">
|
| 655 |
+
Downloaded</th>
|
| 656 |
+
<th class="px-4 py-3 font-semibold text-gray-600 text-xs uppercase tracking-wider">
|
| 657 |
+
Status</th>
|
| 658 |
+
</tr>
|
| 659 |
+
</thead>
|
| 660 |
+
<tbody id="st-tbody" class="divide-y divide-gray-100 bg-white"></tbody>
|
| 661 |
+
</table>
|
| 662 |
+
</div>
|
| 663 |
+
<p id="st-summary" class="text-xs text-gray-400 mt-3 text-right"></p>
|
| 664 |
+
</div>
|
| 665 |
+
|
| 666 |
+
<!-- Error banner -->
|
| 667 |
+
<div id="st-error" class="hidden bg-red-50 border border-red-200 rounded-xl px-4 py-3 text-sm text-red-700">
|
| 668 |
+
</div>
|
| 669 |
+
</div>
|
| 670 |
+
|
| 671 |
+
<!-- Footer -->
|
| 672 |
+
<div class="flex justify-end gap-3 px-6 py-4 border-t border-gray-100 bg-gray-50">
|
| 673 |
+
<button id="st-rerun-btn" onclick="rerunSpeedTest()"
|
| 674 |
+
class="hidden px-4 py-2 text-sm font-medium bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors">
|
| 675 |
+
🔄 Re-run
|
| 676 |
+
</button>
|
| 677 |
+
<button onclick="closeSpeedTest()"
|
| 678 |
+
class="px-4 py-2 text-sm font-medium border border-gray-300 rounded-lg hover:bg-gray-100 transition-colors">
|
| 679 |
+
Close
|
| 680 |
+
</button>
|
| 681 |
+
</div>
|
| 682 |
+
</div>
|
| 683 |
+
</div>
|
| 684 |
+
|
| 685 |
+
<script>
|
| 686 |
+
// ─── Speed Test JS ────────────────────────────────────────────────────────────
|
| 687 |
+
let _stQualityId = null;
|
| 688 |
+
let _stMediaType = null;
|
| 689 |
+
let _stLabel = null;
|
| 690 |
+
|
| 691 |
+
async function runSpeedTest(qualityId, mediaTypeArg, label) {
|
| 692 |
+
_stQualityId = qualityId;
|
| 693 |
+
_stMediaType = mediaTypeArg;
|
| 694 |
+
_stLabel = label;
|
| 695 |
+
_openModal(label);
|
| 696 |
+
await _exec();
|
| 697 |
+
}
|
| 698 |
+
|
| 699 |
+
async function rerunSpeedTest() {
|
| 700 |
+
if (!_stQualityId) return;
|
| 701 |
+
_resetUI(_stLabel);
|
| 702 |
+
await _exec();
|
| 703 |
+
}
|
| 704 |
+
|
| 705 |
+
function _openModal(label) {
|
| 706 |
+
document.getElementById('speed-test-modal').classList.remove('hidden');
|
| 707 |
+
document.body.style.overflow = 'hidden';
|
| 708 |
+
_resetUI(label);
|
| 709 |
+
}
|
| 710 |
+
|
| 711 |
+
function _resetUI(label) {
|
| 712 |
+
document.getElementById('st-label').textContent = label ? `File: ${label}` : '';
|
| 713 |
+
document.getElementById('st-spinner').classList.remove('hidden');
|
| 714 |
+
document.getElementById('st-results').classList.add('hidden');
|
| 715 |
+
document.getElementById('st-error').classList.add('hidden');
|
| 716 |
+
document.getElementById('st-rerun-btn').classList.add('hidden');
|
| 717 |
+
document.getElementById('st-tbody').innerHTML = '';
|
| 718 |
+
document.getElementById('st-summary').textContent = '';
|
| 719 |
+
}
|
| 720 |
+
|
| 721 |
+
function closeSpeedTest() {
|
| 722 |
+
document.getElementById('speed-test-modal').classList.add('hidden');
|
| 723 |
+
document.body.style.overflow = '';
|
| 724 |
+
}
|
| 725 |
+
|
| 726 |
+
function _pingClass(ms) {
|
| 727 |
+
if (ms === null) return 'text-gray-400';
|
| 728 |
+
if (ms < 100) return 'text-green-600 font-semibold';
|
| 729 |
+
if (ms < 300) return 'text-yellow-600 font-semibold';
|
| 730 |
+
return 'text-red-600 font-semibold';
|
| 731 |
+
}
|
| 732 |
+
|
| 733 |
+
function _speedClass(mbps) {
|
| 734 |
+
if (mbps === null) return 'text-gray-400';
|
| 735 |
+
if (mbps >= 20) return 'text-green-600 font-bold';
|
| 736 |
+
if (mbps >= 5) return 'text-yellow-600 font-bold';
|
| 737 |
+
return 'text-red-600 font-bold';
|
| 738 |
+
}
|
| 739 |
+
|
| 740 |
+
function _miniBar(value, max, color) {
|
| 741 |
+
if (!value || !max) return '';
|
| 742 |
+
const pct = Math.min(100, (value / max) * 100).toFixed(1);
|
| 743 |
+
return `<div class="w-full bg-gray-100 rounded-full h-1.5 mt-1">
|
| 744 |
+
<div class="${color} h-1.5 rounded-full transition-all" style="width:${pct}%"></div>
|
| 745 |
+
</div>`;
|
| 746 |
+
}
|
| 747 |
+
|
| 748 |
+
async function _exec() {
|
| 749 |
+
const params = new URLSearchParams({
|
| 750 |
+
quality_id: _stQualityId,
|
| 751 |
+
tmdb_id: tmdbId,
|
| 752 |
+
db_index: dbIndex,
|
| 753 |
+
media_type: mediaType // from template context (movie/tv)
|
| 754 |
+
});
|
| 755 |
+
|
| 756 |
+
// Close any old connection
|
| 757 |
+
if (window._stEventSource) {
|
| 758 |
+
window._stEventSource.close();
|
| 759 |
+
window._stEventSource = null;
|
| 760 |
+
}
|
| 761 |
+
|
| 762 |
+
let maxSpeed = 1;
|
| 763 |
+
let completedCount = 0;
|
| 764 |
+
let totalCount = 0;
|
| 765 |
+
const allResults = [];
|
| 766 |
+
const pendingRows = {};
|
| 767 |
+
|
| 768 |
+
const es = new EventSource(`/api/system/speedtest/stream?${params}`);
|
| 769 |
+
window._stEventSource = es;
|
| 770 |
+
|
| 771 |
+
function updateSummary() {
|
| 772 |
+
const best = allResults.filter(r => r.speed_mbps).sort((a, b) => b.speed_mbps - a.speed_mbps)[0];
|
| 773 |
+
const summaryEl = document.getElementById('st-summary');
|
| 774 |
+
if (best) {
|
| 775 |
+
summaryEl.textContent = `🏆 Fastest: DC ${best.dc_id} — ${best.speed_mbps.toFixed(2)} MB/s | ${completedCount}/${totalCount} client(s) done`;
|
| 776 |
+
} else {
|
| 777 |
+
summaryEl.textContent = `${completedCount}/${totalCount} client(s) done`;
|
| 778 |
+
}
|
| 779 |
+
}
|
| 780 |
+
|
| 781 |
+
es.onmessage = (e) => {
|
| 782 |
+
let msg;
|
| 783 |
+
try { msg = JSON.parse(e.data); } catch { return; }
|
| 784 |
+
|
| 785 |
+
if (msg.type === 'error') {
|
| 786 |
+
es.close();
|
| 787 |
+
document.getElementById('st-spinner').classList.add('hidden');
|
| 788 |
+
document.getElementById('st-error').textContent = `Speed test stream error: ${msg.message}`;
|
| 789 |
+
document.getElementById('st-error').classList.remove('hidden');
|
| 790 |
+
document.getElementById('st-rerun-btn').classList.remove('hidden');
|
| 791 |
+
return;
|
| 792 |
+
}
|
| 793 |
+
|
| 794 |
+
if (msg.type === 'start') {
|
| 795 |
+
totalCount = msg.total;
|
| 796 |
+
document.getElementById('st-spinner').classList.add('hidden');
|
| 797 |
+
document.getElementById('st-results').classList.remove('hidden');
|
| 798 |
+
|
| 799 |
+
if (msg.target_dc && msg.target_dc !== "?") {
|
| 800 |
+
document.getElementById('st-label').innerHTML += ` | Target DC: <span class="text-white font-semibold">${msg.target_dc}</span>`;
|
| 801 |
+
}
|
| 802 |
+
|
| 803 |
+
const tbody = document.getElementById('st-tbody');
|
| 804 |
+
tbody.innerHTML = '';
|
| 805 |
+
for (let i = 0; i < totalCount; i++) {
|
| 806 |
+
const tr = document.createElement('tr');
|
| 807 |
+
tr.className = 'animate-pulse';
|
| 808 |
+
tr.innerHTML = `
|
| 809 |
+
<td class="px-4 py-3 font-medium text-gray-400">🔄 Bot ${i + 1}</td>
|
| 810 |
+
<td class="px-4 py-3"><span class="text-gray-300">testing…</span></td>
|
| 811 |
+
<td class="px-4 py-3"><span class="text-gray-300">testing…</span></td>
|
| 812 |
+
<td class="px-4 py-3 text-gray-300">—</td>
|
| 813 |
+
<td class="px-4 py-3 text-gray-300">—</td>
|
| 814 |
+
<td class="px-4 py-3"><span class="px-2 py-0.5 rounded-full text-xs bg-gray-100 text-gray-400">Pending</span></td>`;
|
| 815 |
+
tbody.appendChild(tr);
|
| 816 |
+
pendingRows[i] = tr;
|
| 817 |
+
}
|
| 818 |
+
updateSummary();
|
| 819 |
+
}
|
| 820 |
+
|
| 821 |
+
if (msg.type === 'progress') {
|
| 822 |
+
const r = msg.data;
|
| 823 |
+
const tr = pendingRows[r.client_index];
|
| 824 |
+
if (tr) {
|
| 825 |
+
maxSpeed = Math.max(maxSpeed, r.speed_mbps || 0, 1);
|
| 826 |
+
|
| 827 |
+
const ping = r.ping_ms !== null ? `<span class="${_pingClass(r.ping_ms)}">${r.ping_ms} ms</span>` : '<span class="text-gray-400">—</span>';
|
| 828 |
+
const speed = r.speed_mbps !== null
|
| 829 |
+
? `<span class="${_speedClass(r.speed_mbps)}">${r.speed_mbps.toFixed(2)} MB/s</span>
|
| 830 |
+
${_miniBar(r.speed_mbps, maxSpeed, r.speed_mbps >= 20 ? 'bg-green-500' : r.speed_mbps >= 5 ? 'bg-yellow-400' : 'bg-red-400')}`
|
| 831 |
+
: '<span class="text-gray-400">—</span>';
|
| 832 |
+
const taken = r.time_taken_sec !== null ? `${r.time_taken_sec.toFixed(2)}s` : '—';
|
| 833 |
+
const bytes = r.bytes_downloaded ? `${(r.bytes_downloaded / 1048576).toFixed(2)} MB` : '—';
|
| 834 |
+
|
| 835 |
+
// Update the innerHTML of the pending row cells
|
| 836 |
+
tr.innerHTML = `
|
| 837 |
+
<td class="px-4 py-3 font-medium text-gray-700">🔄 Bot ${r.client_index + 1} <span class="text-xs text-gray-400">(DC ${r.dc_id})</span></td>
|
| 838 |
+
<td class="px-4 py-3">${ping}</td>
|
| 839 |
+
<td class="px-4 py-3">${speed}</td>
|
| 840 |
+
<td class="px-4 py-3 text-gray-600 text-sm">${taken}</td>
|
| 841 |
+
<td class="px-4 py-3 text-gray-500 text-xs">${bytes}</td>
|
| 842 |
+
<td class="px-4 py-3"><span class="px-2 py-0.5 rounded-full text-xs bg-blue-100 text-blue-700 animate-pulse">Running…</span></td>`;
|
| 843 |
+
}
|
| 844 |
+
}
|
| 845 |
+
|
| 846 |
+
if (msg.type === 'result') {
|
| 847 |
+
completedCount = msg.completed;
|
| 848 |
+
totalCount = msg.total;
|
| 849 |
+
const r = msg.data;
|
| 850 |
+
allResults.push(r);
|
| 851 |
+
|
| 852 |
+
maxSpeed = Math.max(maxSpeed, r.speed_mbps || 0, 1);
|
| 853 |
+
|
| 854 |
+
const isErr = !!r.error && !r.speed_mbps;
|
| 855 |
+
// Currently best logic isn't perfect until all finish, but we try
|
| 856 |
+
const medal = '';
|
| 857 |
+
const dc = `Bot ${r.client_index + 1} <span class="text-xs text-gray-400">(DC ${r.dc_id})</span>`;
|
| 858 |
+
const ping = r.ping_ms !== null ? `<span class="${_pingClass(r.ping_ms)}">${r.ping_ms} ms</span>` : '<span class="text-gray-400">—</span>';
|
| 859 |
+
const speed = r.speed_mbps !== null
|
| 860 |
+
? `<span class="${_speedClass(r.speed_mbps)}">${r.speed_mbps.toFixed(2)} MB/s</span>
|
| 861 |
+
${_miniBar(r.speed_mbps, maxSpeed, r.speed_mbps >= 20 ? 'bg-green-500' : r.speed_mbps >= 5 ? 'bg-yellow-400' : 'bg-red-400')}`
|
| 862 |
+
: '<span class="text-gray-400">—</span>';
|
| 863 |
+
const taken = r.time_taken_sec !== null ? `${r.time_taken_sec.toFixed(2)}s` : '—';
|
| 864 |
+
const bytes = r.bytes_downloaded ? `${(r.bytes_downloaded / 1048576).toFixed(2)} MB` : '—';
|
| 865 |
+
const badge = isErr
|
| 866 |
+
? `<span class="px-2 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-700">Error</span>`
|
| 867 |
+
: `<span class="px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-700">✓ OK</span>`;
|
| 868 |
+
|
| 869 |
+
const tr = document.createElement('tr');
|
| 870 |
+
tr.className = `hover:bg-blue-50 transition-colors ${isErr ? 'opacity-60' : ''}`;
|
| 871 |
+
tr.innerHTML = `
|
| 872 |
+
<td class="px-4 py-3 font-medium">${medal}${dc}</td>
|
| 873 |
+
<td class="px-4 py-3">${ping}</td>
|
| 874 |
+
<td class="px-4 py-3">${speed}${isErr ? `<div class="text-xs text-red-500 mt-1">${r.error}</div>` : ''}</td>
|
| 875 |
+
<td class="px-4 py-3 text-gray-600 text-sm">${taken}</td>
|
| 876 |
+
<td class="px-4 py-3 text-gray-500 text-xs">${bytes}</td>
|
| 877 |
+
<td class="px-4 py-3">${badge}</td>`;
|
| 878 |
+
|
| 879 |
+
if (pendingRows[r.client_index]) {
|
| 880 |
+
pendingRows[r.client_index].replaceWith(tr);
|
| 881 |
+
delete pendingRows[r.client_index];
|
| 882 |
+
} else {
|
| 883 |
+
document.getElementById('st-tbody').appendChild(tr);
|
| 884 |
+
}
|
| 885 |
+
|
| 886 |
+
updateSummary();
|
| 887 |
+
}
|
| 888 |
+
|
| 889 |
+
if (msg.type === 'done') {
|
| 890 |
+
es.close();
|
| 891 |
+
window._stEventSource = null;
|
| 892 |
+
|
| 893 |
+
// Re-sort everything to put fastest at the top with a medal
|
| 894 |
+
allResults.sort((a, b) => (b.speed_mbps || 0) - (a.speed_mbps || 0));
|
| 895 |
+
|
| 896 |
+
const tbody = document.getElementById('st-tbody');
|
| 897 |
+
tbody.innerHTML = '';
|
| 898 |
+
|
| 899 |
+
for (let i = 0; i < allResults.length; i++) {
|
| 900 |
+
const r = allResults[i];
|
| 901 |
+
const isErr = !!r.error && !r.speed_mbps;
|
| 902 |
+
const medal = i === 0 && !isErr ? '🥇 ' : '';
|
| 903 |
+
const dc = `Bot ${r.client_index + 1} <span class="text-xs text-gray-400">(DC ${r.dc_id})</span>`;
|
| 904 |
+
const ping = r.ping_ms !== null ? `<span class="${_pingClass(r.ping_ms)}">${r.ping_ms} ms</span>` : '<span class="text-gray-400">—</span>';
|
| 905 |
+
const speed = r.speed_mbps !== null
|
| 906 |
+
? `<span class="${_speedClass(r.speed_mbps)}">${r.speed_mbps.toFixed(2)} MB/s</span>
|
| 907 |
+
${_miniBar(r.speed_mbps, maxSpeed, r.speed_mbps >= 20 ? 'bg-green-500' : r.speed_mbps >= 5 ? 'bg-yellow-400' : 'bg-red-400')}`
|
| 908 |
+
: '<span class="text-gray-400">—</span>';
|
| 909 |
+
const taken = r.time_taken_sec !== null ? `${r.time_taken_sec.toFixed(2)}s` : '—';
|
| 910 |
+
const bytes = r.bytes_downloaded ? `${(r.bytes_downloaded / 1048576).toFixed(2)} MB` : '—';
|
| 911 |
+
const badge = isErr
|
| 912 |
+
? `<span class="px-2 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-700">Error</span>`
|
| 913 |
+
: `<span class="px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-700">✓ OK</span>`;
|
| 914 |
+
|
| 915 |
+
const tr = document.createElement('tr');
|
| 916 |
+
tr.className = `hover:bg-blue-50 transition-colors ${isErr ? 'opacity-60' : ''}`;
|
| 917 |
+
tr.innerHTML = `
|
| 918 |
+
<td class="px-4 py-3 font-medium">${medal}${dc}</td>
|
| 919 |
+
<td class="px-4 py-3">${ping}</td>
|
| 920 |
+
<td class="px-4 py-3">${speed}${isErr ? `<div class="text-xs text-red-500 mt-1">${r.error}</div>` : ''}</td>
|
| 921 |
+
<td class="px-4 py-3 text-gray-600 text-sm">${taken}</td>
|
| 922 |
+
<td class="px-4 py-3 text-gray-500 text-xs">${bytes}</td>
|
| 923 |
+
<td class="px-4 py-3">${badge}</td>`;
|
| 924 |
+
tbody.appendChild(tr);
|
| 925 |
+
}
|
| 926 |
+
|
| 927 |
+
document.getElementById('st-rerun-btn').classList.remove('hidden');
|
| 928 |
+
updateSummary();
|
| 929 |
+
}
|
| 930 |
+
};
|
| 931 |
+
|
| 932 |
+
es.onerror = (err) => {
|
| 933 |
+
es.close();
|
| 934 |
+
window._stEventSource = null;
|
| 935 |
+
if (completedCount === 0) {
|
| 936 |
+
document.getElementById('st-spinner').classList.add('hidden');
|
| 937 |
+
document.getElementById('st-error').textContent = 'Live tracking connection failed or interrupted.';
|
| 938 |
+
document.getElementById('st-error').classList.remove('hidden');
|
| 939 |
+
}
|
| 940 |
+
document.getElementById('st-rerun-btn').classList.remove('hidden');
|
| 941 |
+
};
|
| 942 |
+
}
|
| 943 |
+
|
| 944 |
+
// Close on Escape key
|
| 945 |
+
document.addEventListener('keydown', e => { if (e.key === 'Escape') closeSpeedTest(); });
|
| 946 |
</script>
|
| 947 |
+
|
| 948 |
+
{% endblock %}
|
Backend/fastapi/templates/media_management.html
CHANGED
|
@@ -3,162 +3,478 @@
|
|
| 3 |
{% block title %}Media Management - 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 |
-
<
|
|
|
|
| 8 |
<div>
|
| 9 |
-
<h1 class="text-3xl font-bold
|
| 10 |
-
<p class="theme-text-secondary mt-
|
| 11 |
-
<span class="w-2 h-2 rounded-full bg-primary animate-pulse"></span>
|
| 12 |
-
Manage your {{ media_type }} collection and metadata.
|
| 13 |
-
</p>
|
| 14 |
</div>
|
| 15 |
|
| 16 |
-
<div class="flex
|
| 17 |
<a href="/media/manage?media_type=movie"
|
| 18 |
-
class="px-
|
| 19 |
Movies
|
| 20 |
</a>
|
| 21 |
<a href="/media/manage?media_type=tv"
|
| 22 |
-
class="px-
|
| 23 |
TV Shows
|
| 24 |
</a>
|
| 25 |
</div>
|
| 26 |
</div>
|
| 27 |
|
| 28 |
-
<
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
</svg>
|
| 35 |
-
</div>
|
| 36 |
-
<input type="text" id="search-input" placeholder="Search by title..."
|
| 37 |
-
class="w-full pl-10 pr-4 py-2.5 theme-input rounded-xl focus:ring-2 focus:ring-primary/50 transition-all text-sm border-none shadow-sm">
|
| 38 |
</div>
|
| 39 |
<div class="flex gap-2">
|
| 40 |
<button onclick="searchMedia()"
|
| 41 |
-
class="bg-
|
| 42 |
Search
|
| 43 |
</button>
|
| 44 |
<button onclick="clearSearch()"
|
| 45 |
-
class="
|
| 46 |
-
|
| 47 |
</button>
|
| 48 |
</div>
|
| 49 |
</div>
|
| 50 |
</div>
|
| 51 |
|
| 52 |
-
<
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
</div>
|
| 57 |
-
<p class="theme-text-secondary mt-4 font-medium animate-pulse">Retrieving your library...</p>
|
| 58 |
</div>
|
| 59 |
|
|
|
|
| 60 |
<div id="error-display" class="hidden mb-8">
|
| 61 |
-
<div class="
|
| 62 |
-
<div class="
|
| 63 |
-
<svg class="h-
|
| 64 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
|
|
| 65 |
</svg>
|
|
|
|
| 66 |
</div>
|
| 67 |
-
<
|
| 68 |
-
<
|
| 69 |
-
|
| 70 |
-
|
| 71 |
</button>
|
| 72 |
</div>
|
| 73 |
</div>
|
| 74 |
|
| 75 |
-
<
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
-
<
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
</
|
| 85 |
-
<h3 class="text-
|
| 86 |
-
<p class="theme-text-secondary text-sm mb-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
</button>
|
| 90 |
</div>
|
| 91 |
</div>
|
| 92 |
|
| 93 |
-
<
|
| 94 |
-
|
|
|
|
|
|
|
| 95 |
|
| 96 |
-
<
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
</span>
|
| 102 |
-
<span id="db-info" class="bg-gray-200 dark:bg-gray-700 px-3 py-1 rounded-full"></span>
|
| 103 |
</div>
|
| 104 |
</div>
|
| 105 |
</div>
|
| 106 |
|
| 107 |
<script>
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
function createMediaCard(item) {
|
| 110 |
const title = item.title || item.name || 'Unknown Title';
|
| 111 |
-
const year = item.release_year || '
|
| 112 |
-
const rating = item.rating ? parseFloat(item.rating).toFixed(1) :
|
| 113 |
const poster = item.poster || 'https://via.placeholder.com/300x450/e5e7eb/9ca3af?text=No+Image';
|
| 114 |
|
| 115 |
return `
|
| 116 |
-
<div class="
|
| 117 |
-
<div class="relative
|
| 118 |
-
<
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
<div class="absolute top-2 right-2 bg-black/60 backdrop-blur-md text-white text-[10px] font-bold px-2 py-1 rounded-lg flex items-center gap-1 border border-white/10">
|
| 125 |
-
<svg class="w-3 h-3 text-yellow-400" fill="currentColor" viewBox="0 0 20 20"><path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/></svg>
|
| 126 |
-
${rating}
|
| 127 |
-
</div>
|
| 128 |
-
` : ''}
|
| 129 |
-
|
| 130 |
-
<div class="absolute inset-0 bg-gradient-to-t from-black/80 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-end p-4">
|
| 131 |
-
<div class="flex gap-2 w-full">
|
| 132 |
-
<a href="/media/edit?tmdb_id=${item.tmdb_id}&db_index=${item.db_index}&media_type=${mediaType}"
|
| 133 |
-
class="flex-1 bg-white text-black py-2 rounded-lg text-xs font-bold text-center hover:bg-primary hover:text-white transition-colors">
|
| 134 |
-
Edit
|
| 135 |
-
</a>
|
| 136 |
-
<button onclick="deleteMedia(${item.tmdb_id}, ${item.db_index}, '${title.replace(/'/g, "\\'")}')"
|
| 137 |
-
class="bg-red-500/20 hover:bg-red-500 backdrop-blur-sm text-red-500 hover:text-white p-2 rounded-lg transition-all">
|
| 138 |
-
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" /></svg>
|
| 139 |
-
</button>
|
| 140 |
-
</div>
|
| 141 |
</div>
|
|
|
|
| 142 |
</div>
|
| 143 |
<div class="p-3">
|
| 144 |
-
<h3 class="font-
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
</div>
|
| 147 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
}
|
| 150 |
-
|
| 151 |
-
//
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
</script>
|
| 154 |
|
| 155 |
<style>
|
| 156 |
-
.
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
</style>
|
| 164 |
-
{% endblock %}
|
|
|
|
| 3 |
{% block title %}Media Management - 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 |
+
<!-- Header -->
|
| 8 |
+
<div class="mb-8 flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
|
| 9 |
<div>
|
| 10 |
+
<h1 class="text-3xl font-bold">Media Management</h1>
|
| 11 |
+
<p class="theme-text-secondary mt-2">Manage your movie and TV show collections</p>
|
|
|
|
|
|
|
|
|
|
| 12 |
</div>
|
| 13 |
|
| 14 |
+
<div class="flex space-x-2">
|
| 15 |
<a href="/media/manage?media_type=movie"
|
| 16 |
+
class="px-4 py-2 rounded-md transition-colors text-sm font-medium {% if media_type == 'movie' %}bg-blue-600 text-white{% else %}theme-card border hover:bg-gray-50{% endif %}">
|
| 17 |
Movies
|
| 18 |
</a>
|
| 19 |
<a href="/media/manage?media_type=tv"
|
| 20 |
+
class="px-4 py-2 rounded-md transition-colors text-sm font-medium {% if media_type == 'tv' %}bg-blue-600 text-white{% else %}theme-card border hover:bg-gray-50{% endif %}">
|
| 21 |
TV Shows
|
| 22 |
</a>
|
| 23 |
</div>
|
| 24 |
</div>
|
| 25 |
|
| 26 |
+
<!-- Search and Filters -->
|
| 27 |
+
<div class="theme-card p-6 rounded-lg shadow mb-8">
|
| 28 |
+
<div class="flex flex-col md:flex-row gap-4">
|
| 29 |
+
<div class="flex-1">
|
| 30 |
+
<input type="text" id="search-input" placeholder="Search {{ media_type }}s by title..."
|
| 31 |
+
class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent text-sm">
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
</div>
|
| 33 |
<div class="flex gap-2">
|
| 34 |
<button onclick="searchMedia()"
|
| 35 |
+
class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-md transition-colors text-sm font-medium shadow-sm">
|
| 36 |
Search
|
| 37 |
</button>
|
| 38 |
<button onclick="clearSearch()"
|
| 39 |
+
class="border border-gray-300 px-6 py-2 rounded-md hover:bg-gray-50 transition-colors text-sm font-medium">
|
| 40 |
+
Clear
|
| 41 |
</button>
|
| 42 |
</div>
|
| 43 |
</div>
|
| 44 |
</div>
|
| 45 |
|
| 46 |
+
<!-- Loading Indicator -->
|
| 47 |
+
<div id="loading" class="text-center py-12 hidden">
|
| 48 |
+
<div class="inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-primary mb-4"></div>
|
| 49 |
+
<p class="theme-text-secondary">Loading {{ media_type }}s...</p>
|
|
|
|
|
|
|
| 50 |
</div>
|
| 51 |
|
| 52 |
+
<!-- Error Display -->
|
| 53 |
<div id="error-display" class="hidden mb-8">
|
| 54 |
+
<div class="theme-card p-6 rounded-lg shadow border-l-4 border-red-500">
|
| 55 |
+
<div class="flex items-center mb-4">
|
| 56 |
+
<svg class="h-6 w-6 text-red-500 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 57 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 58 |
+
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.996-.833-2.764 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z" />
|
| 59 |
</svg>
|
| 60 |
+
<h3 class="text-lg font-semibold text-red-700">Error Loading Media</h3>
|
| 61 |
</div>
|
| 62 |
+
<p id="error-message" class="text-red-600 mb-4"></p>
|
| 63 |
+
<button onclick="retryLoad()"
|
| 64 |
+
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-md transition-colors text-sm shadow-sm">
|
| 65 |
+
Try Again
|
| 66 |
</button>
|
| 67 |
</div>
|
| 68 |
</div>
|
| 69 |
|
| 70 |
+
<!-- Media Grid -->
|
| 71 |
+
<div id="media-grid"
|
| 72 |
+
class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 2xl:grid-cols-8 gap-4 mb-8">
|
| 73 |
+
<!-- Media items will be loaded here via JavaScript -->
|
| 74 |
+
</div>
|
| 75 |
|
| 76 |
+
<!-- No Results Message -->
|
| 77 |
+
<div id="no-results" class="text-center py-12 hidden">
|
| 78 |
+
<div class="theme-card p-8 rounded-lg shadow">
|
| 79 |
+
<svg class="mx-auto h-16 w-16 text-gray-300 mb-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 80 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 81 |
+
d="M7 4V2a1 1 0 011-1h8a1 1 0 011 1v2h4a1 1 0 110 2h-1v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6H3a1 1 0 110-2h4zM9 6v10h6V6H9z" />
|
| 82 |
+
</svg>
|
| 83 |
+
<h3 class="text-lg font-semibold theme-text-secondary mb-2">No {{ media_type }}s found</h3>
|
| 84 |
+
<p class="theme-text-secondary text-sm mb-4">
|
| 85 |
+
{% if media_type == 'movie' %}
|
| 86 |
+
No movies match your search criteria
|
| 87 |
+
{% else %}
|
| 88 |
+
No TV shows match your search criteria
|
| 89 |
+
{% endif %}
|
| 90 |
+
</p>
|
| 91 |
+
<button onclick="clearSearch()"
|
| 92 |
+
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-md transition-colors text-sm shadow-sm">
|
| 93 |
+
Show All {{ media_type|title }}s
|
| 94 |
</button>
|
| 95 |
</div>
|
| 96 |
</div>
|
| 97 |
|
| 98 |
+
<!-- Pagination -->
|
| 99 |
+
<div id="pagination" class="flex justify-center items-center space-x-2 mt-8 hidden">
|
| 100 |
+
<!-- Pagination will be loaded here via JavaScript -->
|
| 101 |
+
</div>
|
| 102 |
|
| 103 |
+
<!-- Media Info -->
|
| 104 |
+
<div id="media-info" class="theme-card p-4 rounded-lg shadow mt-6 hidden">
|
| 105 |
+
<div
|
| 106 |
+
class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-2 text-sm theme-text-secondary">
|
| 107 |
+
<span id="results-info"></span>
|
| 108 |
+
<span id="db-info"></span>
|
|
|
|
| 109 |
</div>
|
| 110 |
</div>
|
| 111 |
</div>
|
| 112 |
|
| 113 |
<script>
|
| 114 |
+
let currentPage = 1;
|
| 115 |
+
let currentSearch = '';
|
| 116 |
+
let isLoading = false;
|
| 117 |
+
const mediaType = '{{ media_type }}';
|
| 118 |
+
|
| 119 |
+
// Show loading state
|
| 120 |
+
function showLoading() {
|
| 121 |
+
isLoading = true;
|
| 122 |
+
document.getElementById('loading').classList.remove('hidden');
|
| 123 |
+
document.getElementById('media-grid').classList.add('hidden');
|
| 124 |
+
document.getElementById('no-results').classList.add('hidden');
|
| 125 |
+
document.getElementById('pagination').classList.add('hidden');
|
| 126 |
+
document.getElementById('media-info').classList.add('hidden');
|
| 127 |
+
document.getElementById('error-display').classList.add('hidden');
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
// Hide loading state
|
| 131 |
+
function hideLoading() {
|
| 132 |
+
isLoading = false;
|
| 133 |
+
document.getElementById('loading').classList.add('hidden');
|
| 134 |
+
document.getElementById('media-grid').classList.remove('hidden');
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
// Show error state
|
| 138 |
+
function showError(message) {
|
| 139 |
+
document.getElementById('error-message').textContent = message;
|
| 140 |
+
document.getElementById('error-display').classList.remove('hidden');
|
| 141 |
+
document.getElementById('loading').classList.add('hidden');
|
| 142 |
+
document.getElementById('media-grid').classList.add('hidden');
|
| 143 |
+
document.getElementById('no-results').classList.add('hidden');
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
// Load media with proper error handling
|
| 147 |
+
async function loadMedia(page = 1, search = '') {
|
| 148 |
+
if (isLoading) return; // Prevent multiple simultaneous requests
|
| 149 |
+
|
| 150 |
+
showLoading();
|
| 151 |
+
currentPage = page;
|
| 152 |
+
currentSearch = search;
|
| 153 |
+
|
| 154 |
+
try {
|
| 155 |
+
const url = `/api/media/list?media_type=${mediaType}&page=${page}&page_size=24&search=${encodeURIComponent(search)}`;
|
| 156 |
+
console.log('Fetching:', url);
|
| 157 |
+
|
| 158 |
+
const response = await fetch(url, {
|
| 159 |
+
method: 'GET',
|
| 160 |
+
credentials: 'same-origin',
|
| 161 |
+
headers: {
|
| 162 |
+
'Accept': 'application/json',
|
| 163 |
+
'Content-Type': 'application/json'
|
| 164 |
+
}
|
| 165 |
+
});
|
| 166 |
+
|
| 167 |
+
console.log('Response status:', response.status);
|
| 168 |
+
|
| 169 |
+
if (!response.ok) {
|
| 170 |
+
if (response.status === 401) {
|
| 171 |
+
window.location.href = '/login';
|
| 172 |
+
return;
|
| 173 |
+
}
|
| 174 |
+
throw new Error(`Server responded with ${response.status}: ${response.statusText}`);
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
const data = await response.json();
|
| 178 |
+
console.log('Response data:', data);
|
| 179 |
+
|
| 180 |
+
hideLoading();
|
| 181 |
+
|
| 182 |
+
const grid = document.getElementById('media-grid');
|
| 183 |
+
const mediaKey = mediaType === 'movie' ? 'movies' : 'tv_shows';
|
| 184 |
+
const mediaItems = data[mediaKey] || [];
|
| 185 |
+
|
| 186 |
+
if (mediaItems.length === 0) {
|
| 187 |
+
grid.innerHTML = '';
|
| 188 |
+
document.getElementById('no-results').classList.remove('hidden');
|
| 189 |
+
document.getElementById('pagination').classList.add('hidden');
|
| 190 |
+
document.getElementById('media-info').classList.add('hidden');
|
| 191 |
+
return;
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
document.getElementById('no-results').classList.add('hidden');
|
| 195 |
+
|
| 196 |
+
// Render media items
|
| 197 |
+
grid.innerHTML = mediaItems.map(item => createMediaCard(item)).join('');
|
| 198 |
+
|
| 199 |
+
// Update pagination
|
| 200 |
+
updatePagination(data.current_page || page, data.total_pages || 1);
|
| 201 |
+
|
| 202 |
+
// Update info
|
| 203 |
+
updateMediaInfo(data);
|
| 204 |
+
|
| 205 |
+
} catch (error) {
|
| 206 |
+
console.error('Error loading media:', error);
|
| 207 |
+
hideLoading();
|
| 208 |
+
showError(`Failed to load ${mediaType}s: ${error.message}`);
|
| 209 |
+
}
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
// Create media card HTML
|
| 213 |
function createMediaCard(item) {
|
| 214 |
const title = item.title || item.name || 'Unknown Title';
|
| 215 |
+
const year = item.release_year || 'Unknown Year';
|
| 216 |
+
const rating = item.rating ? `⭐ ${parseFloat(item.rating).toFixed(1)}` : '';
|
| 217 |
const poster = item.poster || 'https://via.placeholder.com/300x450/e5e7eb/9ca3af?text=No+Image';
|
| 218 |
|
| 219 |
return `
|
| 220 |
+
<div class="theme-card rounded-lg shadow hover:shadow-lg transition-all duration-300 group overflow-hidden">
|
| 221 |
+
<div class="relative">
|
| 222 |
+
<div class="aspect-w-2 aspect-h-3">
|
| 223 |
+
<img src="${poster}"
|
| 224 |
+
alt="${title}"
|
| 225 |
+
class="w-full h-64 object-cover"
|
| 226 |
+
onerror="this.src='https://via.placeholder.com/300x450/e5e7eb/9ca3af?text=No+Image'"
|
| 227 |
+
loading="lazy">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
</div>
|
| 229 |
+
<div class="absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-20 transition-all duration-300"></div>
|
| 230 |
</div>
|
| 231 |
<div class="p-3">
|
| 232 |
+
<h3 class="font-semibold text-sm mb-1 line-clamp-2 min-h-[2.5rem]" title="${title}">
|
| 233 |
+
${title}
|
| 234 |
+
</h3>
|
| 235 |
+
<div class="flex items-center justify-between text-xs theme-text-secondary mb-3">
|
| 236 |
+
<span>${year}</span>
|
| 237 |
+
${rating ? `<span>${rating}</span>` : ''}
|
| 238 |
+
</div>
|
| 239 |
+
<div class="flex justify-between items-center">
|
| 240 |
+
<a href="/media/edit?tmdb_id=${item.tmdb_id}&db_index=${item.db_index}&media_type=${mediaType}"
|
| 241 |
+
class="text-primary hover:underline text-xs font-medium px-2 py-1 rounded transition-colors hover:bg-blue-50">
|
| 242 |
+
Edit
|
| 243 |
+
</a>
|
| 244 |
+
<button onclick="deleteMedia(${item.tmdb_id}, ${item.db_index}, '${title.replace(/'/g, "\\'")}')"
|
| 245 |
+
class="text-red-600 hover:underline text-xs font-medium px-2 py-1 rounded transition-colors hover:bg-red-50">
|
| 246 |
+
Delete
|
| 247 |
+
</button>
|
| 248 |
+
</div>
|
| 249 |
</div>
|
| 250 |
</div>
|
| 251 |
+
`;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
// Update pagination
|
| 255 |
+
function updatePagination(currentPage, totalPages) {
|
| 256 |
+
const pagination = document.getElementById('pagination');
|
| 257 |
+
|
| 258 |
+
if (totalPages <= 1) {
|
| 259 |
+
pagination.classList.add('hidden');
|
| 260 |
+
return;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
pagination.classList.remove('hidden');
|
| 264 |
+
let paginationHTML = '';
|
| 265 |
+
|
| 266 |
+
// Previous button
|
| 267 |
+
if (currentPage > 1) {
|
| 268 |
+
paginationHTML += `
|
| 269 |
+
<button onclick="loadMedia(${currentPage - 1}, '${currentSearch}')"
|
| 270 |
+
class="px-3 py-2 border rounded-md hover:bg-gray-50 transition-colors text-sm">
|
| 271 |
+
Previous
|
| 272 |
+
</button>
|
| 273 |
+
`;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
// Page numbers
|
| 277 |
+
const startPage = Math.max(1, currentPage - 2);
|
| 278 |
+
const endPage = Math.min(totalPages, currentPage + 2);
|
| 279 |
+
|
| 280 |
+
// First page
|
| 281 |
+
if (startPage > 1) {
|
| 282 |
+
paginationHTML += `
|
| 283 |
+
<button onclick="loadMedia(1, '${currentSearch}')"
|
| 284 |
+
class="px-3 py-2 border rounded-md hover:bg-gray-50 transition-colors text-sm">
|
| 285 |
+
1
|
| 286 |
+
</button>
|
| 287 |
`;
|
| 288 |
+
if (startPage > 2) {
|
| 289 |
+
paginationHTML += `<span class="px-3 py-2 text-sm">...</span>`;
|
| 290 |
+
}
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
// Page range
|
| 294 |
+
for (let i = startPage; i <= endPage; i++) {
|
| 295 |
+
const isActive = i === currentPage;
|
| 296 |
+
paginationHTML += `
|
| 297 |
+
<button onclick="loadMedia(${i}, '${currentSearch}')"
|
| 298 |
+
class="px-3 py-2 border rounded-md transition-colors text-sm ${isActive ? 'bg-blue-600 text-white border-blue-600' : 'hover:bg-gray-50'
|
| 299 |
+
}">
|
| 300 |
+
${i}
|
| 301 |
+
</button>
|
| 302 |
+
`;
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
// Last page
|
| 306 |
+
if (endPage < totalPages) {
|
| 307 |
+
if (endPage < totalPages - 1) {
|
| 308 |
+
paginationHTML += `<span class="px-3 py-2 text-sm">...</span>`;
|
| 309 |
+
}
|
| 310 |
+
paginationHTML += `
|
| 311 |
+
<button onclick="loadMedia(${totalPages}, '${currentSearch}')"
|
| 312 |
+
class="px-3 py-2 border rounded-md hover:bg-gray-50 transition-colors text-sm">
|
| 313 |
+
${totalPages}
|
| 314 |
+
</button>
|
| 315 |
+
`;
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
// Next button
|
| 319 |
+
if (currentPage < totalPages) {
|
| 320 |
+
paginationHTML += `
|
| 321 |
+
<button onclick="loadMedia(${currentPage + 1}, '${currentSearch}')"
|
| 322 |
+
class="px-3 py-2 border rounded-md hover:bg-gray-50 transition-colors text-sm">
|
| 323 |
+
Next
|
| 324 |
+
</button>
|
| 325 |
+
`;
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
pagination.innerHTML = paginationHTML;
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
// Update media info display
|
| 332 |
+
function updateMediaInfo(data) {
|
| 333 |
+
const mediaInfo = document.getElementById('media-info');
|
| 334 |
+
const resultsInfo = document.getElementById('results-info');
|
| 335 |
+
const dbInfo = document.getElementById('db-info');
|
| 336 |
+
|
| 337 |
+
const startItem = ((data.current_page - 1) * 24) + 1;
|
| 338 |
+
const endItem = Math.min(data.current_page * 24, data.total_count);
|
| 339 |
+
|
| 340 |
+
resultsInfo.textContent = `Showing ${startItem}-${endItem} of ${data.total_count} ${mediaType}s`;
|
| 341 |
+
|
| 342 |
+
if (data.databases_checked && data.databases_checked.length > 0) {
|
| 343 |
+
dbInfo.textContent = `Database${data.databases_checked.length > 1 ? 's' : ''}: ${data.databases_checked.join(', ')}`;
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
mediaInfo.classList.remove('hidden');
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
// Search functionality
|
| 350 |
+
function searchMedia() {
|
| 351 |
+
const searchInput = document.getElementById('search-input');
|
| 352 |
+
const search = searchInput.value.trim();
|
| 353 |
+
loadMedia(1, search);
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
// Clear search
|
| 357 |
+
function clearSearch() {
|
| 358 |
+
document.getElementById('search-input').value = '';
|
| 359 |
+
loadMedia(1, '');
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
// Retry load function
|
| 363 |
+
function retryLoad() {
|
| 364 |
+
loadMedia(currentPage, currentSearch);
|
| 365 |
}
|
| 366 |
+
|
| 367 |
+
// Delete media with confirmation
|
| 368 |
+
async function deleteMedia(tmdbId, dbIndex, title) {
|
| 369 |
+
if (!confirm(`Are you sure you want to delete "${title}"?\n\nThis action cannot be undone.`)) return;
|
| 370 |
+
|
| 371 |
+
try {
|
| 372 |
+
const response = await fetch(`/api/media/delete?tmdb_id=${tmdbId}&db_index=${dbIndex}&media_type=${mediaType}`, {
|
| 373 |
+
method: 'DELETE',
|
| 374 |
+
credentials: 'same-origin',
|
| 375 |
+
headers: {
|
| 376 |
+
'Accept': 'application/json',
|
| 377 |
+
'Content-Type': 'application/json'
|
| 378 |
+
}
|
| 379 |
+
});
|
| 380 |
+
|
| 381 |
+
if (response.ok) {
|
| 382 |
+
// Show success message briefly
|
| 383 |
+
const successMsg = document.createElement('div');
|
| 384 |
+
successMsg.className = 'fixed top-4 right-4 bg-green-500 text-white px-4 py-2 rounded-md shadow-lg z-50';
|
| 385 |
+
successMsg.textContent = `"${title}" deleted successfully`;
|
| 386 |
+
document.body.appendChild(successMsg);
|
| 387 |
+
|
| 388 |
+
setTimeout(() => {
|
| 389 |
+
document.body.removeChild(successMsg);
|
| 390 |
+
}, 3000);
|
| 391 |
+
|
| 392 |
+
// Reload current page
|
| 393 |
+
loadMedia(currentPage, currentSearch);
|
| 394 |
+
} else {
|
| 395 |
+
const error = await response.json();
|
| 396 |
+
alert(`Error deleting "${title}": ${error.detail || 'Unknown error'}`);
|
| 397 |
+
}
|
| 398 |
+
} catch (error) {
|
| 399 |
+
console.error('Error deleting media:', error);
|
| 400 |
+
alert(`Error deleting "${title}": ${error.message}`);
|
| 401 |
+
}
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
// Initialize page
|
| 405 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 406 |
+
// Load media on page load
|
| 407 |
+
loadMedia();
|
| 408 |
+
|
| 409 |
+
// Add enter key listener to search input
|
| 410 |
+
document.getElementById('search-input').addEventListener('keypress', (e) => {
|
| 411 |
+
if (e.key === 'Enter') {
|
| 412 |
+
e.preventDefault();
|
| 413 |
+
searchMedia();
|
| 414 |
+
}
|
| 415 |
+
});
|
| 416 |
+
|
| 417 |
+
// Add input event for real-time search (with debouncing)
|
| 418 |
+
let searchTimeout;
|
| 419 |
+
document.getElementById('search-input').addEventListener('input', (e) => {
|
| 420 |
+
clearTimeout(searchTimeout);
|
| 421 |
+
const searchValue = e.target.value.trim();
|
| 422 |
+
|
| 423 |
+
if (searchValue.length === 0) {
|
| 424 |
+
searchTimeout = setTimeout(() => {
|
| 425 |
+
loadMedia(1, '');
|
| 426 |
+
}, 300);
|
| 427 |
+
}
|
| 428 |
+
});
|
| 429 |
+
});
|
| 430 |
</script>
|
| 431 |
|
| 432 |
<style>
|
| 433 |
+
.line-clamp-2 {
|
| 434 |
+
display: -webkit-box;
|
| 435 |
+
-webkit-line-clamp: 2;
|
| 436 |
+
-webkit-box-orient: vertical;
|
| 437 |
+
overflow: hidden;
|
| 438 |
+
}
|
| 439 |
|
| 440 |
+
.aspect-w-2 {
|
| 441 |
+
position: relative;
|
| 442 |
+
padding-bottom: 150%;
|
| 443 |
+
/* 2:3 aspect ratio */
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
.aspect-w-2>img {
|
| 447 |
+
position: absolute;
|
| 448 |
+
height: 100%;
|
| 449 |
+
width: 100%;
|
| 450 |
+
top: 0;
|
| 451 |
+
right: 0;
|
| 452 |
+
bottom: 0;
|
| 453 |
+
left: 0;
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
@media (max-width: 640px) {
|
| 457 |
+
.grid {
|
| 458 |
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
| 459 |
+
gap: 0.75rem;
|
| 460 |
+
}
|
| 461 |
+
}
|
| 462 |
+
|
| 463 |
+
@media (min-width: 1536px) {
|
| 464 |
+
.grid {
|
| 465 |
+
grid-template-columns: repeat(8, minmax(0, 1fr));
|
| 466 |
+
}
|
| 467 |
+
}
|
| 468 |
+
|
| 469 |
+
/* Loading animation */
|
| 470 |
+
@keyframes spin {
|
| 471 |
+
to {
|
| 472 |
+
transform: rotate(360deg);
|
| 473 |
+
}
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
.animate-spin {
|
| 477 |
+
animation: spin 1s linear infinite;
|
| 478 |
+
}
|
| 479 |
</style>
|
| 480 |
+
{% endblock %}
|
Backend/fastapi/templates/public_status.html
CHANGED
|
@@ -3,107 +3,69 @@
|
|
| 3 |
{% block title %}System Status - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
-
<div class="max-w-
|
| 7 |
-
<
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
<span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"></span>
|
| 13 |
-
<span class="relative inline-flex rounded-full h-3 w-3 bg-green-500"></span>
|
| 14 |
-
</span>
|
| 15 |
-
Real-time health and availability metrics.
|
| 16 |
-
</p>
|
| 17 |
-
</div>
|
| 18 |
-
<div class="text-xs font-mono bg-gray-100 dark:bg-gray-800 px-3 py-1.5 rounded-lg theme-text-secondary border border-gray-200 dark:border-gray-700">
|
| 19 |
-
LAST CHECK: <span id="current-time">JUST NOW</span>
|
| 20 |
-
</div>
|
| 21 |
-
</section>
|
| 22 |
|
| 23 |
-
<
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
</svg>
|
| 29 |
</div>
|
| 30 |
-
<h3 class="text-
|
| 31 |
-
<p class="text-
|
| 32 |
</div>
|
| 33 |
|
| 34 |
-
<div class="theme-card p-6
|
| 35 |
-
<div class="w-16 h-16 mx-auto mb-4
|
| 36 |
-
<
|
| 37 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
|
| 38 |
-
</svg>
|
| 39 |
</div>
|
| 40 |
-
<h3 class="text-
|
| 41 |
-
<p class="text-
|
| 42 |
</div>
|
| 43 |
|
| 44 |
-
<div class="theme-card p-6
|
| 45 |
-
<div class="w-16 h-16 mx-auto mb-4
|
| 46 |
-
<
|
| 47 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z" />
|
| 48 |
-
</svg>
|
| 49 |
</div>
|
| 50 |
-
<h3 class="text-
|
| 51 |
-
<p class="text-
|
| 52 |
</div>
|
| 53 |
-
</
|
| 54 |
|
| 55 |
-
<
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
<
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
<
|
| 62 |
-
<div class="w-2 h-2 rounded-full bg-green-500"></div>
|
| 63 |
-
<span class="font-semibold">API Endpoints</span>
|
| 64 |
-
</div>
|
| 65 |
-
<span class="px-3 py-1 rounded-full bg-green-500/10 text-green-500 text-xs font-bold uppercase">Active</span>
|
| 66 |
</div>
|
| 67 |
-
<div class="flex justify-between items-center
|
| 68 |
-
<
|
| 69 |
-
|
| 70 |
-
<span class="font-semibold">Stremio Addon Engine</span>
|
| 71 |
-
</div>
|
| 72 |
-
<span class="px-3 py-1 rounded-full bg-green-500/10 text-green-500 text-xs font-bold uppercase">Active</span>
|
| 73 |
</div>
|
| 74 |
-
<div class="flex justify-between items-center
|
| 75 |
-
<
|
| 76 |
-
|
| 77 |
-
<span class="font-semibold">Database Connection</span>
|
| 78 |
-
</div>
|
| 79 |
-
<span class="px-3 py-1 rounded-full bg-green-500/10 text-green-500 text-xs font-bold uppercase">Connected</span>
|
| 80 |
</div>
|
| 81 |
</div>
|
| 82 |
-
</
|
| 83 |
|
| 84 |
{% if not is_authenticated %}
|
| 85 |
-
<
|
| 86 |
-
|
| 87 |
-
<
|
| 88 |
-
<
|
| 89 |
-
|
| 90 |
-
|
|
|
|
| 91 |
</a>
|
| 92 |
-
</
|
| 93 |
{% endif %}
|
| 94 |
</div>
|
| 95 |
-
|
| 96 |
-
<style>
|
| 97 |
-
.animate-fade-in { animation: fadeIn 0.4s ease-out; }
|
| 98 |
-
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
|
| 99 |
-
</style>
|
| 100 |
-
|
| 101 |
-
<script>
|
| 102 |
-
// Simple script to update the "last check" time
|
| 103 |
-
document.addEventListener('DOMContentLoaded', () => {
|
| 104 |
-
const timeDisplay = document.getElementById('current-time');
|
| 105 |
-
const now = new Date();
|
| 106 |
-
timeDisplay.textContent = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
| 107 |
-
});
|
| 108 |
-
</script>
|
| 109 |
-
{% endblock %}
|
|
|
|
| 3 |
{% block title %}System Status - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
+
<div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
| 7 |
+
<!-- Header -->
|
| 8 |
+
<div class="mb-8 text-center">
|
| 9 |
+
<h1 class="text-3xl font-bold">System Status</h1>
|
| 10 |
+
<p class="theme-text-secondary mt-2">Current status of Telegram Stremio services</p>
|
| 11 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
<!-- Status Cards -->
|
| 14 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
|
| 15 |
+
<div class="theme-card p-6 rounded-lg shadow text-center">
|
| 16 |
+
<div class="w-16 h-16 mx-auto mb-4 theme-primary rounded-full flex items-center justify-center">
|
| 17 |
+
<span class="text-white text-2xl">✓</span>
|
|
|
|
| 18 |
</div>
|
| 19 |
+
<h3 class="text-lg font-semibold mb-2">Backend Status</h3>
|
| 20 |
+
<p class="text-green-600 font-medium">{{ stats.status|title }}</p>
|
| 21 |
</div>
|
| 22 |
|
| 23 |
+
<div class="theme-card p-6 rounded-lg shadow text-center">
|
| 24 |
+
<div class="w-16 h-16 mx-auto mb-4 bg-blue-500 rounded-full flex items-center justify-center">
|
| 25 |
+
<span class="text-white text-2xl">↑</span>
|
|
|
|
|
|
|
| 26 |
</div>
|
| 27 |
+
<h3 class="text-lg font-semibold mb-2">Uptime</h3>
|
| 28 |
+
<p class="text-green-600 font-medium">{{ stats.uptime }}</p>
|
| 29 |
</div>
|
| 30 |
|
| 31 |
+
<div class="theme-card p-6 rounded-lg shadow text-center">
|
| 32 |
+
<div class="w-16 h-16 mx-auto mb-4 bg-purple-500 rounded-full flex items-center justify-center">
|
| 33 |
+
<span class="text-white text-2xl">v</span>
|
|
|
|
|
|
|
| 34 |
</div>
|
| 35 |
+
<h3 class="text-lg font-semibold mb-2">Version</h3>
|
| 36 |
+
<p class="theme-text-secondary font-medium">{{ stats.version }}</p>
|
| 37 |
</div>
|
| 38 |
+
</div>
|
| 39 |
|
| 40 |
+
<!-- Services Status -->
|
| 41 |
+
<div class="theme-card p-6 rounded-lg shadow mb-8">
|
| 42 |
+
<h2 class="text-xl font-semibold mb-4">Service Status</h2>
|
| 43 |
+
<div class="space-y-4">
|
| 44 |
+
<div class="flex justify-between items-center">
|
| 45 |
+
<span>API Endpoints</span>
|
| 46 |
+
<span class="bg-green-100 text-green-800 px-2 py-1 rounded-full text-sm">Active</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
</div>
|
| 48 |
+
<div class="flex justify-between items-center">
|
| 49 |
+
<span>Stremio Addon</span>
|
| 50 |
+
<span class="bg-green-100 text-green-800 px-2 py-1 rounded-full text-sm">Active</span>
|
|
|
|
|
|
|
|
|
|
| 51 |
</div>
|
| 52 |
+
<div class="flex justify-between items-center">
|
| 53 |
+
<span>Database</span>
|
| 54 |
+
<span class="bg-green-100 text-green-800 px-2 py-1 rounded-full text-sm">Connected</span>
|
|
|
|
|
|
|
|
|
|
| 55 |
</div>
|
| 56 |
</div>
|
| 57 |
+
</div>
|
| 58 |
|
| 59 |
{% if not is_authenticated %}
|
| 60 |
+
<!-- Admin Access -->
|
| 61 |
+
<div class="theme-card p-6 rounded-lg shadow text-center">
|
| 62 |
+
<h2 class="text-xl font-semibold mb-4">Administrator Access</h2>
|
| 63 |
+
<p class="theme-text-secondary mb-4">Login to access the full admin dashboard</p>
|
| 64 |
+
<a href="/login"
|
| 65 |
+
class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-md transition-colors inline-block shadow-sm">
|
| 66 |
+
Admin Login
|
| 67 |
</a>
|
| 68 |
+
</div>
|
| 69 |
{% endif %}
|
| 70 |
</div>
|
| 71 |
+
{% endblock %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Backend/fastapi/templates/stremio_guide.html
CHANGED
|
@@ -3,137 +3,112 @@
|
|
| 3 |
{% block title %}Stremio Setup Guide - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
-
<div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8
|
| 7 |
-
<
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
</div>
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
<span class="flex-shrink-0 w-10 h-10 rounded-xl bg-primary text-white flex items-center justify-center font-bold shadow-lg shadow-primary/20">1</span>
|
| 27 |
-
<div class="w-full">
|
| 28 |
-
<h3 class="text-lg font-bold mb-1">Copy Addon Manifest URL</h3>
|
| 29 |
-
<p class="theme-text-secondary text-sm mb-4">Use this unique URL to register your library within the Stremio app.</p>
|
| 30 |
-
|
| 31 |
-
<div class="relative group">
|
| 32 |
-
<div class="theme-input rounded-xl p-4 font-mono text-xs sm:text-sm break-all flex items-center justify-between gap-4 bg-gray-50/50 dark:bg-gray-800/50 border-none shadow-inner">
|
| 33 |
-
<span id="addon-url" class="theme-text font-medium">{{ request.base_url }}stremio/manifest.json</span>
|
| 34 |
-
<button onclick="copyToClipboard('addon-url')"
|
| 35 |
-
class="bg-primary/10 hover:bg-primary text-primary hover:text-white px-4 py-2 rounded-lg text-xs font-bold transition-all whitespace-nowrap">
|
| 36 |
-
Copy Link
|
| 37 |
-
</button>
|
| 38 |
-
</div>
|
| 39 |
</div>
|
| 40 |
</div>
|
| 41 |
</div>
|
| 42 |
-
</
|
| 43 |
-
|
| 44 |
-
<div class="
|
| 45 |
-
<div class="
|
| 46 |
-
<div class="flex items-
|
| 47 |
-
<span class="
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
</
|
| 52 |
</div>
|
| 53 |
</div>
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
| 62 |
</div>
|
| 63 |
</div>
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
<p><strong>Note:</strong> Ensure your Stremio device can ping this server's IP address.</p>
|
| 77 |
-
</div>
|
| 78 |
</div>
|
| 79 |
</div>
|
| 80 |
</div>
|
| 81 |
</div>
|
| 82 |
</div>
|
| 83 |
-
|
| 84 |
-
<
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
<
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
<div class="grid grid-cols-1 sm:grid-cols-3 gap-6">
|
| 92 |
-
<div class="space-y-1">
|
| 93 |
-
<span class="text-[10px] font-bold uppercase tracking-widest text-primary">Protocol</span>
|
| 94 |
-
<p class="text-sm theme-text font-medium">Stremio Addon SDK v3</p>
|
| 95 |
-
<p class="text-xs theme-text-secondary">Fully compatible with official clients.</p>
|
| 96 |
</div>
|
| 97 |
-
<div
|
| 98 |
-
<
|
| 99 |
-
<p class="
|
| 100 |
-
<p class="text-xs theme-text-secondary">Automatic metadata enrichment via TMDB.</p>
|
| 101 |
</div>
|
| 102 |
-
<div
|
| 103 |
-
<
|
| 104 |
-
<p class="
|
| 105 |
-
<p class="text-xs theme-text-secondary">Library changes reflect without re-installing.</p>
|
| 106 |
</div>
|
| 107 |
</div>
|
| 108 |
-
</
|
| 109 |
</div>
|
| 110 |
|
| 111 |
<script>
|
| 112 |
function copyToClipboard(elementId) {
|
| 113 |
const element = document.getElementById(elementId);
|
| 114 |
const text = element.textContent;
|
| 115 |
-
|
| 116 |
navigator.clipboard.writeText(text).then(() => {
|
| 117 |
-
|
|
|
|
| 118 |
const originalText = button.textContent;
|
| 119 |
-
|
| 120 |
button.textContent = 'Copied!';
|
| 121 |
-
button.classList.
|
| 122 |
-
|
| 123 |
-
|
| 124 |
setTimeout(() => {
|
| 125 |
button.textContent = originalText;
|
| 126 |
-
button.classList.
|
| 127 |
-
button.classList.remove('bg-green-500', 'text-white');
|
| 128 |
}, 2000);
|
| 129 |
}).catch(err => {
|
| 130 |
console.error('Failed to copy: ', err);
|
|
|
|
| 131 |
});
|
| 132 |
}
|
| 133 |
</script>
|
| 134 |
-
|
| 135 |
-
<style>
|
| 136 |
-
.animate-fade-in { animation: fadeIn 0.4s ease-out; }
|
| 137 |
-
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
|
| 138 |
-
</style>
|
| 139 |
{% endblock %}
|
|
|
|
| 3 |
{% block title %}Stremio Setup Guide - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
+
<div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
| 7 |
+
<!-- Header -->
|
| 8 |
+
<div class="mb-8 text-center">
|
| 9 |
+
<h1 class="text-3xl font-bold">Stremio Addon Setup</h1>
|
| 10 |
+
<p class="theme-text-secondary mt-2">Install the Telegram Stremio addon to access your media through Stremio</p>
|
| 11 |
+
</div>
|
| 12 |
+
|
| 13 |
+
<!-- Installation Steps -->
|
| 14 |
+
<div class="space-y-6">
|
| 15 |
+
<div class="theme-card p-6 rounded-lg shadow">
|
| 16 |
+
<div class="flex items-start space-x-4">
|
| 17 |
+
<div class="w-8 h-8 theme-primary rounded-full flex items-center justify-center flex-shrink-0">
|
| 18 |
+
<span class="text-white font-semibold">1</span>
|
| 19 |
</div>
|
| 20 |
+
<div>
|
| 21 |
+
<h3 class="text-lg font-semibold mb-2">Copy the Addon URL</h3>
|
| 22 |
+
<p class="theme-text-secondary mb-4">Copy the manifest URL below to your clipboard</p>
|
| 23 |
+
<div class="bg-gray-100 p-4 rounded-md font-mono text-sm break-all">
|
| 24 |
+
<span id="addon-url">{{ request.base_url }}stremio/manifest.json</span>
|
| 25 |
+
<button onclick="copyToClipboard('addon-url')"
|
| 26 |
+
class="ml-2 text-primary hover:underline">Copy</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
</div>
|
| 28 |
</div>
|
| 29 |
</div>
|
| 30 |
+
</div>
|
| 31 |
+
|
| 32 |
+
<div class="theme-card p-6 rounded-lg shadow">
|
| 33 |
+
<div class="flex items-start space-x-4">
|
| 34 |
+
<div class="w-8 h-8 theme-primary rounded-full flex items-center justify-center flex-shrink-0">
|
| 35 |
+
<span class="text-white font-semibold">2</span>
|
| 36 |
+
</div>
|
| 37 |
+
<div>
|
| 38 |
+
<h3 class="text-lg font-semibold mb-2">Open Stremio</h3>
|
| 39 |
+
<p class="theme-text-secondary">Launch the Stremio application on your device</p>
|
| 40 |
</div>
|
| 41 |
</div>
|
| 42 |
+
</div>
|
| 43 |
+
|
| 44 |
+
<div class="theme-card p-6 rounded-lg shadow">
|
| 45 |
+
<div class="flex items-start space-x-4">
|
| 46 |
+
<div class="w-8 h-8 theme-primary rounded-full flex items-center justify-center flex-shrink-0">
|
| 47 |
+
<span class="text-white font-semibold">3</span>
|
| 48 |
+
</div>
|
| 49 |
+
<div>
|
| 50 |
+
<h3 class="text-lg font-semibold mb-2">Navigate to Addons</h3>
|
| 51 |
+
<p class="theme-text-secondary">Go to the "Addons" section in Stremio's main menu</p>
|
| 52 |
</div>
|
| 53 |
</div>
|
| 54 |
+
</div>
|
| 55 |
+
|
| 56 |
+
<div class="theme-card p-6 rounded-lg shadow">
|
| 57 |
+
<div class="flex items-start space-x-4">
|
| 58 |
+
<div class="w-8 h-8 theme-primary rounded-full flex items-center justify-center flex-shrink-0">
|
| 59 |
+
<span class="text-white font-semibold">4</span>
|
| 60 |
+
</div>
|
| 61 |
+
<div>
|
| 62 |
+
<h3 class="text-lg font-semibold mb-2">Install the Addon</h3>
|
| 63 |
+
<p class="theme-text-secondary mb-4">Paste the URL in the "Add Addon" field and click install</p>
|
| 64 |
+
<div class="bg-blue-50 border border-blue-200 text-blue-700 p-4 rounded-md">
|
| 65 |
+
<strong>Tip:</strong> Make sure your device can access this server's IP address on the network
|
|
|
|
|
|
|
| 66 |
</div>
|
| 67 |
</div>
|
| 68 |
</div>
|
| 69 |
</div>
|
| 70 |
</div>
|
| 71 |
+
|
| 72 |
+
<!-- Additional Information -->
|
| 73 |
+
<div class="theme-card p-6 rounded-lg shadow mt-8">
|
| 74 |
+
<h2 class="text-xl font-semibold mb-4">Additional Information</h2>
|
| 75 |
+
<div class="space-y-4">
|
| 76 |
+
<div>
|
| 77 |
+
<h4 class="font-medium">Network Requirements</h4>
|
| 78 |
+
<p class="theme-text-secondary text-sm">Both Stremio and this server must be on the same network or the server must be accessible via internet</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
</div>
|
| 80 |
+
<div>
|
| 81 |
+
<h4 class="font-medium">Supported Content</h4>
|
| 82 |
+
<p class="theme-text-secondary text-sm">The addon provides access to movies and TV shows in your media collection</p>
|
|
|
|
| 83 |
</div>
|
| 84 |
+
<div>
|
| 85 |
+
<h4 class="font-medium">Updates</h4>
|
| 86 |
+
<p class="theme-text-secondary text-sm">The addon will automatically sync with your media library changes</p>
|
|
|
|
| 87 |
</div>
|
| 88 |
</div>
|
| 89 |
+
</div>
|
| 90 |
</div>
|
| 91 |
|
| 92 |
<script>
|
| 93 |
function copyToClipboard(elementId) {
|
| 94 |
const element = document.getElementById(elementId);
|
| 95 |
const text = element.textContent;
|
| 96 |
+
|
| 97 |
navigator.clipboard.writeText(text).then(() => {
|
| 98 |
+
// Show success message
|
| 99 |
+
const button = element.nextElementSibling;
|
| 100 |
const originalText = button.textContent;
|
|
|
|
| 101 |
button.textContent = 'Copied!';
|
| 102 |
+
button.classList.add('text-green-600');
|
| 103 |
+
|
|
|
|
| 104 |
setTimeout(() => {
|
| 105 |
button.textContent = originalText;
|
| 106 |
+
button.classList.remove('text-green-600');
|
|
|
|
| 107 |
}, 2000);
|
| 108 |
}).catch(err => {
|
| 109 |
console.error('Failed to copy: ', err);
|
| 110 |
+
alert('Failed to copy to clipboard');
|
| 111 |
});
|
| 112 |
}
|
| 113 |
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
{% endblock %}
|
Backend/fastapi/templates/subscriptions_manage.html
CHANGED
|
@@ -3,143 +3,163 @@
|
|
| 3 |
{% block title %}Subscription Management - 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 |
-
<
|
| 8 |
<div>
|
| 9 |
-
<h1 class="text-3xl font-bold
|
| 10 |
-
<p class="
|
|
|
|
| 11 |
</div>
|
| 12 |
-
|
| 13 |
-
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" /></svg>
|
| 14 |
-
Add New Plan
|
| 15 |
-
</button>
|
| 16 |
-
</section>
|
| 17 |
|
| 18 |
-
<
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
<h2 class="text-xl font-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
</div>
|
| 23 |
<div class="grid grid-cols-1 md:grid-cols-3 gap-6" id="plans-container">
|
| 24 |
-
<div class="col-span-
|
| 25 |
-
<
|
| 26 |
-
<p class="theme-text-secondary">Syncing plans...</p>
|
| 27 |
</div>
|
| 28 |
</div>
|
| 29 |
-
</
|
| 30 |
|
| 31 |
-
<
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
<
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
</
|
| 50 |
-
<
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
</div>
|
| 55 |
|
| 56 |
-
<div class="theme-card rounded-
|
| 57 |
<div class="overflow-x-auto">
|
| 58 |
-
<table class="w-full text-
|
| 59 |
-
<thead class="bg-gray-50
|
| 60 |
<tr>
|
| 61 |
-
<th class="px-6 py-4
|
| 62 |
-
<th class="px-6 py-4
|
| 63 |
-
<th class="px-6 py-4
|
| 64 |
-
<th class="px-6 py-4
|
| 65 |
</tr>
|
| 66 |
</thead>
|
| 67 |
<tbody id="subscribers-tbody" class="divide-y divide-gray-100 dark:divide-gray-800">
|
| 68 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
</table>
|
| 70 |
</div>
|
| 71 |
</div>
|
| 72 |
|
| 73 |
-
<
|
| 74 |
-
|
| 75 |
-
<
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
<span id="sub-page-num" class="px-
|
| 80 |
-
<button id="sub-btn-next" onclick="subChangePage(1)"
|
| 81 |
-
|
| 82 |
-
</button>
|
| 83 |
</div>
|
| 84 |
</div>
|
| 85 |
-
</
|
| 86 |
</div>
|
| 87 |
|
| 88 |
-
<
|
| 89 |
-
|
| 90 |
-
<div class="
|
| 91 |
-
<div class="
|
| 92 |
-
<
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
</div>
|
| 98 |
-
<form id="plan-form" onsubmit="submitPlanForm(event)" class="p-6 space-y-4">
|
| 99 |
-
<input type="hidden" id="plan-id">
|
| 100 |
-
<div>
|
| 101 |
-
<label class="block text-sm font-bold mb-2">Duration (Days)</label>
|
| 102 |
-
<input type="number" id="plan-days" class="theme-input w-full px-4 py-3 rounded-xl" required min="1" placeholder="e.g. 30">
|
| 103 |
-
</div>
|
| 104 |
-
<div>
|
| 105 |
-
<label class="block text-sm font-bold mb-2">Price (₹)</label>
|
| 106 |
-
<input type="number" id="plan-price" class="theme-input w-full px-4 py-3 rounded-xl" required min="0" step="0.01" placeholder="e.g. 199.00">
|
| 107 |
-
</div>
|
| 108 |
-
<div class="pt-4 flex gap-3">
|
| 109 |
-
<button type="button" onclick="closePlanModal()" class="flex-1 px-4 py-3 rounded-xl font-bold theme-text-secondary bg-gray-100 dark:bg-gray-800 hover:brightness-95 transition-all">Cancel</button>
|
| 110 |
-
<button type="submit" class="flex-1 px-4 py-3 rounded-xl font-bold bg-primary text-white shadow-lg shadow-primary/20 hover:brightness-110 transition-all">Save Changes</button>
|
| 111 |
-
</div>
|
| 112 |
-
</form>
|
| 113 |
</div>
|
| 114 |
</div>
|
| 115 |
</div>
|
| 116 |
|
| 117 |
-
<
|
| 118 |
-
|
| 119 |
-
<div class="
|
| 120 |
-
<div class="
|
| 121 |
-
<
|
| 122 |
-
|
| 123 |
-
<
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
<
|
| 135 |
-
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
</div>
|
| 138 |
</div>
|
| 139 |
</div>
|
| 140 |
|
| 141 |
<script>
|
| 142 |
-
// ---
|
| 143 |
async function fetchPlans() {
|
| 144 |
try {
|
| 145 |
const res = await fetch('/api/admin/subscriptions/plans');
|
|
@@ -148,139 +168,176 @@
|
|
| 148 |
const data = await res.json();
|
| 149 |
const plans = data.data || data.plans || [];
|
| 150 |
if (!plans.length) {
|
| 151 |
-
container.innerHTML =
|
| 152 |
return;
|
| 153 |
}
|
| 154 |
container.innerHTML = plans.map(p => `
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
<p class="theme-text-secondary font-bold text-sm uppercase tracking-widest">${p.days} Days Access</p>
|
| 171 |
-
<div class="mt-4 pt-4 border-t border-gray-50 dark:border-gray-800 text-xs theme-text-secondary flex items-center gap-2">
|
| 172 |
-
<svg class="w-4 h-4 text-green-500" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" /></svg>
|
| 173 |
-
Full Library Access
|
| 174 |
-
</div>
|
| 175 |
-
</div>`).join('');
|
| 176 |
}
|
| 177 |
} catch (err) { console.error(err); }
|
| 178 |
}
|
| 179 |
|
| 180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
function renderSubPage() {
|
| 182 |
const filtered = getSubFiltered();
|
| 183 |
-
const pageSize =
|
| 184 |
const totalPages = Math.max(1, Math.ceil(filtered.length / pageSize));
|
| 185 |
if (subPage > totalPages) subPage = totalPages;
|
| 186 |
const start = (subPage - 1) * pageSize;
|
| 187 |
const slice = filtered.slice(start, start + pageSize);
|
| 188 |
|
| 189 |
-
document.getElementById('sub-page-info').textContent = `Showing ${start + 1}
|
| 190 |
-
document.getElementById('sub-page-num').textContent = subPage;
|
| 191 |
document.getElementById('sub-btn-prev').disabled = subPage <= 1;
|
| 192 |
document.getElementById('sub-btn-next').disabled = subPage >= totalPages;
|
| 193 |
|
| 194 |
const tbody = document.getElementById('subscribers-tbody');
|
| 195 |
if (!slice.length) {
|
| 196 |
-
tbody.innerHTML = '<tr><td colspan="4" class="px-6 py-
|
| 197 |
return;
|
| 198 |
}
|
| 199 |
|
| 200 |
tbody.innerHTML = slice.map(u => {
|
| 201 |
-
const
|
| 202 |
-
const statusClass = isActive ? 'bg-green-500/10 text-green-500' : 'bg-red-500/10 text-red-500';
|
| 203 |
-
|
| 204 |
let expiry = 'N/A';
|
| 205 |
if (u.subscription_expiry) {
|
| 206 |
-
|
|
|
|
|
|
|
| 207 |
}
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
const safeName = name.replace(/'/g, "\\'");
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
<td class="px-6 py-4 text-right">
|
| 233 |
-
<div class="flex justify-end gap-2">
|
| 234 |
-
<button onclick="openUserModal(${u._id}, '${safeName}', 'extend')" class="p-2 rounded-lg bg-gray-100 dark:bg-gray-800 hover:text-green-500 transition-colors" title="Extend">
|
| 235 |
-
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" /></svg>
|
| 236 |
-
</button>
|
| 237 |
-
<button onclick="openUserModal(${u._id}, '${safeName}', 'delete')" class="p-2 rounded-lg bg-gray-100 dark:bg-gray-800 hover:text-red-500 transition-colors" title="Revoke">
|
| 238 |
-
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636" /></svg>
|
| 239 |
-
</button>
|
| 240 |
-
</div>
|
| 241 |
-
</td>
|
| 242 |
-
</tr>`;
|
| 243 |
}).join('');
|
| 244 |
}
|
| 245 |
|
| 246 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
function openUserModal(userId, userName, action) {
|
| 248 |
-
const modal = document.getElementById('user-modal');
|
| 249 |
-
const iconContainer = document.getElementById('user-modal-icon');
|
| 250 |
-
const btn = document.getElementById('btn-user-save');
|
| 251 |
-
|
| 252 |
document.getElementById('manage-user-id').value = userId;
|
| 253 |
document.getElementById('manage-action').value = action;
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
}
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
document.getElementById('
|
| 270 |
-
|
|
|
|
| 271 |
}
|
| 272 |
|
| 273 |
-
// (Remaining original JS functions: fetchSubscribers, closePlanModal, closeUserModal, submitPlanForm, deletePlan, getSubFiltered, subChangePage, submitUserForm remain the same but work with the new UI)
|
| 274 |
-
|
| 275 |
-
function closePlanModal() { document.getElementById('plan-modal').classList.add('hidden'); }
|
| 276 |
function closeUserModal() { document.getElementById('user-modal').classList.add('hidden'); }
|
| 277 |
|
| 278 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
document.addEventListener('DOMContentLoaded', () => { fetchPlans(); fetchSubscribers(); });
|
| 280 |
</script>
|
| 281 |
-
|
| 282 |
-
<style>
|
| 283 |
-
.animate-fade-in { animation: fadeIn 0.3s ease-out; }
|
| 284 |
-
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
|
| 285 |
-
</style>
|
| 286 |
-
{% endblock %}
|
|
|
|
| 3 |
{% block title %}Subscription Management - 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">Subscription Management</h1>
|
| 10 |
+
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">Manage subscription plans and view or edit active
|
| 11 |
+
users.</p>
|
| 12 |
</div>
|
| 13 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
<!-- Subscription Plans 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">Subscription Plans</h2>
|
| 19 |
+
<button onclick="openPlanModal()"
|
| 20 |
+
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-md text-sm font-medium transition-colors shadow-sm flex items-center">
|
| 21 |
+
<i class="fas fa-plus mr-2"></i> Add Plan
|
| 22 |
+
</button>
|
| 23 |
</div>
|
| 24 |
<div class="grid grid-cols-1 md:grid-cols-3 gap-6" id="plans-container">
|
| 25 |
+
<div class="col-span-3 text-center text-gray-500 py-8">
|
| 26 |
+
<i class="fas fa-spinner fa-spin mr-2"></i> Loading plans...
|
|
|
|
| 27 |
</div>
|
| 28 |
</div>
|
| 29 |
+
</div>
|
| 30 |
|
| 31 |
+
<!-- User Subscriptions Section -->
|
| 32 |
+
<div class="mb-10">
|
| 33 |
+
<div class="flex items-center justify-between mb-3">
|
| 34 |
+
<h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">User Subscriptions</h2>
|
| 35 |
+
<button onclick="fetchSubscribers()"
|
| 36 |
+
class="bg-gray-200 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-800 dark:text-gray-200 px-4 py-2 rounded-md text-sm font-medium transition-colors shadow-sm flex items-center">
|
| 37 |
+
<i class="fas fa-sync-alt mr-2"></i> Refresh
|
| 38 |
+
</button>
|
| 39 |
+
</div>
|
| 40 |
+
|
| 41 |
+
<!-- Search & Filter bar -->
|
| 42 |
+
<div class="flex flex-wrap gap-3 mb-3 items-center">
|
| 43 |
+
<input id="sub-search" type="text" placeholder="🔍 Search by name, username or ID…"
|
| 44 |
+
class="flex-1 min-w-[200px] border border-gray-300 dark:border-gray-600 rounded-lg px-4 py-2 text-sm focus:outline-none focus:border-primary bg-white dark:bg-gray-800 text-text"
|
| 45 |
+
oninput="renderSubPage()">
|
| 46 |
+
<select id="sub-filter"
|
| 47 |
+
class="border border-gray-300 dark:border-gray-600 rounded-lg px-3 py-2 text-sm focus:outline-none bg-white dark:bg-gray-800 text-text"
|
| 48 |
+
onchange="renderSubPage()">
|
| 49 |
+
<option value="all">All Status</option>
|
| 50 |
+
<option value="active">🟢 Active</option>
|
| 51 |
+
<option value="expired">🔴 Expired</option>
|
| 52 |
+
</select>
|
| 53 |
+
<select id="sub-page-size"
|
| 54 |
+
class="border border-gray-300 dark:border-gray-600 rounded-lg px-3 py-2 text-sm focus:outline-none bg-white dark:bg-gray-800 text-text"
|
| 55 |
+
onchange="subPage=1; renderSubPage()">
|
| 56 |
+
<option value="10">10 / page</option>
|
| 57 |
+
<option value="25">25 / page</option>
|
| 58 |
+
<option value="50">50 / page</option>
|
| 59 |
+
</select>
|
| 60 |
</div>
|
| 61 |
|
| 62 |
+
<div class="theme-card border rounded-xl overflow-hidden shadow-sm">
|
| 63 |
<div class="overflow-x-auto">
|
| 64 |
+
<table class="w-full text-sm text-left">
|
| 65 |
+
<thead class="text-xs uppercase bg-gray-50 dark:bg-gray-800 dark:text-gray-300 border-b">
|
| 66 |
<tr>
|
| 67 |
+
<th class="px-6 py-4 font-semibold">User Details</th>
|
| 68 |
+
<th class="px-6 py-4 font-semibold text-center">Status</th>
|
| 69 |
+
<th class="px-6 py-4 font-semibold text-center">Expiry Date</th>
|
| 70 |
+
<th class="px-6 py-4 font-semibold text-right">Actions</th>
|
| 71 |
</tr>
|
| 72 |
</thead>
|
| 73 |
<tbody id="subscribers-tbody" class="divide-y divide-gray-100 dark:divide-gray-800">
|
| 74 |
+
<tr>
|
| 75 |
+
<td colspan="4" class="px-6 py-8 text-center text-gray-500"><i
|
| 76 |
+
class="fas fa-spinner fa-spin mr-2"></i> Loading...</td>
|
| 77 |
+
</tr>
|
| 78 |
+
</tbody>
|
| 79 |
</table>
|
| 80 |
</div>
|
| 81 |
</div>
|
| 82 |
|
| 83 |
+
<!-- Pagination -->
|
| 84 |
+
<div class="flex items-center justify-between mt-3 text-sm text-text opacity-70" id="sub-pagination">
|
| 85 |
+
<span id="sub-page-info"></span>
|
| 86 |
+
<div class="flex gap-2">
|
| 87 |
+
<button id="sub-btn-prev" onclick="subChangePage(-1)"
|
| 88 |
+
class="px-3 py-1 rounded border border-gray-300 hover:bg-gray-100 transition">‹ Prev</button>
|
| 89 |
+
<span id="sub-page-num" class="px-3 py-1 font-semibold"></span>
|
| 90 |
+
<button id="sub-btn-next" onclick="subChangePage(1)"
|
| 91 |
+
class="px-3 py-1 rounded border border-gray-300 hover:bg-gray-100 transition">Next ›</button>
|
|
|
|
| 92 |
</div>
|
| 93 |
</div>
|
| 94 |
+
</div>
|
| 95 |
</div>
|
| 96 |
|
| 97 |
+
<!-- Plan Modal -->
|
| 98 |
+
<div id="plan-modal" class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full hidden z-50">
|
| 99 |
+
<div class="relative top-20 mx-auto p-5 border shadow-lg rounded-md theme-card sm:w-11/12 md:max-w-md">
|
| 100 |
+
<div class="mt-3 text-center">
|
| 101 |
+
<h3 class="text-lg leading-6 font-medium text-gray-900 dark:text-white mb-2" id="plan-modal-title">Add New
|
| 102 |
+
Plan</h3>
|
| 103 |
+
<div class="mt-2 text-left">
|
| 104 |
+
<form id="plan-form" onsubmit="submitPlanForm(event)">
|
| 105 |
+
<input type="hidden" id="plan-id">
|
| 106 |
+
<div class="mb-4">
|
| 107 |
+
<label class="block text-gray-700 dark:text-gray-300 text-sm font-bold mb-2">Duration
|
| 108 |
+
(Days)</label>
|
| 109 |
+
<input type="number" id="plan-days"
|
| 110 |
+
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none dark:bg-gray-700 dark:text-white dark:border-gray-600"
|
| 111 |
+
required min="1">
|
| 112 |
+
</div>
|
| 113 |
+
<div class="mb-4">
|
| 114 |
+
<label class="block text-gray-700 dark:text-gray-300 text-sm font-bold mb-2">Price (₹)</label>
|
| 115 |
+
<input type="number" id="plan-price"
|
| 116 |
+
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none dark:bg-gray-700 dark:text-white dark:border-gray-600"
|
| 117 |
+
required min="0" step="0.01">
|
| 118 |
+
</div>
|
| 119 |
+
<div class="flex justify-end gap-2 mt-6">
|
| 120 |
+
<button type="button" onclick="closePlanModal()"
|
| 121 |
+
class="bg-gray-300 hover:bg-gray-400 text-gray-800 px-4 py-2 rounded shadow">Cancel</button>
|
| 122 |
+
<button type="submit"
|
| 123 |
+
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded shadow">Save Plan</button>
|
| 124 |
+
</div>
|
| 125 |
+
</form>
|
| 126 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
</div>
|
| 128 |
</div>
|
| 129 |
</div>
|
| 130 |
|
| 131 |
+
<!-- User Action Modal -->
|
| 132 |
+
<div id="user-modal" class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full hidden z-50">
|
| 133 |
+
<div class="relative top-20 mx-auto p-5 border shadow-lg rounded-md theme-card sm:w-11/12 md:max-w-md">
|
| 134 |
+
<div class="mt-3 text-center">
|
| 135 |
+
<h3 class="text-lg leading-6 font-medium text-gray-900 dark:text-white mb-2" id="user-modal-title">Manage
|
| 136 |
+
User</h3>
|
| 137 |
+
<div class="text-sm text-gray-500 dark:text-gray-400 mb-4" id="user-modal-desc"></div>
|
| 138 |
+
<div class="mt-2 text-left">
|
| 139 |
+
<form id="user-form" onsubmit="submitUserForm(event)">
|
| 140 |
+
<input type="hidden" id="manage-user-id">
|
| 141 |
+
<input type="hidden" id="manage-action">
|
| 142 |
+
<div class="mb-4" id="days-input-group">
|
| 143 |
+
<label class="block text-gray-700 dark:text-gray-300 text-sm font-bold mb-2">Days to <span
|
| 144 |
+
id="days-action-label"></span></label>
|
| 145 |
+
<input type="number" id="manage-days"
|
| 146 |
+
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 focus:outline-none dark:bg-gray-700 dark:text-white dark:border-gray-600"
|
| 147 |
+
min="1" value="30">
|
| 148 |
+
</div>
|
| 149 |
+
<div class="flex justify-end gap-2 mt-6">
|
| 150 |
+
<button type="button" onclick="closeUserModal()"
|
| 151 |
+
class="bg-gray-300 hover:bg-gray-400 text-gray-800 px-4 py-2 rounded shadow">Cancel</button>
|
| 152 |
+
<button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded shadow"
|
| 153 |
+
id="btn-user-save">Confirm</button>
|
| 154 |
+
</div>
|
| 155 |
+
</form>
|
| 156 |
+
</div>
|
| 157 |
</div>
|
| 158 |
</div>
|
| 159 |
</div>
|
| 160 |
|
| 161 |
<script>
|
| 162 |
+
// ---- Plans ----
|
| 163 |
async function fetchPlans() {
|
| 164 |
try {
|
| 165 |
const res = await fetch('/api/admin/subscriptions/plans');
|
|
|
|
| 168 |
const data = await res.json();
|
| 169 |
const plans = data.data || data.plans || [];
|
| 170 |
if (!plans.length) {
|
| 171 |
+
container.innerHTML = '<div class="col-span-3 text-center text-gray-500 py-8">No plans found. Create one.</div>';
|
| 172 |
return;
|
| 173 |
}
|
| 174 |
container.innerHTML = plans.map(p => `
|
| 175 |
+
<div class="theme-card rounded-xl border p-6 shadow-sm relative group">
|
| 176 |
+
<div class="absolute right-4 top-4 hidden group-hover:flex gap-2">
|
| 177 |
+
<button onclick="openPlanModal('${p._id}', ${p.days}, ${p.price})" class="text-blue-500 hover:text-blue-700"><i class="fas fa-edit"></i></button>
|
| 178 |
+
<button onclick="deletePlan('${p._id}')" class="text-red-500 hover:text-red-700"><i class="fas fa-trash"></i></button>
|
| 179 |
+
</div>
|
| 180 |
+
<div class="flex items-center">
|
| 181 |
+
<div class="flex-shrink-0 bg-yellow-100 dark:bg-yellow-900/30 p-3 rounded-lg">
|
| 182 |
+
<i class="fas fa-calendar-alt text-xl text-yellow-600 dark:text-yellow-400"></i>
|
| 183 |
+
</div>
|
| 184 |
+
<div class="ml-4">
|
| 185 |
+
<h3 class="text-sm font-medium text-gray-500 dark:text-gray-400">${p.days} Days Plan</h3>
|
| 186 |
+
<p class="text-2xl font-bold text-gray-900 dark:text-white">₹${p.price}</p>
|
| 187 |
+
</div>
|
| 188 |
+
</div>
|
| 189 |
+
</div>`).join('');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
}
|
| 191 |
} catch (err) { console.error(err); }
|
| 192 |
}
|
| 193 |
|
| 194 |
+
function openPlanModal(id = '', days = '', price = '') {
|
| 195 |
+
document.getElementById('plan-id').value = id;
|
| 196 |
+
document.getElementById('plan-days').value = days;
|
| 197 |
+
document.getElementById('plan-price').value = price;
|
| 198 |
+
document.getElementById('plan-modal-title').innerText = id ? 'Edit Plan' : 'Add New Plan';
|
| 199 |
+
document.getElementById('plan-modal').classList.remove('hidden');
|
| 200 |
+
}
|
| 201 |
+
function closePlanModal() { document.getElementById('plan-modal').classList.add('hidden'); }
|
| 202 |
+
|
| 203 |
+
async function submitPlanForm(e) {
|
| 204 |
+
e.preventDefault();
|
| 205 |
+
const id = document.getElementById('plan-id').value;
|
| 206 |
+
const payload = { days: parseInt(document.getElementById('plan-days').value), price: parseFloat(document.getElementById('plan-price').value) };
|
| 207 |
+
const res = await fetch(id ? `/api/admin/subscriptions/plans/${id}` : '/api/admin/subscriptions/plans', {
|
| 208 |
+
method: id ? 'PUT' : 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload)
|
| 209 |
+
});
|
| 210 |
+
if (res.ok) { closePlanModal(); fetchPlans(); } else alert('Failed to save plan.');
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
async function deletePlan(id) {
|
| 214 |
+
if (!confirm('Delete this plan?')) return;
|
| 215 |
+
const res = await fetch(`/api/admin/subscriptions/plans/${id}`, { method: 'DELETE' });
|
| 216 |
+
if (res.ok) fetchPlans(); else alert('Failed to delete.');
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
// ---- Subscribers with Search + Pagination ----
|
| 220 |
+
let allUsers = [];
|
| 221 |
+
let subPage = 1;
|
| 222 |
+
|
| 223 |
+
function getSubFiltered() {
|
| 224 |
+
const q = document.getElementById('sub-search').value.toLowerCase();
|
| 225 |
+
const status = document.getElementById('sub-filter').value;
|
| 226 |
+
return allUsers.filter(u => {
|
| 227 |
+
const name = ((u.first_name || '') + ' ' + (u.username || '') + ' ' + (u._id || '')).toLowerCase();
|
| 228 |
+
const matchQ = !q || name.includes(q);
|
| 229 |
+
const matchStatus = status === 'all' || u.subscription_status === status;
|
| 230 |
+
return matchQ && matchStatus;
|
| 231 |
+
});
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
function renderSubPage() {
|
| 235 |
const filtered = getSubFiltered();
|
| 236 |
+
const pageSize = parseInt(document.getElementById('sub-page-size').value);
|
| 237 |
const totalPages = Math.max(1, Math.ceil(filtered.length / pageSize));
|
| 238 |
if (subPage > totalPages) subPage = totalPages;
|
| 239 |
const start = (subPage - 1) * pageSize;
|
| 240 |
const slice = filtered.slice(start, start + pageSize);
|
| 241 |
|
| 242 |
+
document.getElementById('sub-page-info').textContent = `Showing ${start + 1}–${Math.min(start + pageSize, filtered.length)} of ${filtered.length}`;
|
| 243 |
+
document.getElementById('sub-page-num').textContent = `Page ${subPage} / ${totalPages}`;
|
| 244 |
document.getElementById('sub-btn-prev').disabled = subPage <= 1;
|
| 245 |
document.getElementById('sub-btn-next').disabled = subPage >= totalPages;
|
| 246 |
|
| 247 |
const tbody = document.getElementById('subscribers-tbody');
|
| 248 |
if (!slice.length) {
|
| 249 |
+
tbody.innerHTML = '<tr><td colspan="4" class="px-6 py-8 text-center text-gray-500">No users match your search.</td></tr>';
|
| 250 |
return;
|
| 251 |
}
|
| 252 |
|
| 253 |
tbody.innerHTML = slice.map(u => {
|
| 254 |
+
const statusColor = u.subscription_status === 'active' ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800';
|
|
|
|
|
|
|
| 255 |
let expiry = 'N/A';
|
| 256 |
if (u.subscription_expiry) {
|
| 257 |
+
const d = new Date(u.subscription_expiry);
|
| 258 |
+
expiry = d.toLocaleDateString('en-IN', { timeZone: 'Asia/Kolkata', day: '2-digit', month: 'short', year: 'numeric' }) +
|
| 259 |
+
' ' + d.toLocaleTimeString('en-IN', { timeZone: 'Asia/Kolkata', hour: '2-digit', minute: '2-digit' });
|
| 260 |
}
|
| 261 |
+
let name = u.first_name || '';
|
| 262 |
+
if (u.username) name += (name ? ' ' : '') + `(@${u.username})`;
|
| 263 |
+
if (!name) name = `User ${u._id}`;
|
| 264 |
const safeName = name.replace(/'/g, "\\'");
|
| 265 |
+
return `<tr class="hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors">
|
| 266 |
+
<td class="px-6 py-4">
|
| 267 |
+
<div class="font-medium text-gray-900 dark:text-gray-100">${name}</div>
|
| 268 |
+
<div class="text-xs text-gray-500">ID: ${u._id}</div>
|
| 269 |
+
</td>
|
| 270 |
+
<td class="px-6 py-4 text-center">
|
| 271 |
+
<span class="px-2 py-1 rounded ${statusColor} text-xs font-bold uppercase tracking-wider">${u.subscription_status}</span>
|
| 272 |
+
</td>
|
| 273 |
+
<td class="px-6 py-4 text-center text-sm">${expiry}</td>
|
| 274 |
+
<td class="px-6 py-4 text-right">
|
| 275 |
+
<div class="flex justify-end gap-2 flex-wrap">
|
| 276 |
+
<button onclick="openUserModal(${u._id}, '${safeName}', 'extend')"
|
| 277 |
+
class="bg-green-50 text-green-600 hover:bg-green-100 px-2 py-1 rounded text-xs font-medium border border-green-200">Extend</button>
|
| 278 |
+
<button onclick="openUserModal(${u._id}, '${safeName}', 'reduce')"
|
| 279 |
+
class="bg-yellow-50 text-yellow-600 hover:bg-yellow-100 px-2 py-1 rounded text-xs font-medium border border-yellow-200">Reduce</button>
|
| 280 |
+
<button onclick="openUserModal(${u._id}, '${safeName}', 'delete')"
|
| 281 |
+
class="bg-red-50 text-red-600 hover:bg-red-100 px-2 py-1 rounded text-xs font-medium border border-red-200">Revoke</button>
|
| 282 |
+
</div>
|
| 283 |
+
</td>
|
| 284 |
+
</tr>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
}).join('');
|
| 286 |
}
|
| 287 |
|
| 288 |
+
function subChangePage(dir) { subPage += dir; renderSubPage(); }
|
| 289 |
+
|
| 290 |
+
async function fetchSubscribers() {
|
| 291 |
+
document.getElementById('subscribers-tbody').innerHTML =
|
| 292 |
+
'<tr><td colspan="4" class="px-6 py-8 text-center text-gray-500"><i class="fas fa-spinner fa-spin mr-2"></i> Loading...</td></tr>';
|
| 293 |
+
try {
|
| 294 |
+
const res = await fetch('/api/admin/subscriptions/users');
|
| 295 |
+
if (res.ok) {
|
| 296 |
+
const data = await res.json();
|
| 297 |
+
allUsers = data.data || [];
|
| 298 |
+
subPage = 1;
|
| 299 |
+
renderSubPage();
|
| 300 |
+
}
|
| 301 |
+
} catch (err) { console.error(err); }
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
function openUserModal(userId, userName, action) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
document.getElementById('manage-user-id').value = userId;
|
| 306 |
document.getElementById('manage-action').value = action;
|
| 307 |
+
let title = '', desc = '', btnColor = 'bg-blue-600 hover:bg-blue-700', showDays = true;
|
| 308 |
+
if (action === 'extend') {
|
| 309 |
+
title = 'Extend Subscription'; desc = `Add days to <b>${userName}</b>'s subscription.`;
|
| 310 |
+
document.getElementById('days-action-label').innerText = 'Add';
|
| 311 |
+
} else if (action === 'reduce') {
|
| 312 |
+
title = 'Reduce Subscription'; desc = `Remove days from <b>${userName}</b>'s subscription.`;
|
| 313 |
+
document.getElementById('days-action-label').innerText = 'Subtract'; btnColor = 'bg-yellow-600 hover:bg-yellow-700';
|
| 314 |
+
} else {
|
| 315 |
+
title = 'Revoke Subscription'; desc = `<b>Warning:</b> This will revoke <b>${userName}</b>'s subscription entirely.`;
|
| 316 |
+
showDays = false; btnColor = 'bg-red-600 hover:bg-red-700';
|
| 317 |
+
}
|
| 318 |
+
document.getElementById('user-modal-title').innerText = title;
|
| 319 |
+
document.getElementById('user-modal-desc').innerHTML = desc;
|
| 320 |
+
document.getElementById('days-input-group').className = showDays ? 'mb-4' : 'hidden';
|
| 321 |
+
document.getElementById('btn-user-save').className = `${btnColor} text-white px-4 py-2 rounded shadow`;
|
| 322 |
+
if (!showDays) { document.getElementById('manage-days').value = 0; document.getElementById('manage-days').removeAttribute('required'); }
|
| 323 |
+
else document.getElementById('manage-days').setAttribute('required', 'required');
|
| 324 |
+
document.getElementById('user-modal').classList.remove('hidden');
|
| 325 |
}
|
| 326 |
|
|
|
|
|
|
|
|
|
|
| 327 |
function closeUserModal() { document.getElementById('user-modal').classList.add('hidden'); }
|
| 328 |
|
| 329 |
+
async function submitUserForm(e) {
|
| 330 |
+
e.preventDefault();
|
| 331 |
+
const userId = document.getElementById('manage-user-id').value;
|
| 332 |
+
const action = document.getElementById('manage-action').value;
|
| 333 |
+
const days = document.getElementById('manage-days').value;
|
| 334 |
+
const res = await fetch(`/api/admin/subscriptions/users/${userId}/manage`, {
|
| 335 |
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
| 336 |
+
body: JSON.stringify({ action, days: parseInt(days) || 0 })
|
| 337 |
+
});
|
| 338 |
+
if (res.ok) { closeUserModal(); fetchSubscribers(); } else alert('Failed to update user.');
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
document.addEventListener('DOMContentLoaded', () => { fetchPlans(); fetchSubscribers(); });
|
| 342 |
</script>
|
| 343 |
+
{% endblock %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Backend/fastapi/themes.py
CHANGED
|
@@ -1,15 +1,14 @@
|
|
| 1 |
-
#
|
| 2 |
THEMES = {
|
| 3 |
"purple_gradient": {
|
| 4 |
"name": "Purple Gradient",
|
| 5 |
"colors": {
|
| 6 |
"primary": "#A855F7",
|
| 7 |
-
"secondary": "#7C3AED",
|
| 8 |
"accent": "#C084FC",
|
| 9 |
"background": "#F8FAFC",
|
| 10 |
"card": "#FFFFFF",
|
| 11 |
-
"
|
| 12 |
-
"text": "#0F172A", # Deepened for better readability
|
| 13 |
"text_secondary": "#64748B"
|
| 14 |
},
|
| 15 |
"css_classes": "theme-purple-gradient"
|
|
@@ -17,98 +16,191 @@ THEMES = {
|
|
| 17 |
"blue_navy": {
|
| 18 |
"name": "Navy Blue",
|
| 19 |
"colors": {
|
| 20 |
-
"primary": "#
|
| 21 |
"secondary": "#1E3A8A",
|
| 22 |
"accent": "#3B82F6",
|
| 23 |
"background": "#F1F5F9",
|
| 24 |
"card": "#FFFFFF",
|
| 25 |
-
"border": "#CBD5E1",
|
| 26 |
"text": "#1E293B",
|
| 27 |
"text_secondary": "#475569"
|
| 28 |
},
|
| 29 |
"css_classes": "theme-blue-navy"
|
| 30 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
"dark_professional": {
|
| 32 |
"name": "Dark Professional",
|
| 33 |
"colors": {
|
| 34 |
"primary": "#06B6D4",
|
| 35 |
"secondary": "#0891B2",
|
| 36 |
"accent": "#22D3EE",
|
| 37 |
-
"background": "#0F172A",
|
| 38 |
-
"card": "#1E293B",
|
| 39 |
-
"border": "#334155", # Subtle border for dark mode
|
| 40 |
"text": "#F8FAFC",
|
| 41 |
-
"text_secondary": "#
|
| 42 |
},
|
| 43 |
"css_classes": "theme-dark-professional"
|
| 44 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
"cyber_neon": {
|
| 46 |
"name": "Cyber Neon",
|
| 47 |
"colors": {
|
| 48 |
"primary": "#00FFF0",
|
| 49 |
"secondary": "#FF00FF",
|
| 50 |
"accent": "#00FF88",
|
| 51 |
-
"background": "#
|
| 52 |
-
"card": "#
|
| 53 |
-
"border": "#1A1F3A",
|
| 54 |
"text": "#FFFFFF",
|
| 55 |
-
"text_secondary": "#
|
| 56 |
},
|
| 57 |
"css_classes": "theme-cyber-neon"
|
| 58 |
},
|
| 59 |
-
"
|
| 60 |
-
"name": "
|
| 61 |
"colors": {
|
| 62 |
-
"primary": "#
|
| 63 |
-
"secondary": "#
|
| 64 |
-
"accent": "#
|
| 65 |
-
"background": "#
|
| 66 |
-
"card": "#
|
| 67 |
-
"
|
| 68 |
-
"
|
| 69 |
-
"text_secondary": "#9CA3AF"
|
| 70 |
},
|
| 71 |
-
"css_classes": "theme-
|
| 72 |
},
|
| 73 |
-
"
|
| 74 |
-
"name": "
|
| 75 |
"colors": {
|
| 76 |
-
"primary": "#
|
| 77 |
-
"secondary": "#
|
| 78 |
-
"accent": "#
|
| 79 |
-
"background": "#
|
| 80 |
"card": "#FFFFFF",
|
| 81 |
-
"
|
| 82 |
-
"
|
| 83 |
-
"text_secondary": "#374151"
|
| 84 |
},
|
| 85 |
-
"css_classes": "theme-
|
| 86 |
},
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
"name": "Sunset Warm",
|
| 90 |
"colors": {
|
| 91 |
-
"primary": "#
|
| 92 |
-
"
|
| 93 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
},
|
| 95 |
-
"css_classes": "theme-
|
| 96 |
},
|
| 97 |
-
"
|
| 98 |
-
"name": "
|
| 99 |
"colors": {
|
| 100 |
-
"primary": "#
|
| 101 |
-
"
|
| 102 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
},
|
| 104 |
-
"css_classes": "theme-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
}
|
| 106 |
}
|
| 107 |
|
|
|
|
| 108 |
def get_theme(theme_name: str = "purple_gradient"):
|
| 109 |
-
"""Returns the dictionary for the requested theme or the default."""
|
| 110 |
return THEMES.get(theme_name, THEMES["purple_gradient"])
|
| 111 |
|
|
|
|
| 112 |
def get_all_themes():
|
| 113 |
-
"""Returns all available theme configurations."""
|
| 114 |
return THEMES
|
|
|
|
| 1 |
+
# Theme configurations based on your color palettes
|
| 2 |
THEMES = {
|
| 3 |
"purple_gradient": {
|
| 4 |
"name": "Purple Gradient",
|
| 5 |
"colors": {
|
| 6 |
"primary": "#A855F7",
|
| 7 |
+
"secondary": "#7C3AED",
|
| 8 |
"accent": "#C084FC",
|
| 9 |
"background": "#F8FAFC",
|
| 10 |
"card": "#FFFFFF",
|
| 11 |
+
"text": "#1E293B",
|
|
|
|
| 12 |
"text_secondary": "#64748B"
|
| 13 |
},
|
| 14 |
"css_classes": "theme-purple-gradient"
|
|
|
|
| 16 |
"blue_navy": {
|
| 17 |
"name": "Navy Blue",
|
| 18 |
"colors": {
|
| 19 |
+
"primary": "#1E40AF",
|
| 20 |
"secondary": "#1E3A8A",
|
| 21 |
"accent": "#3B82F6",
|
| 22 |
"background": "#F1F5F9",
|
| 23 |
"card": "#FFFFFF",
|
|
|
|
| 24 |
"text": "#1E293B",
|
| 25 |
"text_secondary": "#475569"
|
| 26 |
},
|
| 27 |
"css_classes": "theme-blue-navy"
|
| 28 |
},
|
| 29 |
+
"sunset_warm": {
|
| 30 |
+
"name": "Sunset Warm",
|
| 31 |
+
"colors": {
|
| 32 |
+
"primary": "#F59E0B",
|
| 33 |
+
"secondary": "#DC2626",
|
| 34 |
+
"accent": "#EC4899",
|
| 35 |
+
"background": "#FFFBEB",
|
| 36 |
+
"card": "#FFFFFF",
|
| 37 |
+
"text": "#1F2937",
|
| 38 |
+
"text_secondary": "#6B7280"
|
| 39 |
+
},
|
| 40 |
+
"css_classes": "theme-sunset-warm"
|
| 41 |
+
},
|
| 42 |
+
"ocean_mint": {
|
| 43 |
+
"name": "Ocean Mint",
|
| 44 |
+
"colors": {
|
| 45 |
+
"primary": "#10B981",
|
| 46 |
+
"secondary": "#059669",
|
| 47 |
+
"accent": "#06B6D4",
|
| 48 |
+
"background": "#F0FDF4",
|
| 49 |
+
"card": "#FFFFFF",
|
| 50 |
+
"text": "#1F2937",
|
| 51 |
+
"text_secondary": "#4B5563"
|
| 52 |
+
},
|
| 53 |
+
"css_classes": "theme-ocean-mint"
|
| 54 |
+
},
|
| 55 |
"dark_professional": {
|
| 56 |
"name": "Dark Professional",
|
| 57 |
"colors": {
|
| 58 |
"primary": "#06B6D4",
|
| 59 |
"secondary": "#0891B2",
|
| 60 |
"accent": "#22D3EE",
|
| 61 |
+
"background": "#0F172A",
|
| 62 |
+
"card": "#1E293B",
|
|
|
|
| 63 |
"text": "#F8FAFC",
|
| 64 |
+
"text_secondary": "#CBD5E1"
|
| 65 |
},
|
| 66 |
"css_classes": "theme-dark-professional"
|
| 67 |
},
|
| 68 |
+
"crimson_elegance": {
|
| 69 |
+
"name": "Crimson Elegance",
|
| 70 |
+
"colors": {
|
| 71 |
+
"primary": "#DC2626",
|
| 72 |
+
"secondary": "#991B1B",
|
| 73 |
+
"accent": "#F87171",
|
| 74 |
+
"background": "#FEF2F2",
|
| 75 |
+
"card": "#FFFFFF",
|
| 76 |
+
"text": "#1F2937",
|
| 77 |
+
"text_secondary": "#6B7280"
|
| 78 |
+
},
|
| 79 |
+
"css_classes": "theme-crimson-elegance"
|
| 80 |
+
},
|
| 81 |
+
"coral_bliss": {
|
| 82 |
+
"name": "Coral Bliss",
|
| 83 |
+
"colors": {
|
| 84 |
+
"primary": "#FF6B6B",
|
| 85 |
+
"secondary": "#EE5A6F",
|
| 86 |
+
"accent": "#FFB347",
|
| 87 |
+
"background": "#FFF5F5",
|
| 88 |
+
"card": "#FFFFFF",
|
| 89 |
+
"text": "#2D3748",
|
| 90 |
+
"text_secondary": "#718096"
|
| 91 |
+
},
|
| 92 |
+
"css_classes": "theme-coral-bliss"
|
| 93 |
+
},
|
| 94 |
"cyber_neon": {
|
| 95 |
"name": "Cyber Neon",
|
| 96 |
"colors": {
|
| 97 |
"primary": "#00FFF0",
|
| 98 |
"secondary": "#FF00FF",
|
| 99 |
"accent": "#00FF88",
|
| 100 |
+
"background": "#0A0E27",
|
| 101 |
+
"card": "#1A1F3A",
|
|
|
|
| 102 |
"text": "#FFFFFF",
|
| 103 |
+
"text_secondary": "#A0AEC0"
|
| 104 |
},
|
| 105 |
"css_classes": "theme-cyber-neon"
|
| 106 |
},
|
| 107 |
+
"forest_earth": {
|
| 108 |
+
"name": "Forest Earth",
|
| 109 |
"colors": {
|
| 110 |
+
"primary": "#2D5016",
|
| 111 |
+
"secondary": "#50623A",
|
| 112 |
+
"accent": "#86A789",
|
| 113 |
+
"background": "#F5F5DC",
|
| 114 |
+
"card": "#FFFFFF",
|
| 115 |
+
"text": "#1C1C1C",
|
| 116 |
+
"text_secondary": "#5C5C5C"
|
|
|
|
| 117 |
},
|
| 118 |
+
"css_classes": "theme-forest-earth"
|
| 119 |
},
|
| 120 |
+
"lavender_dream": {
|
| 121 |
+
"name": "Lavender Dream",
|
| 122 |
"colors": {
|
| 123 |
+
"primary": "#B08BBB",
|
| 124 |
+
"secondary": "#9370DB",
|
| 125 |
+
"accent": "#DDA0DD",
|
| 126 |
+
"background": "#FAF5FF",
|
| 127 |
"card": "#FFFFFF",
|
| 128 |
+
"text": "#2D3748",
|
| 129 |
+
"text_secondary": "#718096"
|
|
|
|
| 130 |
},
|
| 131 |
+
"css_classes": "theme-lavender-dream"
|
| 132 |
},
|
| 133 |
+
"golden_luxury": {
|
| 134 |
+
"name": "Golden Luxury",
|
|
|
|
| 135 |
"colors": {
|
| 136 |
+
"primary": "#D4AF37",
|
| 137 |
+
"secondary": "#B8860B",
|
| 138 |
+
"accent": "#FFD700",
|
| 139 |
+
"background": "#FFFEF7",
|
| 140 |
+
"card": "#FFFFFF",
|
| 141 |
+
"text": "#1A202C",
|
| 142 |
+
"text_secondary": "#4A5568"
|
| 143 |
},
|
| 144 |
+
"css_classes": "theme-golden-luxury"
|
| 145 |
},
|
| 146 |
+
"arctic_frost": {
|
| 147 |
+
"name": "Arctic Frost",
|
| 148 |
"colors": {
|
| 149 |
+
"primary": "#B0E0E6",
|
| 150 |
+
"secondary": "#4682B4",
|
| 151 |
+
"accent": "#87CEEB",
|
| 152 |
+
"background": "#F0F8FF",
|
| 153 |
+
"card": "#FFFFFF",
|
| 154 |
+
"text": "#1E3A5F",
|
| 155 |
+
"text_secondary": "#5B7C99"
|
| 156 |
},
|
| 157 |
+
"css_classes": "theme-arctic-frost"
|
| 158 |
+
},
|
| 159 |
+
"cherry_cola": {
|
| 160 |
+
"name": "Cherry Cola",
|
| 161 |
+
"colors": {
|
| 162 |
+
"primary": "#BF1922",
|
| 163 |
+
"secondary": "#8B0000",
|
| 164 |
+
"accent": "#DC143C",
|
| 165 |
+
"background": "#FFF0F0",
|
| 166 |
+
"card": "#FFFFFF",
|
| 167 |
+
"text": "#1F2937",
|
| 168 |
+
"text_secondary": "#6B7280"
|
| 169 |
+
},
|
| 170 |
+
"css_classes": "theme-cherry-cola"
|
| 171 |
+
},
|
| 172 |
+
"emerald_tech": {
|
| 173 |
+
"name": "Emerald Tech",
|
| 174 |
+
"colors": {
|
| 175 |
+
"primary": "#047857",
|
| 176 |
+
"secondary": "#065F46",
|
| 177 |
+
"accent": "#10B981",
|
| 178 |
+
"background": "#ECFDF5",
|
| 179 |
+
"card": "#FFFFFF",
|
| 180 |
+
"text": "#1F2937",
|
| 181 |
+
"text_secondary": "#4B5563"
|
| 182 |
+
},
|
| 183 |
+
"css_classes": "theme-emerald-tech"
|
| 184 |
+
},
|
| 185 |
+
"midnight_carbon": {
|
| 186 |
+
"name": "Midnight Carbon",
|
| 187 |
+
"colors": {
|
| 188 |
+
"primary": "#3B82F6",
|
| 189 |
+
"secondary": "#1E40AF",
|
| 190 |
+
"accent": "#60A5FA",
|
| 191 |
+
"background": "#111827",
|
| 192 |
+
"card": "#1F2937",
|
| 193 |
+
"text": "#F9FAFB",
|
| 194 |
+
"text_secondary": "#D1D5DB"
|
| 195 |
+
},
|
| 196 |
+
"css_classes": "theme-midnight-carbon"
|
| 197 |
}
|
| 198 |
}
|
| 199 |
|
| 200 |
+
|
| 201 |
def get_theme(theme_name: str = "purple_gradient"):
|
|
|
|
| 202 |
return THEMES.get(theme_name, THEMES["purple_gradient"])
|
| 203 |
|
| 204 |
+
|
| 205 |
def get_all_themes():
|
|
|
|
| 206 |
return THEMES
|
docker-compose.yaml
CHANGED
|
@@ -3,7 +3,7 @@ services:
|
|
| 3 |
build: .
|
| 4 |
container_name: tg_stremio
|
| 5 |
ports:
|
| 6 |
-
- "
|
| 7 |
volumes:
|
| 8 |
- ./config.env:/app/config.env
|
| 9 |
restart: unless-stopped
|
|
|
|
| 3 |
build: .
|
| 4 |
container_name: tg_stremio
|
| 5 |
ports:
|
| 6 |
+
- "8000:8000"
|
| 7 |
volumes:
|
| 8 |
- ./config.env:/app/config.env
|
| 9 |
restart: unless-stopped
|
sample_config.env
CHANGED
|
@@ -12,7 +12,7 @@ AUTH_CHANNEL=""
|
|
| 12 |
DATABASE=""
|
| 13 |
TMDB_API=""
|
| 14 |
BASE_URL=""
|
| 15 |
-
PORT="
|
| 16 |
UPSTREAM_REPO="https://github.com/weebzone/Telegram-Stremio"
|
| 17 |
UPSTREAM_BRANCH="master"
|
| 18 |
ADMIN_USERNAME=""
|
|
|
|
| 12 |
DATABASE=""
|
| 13 |
TMDB_API=""
|
| 14 |
BASE_URL=""
|
| 15 |
+
PORT="8001"
|
| 16 |
UPSTREAM_REPO="https://github.com/weebzone/Telegram-Stremio"
|
| 17 |
UPSTREAM_BRANCH="master"
|
| 18 |
ADMIN_USERNAME=""
|