Karan Adhikari commited on
Redesign Dashboard with Glassmorphism
Browse files- Implemented Glassmorphism UI across all Admin panel components.
- Added support for dynamic color themes (including Cyber Neon and Midnight Carbon)
- Optimized layout for mobile and desktop consistency.
- Backend/fastapi/routes/template_routes.py +10 -10
- Backend/fastapi/templates/access_manage.html +910 -270
- Backend/fastapi/templates/admin_dashboard.html +588 -212
- Backend/fastapi/templates/base.html +387 -203
- Backend/fastapi/templates/dashboard.html +728 -762
- Backend/fastapi/templates/login.html +85 -52
- Backend/fastapi/templates/media_edit.html +558 -518
- Backend/fastapi/templates/media_management.html +236 -223
- Backend/fastapi/templates/public_status.html +0 -71
- Backend/fastapi/templates/stremio_guide.html +0 -114
- Backend/fastapi/templates/subscriptions_manage.html +913 -228
- Backend/fastapi/themes.py +70 -153
- sample_config.env +25 -10
Backend/fastapi/routes/template_routes.py
CHANGED
|
@@ -13,7 +13,7 @@ from Backend.helper.custom_dl import ACTIVE_STREAMS, RECENT_STREAMS
|
|
| 13 |
templates = Jinja2Templates(directory="Backend/fastapi/templates")
|
| 14 |
|
| 15 |
async def admin_dashboard_page(request: Request, _: bool = Depends(require_auth)):
|
| 16 |
-
theme_name = request.session.get("theme", "
|
| 17 |
theme = get_theme(theme_name)
|
| 18 |
current_user = get_current_user(request)
|
| 19 |
|
|
@@ -29,7 +29,7 @@ async def login_page(request: Request):
|
|
| 29 |
if is_authenticated(request):
|
| 30 |
return RedirectResponse(url="/", status_code=302)
|
| 31 |
|
| 32 |
-
theme_name = request.session.get("theme", "
|
| 33 |
theme = get_theme(theme_name)
|
| 34 |
|
| 35 |
return templates.TemplateResponse("login.html", {
|
|
@@ -45,7 +45,7 @@ async def login_post(request: Request, username: str = Form(...), password: str
|
|
| 45 |
request.session["username"] = username
|
| 46 |
return RedirectResponse(url="/", status_code=302)
|
| 47 |
else:
|
| 48 |
-
theme_name = request.session.get("theme", "
|
| 49 |
theme = get_theme(theme_name)
|
| 50 |
return templates.TemplateResponse("login.html", {
|
| 51 |
"request": request,
|
|
@@ -65,7 +65,7 @@ async def set_theme(request: Request, theme: str = Form(...)):
|
|
| 65 |
return RedirectResponse(url=request.headers.get("referer", "/"), status_code=302)
|
| 66 |
|
| 67 |
async def dashboard_page(request: Request, _: bool = Depends(require_auth)):
|
| 68 |
-
theme_name = request.session.get("theme", "
|
| 69 |
theme = get_theme(theme_name)
|
| 70 |
current_user = get_current_user(request)
|
| 71 |
|
|
@@ -159,7 +159,7 @@ async def dashboard_page(request: Request, _: bool = Depends(require_auth)):
|
|
| 159 |
|
| 160 |
|
| 161 |
async def media_management_page(request: Request, media_type: str = "movie", _: bool = Depends(require_auth)):
|
| 162 |
-
theme_name = request.session.get("theme", "
|
| 163 |
theme = get_theme(theme_name)
|
| 164 |
current_user = get_current_user(request)
|
| 165 |
|
|
@@ -173,7 +173,7 @@ async def media_management_page(request: Request, media_type: str = "movie", _:
|
|
| 173 |
})
|
| 174 |
|
| 175 |
async def edit_media_page(request: Request, tmdb_id: int, db_index: int, media_type: str, _: bool = Depends(require_auth)):
|
| 176 |
-
theme_name = request.session.get("theme", "
|
| 177 |
theme = get_theme(theme_name)
|
| 178 |
current_user = get_current_user(request)
|
| 179 |
|
|
@@ -197,7 +197,7 @@ async def edit_media_page(request: Request, tmdb_id: int, db_index: int, media_t
|
|
| 197 |
})
|
| 198 |
|
| 199 |
async def public_status_page(request: Request):
|
| 200 |
-
theme_name = request.session.get("theme", "
|
| 201 |
theme = get_theme(theme_name)
|
| 202 |
|
| 203 |
try:
|
|
@@ -229,7 +229,7 @@ async def public_status_page(request: Request):
|
|
| 229 |
})
|
| 230 |
|
| 231 |
async def stremio_guide_page(request: Request):
|
| 232 |
-
theme_name = request.session.get("theme", "
|
| 233 |
theme = get_theme(theme_name)
|
| 234 |
|
| 235 |
return templates.TemplateResponse("stremio_guide.html", {
|
|
@@ -241,7 +241,7 @@ async def stremio_guide_page(request: Request):
|
|
| 241 |
})
|
| 242 |
|
| 243 |
async def admin_subscriptions_page(request: Request, _: bool = Depends(require_auth)):
|
| 244 |
-
theme_name = request.session.get("theme", "
|
| 245 |
theme = get_theme(theme_name)
|
| 246 |
current_user = get_current_user(request)
|
| 247 |
|
|
@@ -255,7 +255,7 @@ async def admin_subscriptions_page(request: Request, _: bool = Depends(require_a
|
|
| 255 |
|
| 256 |
|
| 257 |
async def admin_access_page(request: Request, _: bool = Depends(require_auth)):
|
| 258 |
-
theme_name = request.session.get("theme", "
|
| 259 |
theme = get_theme(theme_name)
|
| 260 |
current_user = get_current_user(request)
|
| 261 |
|
|
|
|
| 13 |
templates = Jinja2Templates(directory="Backend/fastapi/templates")
|
| 14 |
|
| 15 |
async def admin_dashboard_page(request: Request, _: bool = Depends(require_auth)):
|
| 16 |
+
theme_name = request.session.get("theme", "dark_professional")
|
| 17 |
theme = get_theme(theme_name)
|
| 18 |
current_user = get_current_user(request)
|
| 19 |
|
|
|
|
| 29 |
if is_authenticated(request):
|
| 30 |
return RedirectResponse(url="/", status_code=302)
|
| 31 |
|
| 32 |
+
theme_name = request.session.get("theme", "dark_professional")
|
| 33 |
theme = get_theme(theme_name)
|
| 34 |
|
| 35 |
return templates.TemplateResponse("login.html", {
|
|
|
|
| 45 |
request.session["username"] = username
|
| 46 |
return RedirectResponse(url="/", status_code=302)
|
| 47 |
else:
|
| 48 |
+
theme_name = request.session.get("theme", "dark_professional")
|
| 49 |
theme = get_theme(theme_name)
|
| 50 |
return templates.TemplateResponse("login.html", {
|
| 51 |
"request": request,
|
|
|
|
| 65 |
return RedirectResponse(url=request.headers.get("referer", "/"), status_code=302)
|
| 66 |
|
| 67 |
async def dashboard_page(request: Request, _: bool = Depends(require_auth)):
|
| 68 |
+
theme_name = request.session.get("theme", "dark_professional")
|
| 69 |
theme = get_theme(theme_name)
|
| 70 |
current_user = get_current_user(request)
|
| 71 |
|
|
|
|
| 159 |
|
| 160 |
|
| 161 |
async def media_management_page(request: Request, media_type: str = "movie", _: bool = Depends(require_auth)):
|
| 162 |
+
theme_name = request.session.get("theme", "dark_professional")
|
| 163 |
theme = get_theme(theme_name)
|
| 164 |
current_user = get_current_user(request)
|
| 165 |
|
|
|
|
| 173 |
})
|
| 174 |
|
| 175 |
async def edit_media_page(request: Request, tmdb_id: int, db_index: int, media_type: str, _: bool = Depends(require_auth)):
|
| 176 |
+
theme_name = request.session.get("theme", "dark_professional")
|
| 177 |
theme = get_theme(theme_name)
|
| 178 |
current_user = get_current_user(request)
|
| 179 |
|
|
|
|
| 197 |
})
|
| 198 |
|
| 199 |
async def public_status_page(request: Request):
|
| 200 |
+
theme_name = request.session.get("theme", "dark_professional")
|
| 201 |
theme = get_theme(theme_name)
|
| 202 |
|
| 203 |
try:
|
|
|
|
| 229 |
})
|
| 230 |
|
| 231 |
async def stremio_guide_page(request: Request):
|
| 232 |
+
theme_name = request.session.get("theme", "dark_professional")
|
| 233 |
theme = get_theme(theme_name)
|
| 234 |
|
| 235 |
return templates.TemplateResponse("stremio_guide.html", {
|
|
|
|
| 241 |
})
|
| 242 |
|
| 243 |
async def admin_subscriptions_page(request: Request, _: bool = Depends(require_auth)):
|
| 244 |
+
theme_name = request.session.get("theme", "dark_professional")
|
| 245 |
theme = get_theme(theme_name)
|
| 246 |
current_user = get_current_user(request)
|
| 247 |
|
|
|
|
| 255 |
|
| 256 |
|
| 257 |
async def admin_access_page(request: Request, _: bool = Depends(require_auth)):
|
| 258 |
+
theme_name = request.session.get("theme", "dark_professional")
|
| 259 |
theme = get_theme(theme_name)
|
| 260 |
current_user = get_current_user(request)
|
| 261 |
|
Backend/fastapi/templates/access_manage.html
CHANGED
|
@@ -1,125 +1,563 @@
|
|
| 1 |
{% extends "base.html" %}
|
| 2 |
{% block title %}Access Management{% endblock %}
|
|
|
|
| 3 |
{% block content %}
|
| 4 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
</div>
|
| 12 |
-
|
| 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 |
-
<
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
<div class="
|
| 22 |
-
<div class="text-xs text-text opacity-60 mt-1">Total Tokens</div>
|
| 23 |
</div>
|
| 24 |
-
<div class="
|
| 25 |
-
<div class="
|
| 26 |
-
<div class="
|
| 27 |
</div>
|
| 28 |
-
<div class="
|
| 29 |
-
<div class="
|
| 30 |
-
<div class="
|
| 31 |
</div>
|
| 32 |
-
</
|
| 33 |
|
| 34 |
-
<
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 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 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
<
|
| 69 |
-
|
| 70 |
-
<
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
</table>
|
| 75 |
</div>
|
| 76 |
-
</div>
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
</div>
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
</div>
|
| 92 |
|
| 93 |
-
<
|
| 94 |
-
<div
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
<input type="hidden" id="assign-user-id">
|
| 100 |
|
| 101 |
-
<div class="
|
| 102 |
-
<
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
</div>
|
| 108 |
|
| 109 |
-
<
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
<
|
| 115 |
</div>
|
| 116 |
|
| 117 |
-
<div class="flex justify-end gap-3
|
| 118 |
-
<button onclick="
|
| 119 |
-
|
| 120 |
-
<button
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
| 123 |
</div>
|
| 124 |
</div>
|
| 125 |
</div>
|
|
@@ -128,127 +566,277 @@
|
|
| 128 |
let allTokens = [];
|
| 129 |
let currentPage = 1;
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
function getFiltered() {
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
return matchQ && matchStatus;
|
| 140 |
});
|
| 141 |
}
|
| 142 |
|
| 143 |
-
function
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
const start = (currentPage - 1) * pageSize;
|
| 150 |
-
const slice = filtered.slice(start, start + pageSize);
|
| 151 |
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
let actionBtns = '';
|
|
|
|
| 197 |
if (t.user_id) {
|
| 198 |
-
// Full actions for linked tokens/subscribers
|
| 199 |
actionBtns = `
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 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 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
}
|
| 225 |
|
| 226 |
const revokeTokenBtn = t.token ? `
|
| 227 |
-
<button onclick="revokeToken('${escHtml(t.token)}')"
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
return
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
}
|
| 243 |
|
| 244 |
function changePage(dir) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
currentPage += dir;
|
|
|
|
|
|
|
|
|
|
| 246 |
renderPage();
|
| 247 |
}
|
| 248 |
|
| 249 |
async function loadTokens() {
|
| 250 |
-
|
| 251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
try {
|
| 253 |
const resp = await fetch('/api/admin/access/tokens');
|
| 254 |
const data = await resp.json();
|
|
@@ -261,19 +849,48 @@
|
|
| 261 |
currentPage = 1;
|
| 262 |
renderPage();
|
| 263 |
} catch (err) {
|
| 264 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
}
|
| 266 |
}
|
| 267 |
|
| 268 |
async function loadPlans() {
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
}
|
| 278 |
|
| 279 |
function openAssignModal(userId, userName) {
|
|
@@ -281,12 +898,11 @@
|
|
| 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 |
-
|
| 285 |
-
modal.style.display = 'flex';
|
| 286 |
}
|
| 287 |
|
| 288 |
function closeAssignModal() {
|
| 289 |
-
|
| 290 |
}
|
| 291 |
|
| 292 |
async function assignPlan() {
|
|
@@ -295,7 +911,10 @@
|
|
| 295 |
const planDays = parseInt(document.getElementById('assign-plan-select').value) || 0;
|
| 296 |
const days = customDays || planDays;
|
| 297 |
|
| 298 |
-
if (!days || days < 1) {
|
|
|
|
|
|
|
|
|
|
| 299 |
|
| 300 |
try {
|
| 301 |
const resp = await fetch(`/api/admin/access/users/${userId}/assign-plan`, {
|
|
@@ -303,137 +922,158 @@
|
|
| 303 |
headers: { 'Content-Type': 'application/json' },
|
| 304 |
body: JSON.stringify({ days })
|
| 305 |
});
|
|
|
|
| 306 |
const data = await resp.json();
|
|
|
|
| 307 |
if (resp.ok) {
|
| 308 |
-
showToast(`
|
| 309 |
closeAssignModal();
|
| 310 |
loadTokens();
|
| 311 |
} else {
|
| 312 |
-
showToast(data.detail || 'Failed to assign plan.', '
|
| 313 |
}
|
| 314 |
-
} catch (err) {
|
|
|
|
|
|
|
| 315 |
}
|
| 316 |
|
| 317 |
async function revokeToken(token) {
|
| 318 |
if (!confirm('Delete this token? The user will lose addon access immediately.')) return;
|
|
|
|
| 319 |
try {
|
| 320 |
const resp = await fetch(`/api/admin/access/tokens/${encodeURIComponent(token)}`, { method: 'DELETE' });
|
| 321 |
const data = await resp.json();
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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))) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
try {
|
| 331 |
const resp = await fetch(`/api/admin/access/tokens/${encodeURIComponent(token)}/link-user`, {
|
| 332 |
method: 'PATCH',
|
| 333 |
headers: { 'Content-Type': 'application/json' },
|
| 334 |
body: JSON.stringify({ user_id: parseInt(userId) })
|
| 335 |
});
|
|
|
|
| 336 |
const data = await resp.json();
|
|
|
|
| 337 |
if (resp.ok) {
|
| 338 |
-
showToast(`
|
| 339 |
loadTokens();
|
| 340 |
-
} else {
|
| 341 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 357 |
-
document.getElementById('sub-action-days')
|
| 358 |
const btn = document.getElementById('sub-action-btn');
|
| 359 |
-
|
| 360 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
}
|
| 362 |
|
| 363 |
-
function closeSubModal() {
|
|
|
|
|
|
|
| 364 |
|
| 365 |
async function submitSubAction() {
|
| 366 |
const userId = parseInt(document.getElementById('sub-action-user-id').value);
|
| 367 |
const action = document.getElementById('sub-action-action').value;
|
| 368 |
const days = parseInt(document.getElementById('sub-action-days').value) || 0;
|
|
|
|
| 369 |
try {
|
| 370 |
const resp = await fetch(`/api/admin/subscriptions/users/${userId}/manage`, {
|
| 371 |
method: 'POST',
|
| 372 |
headers: { 'Content-Type': 'application/json' },
|
| 373 |
body: JSON.stringify({ action, days })
|
| 374 |
});
|
|
|
|
| 375 |
const data = await resp.json();
|
|
|
|
| 376 |
if (resp.ok) {
|
| 377 |
-
showToast(`
|
| 378 |
closeSubModal();
|
| 379 |
loadTokens();
|
| 380 |
-
} else {
|
| 381 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 382 |
}
|
| 383 |
|
| 384 |
async function copyLink(url) {
|
| 385 |
-
try {
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 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 %}
|
|
|
|
| 1 |
{% extends "base.html" %}
|
| 2 |
{% block title %}Access Management{% endblock %}
|
| 3 |
+
|
| 4 |
{% block content %}
|
| 5 |
+
<style>
|
| 6 |
+
.access-shell {
|
| 7 |
+
display: flex;
|
| 8 |
+
flex-direction: column;
|
| 9 |
+
gap: 1.5rem;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
.page-hero,
|
| 13 |
+
.section-panel,
|
| 14 |
+
.table-shell,
|
| 15 |
+
.stat-card,
|
| 16 |
+
.mobile-token-card,
|
| 17 |
+
.empty-state,
|
| 18 |
+
.modal-glass {
|
| 19 |
+
background: color-mix(in srgb, var(--card) 50%, transparent);
|
| 20 |
+
backdrop-filter: blur(20px);
|
| 21 |
+
-webkit-backdrop-filter: blur(20px);
|
| 22 |
+
border: 1px solid var(--border);
|
| 23 |
+
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
.page-hero,
|
| 27 |
+
.section-panel,
|
| 28 |
+
.table-shell,
|
| 29 |
+
.stat-card,
|
| 30 |
+
.mobile-token-card,
|
| 31 |
+
.empty-state {
|
| 32 |
+
border-radius: 1.5rem;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
.hero-glow {
|
| 36 |
+
position: relative;
|
| 37 |
+
overflow: hidden;
|
| 38 |
+
isolation: isolate;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
.hero-glow::before {
|
| 42 |
+
content: "";
|
| 43 |
+
position: absolute;
|
| 44 |
+
inset: -30% auto auto -10%;
|
| 45 |
+
width: 16rem;
|
| 46 |
+
height: 16rem;
|
| 47 |
+
border-radius: 9999px;
|
| 48 |
+
background: color-mix(in srgb, var(--primary) 18%, transparent);
|
| 49 |
+
filter: blur(52px);
|
| 50 |
+
z-index: -1;
|
| 51 |
+
pointer-events: none;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.hero-glow::after {
|
| 55 |
+
content: "";
|
| 56 |
+
position: absolute;
|
| 57 |
+
inset: auto -4% -34% auto;
|
| 58 |
+
width: 14rem;
|
| 59 |
+
height: 14rem;
|
| 60 |
+
border-radius: 9999px;
|
| 61 |
+
background: color-mix(in srgb, var(--accent) 16%, transparent);
|
| 62 |
+
filter: blur(52px);
|
| 63 |
+
z-index: -1;
|
| 64 |
+
pointer-events: none;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
.section-title { color: var(--text); }
|
| 68 |
+
.section-muted { color: var(--text-sec); }
|
| 69 |
+
|
| 70 |
+
.glass-btn {
|
| 71 |
+
border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
|
| 72 |
+
background: color-mix(in srgb, var(--card) 72%, transparent);
|
| 73 |
+
color: var(--text);
|
| 74 |
+
backdrop-filter: blur(14px);
|
| 75 |
+
-webkit-backdrop-filter: blur(14px);
|
| 76 |
+
transition: all 0.25s ease;
|
| 77 |
+
box-shadow: 0 8px 24px rgba(0,0,0,0.14);
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
.glass-btn:hover {
|
| 81 |
+
transform: translateY(-1px);
|
| 82 |
+
border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
|
| 83 |
+
box-shadow: 0 10px 28px rgba(0,0,0,0.18);
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
.glass-btn-primary {
|
| 87 |
+
background: linear-gradient(
|
| 88 |
+
135deg,
|
| 89 |
+
color-mix(in srgb, var(--primary) 88%, white 8%),
|
| 90 |
+
color-mix(in srgb, var(--accent) 82%, var(--primary) 18%)
|
| 91 |
+
);
|
| 92 |
+
color: white;
|
| 93 |
+
border: 1px solid color-mix(in srgb, var(--primary) 50%, transparent);
|
| 94 |
+
box-shadow: 0 10px 26px color-mix(in srgb, var(--primary) 22%, transparent);
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
.glass-btn-primary:hover {
|
| 98 |
+
filter: brightness(1.05);
|
| 99 |
+
box-shadow: 0 14px 34px color-mix(in srgb, var(--primary) 28%, transparent);
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.glass-btn-success {
|
| 103 |
+
background: color-mix(in srgb, #22c55e 18%, transparent);
|
| 104 |
+
color: #bbf7d0;
|
| 105 |
+
border-color: color-mix(in srgb, #22c55e 40%, transparent);
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
.glass-btn-warning {
|
| 109 |
+
background: color-mix(in srgb, #f59e0b 20%, transparent);
|
| 110 |
+
color: #fde68a;
|
| 111 |
+
border-color: color-mix(in srgb, #f59e0b 40%, transparent);
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
.glass-btn-danger {
|
| 115 |
+
background: color-mix(in srgb, #ef4444 20%, transparent);
|
| 116 |
+
color: #fecaca;
|
| 117 |
+
border-color: color-mix(in srgb, #ef4444 40%, transparent);
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
.glass-btn-purple {
|
| 121 |
+
background: color-mix(in srgb, #a855f7 18%, transparent);
|
| 122 |
+
color: #e9d5ff;
|
| 123 |
+
border-color: color-mix(in srgb, #a855f7 40%, transparent);
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
.glass-input,
|
| 127 |
+
.glass-select {
|
| 128 |
+
width: 100%;
|
| 129 |
+
border-radius: 1rem;
|
| 130 |
+
border: 1px solid color-mix(in srgb, var(--border) 90%, transparent);
|
| 131 |
+
background: color-mix(in srgb, var(--bg) 68%, transparent);
|
| 132 |
+
color: var(--text);
|
| 133 |
+
padding: 0.85rem 1rem;
|
| 134 |
+
outline: none;
|
| 135 |
+
transition: all 0.2s ease;
|
| 136 |
+
box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
.glass-input::placeholder {
|
| 140 |
+
color: color-mix(in srgb, var(--text-sec) 85%, transparent);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
.glass-input:focus,
|
| 144 |
+
.glass-select:focus {
|
| 145 |
+
border-color: color-mix(in srgb, var(--primary) 65%, var(--border));
|
| 146 |
+
box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 12%, transparent);
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
.stat-card {
|
| 150 |
+
padding: 1.25rem;
|
| 151 |
+
text-align: center;
|
| 152 |
+
position: relative;
|
| 153 |
+
overflow: hidden;
|
| 154 |
+
}
|
| 155 |
|
| 156 |
+
.stat-card::before {
|
| 157 |
+
content: "";
|
| 158 |
+
position: absolute;
|
| 159 |
+
width: 7rem;
|
| 160 |
+
height: 7rem;
|
| 161 |
+
border-radius: 9999px;
|
| 162 |
+
filter: blur(42px);
|
| 163 |
+
top: -25%;
|
| 164 |
+
right: -10%;
|
| 165 |
+
opacity: 0.7;
|
| 166 |
+
pointer-events: none;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
.stat-primary::before { background: color-mix(in srgb, var(--primary) 24%, transparent); }
|
| 170 |
+
.stat-success::before { background: color-mix(in srgb, #22c55e 24%, transparent); }
|
| 171 |
+
.stat-danger::before { background: color-mix(in srgb, #ef4444 24%, transparent); }
|
| 172 |
+
|
| 173 |
+
.stat-value {
|
| 174 |
+
font-size: 1.9rem;
|
| 175 |
+
font-weight: 800;
|
| 176 |
+
line-height: 1;
|
| 177 |
+
position: relative;
|
| 178 |
+
z-index: 1;
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
.stat-label {
|
| 182 |
+
margin-top: 0.55rem;
|
| 183 |
+
font-size: 0.76rem;
|
| 184 |
+
font-weight: 700;
|
| 185 |
+
letter-spacing: 0.08em;
|
| 186 |
+
text-transform: uppercase;
|
| 187 |
+
color: var(--text-sec);
|
| 188 |
+
position: relative;
|
| 189 |
+
z-index: 1;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
.table-shell { overflow: hidden; }
|
| 193 |
+
|
| 194 |
+
.access-table {
|
| 195 |
+
width: 100%;
|
| 196 |
+
border-collapse: separate;
|
| 197 |
+
border-spacing: 0;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
.access-table thead th {
|
| 201 |
+
background: color-mix(in srgb, var(--bg) 65%, transparent);
|
| 202 |
+
color: var(--text-sec);
|
| 203 |
+
font-size: 0.72rem;
|
| 204 |
+
text-transform: uppercase;
|
| 205 |
+
letter-spacing: 0.08em;
|
| 206 |
+
border-bottom: 1px solid color-mix(in srgb, var(--border) 92%, transparent);
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
.access-table tbody tr {
|
| 210 |
+
transition: background 0.22s ease;
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
.access-table tbody tr:hover {
|
| 214 |
+
background: color-mix(in srgb, var(--primary) 6%, transparent);
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
.access-table td {
|
| 218 |
+
border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
|
| 219 |
+
color: var(--text);
|
| 220 |
+
vertical-align: top;
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
.access-table tbody tr:last-child td {
|
| 224 |
+
border-bottom: none;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
.row-expired {
|
| 228 |
+
background: color-mix(in srgb, #ef4444 8%, transparent);
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
.status-badge {
|
| 232 |
+
display: inline-flex;
|
| 233 |
+
align-items: center;
|
| 234 |
+
gap: 0.45rem;
|
| 235 |
+
padding: 0.45rem 0.8rem;
|
| 236 |
+
border-radius: 9999px;
|
| 237 |
+
font-size: 0.78rem;
|
| 238 |
+
font-weight: 700;
|
| 239 |
+
letter-spacing: 0.02em;
|
| 240 |
+
border: 1px solid transparent;
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
.status-active {
|
| 244 |
+
background: color-mix(in srgb, #22c55e 16%, transparent);
|
| 245 |
+
color: #86efac;
|
| 246 |
+
border-color: color-mix(in srgb, #22c55e 28%, transparent);
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
.status-expired {
|
| 250 |
+
background: color-mix(in srgb, #ef4444 14%, transparent);
|
| 251 |
+
color: #fca5a5;
|
| 252 |
+
border-color: color-mix(in srgb, #ef4444 28%, transparent);
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
.status-warning {
|
| 256 |
+
background: color-mix(in srgb, #f59e0b 16%, transparent);
|
| 257 |
+
color: #fde68a;
|
| 258 |
+
border-color: color-mix(in srgb, #f59e0b 28%, transparent);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
.action-chip {
|
| 262 |
+
border-radius: 9999px;
|
| 263 |
+
padding: 0.5rem 0.85rem;
|
| 264 |
+
font-size: 0.72rem;
|
| 265 |
+
font-weight: 700;
|
| 266 |
+
border: 1px solid transparent;
|
| 267 |
+
transition: all 0.2s ease;
|
| 268 |
+
white-space: nowrap;
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
.action-chip:hover {
|
| 272 |
+
transform: translateY(-1px);
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
.addon-box {
|
| 276 |
+
padding: 0.8rem;
|
| 277 |
+
border-radius: 1rem;
|
| 278 |
+
background: color-mix(in srgb, var(--bg) 56%, transparent);
|
| 279 |
+
border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
.mobile-token-card {
|
| 283 |
+
padding: 1rem;
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
.mobile-token-card + .mobile-token-card {
|
| 287 |
+
margin-top: 0.9rem;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
.mobile-grid {
|
| 291 |
+
display: none;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
.pagination-shell {
|
| 295 |
+
display: flex;
|
| 296 |
+
align-items: center;
|
| 297 |
+
justify-content: space-between;
|
| 298 |
+
gap: 1rem;
|
| 299 |
+
flex-wrap: wrap;
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
.pagination-text {
|
| 303 |
+
color: var(--text-sec);
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
.pagination-btn {
|
| 307 |
+
min-width: 92px;
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
.modal-backdrop {
|
| 311 |
+
background: rgba(4, 8, 18, 0.58);
|
| 312 |
+
backdrop-filter: blur(10px);
|
| 313 |
+
-webkit-backdrop-filter: blur(10px);
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
.modal-glass {
|
| 317 |
+
border-radius: 1.6rem;
|
| 318 |
+
padding: 1.4rem;
|
| 319 |
+
border: 1px solid color-mix(in srgb, var(--border) 95%, transparent);
|
| 320 |
+
width: min(92vw, 32rem);
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
.modal-field label {
|
| 324 |
+
color: var(--text-sec);
|
| 325 |
+
font-size: 0.82rem;
|
| 326 |
+
font-weight: 700;
|
| 327 |
+
margin-bottom: 0.55rem;
|
| 328 |
+
display: block;
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
.text-soft { color: var(--text-sec); }
|
| 332 |
+
|
| 333 |
+
.no-scrollbar::-webkit-scrollbar { display: none; }
|
| 334 |
+
.no-scrollbar {
|
| 335 |
+
-ms-overflow-style: none;
|
| 336 |
+
scrollbar-width: none;
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
@media (max-width: 1024px) {
|
| 340 |
+
.access-table th,
|
| 341 |
+
.access-table td {
|
| 342 |
+
padding-left: 1rem;
|
| 343 |
+
padding-right: 1rem;
|
| 344 |
+
}
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
@media (max-width: 767px) {
|
| 348 |
+
.desktop-table-wrap {
|
| 349 |
+
display: none;
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
.mobile-grid {
|
| 353 |
+
display: block;
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
.page-hero,
|
| 357 |
+
.section-panel {
|
| 358 |
+
padding: 1rem;
|
| 359 |
+
border-radius: 1.35rem;
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
.pagination-shell {
|
| 363 |
+
flex-direction: column;
|
| 364 |
+
align-items: stretch;
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
.pagination-shell .controls {
|
| 368 |
+
width: 100%;
|
| 369 |
+
display: grid;
|
| 370 |
+
grid-template-columns: 1fr auto 1fr;
|
| 371 |
+
gap: 0.6rem;
|
| 372 |
+
align-items: center;
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
.pagination-btn {
|
| 376 |
+
width: 100%;
|
| 377 |
+
}
|
| 378 |
+
}
|
| 379 |
+
</style>
|
| 380 |
+
|
| 381 |
+
<div class="access-shell py-2 sm:py-4">
|
| 382 |
+
<section class="page-hero hero-glow p-5 sm:p-6 lg:p-8">
|
| 383 |
+
<div class="flex flex-col gap-5 lg:flex-row lg:items-center lg:justify-between">
|
| 384 |
+
<div>
|
| 385 |
+
<div class="inline-flex items-center gap-2 rounded-full border px-3 py-1 text-xs font-bold tracking-[0.18em] uppercase mb-3"
|
| 386 |
+
style="border-color: color-mix(in srgb, var(--primary) 28%, var(--border)); color: var(--text-sec); background: color-mix(in srgb, var(--primary) 10%, transparent);">
|
| 387 |
+
<i class="fas fa-shield-halved text-[11px]" style="color: var(--primary);"></i>
|
| 388 |
+
Access Control Hub
|
| 389 |
+
</div>
|
| 390 |
+
<h1 class="text-2xl sm:text-3xl lg:text-4xl font-extrabold tracking-tight section-title">
|
| 391 |
+
Access Management
|
| 392 |
+
</h1>
|
| 393 |
+
<p class="mt-2 text-sm sm:text-base section-muted max-w-2xl">
|
| 394 |
+
Manage addon access tokens, link users, assign plans, and control subscription access.
|
| 395 |
+
</p>
|
| 396 |
+
</div>
|
| 397 |
+
|
| 398 |
+
<div class="flex flex-wrap gap-3">
|
| 399 |
+
<button onclick="loadTokens()" class="glass-btn glass-btn-primary rounded-2xl px-5 py-3 text-sm font-bold inline-flex items-center gap-2">
|
| 400 |
+
<i class="fas fa-rotate-right"></i>
|
| 401 |
+
Refresh
|
| 402 |
+
</button>
|
| 403 |
+
</div>
|
| 404 |
</div>
|
| 405 |
+
</section>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
|
| 407 |
+
<section class="grid grid-cols-1 sm:grid-cols-3 gap-4">
|
| 408 |
+
<div class="stat-card stat-primary">
|
| 409 |
+
<div class="stat-value" style="color: var(--primary);" id="stat-total">–</div>
|
| 410 |
+
<div class="stat-label">Total Tokens</div>
|
|
|
|
| 411 |
</div>
|
| 412 |
+
<div class="stat-card stat-success">
|
| 413 |
+
<div class="stat-value" style="color: #4ade80;" id="stat-active">–</div>
|
| 414 |
+
<div class="stat-label">Active</div>
|
| 415 |
</div>
|
| 416 |
+
<div class="stat-card stat-danger">
|
| 417 |
+
<div class="stat-value" style="color: #f87171;" id="stat-expired">–</div>
|
| 418 |
+
<div class="stat-label">Expired / No Sub</div>
|
| 419 |
</div>
|
| 420 |
+
</section>
|
| 421 |
|
| 422 |
+
<section class="section-panel p-4 sm:p-5 lg:p-6">
|
| 423 |
+
<div class="flex flex-col lg:flex-row lg:items-end lg:justify-between gap-4 mb-5">
|
| 424 |
+
<div>
|
| 425 |
+
<h2 class="text-lg sm:text-xl font-bold section-title">Access Tokens</h2>
|
| 426 |
+
<p class="text-sm section-muted mt-1">Search, filter, manage tokens, and control user access.</p>
|
| 427 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 428 |
|
| 429 |
+
<div class="w-full lg:w-auto grid grid-cols-1 sm:grid-cols-3 gap-3">
|
| 430 |
+
<input
|
| 431 |
+
id="search-input"
|
| 432 |
+
type="text"
|
| 433 |
+
placeholder="Search by name or user ID..."
|
| 434 |
+
class="glass-input"
|
| 435 |
+
oninput="currentPage=1; renderPage()"
|
| 436 |
+
>
|
| 437 |
+
<select id="filter-status" class="glass-select" onchange="currentPage=1; renderPage()">
|
| 438 |
+
<option value="all">All Status</option>
|
| 439 |
+
<option value="active">Active</option>
|
| 440 |
+
<option value="expired">Expired</option>
|
| 441 |
+
</select>
|
| 442 |
+
<select id="page-size" class="glass-select" onchange="currentPage=1; renderPage()">
|
| 443 |
+
<option value="10">10 / page</option>
|
| 444 |
+
<option value="25">25 / page</option>
|
| 445 |
+
<option value="50">50 / page</option>
|
| 446 |
+
</select>
|
| 447 |
+
</div>
|
|
|
|
| 448 |
</div>
|
|
|
|
| 449 |
|
| 450 |
+
<div class="desktop-table-wrap table-shell">
|
| 451 |
+
<div class="overflow-x-auto no-scrollbar">
|
| 452 |
+
<table class="access-table min-w-[1120px] text-sm">
|
| 453 |
+
<thead>
|
| 454 |
+
<tr>
|
| 455 |
+
<th class="px-4 py-4 text-left font-semibold">Status</th>
|
| 456 |
+
<th class="px-4 py-4 text-left font-semibold">User</th>
|
| 457 |
+
<th class="px-4 py-4 text-left font-semibold">Addon Link</th>
|
| 458 |
+
<th class="px-4 py-4 text-left font-semibold">Created</th>
|
| 459 |
+
<th class="px-4 py-4 text-left font-semibold">Expires</th>
|
| 460 |
+
<th class="px-4 py-4 text-center font-semibold">Actions</th>
|
| 461 |
+
</tr>
|
| 462 |
+
</thead>
|
| 463 |
+
<tbody id="token-table-body">
|
| 464 |
+
<tr>
|
| 465 |
+
<td colspan="6" class="text-center py-10 text-soft">Loading tokens…</td>
|
| 466 |
+
</tr>
|
| 467 |
+
</tbody>
|
| 468 |
+
</table>
|
| 469 |
+
</div>
|
| 470 |
</div>
|
| 471 |
+
|
| 472 |
+
<div id="token-mobile-list" class="mobile-grid mt-1">
|
| 473 |
+
<div class="empty-state text-center px-4 py-8 text-soft">Loading tokens…</div>
|
| 474 |
+
</div>
|
| 475 |
+
|
| 476 |
+
<div class="pagination-shell mt-5" id="pagination-bar">
|
| 477 |
+
<div id="page-info" class="pagination-text text-sm"></div>
|
| 478 |
+
<div class="controls">
|
| 479 |
+
<button id="btn-prev" onclick="changePage(-1)"
|
| 480 |
+
class="glass-btn pagination-btn rounded-xl px-4 py-2.5 text-sm font-semibold">
|
| 481 |
+
‹ Prev
|
| 482 |
+
</button>
|
| 483 |
+
<span id="page-num" class="text-sm font-bold text-center section-title px-2"></span>
|
| 484 |
+
<button id="btn-next" onclick="changePage(1)"
|
| 485 |
+
class="glass-btn pagination-btn rounded-xl px-4 py-2.5 text-sm font-semibold">
|
| 486 |
+
Next ›
|
| 487 |
+
</button>
|
| 488 |
+
</div>
|
| 489 |
+
</div>
|
| 490 |
+
</section>
|
| 491 |
</div>
|
| 492 |
|
| 493 |
+
<div id="assign-modal" class="fixed inset-0 hidden z-50 modal-backdrop items-center justify-center p-4">
|
| 494 |
+
<div class="modal-glass">
|
| 495 |
+
<div class="flex items-start justify-between gap-4 mb-5">
|
| 496 |
+
<div>
|
| 497 |
+
<h3 class="text-xl font-bold section-title">Assign Subscription Plan</h3>
|
| 498 |
+
<p class="text-sm text-soft mt-1" id="assign-user-label">User: –</p>
|
| 499 |
+
</div>
|
| 500 |
+
<button onclick="closeAssignModal()" class="glass-btn rounded-full w-10 h-10 flex items-center justify-center">
|
| 501 |
+
<i class="fas fa-xmark"></i>
|
| 502 |
+
</button>
|
| 503 |
+
</div>
|
| 504 |
+
|
| 505 |
<input type="hidden" id="assign-user-id">
|
| 506 |
|
| 507 |
+
<div class="space-y-4">
|
| 508 |
+
<div class="modal-field">
|
| 509 |
+
<label>Select a Plan</label>
|
| 510 |
+
<select id="assign-plan-select" class="glass-select">
|
| 511 |
+
<option value="">— Select plan —</option>
|
| 512 |
+
</select>
|
| 513 |
+
</div>
|
| 514 |
+
|
| 515 |
+
<div class="modal-field">
|
| 516 |
+
<label>Or enter custom days</label>
|
| 517 |
+
<input type="number" id="assign-custom-days" placeholder="e.g. 30" min="1" class="glass-input">
|
| 518 |
+
<p class="text-xs text-soft mt-2">Custom days override selected plan.</p>
|
| 519 |
+
</div>
|
| 520 |
+
</div>
|
| 521 |
+
|
| 522 |
+
<div class="flex flex-col-reverse sm:flex-row justify-end gap-3 pt-6">
|
| 523 |
+
<button onclick="closeAssignModal()" class="glass-btn rounded-2xl px-5 py-3 text-sm font-bold">
|
| 524 |
+
Cancel
|
| 525 |
+
</button>
|
| 526 |
+
<button onclick="assignPlan()" class="glass-btn glass-btn-primary rounded-2xl px-5 py-3 text-sm font-bold">
|
| 527 |
+
Assign & Activate
|
| 528 |
+
</button>
|
| 529 |
+
</div>
|
| 530 |
+
</div>
|
| 531 |
+
</div>
|
| 532 |
+
|
| 533 |
+
<div id="sub-action-modal" class="fixed inset-0 hidden z-50 modal-backdrop items-center justify-center p-4">
|
| 534 |
+
<div class="modal-glass">
|
| 535 |
+
<div class="flex items-start justify-between gap-4 mb-5">
|
| 536 |
+
<div>
|
| 537 |
+
<h3 class="text-xl font-bold section-title" id="sub-action-title">Manage Subscription</h3>
|
| 538 |
+
<p class="text-sm text-soft mt-1" id="sub-action-desc"></p>
|
| 539 |
+
</div>
|
| 540 |
+
<button onclick="closeSubModal()" class="glass-btn rounded-full w-10 h-10 flex items-center justify-center">
|
| 541 |
+
<i class="fas fa-xmark"></i>
|
| 542 |
+
</button>
|
| 543 |
</div>
|
| 544 |
|
| 545 |
+
<input type="hidden" id="sub-action-user-id">
|
| 546 |
+
<input type="hidden" id="sub-action-action">
|
| 547 |
+
|
| 548 |
+
<div id="sub-action-days-group" class="modal-field">
|
| 549 |
+
<label>Number of Days</label>
|
| 550 |
+
<input type="number" id="sub-action-days" value="30" min="1" class="glass-input">
|
| 551 |
</div>
|
| 552 |
|
| 553 |
+
<div class="flex flex-col-reverse sm:flex-row justify-end gap-3 pt-6">
|
| 554 |
+
<button onclick="closeSubModal()" class="glass-btn rounded-2xl px-5 py-3 text-sm font-bold">
|
| 555 |
+
Cancel
|
| 556 |
+
</button>
|
| 557 |
+
<button id="sub-action-btn" onclick="submitSubAction()"
|
| 558 |
+
class="glass-btn glass-btn-success rounded-2xl px-5 py-3 text-sm font-bold">
|
| 559 |
+
Confirm
|
| 560 |
+
</button>
|
| 561 |
</div>
|
| 562 |
</div>
|
| 563 |
</div>
|
|
|
|
| 566 |
let allTokens = [];
|
| 567 |
let currentPage = 1;
|
| 568 |
|
| 569 |
+
function fmtDate(iso) {
|
| 570 |
+
if (!iso) return '—';
|
| 571 |
+
const d = new Date(iso);
|
| 572 |
+
return d.toLocaleDateString('en-IN', {
|
| 573 |
+
timeZone: 'Asia/Kolkata',
|
| 574 |
+
day: '2-digit',
|
| 575 |
+
month: 'short',
|
| 576 |
+
year: 'numeric'
|
| 577 |
+
}) + ' ' + d.toLocaleTimeString('en-IN', {
|
| 578 |
+
timeZone: 'Asia/Kolkata',
|
| 579 |
+
hour: '2-digit',
|
| 580 |
+
minute: '2-digit'
|
| 581 |
+
});
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
function escHtml(s) {
|
| 585 |
+
return String(s || '')
|
| 586 |
+
.replace(/&/g, '&')
|
| 587 |
+
.replace(/</g, '<')
|
| 588 |
+
.replace(/>/g, '>')
|
| 589 |
+
.replace(/"/g, '"')
|
| 590 |
+
.replace(/'/g, ''');
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
function getFiltered() {
|
| 594 |
+
const q = document.getElementById('search-input').value.toLowerCase().trim();
|
| 595 |
const status = document.getElementById('filter-status').value;
|
| 596 |
+
|
| 597 |
return allTokens.filter(t => {
|
| 598 |
const matchQ = !q ||
|
| 599 |
(t.user_name && t.user_name.toLowerCase().includes(q)) ||
|
| 600 |
(t.user_id && String(t.user_id).includes(q));
|
| 601 |
+
|
| 602 |
+
const matchStatus =
|
| 603 |
+
status === 'all' ||
|
| 604 |
+
(status === 'active' && !t.is_expired) ||
|
| 605 |
+
(status === 'expired' && t.is_expired);
|
| 606 |
+
|
| 607 |
return matchQ && matchStatus;
|
| 608 |
});
|
| 609 |
}
|
| 610 |
|
| 611 |
+
function getStatusBadge(t) {
|
| 612 |
+
return t.is_expired
|
| 613 |
+
? `<span class="status-badge status-expired"><i class="fas fa-circle text-[8px]"></i> Expired</span>`
|
| 614 |
+
: `<span class="status-badge status-active"><i class="fas fa-circle text-[8px]"></i> Active</span>`;
|
| 615 |
+
}
|
|
|
|
|
|
|
|
|
|
| 616 |
|
| 617 |
+
function buildAddonHtml(t) {
|
| 618 |
+
if (!t.has_token) {
|
| 619 |
+
return `
|
| 620 |
+
<div class="addon-box">
|
| 621 |
+
<span class="status-badge status-warning">No Token Yet</span>
|
| 622 |
+
<div class="text-xs text-soft italic mt-2">User hasn't generated addon token via bot.</div>
|
| 623 |
+
</div>
|
| 624 |
+
`;
|
| 625 |
+
}
|
| 626 |
|
| 627 |
+
if (t.is_expired) {
|
| 628 |
+
return `
|
| 629 |
+
<div class="addon-box">
|
| 630 |
+
<span class="status-badge status-expired">Subscription Expired</span>
|
| 631 |
+
<div class="text-xs text-soft italic mt-2">
|
| 632 |
+
${t.user_found ? 'Subscription inactive/expired' : 'No subscription record'}
|
| 633 |
+
</div>
|
| 634 |
+
${t.addon_url ? `
|
| 635 |
+
<button onclick="copyLink('${escHtml(t.addon_url)}')"
|
| 636 |
+
class="mt-3 text-xs font-semibold underline opacity-70 hover:opacity-100 transition">
|
| 637 |
+
Copy URL (admin)
|
| 638 |
+
</button>
|
| 639 |
+
` : ''}
|
| 640 |
+
</div>
|
| 641 |
+
`;
|
| 642 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 643 |
|
| 644 |
+
return t.addon_url
|
| 645 |
+
? `
|
| 646 |
+
<div class="addon-box">
|
| 647 |
+
<button onclick="copyLink('${escHtml(t.addon_url)}')"
|
| 648 |
+
class="glass-btn glass-btn-primary rounded-xl px-3 py-2 text-xs font-bold inline-flex items-center gap-2">
|
| 649 |
+
<i class="fas fa-copy"></i>
|
| 650 |
+
Copy Install Link
|
| 651 |
+
</button>
|
| 652 |
+
</div>
|
| 653 |
+
`
|
| 654 |
+
: `<div class="addon-box text-soft text-xs">—</div>`;
|
| 655 |
+
}
|
| 656 |
+
|
| 657 |
+
function buildActions(t) {
|
| 658 |
+
const safeName = escHtml(t.user_name || String(t.user_id || ''));
|
| 659 |
let actionBtns = '';
|
| 660 |
+
|
| 661 |
if (t.user_id) {
|
|
|
|
| 662 |
actionBtns = `
|
| 663 |
+
<button onclick="openAssignModal(${t.user_id}, '${safeName}')" class="action-chip glass-btn-primary">
|
| 664 |
+
Assign
|
| 665 |
+
</button>
|
| 666 |
+
<button onclick="openSubModal(${t.user_id}, '${safeName}', 'extend')" class="action-chip glass-btn-success">
|
| 667 |
+
Extend
|
| 668 |
+
</button>
|
| 669 |
+
<button onclick="openSubModal(${t.user_id}, '${safeName}', 'reduce')" class="action-chip glass-btn-warning">
|
| 670 |
+
Reduce
|
| 671 |
+
</button>
|
| 672 |
+
<button onclick="openSubModal(${t.user_id}, '${safeName}', 'delete')" class="action-chip glass-btn-danger">
|
| 673 |
+
Revoke
|
| 674 |
+
</button>
|
| 675 |
+
`;
|
|
|
|
|
|
|
|
|
|
| 676 |
} else if (t.token) {
|
|
|
|
| 677 |
actionBtns = `
|
| 678 |
+
<button onclick="linkUser('${escHtml(t.token)}')" class="action-chip glass-btn-purple">
|
| 679 |
+
Link User ID
|
| 680 |
+
</button>
|
| 681 |
+
<div class="text-xs text-soft italic w-full mt-1">Enter Telegram user_id to enable management.</div>
|
| 682 |
+
`;
|
| 683 |
}
|
| 684 |
|
| 685 |
const revokeTokenBtn = t.token ? `
|
| 686 |
+
<button onclick="revokeToken('${escHtml(t.token)}')" class="action-chip glass-btn">
|
| 687 |
+
Del Token
|
| 688 |
+
</button>
|
| 689 |
+
` : '';
|
| 690 |
+
|
| 691 |
+
return actionBtns + revokeTokenBtn;
|
| 692 |
+
}
|
| 693 |
+
|
| 694 |
+
function renderDesktopRows(slice) {
|
| 695 |
+
const tbody = document.getElementById('token-table-body');
|
| 696 |
+
|
| 697 |
+
if (!slice.length) {
|
| 698 |
+
tbody.innerHTML = `
|
| 699 |
+
<tr>
|
| 700 |
+
<td colspan="6" class="text-center py-10 text-soft">No tokens match your search.</td>
|
| 701 |
+
</tr>
|
| 702 |
+
`;
|
| 703 |
+
return;
|
| 704 |
+
}
|
| 705 |
+
|
| 706 |
+
tbody.innerHTML = slice.map(t => {
|
| 707 |
+
const displayName = t.user_name || (t.user_id ? 'Telegram User' : 'Unknown');
|
| 708 |
+
const idHtml = t.user_id ? `<div class="text-xs text-soft mt-1">ID: ${t.user_id}</div>` : '';
|
| 709 |
+
const rowCls = t.is_expired ? 'row-expired' : '';
|
| 710 |
+
|
| 711 |
+
return `
|
| 712 |
+
<tr class="${rowCls}">
|
| 713 |
+
<td class="px-4 py-4">${getStatusBadge(t)}</td>
|
| 714 |
+
<td class="px-4 py-4">
|
| 715 |
+
<div class="font-semibold section-title">${escHtml(displayName)}</div>
|
| 716 |
+
${idHtml}
|
| 717 |
+
</td>
|
| 718 |
+
<td class="px-4 py-4">${buildAddonHtml(t)}</td>
|
| 719 |
+
<td class="px-4 py-4 text-soft text-xs">${t.created_at ? fmtDate(t.created_at) : '—'}</td>
|
| 720 |
+
<td class="px-4 py-4 text-xs">
|
| 721 |
+
${t.expires_at
|
| 722 |
+
? `<span class="${t.is_expired ? 'text-red-300 font-semibold' : 'section-title'}">${fmtDate(t.expires_at)}</span>`
|
| 723 |
+
: `<span class="text-red-300 italic">No expiry</span>`
|
| 724 |
+
}
|
| 725 |
+
</td>
|
| 726 |
+
<td class="px-4 py-4">
|
| 727 |
+
<div class="flex flex-wrap gap-2 justify-center">${buildActions(t)}</div>
|
| 728 |
+
</td>
|
| 729 |
+
</tr>
|
| 730 |
+
`;
|
| 731 |
+
}).join('');
|
| 732 |
+
}
|
| 733 |
+
|
| 734 |
+
function renderMobileCards(slice) {
|
| 735 |
+
const mobileWrap = document.getElementById('token-mobile-list');
|
| 736 |
+
|
| 737 |
+
if (!slice.length) {
|
| 738 |
+
mobileWrap.innerHTML = `
|
| 739 |
+
<div class="empty-state text-center px-4 py-8 text-soft">
|
| 740 |
+
No tokens match your search.
|
| 741 |
+
</div>
|
| 742 |
+
`;
|
| 743 |
+
return;
|
| 744 |
+
}
|
| 745 |
+
|
| 746 |
+
mobileWrap.innerHTML = slice.map(t => {
|
| 747 |
+
const displayName = t.user_name || (t.user_id ? 'Telegram User' : 'Unknown');
|
| 748 |
+
|
| 749 |
+
return `
|
| 750 |
+
<div class="mobile-token-card ${t.is_expired ? 'row-expired' : ''}">
|
| 751 |
+
<div class="flex items-start justify-between gap-3 mb-3">
|
| 752 |
+
<div class="min-w-0">
|
| 753 |
+
<div class="font-semibold section-title break-words">${escHtml(displayName)}</div>
|
| 754 |
+
<div class="text-xs text-soft mt-1 break-all">${t.user_id ? 'ID: ' + t.user_id : 'No linked user'}</div>
|
| 755 |
+
</div>
|
| 756 |
+
<div class="shrink-0">${getStatusBadge(t)}</div>
|
| 757 |
+
</div>
|
| 758 |
+
|
| 759 |
+
<div class="grid grid-cols-1 gap-3 mb-3">
|
| 760 |
+
<div class="rounded-2xl px-4 py-3"
|
| 761 |
+
style="background: color-mix(in srgb, var(--bg) 55%, transparent); border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);">
|
| 762 |
+
<div class="text-[11px] uppercase tracking-[0.14em] text-soft font-bold mb-1">Addon Access</div>
|
| 763 |
+
${buildAddonHtml(t)}
|
| 764 |
+
</div>
|
| 765 |
+
|
| 766 |
+
<div class="grid grid-cols-2 gap-3">
|
| 767 |
+
<div class="rounded-2xl px-4 py-3"
|
| 768 |
+
style="background: color-mix(in srgb, var(--bg) 55%, transparent); border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);">
|
| 769 |
+
<div class="text-[11px] uppercase tracking-[0.14em] text-soft font-bold mb-1">Created</div>
|
| 770 |
+
<div class="text-sm font-semibold section-title break-words">${t.created_at ? fmtDate(t.created_at) : '—'}</div>
|
| 771 |
+
</div>
|
| 772 |
+
<div class="rounded-2xl px-4 py-3"
|
| 773 |
+
style="background: color-mix(in srgb, var(--bg) 55%, transparent); border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);">
|
| 774 |
+
<div class="text-[11px] uppercase tracking-[0.14em] text-soft font-bold mb-1">Expires</div>
|
| 775 |
+
<div class="text-sm font-semibold ${t.is_expired ? 'text-red-300' : 'section-title'} break-words">
|
| 776 |
+
${t.expires_at ? fmtDate(t.expires_at) : 'No expiry'}
|
| 777 |
+
</div>
|
| 778 |
+
</div>
|
| 779 |
+
</div>
|
| 780 |
+
</div>
|
| 781 |
+
|
| 782 |
+
<div class="flex flex-wrap gap-2">
|
| 783 |
+
${buildActions(t)}
|
| 784 |
+
</div>
|
| 785 |
+
</div>
|
| 786 |
+
`;
|
| 787 |
+
}).join('');
|
| 788 |
+
}
|
| 789 |
+
|
| 790 |
+
function renderPage() {
|
| 791 |
+
const filtered = getFiltered();
|
| 792 |
+
const pageSize = parseInt(document.getElementById('page-size').value);
|
| 793 |
+
const totalPages = Math.max(1, Math.ceil(filtered.length / pageSize));
|
| 794 |
+
|
| 795 |
+
if (currentPage > totalPages) currentPage = totalPages;
|
| 796 |
+
|
| 797 |
+
const start = filtered.length ? (currentPage - 1) * pageSize : 0;
|
| 798 |
+
const slice = filtered.slice(start, start + pageSize);
|
| 799 |
+
|
| 800 |
+
document.getElementById('page-info').textContent =
|
| 801 |
+
filtered.length
|
| 802 |
+
? `Showing ${start + 1}–${Math.min(start + pageSize, filtered.length)} of ${filtered.length}`
|
| 803 |
+
: 'Showing 0 of 0';
|
| 804 |
+
|
| 805 |
+
document.getElementById('page-num').textContent = `Page ${currentPage} / ${totalPages}`;
|
| 806 |
+
|
| 807 |
+
const prevBtn = document.getElementById('btn-prev');
|
| 808 |
+
const nextBtn = document.getElementById('btn-next');
|
| 809 |
+
|
| 810 |
+
prevBtn.disabled = currentPage <= 1;
|
| 811 |
+
nextBtn.disabled = currentPage >= totalPages;
|
| 812 |
+
|
| 813 |
+
prevBtn.style.opacity = currentPage <= 1 ? '0.45' : '1';
|
| 814 |
+
nextBtn.style.opacity = currentPage >= totalPages ? '0.45' : '1';
|
| 815 |
+
|
| 816 |
+
renderDesktopRows(slice);
|
| 817 |
+
renderMobileCards(slice);
|
| 818 |
}
|
| 819 |
|
| 820 |
function changePage(dir) {
|
| 821 |
+
const filtered = getFiltered();
|
| 822 |
+
const pageSize = parseInt(document.getElementById('page-size').value);
|
| 823 |
+
const totalPages = Math.max(1, Math.ceil(filtered.length / pageSize));
|
| 824 |
+
|
| 825 |
currentPage += dir;
|
| 826 |
+
if (currentPage < 1) currentPage = 1;
|
| 827 |
+
if (currentPage > totalPages) currentPage = totalPages;
|
| 828 |
+
|
| 829 |
renderPage();
|
| 830 |
}
|
| 831 |
|
| 832 |
async function loadTokens() {
|
| 833 |
+
document.getElementById('token-table-body').innerHTML = `
|
| 834 |
+
<tr><td colspan="6" class="text-center py-10 text-soft">Loading…</td></tr>
|
| 835 |
+
`;
|
| 836 |
+
document.getElementById('token-mobile-list').innerHTML = `
|
| 837 |
+
<div class="empty-state text-center px-4 py-8 text-soft">Loading…</div>
|
| 838 |
+
`;
|
| 839 |
+
|
| 840 |
try {
|
| 841 |
const resp = await fetch('/api/admin/access/tokens');
|
| 842 |
const data = await resp.json();
|
|
|
|
| 849 |
currentPage = 1;
|
| 850 |
renderPage();
|
| 851 |
} catch (err) {
|
| 852 |
+
document.getElementById('token-table-body').innerHTML = `
|
| 853 |
+
<tr><td colspan="6" class="text-center py-10 text-red-300">Error: ${err.message}</td></tr>
|
| 854 |
+
`;
|
| 855 |
+
document.getElementById('token-mobile-list').innerHTML = `
|
| 856 |
+
<div class="empty-state text-center px-4 py-8 text-red-300">Error: ${err.message}</div>
|
| 857 |
+
`;
|
| 858 |
+
showToast('Failed to load access tokens.', 'error', 'Load Error');
|
| 859 |
}
|
| 860 |
}
|
| 861 |
|
| 862 |
async function loadPlans() {
|
| 863 |
+
try {
|
| 864 |
+
const resp = await fetch('/api/admin/subscriptions/plans');
|
| 865 |
+
if (!resp.ok) throw new Error(`HTTP error! status: ${resp.status}`);
|
| 866 |
+
const result = await resp.json();
|
| 867 |
+
const plans = result.data || [];
|
| 868 |
+
const sel = document.getElementById('assign-plan-select');
|
| 869 |
+
if (!sel) return;
|
| 870 |
+
sel.innerHTML = '<option value="">— Select a plan —</option>' +
|
| 871 |
+
plans.map(p => `
|
| 872 |
+
<option value="${p.days}">
|
| 873 |
+
${p.days} days${p.price ? ' — ₹' + p.price : ''}
|
| 874 |
+
</option>
|
| 875 |
+
`).join('');
|
| 876 |
+
|
| 877 |
+
} catch (e) {
|
| 878 |
+
console.warn('Could not load plans', e);
|
| 879 |
+
showToast('Could not load subscription plans.', 'error', 'Plan Error');
|
| 880 |
+
}
|
| 881 |
+
}
|
| 882 |
+
function openModal(modalId) {
|
| 883 |
+
const modal = document.getElementById(modalId);
|
| 884 |
+
modal.classList.remove('hidden');
|
| 885 |
+
modal.classList.add('flex');
|
| 886 |
+
document.body.classList.add('overflow-hidden');
|
| 887 |
+
}
|
| 888 |
+
|
| 889 |
+
function closeModal(modalId) {
|
| 890 |
+
const modal = document.getElementById(modalId);
|
| 891 |
+
modal.classList.add('hidden');
|
| 892 |
+
modal.classList.remove('flex');
|
| 893 |
+
document.body.classList.remove('overflow-hidden');
|
| 894 |
}
|
| 895 |
|
| 896 |
function openAssignModal(userId, userName) {
|
|
|
|
| 898 |
document.getElementById('assign-user-label').textContent = `User: ${userName} (ID: ${userId})`;
|
| 899 |
document.getElementById('assign-custom-days').value = '';
|
| 900 |
document.getElementById('assign-plan-select').value = '';
|
| 901 |
+
openModal('assign-modal');
|
|
|
|
| 902 |
}
|
| 903 |
|
| 904 |
function closeAssignModal() {
|
| 905 |
+
closeModal('assign-modal');
|
| 906 |
}
|
| 907 |
|
| 908 |
async function assignPlan() {
|
|
|
|
| 911 |
const planDays = parseInt(document.getElementById('assign-plan-select').value) || 0;
|
| 912 |
const days = customDays || planDays;
|
| 913 |
|
| 914 |
+
if (!days || days < 1) {
|
| 915 |
+
showToast('Please select a plan or enter custom days.', 'error', 'Validation');
|
| 916 |
+
return;
|
| 917 |
+
}
|
| 918 |
|
| 919 |
try {
|
| 920 |
const resp = await fetch(`/api/admin/access/users/${userId}/assign-plan`, {
|
|
|
|
| 922 |
headers: { 'Content-Type': 'application/json' },
|
| 923 |
body: JSON.stringify({ days })
|
| 924 |
});
|
| 925 |
+
|
| 926 |
const data = await resp.json();
|
| 927 |
+
|
| 928 |
if (resp.ok) {
|
| 929 |
+
showToast(`Assigned ${days} days to user ${userId}.`, 'success', 'Plan Assigned');
|
| 930 |
closeAssignModal();
|
| 931 |
loadTokens();
|
| 932 |
} else {
|
| 933 |
+
showToast(data.detail || 'Failed to assign plan.', 'error', 'Request Failed');
|
| 934 |
}
|
| 935 |
+
} catch (err) {
|
| 936 |
+
showToast('Error: ' + err.message, 'error', 'Network Error');
|
| 937 |
+
}
|
| 938 |
}
|
| 939 |
|
| 940 |
async function revokeToken(token) {
|
| 941 |
if (!confirm('Delete this token? The user will lose addon access immediately.')) return;
|
| 942 |
+
|
| 943 |
try {
|
| 944 |
const resp = await fetch(`/api/admin/access/tokens/${encodeURIComponent(token)}`, { method: 'DELETE' });
|
| 945 |
const data = await resp.json();
|
| 946 |
+
|
| 947 |
+
if (resp.ok) {
|
| 948 |
+
showToast('Token deleted.', 'success', 'Access Updated');
|
| 949 |
+
loadTokens();
|
| 950 |
+
} else {
|
| 951 |
+
showToast(data.detail || 'Failed.', 'error', 'Delete Failed');
|
| 952 |
+
}
|
| 953 |
+
} catch (err) {
|
| 954 |
+
showToast('Error: ' + err.message, 'error', 'Network Error');
|
| 955 |
+
}
|
| 956 |
}
|
| 957 |
|
| 958 |
async function linkUser(token) {
|
| 959 |
const userId = prompt('Enter the Telegram User ID to link this token to:');
|
| 960 |
+
if (!userId || isNaN(parseInt(userId))) {
|
| 961 |
+
showToast('Invalid user ID.', 'error', 'Invalid Input');
|
| 962 |
+
return;
|
| 963 |
+
}
|
| 964 |
+
|
| 965 |
try {
|
| 966 |
const resp = await fetch(`/api/admin/access/tokens/${encodeURIComponent(token)}/link-user`, {
|
| 967 |
method: 'PATCH',
|
| 968 |
headers: { 'Content-Type': 'application/json' },
|
| 969 |
body: JSON.stringify({ user_id: parseInt(userId) })
|
| 970 |
});
|
| 971 |
+
|
| 972 |
const data = await resp.json();
|
| 973 |
+
|
| 974 |
if (resp.ok) {
|
| 975 |
+
showToast(`Token linked to user ${userId}.`, 'success', 'User Linked');
|
| 976 |
loadTokens();
|
| 977 |
+
} else {
|
| 978 |
+
showToast(data.detail || 'Failed to link.', 'error', 'Link Failed');
|
| 979 |
+
}
|
| 980 |
+
} catch (err) {
|
| 981 |
+
showToast('Error: ' + err.message, 'error', 'Network Error');
|
| 982 |
+
}
|
| 983 |
}
|
| 984 |
|
|
|
|
| 985 |
function openSubModal(userId, userName, action) {
|
| 986 |
document.getElementById('sub-action-user-id').value = userId;
|
| 987 |
document.getElementById('sub-action-action').value = action;
|
| 988 |
+
|
| 989 |
+
const titles = {
|
| 990 |
+
extend: 'Extend Subscription',
|
| 991 |
+
reduce: 'Reduce Subscription',
|
| 992 |
+
delete: 'Revoke Subscription'
|
| 993 |
+
};
|
| 994 |
+
|
| 995 |
const descs = {
|
| 996 |
extend: `Add days to <b>${userName}</b>'s subscription.`,
|
| 997 |
reduce: `Remove days from <b>${userName}</b>'s subscription.`,
|
| 998 |
delete: `<b>Warning:</b> Revoke <b>${userName}</b>'s subscription entirely.`
|
| 999 |
};
|
| 1000 |
+
|
| 1001 |
document.getElementById('sub-action-title').textContent = titles[action];
|
| 1002 |
document.getElementById('sub-action-desc').innerHTML = descs[action];
|
| 1003 |
+
|
| 1004 |
+
const daysGroup = document.getElementById('sub-action-days-group');
|
| 1005 |
const btn = document.getElementById('sub-action-btn');
|
| 1006 |
+
|
| 1007 |
+
if (action === 'delete') {
|
| 1008 |
+
daysGroup.style.display = 'none';
|
| 1009 |
+
btn.className = 'glass-btn glass-btn-danger rounded-2xl px-5 py-3 text-sm font-bold';
|
| 1010 |
+
} else if (action === 'reduce') {
|
| 1011 |
+
daysGroup.style.display = 'block';
|
| 1012 |
+
btn.className = 'glass-btn glass-btn-warning rounded-2xl px-5 py-3 text-sm font-bold';
|
| 1013 |
+
} else {
|
| 1014 |
+
daysGroup.style.display = 'block';
|
| 1015 |
+
btn.className = 'glass-btn glass-btn-success rounded-2xl px-5 py-3 text-sm font-bold';
|
| 1016 |
+
}
|
| 1017 |
+
|
| 1018 |
+
document.getElementById('sub-action-days').value = 30;
|
| 1019 |
+
openModal('sub-action-modal');
|
| 1020 |
}
|
| 1021 |
|
| 1022 |
+
function closeSubModal() {
|
| 1023 |
+
closeModal('sub-action-modal');
|
| 1024 |
+
}
|
| 1025 |
|
| 1026 |
async function submitSubAction() {
|
| 1027 |
const userId = parseInt(document.getElementById('sub-action-user-id').value);
|
| 1028 |
const action = document.getElementById('sub-action-action').value;
|
| 1029 |
const days = parseInt(document.getElementById('sub-action-days').value) || 0;
|
| 1030 |
+
|
| 1031 |
try {
|
| 1032 |
const resp = await fetch(`/api/admin/subscriptions/users/${userId}/manage`, {
|
| 1033 |
method: 'POST',
|
| 1034 |
headers: { 'Content-Type': 'application/json' },
|
| 1035 |
body: JSON.stringify({ action, days })
|
| 1036 |
});
|
| 1037 |
+
|
| 1038 |
const data = await resp.json();
|
| 1039 |
+
|
| 1040 |
if (resp.ok) {
|
| 1041 |
+
showToast(`${action.charAt(0).toUpperCase() + action.slice(1)}d subscription for user ${userId}.`, 'success', 'Subscription Updated');
|
| 1042 |
closeSubModal();
|
| 1043 |
loadTokens();
|
| 1044 |
+
} else {
|
| 1045 |
+
showToast(data.detail || 'Failed.', 'error', 'Update Failed');
|
| 1046 |
+
}
|
| 1047 |
+
} catch (err) {
|
| 1048 |
+
showToast('Error: ' + err.message, 'error', 'Network Error');
|
| 1049 |
+
}
|
| 1050 |
}
|
| 1051 |
|
| 1052 |
async function copyLink(url) {
|
| 1053 |
+
try {
|
| 1054 |
+
await navigator.clipboard.writeText(url);
|
| 1055 |
+
showToast('Link copied!', 'success', 'Copied');
|
| 1056 |
+
} catch {
|
| 1057 |
+
prompt('Copy this link:', url);
|
| 1058 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1059 |
}
|
| 1060 |
|
|
|
|
| 1061 |
document.getElementById('assign-modal').addEventListener('click', function (e) {
|
| 1062 |
if (e.target === this) closeAssignModal();
|
| 1063 |
});
|
| 1064 |
|
| 1065 |
+
document.getElementById('sub-action-modal').addEventListener('click', function (e) {
|
| 1066 |
+
if (e.target === this) closeSubModal();
|
| 1067 |
+
});
|
| 1068 |
+
|
| 1069 |
+
document.addEventListener('keydown', function (e) {
|
| 1070 |
+
if (e.key === 'Escape') {
|
| 1071 |
+
closeAssignModal();
|
| 1072 |
+
closeSubModal();
|
| 1073 |
+
}
|
| 1074 |
+
});
|
| 1075 |
+
|
| 1076 |
loadPlans();
|
| 1077 |
loadTokens();
|
| 1078 |
</script>
|
| 1079 |
+
{% endblock %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Backend/fastapi/templates/admin_dashboard.html
CHANGED
|
@@ -3,179 +3,487 @@
|
|
| 3 |
{% block title %}Admin Dashboard - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
-
<
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 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 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
</div>
|
|
|
|
|
|
|
| 36 |
</div>
|
| 37 |
|
| 38 |
-
<
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
<
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
</div>
|
| 49 |
</div>
|
| 50 |
</div>
|
| 51 |
|
| 52 |
-
<
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
</
|
| 59 |
-
<
|
|
|
|
| 60 |
</div>
|
| 61 |
</div>
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
</div>
|
| 66 |
</div>
|
| 67 |
|
| 68 |
-
<
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
</button>
|
| 76 |
</div>
|
| 77 |
|
| 78 |
-
<div class="
|
| 79 |
-
<div class="
|
| 80 |
-
<
|
| 81 |
-
<
|
| 82 |
-
<
|
| 83 |
-
<
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
<
|
| 95 |
-
<
|
| 96 |
-
<
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
</div>
|
| 102 |
</div>
|
| 103 |
</div>
|
| 104 |
|
| 105 |
-
<
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
<
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
<
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
<div class="flex
|
| 151 |
-
<div class="flex items-center gap-3">
|
| 152 |
-
<
|
| 153 |
-
|
|
|
|
|
|
|
|
|
|
| 154 |
</div>
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
<div class="
|
|
|
|
| 159 |
</div>
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
<div class="
|
|
|
|
|
|
|
| 163 |
</div>
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
<div class="
|
|
|
|
| 167 |
</div>
|
| 168 |
</div>
|
| 169 |
</div>
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
}
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
|
|
|
| 176 |
}
|
| 177 |
} catch (err) {
|
| 178 |
console.error(err);
|
|
|
|
| 179 |
}
|
| 180 |
}
|
| 181 |
|
|
@@ -183,44 +491,73 @@
|
|
| 183 |
try {
|
| 184 |
const res = await fetch('/api/admin/stream-analytics');
|
| 185 |
const tbody = document.getElementById('analytics-tbody');
|
| 186 |
-
|
| 187 |
-
const data = await res.json();
|
| 188 |
-
const streams = data.data.recent;
|
| 189 |
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 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 |
-
|
| 204 |
-
|
| 205 |
-
if (s.status === 'cancelled') statusColor = 'text-yellow-500';
|
| 206 |
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 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 |
|
|
@@ -228,47 +565,87 @@
|
|
| 228 |
try {
|
| 229 |
const res = await fetch('/api/admin/dead-links');
|
| 230 |
const tbody = document.getElementById('dead-links-tbody');
|
| 231 |
-
|
| 232 |
-
const data = await res.json();
|
| 233 |
-
const links = data.data;
|
| 234 |
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
|
| 240 |
-
|
| 241 |
-
|
| 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 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 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 |
|
|
@@ -279,13 +656,13 @@
|
|
| 279 |
const res = await fetch('/api/admin/clear-cache', { method: 'POST' });
|
| 280 |
if (res.ok) {
|
| 281 |
const data = await res.json();
|
| 282 |
-
|
| 283 |
fetchStats();
|
| 284 |
} else {
|
| 285 |
-
|
| 286 |
}
|
| 287 |
} catch (err) {
|
| 288 |
-
|
| 289 |
}
|
| 290 |
}
|
| 291 |
|
|
@@ -296,14 +673,14 @@
|
|
| 296 |
const res = await fetch('/api/admin/clear-analytics', { method: 'POST' });
|
| 297 |
if (res.ok) {
|
| 298 |
const data = await res.json();
|
| 299 |
-
|
| 300 |
fetchAnalytics();
|
| 301 |
} else {
|
| 302 |
const err = await res.json().catch(() => ({}));
|
| 303 |
-
|
| 304 |
}
|
| 305 |
} catch (err) {
|
| 306 |
-
|
| 307 |
}
|
| 308 |
}
|
| 309 |
|
|
@@ -320,21 +697,20 @@
|
|
| 320 |
|
| 321 |
const res = await fetch(endpoint, { method: 'DELETE' });
|
| 322 |
if (res.ok) {
|
| 323 |
-
|
|
|
|
| 324 |
} else {
|
| 325 |
-
|
| 326 |
}
|
| 327 |
} catch (err) {
|
| 328 |
-
|
| 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 |
});
|
|
|
|
| 3 |
{% block title %}Admin Dashboard - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
+
<style>
|
| 7 |
+
.glass-card {
|
| 8 |
+
background: color-mix(in srgb, var(--card) 52%, transparent);
|
| 9 |
+
border: 1px solid color-mix(in srgb, var(--border) 95%, transparent);
|
| 10 |
+
backdrop-filter: blur(22px);
|
| 11 |
+
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
|
| 12 |
+
}
|
| 13 |
|
| 14 |
+
.glass-card-soft {
|
| 15 |
+
background: color-mix(in srgb, var(--card) 40%, transparent);
|
| 16 |
+
border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
|
| 17 |
+
backdrop-filter: blur(18px);
|
| 18 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
.section-title {
|
| 21 |
+
color: var(--text);
|
| 22 |
+
font-weight: 800;
|
| 23 |
+
letter-spacing: -0.02em;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
.muted {
|
| 27 |
+
color: var(--text-sec);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
.pill {
|
| 31 |
+
display: inline-flex;
|
| 32 |
+
align-items: center;
|
| 33 |
+
gap: 0.45rem;
|
| 34 |
+
padding: 0.45rem 0.85rem;
|
| 35 |
+
border-radius: 9999px;
|
| 36 |
+
font-size: 0.82rem;
|
| 37 |
+
font-weight: 800;
|
| 38 |
+
border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
|
| 39 |
+
background: color-mix(in srgb, var(--bg) 66%, transparent);
|
| 40 |
+
color: var(--text);
|
| 41 |
+
white-space: nowrap;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.metric-card {
|
| 45 |
+
position: relative;
|
| 46 |
+
overflow: hidden;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.metric-card::before {
|
| 50 |
+
content: "";
|
| 51 |
+
position: absolute;
|
| 52 |
+
inset: -30% auto auto -10%;
|
| 53 |
+
width: 140px;
|
| 54 |
+
height: 140px;
|
| 55 |
+
border-radius: 9999px;
|
| 56 |
+
background: color-mix(in srgb, var(--primary) 12%, transparent);
|
| 57 |
+
filter: blur(18px);
|
| 58 |
+
pointer-events: none;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
.metric-icon {
|
| 62 |
+
width: 3.25rem;
|
| 63 |
+
height: 3.25rem;
|
| 64 |
+
border-radius: 1.1rem;
|
| 65 |
+
display: flex;
|
| 66 |
+
align-items: center;
|
| 67 |
+
justify-content: center;
|
| 68 |
+
background: color-mix(in srgb, var(--primary) 14%, transparent);
|
| 69 |
+
color: var(--primary);
|
| 70 |
+
border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
|
| 71 |
+
box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.btn-ui {
|
| 75 |
+
display: inline-flex;
|
| 76 |
+
align-items: center;
|
| 77 |
+
justify-content: center;
|
| 78 |
+
gap: 0.55rem;
|
| 79 |
+
border-radius: 1rem;
|
| 80 |
+
padding: 0.82rem 1.1rem;
|
| 81 |
+
font-size: 0.92rem;
|
| 82 |
+
font-weight: 800;
|
| 83 |
+
transition: all 0.2s ease;
|
| 84 |
+
border: 1px solid transparent;
|
| 85 |
+
white-space: nowrap;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
.btn-ui:hover { transform: translateY(-1px); }
|
| 89 |
+
|
| 90 |
+
.btn-danger {
|
| 91 |
+
background: color-mix(in srgb, rgb(239 68 68) 16%, transparent);
|
| 92 |
+
color: rgb(248 113 113);
|
| 93 |
+
border-color: color-mix(in srgb, rgb(239 68 68) 26%, transparent);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
.btn-primary {
|
| 97 |
+
background: var(--primary);
|
| 98 |
+
color: white;
|
| 99 |
+
box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 26%, transparent);
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.btn-ghost {
|
| 103 |
+
background: color-mix(in srgb, var(--bg) 74%, transparent);
|
| 104 |
+
color: var(--text);
|
| 105 |
+
border-color: color-mix(in srgb, var(--border) 95%, transparent);
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
.workload-row,
|
| 109 |
+
.table-row-card {
|
| 110 |
+
background: color-mix(in srgb, var(--bg) 68%, transparent);
|
| 111 |
+
border: 1px solid color-mix(in srgb, var(--border) 90%, transparent);
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
.status-badge {
|
| 115 |
+
display: inline-flex;
|
| 116 |
+
align-items: center;
|
| 117 |
+
gap: 0.35rem;
|
| 118 |
+
padding: 0.35rem 0.65rem;
|
| 119 |
+
border-radius: 9999px;
|
| 120 |
+
font-size: 0.72rem;
|
| 121 |
+
font-weight: 800;
|
| 122 |
+
letter-spacing: .05em;
|
| 123 |
+
text-transform: uppercase;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
.status-good {
|
| 127 |
+
background: color-mix(in srgb, rgb(34 197 94) 16%, transparent);
|
| 128 |
+
color: rgb(74 222 128);
|
| 129 |
+
border: 1px solid color-mix(in srgb, rgb(34 197 94) 22%, transparent);
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
.status-warn {
|
| 133 |
+
background: color-mix(in srgb, rgb(234 179 8) 16%, transparent);
|
| 134 |
+
color: rgb(250 204 21);
|
| 135 |
+
border: 1px solid color-mix(in srgb, rgb(234 179 8) 22%, transparent);
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
.status-bad {
|
| 139 |
+
background: color-mix(in srgb, rgb(239 68 68) 16%, transparent);
|
| 140 |
+
color: rgb(248 113 113);
|
| 141 |
+
border: 1px solid color-mix(in srgb, rgb(239 68 68) 22%, transparent);
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
.table-shell {
|
| 145 |
+
overflow: hidden;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
.table-scroll {
|
| 149 |
+
overflow-x: auto;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
.table-ui {
|
| 153 |
+
width: 100%;
|
| 154 |
+
min-width: 920px;
|
| 155 |
+
border-collapse: separate;
|
| 156 |
+
border-spacing: 0;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
.table-ui thead th {
|
| 160 |
+
color: var(--text-sec);
|
| 161 |
+
font-size: 0.72rem;
|
| 162 |
+
font-weight: 800;
|
| 163 |
+
text-transform: uppercase;
|
| 164 |
+
letter-spacing: .06em;
|
| 165 |
+
padding: 1rem 1.25rem;
|
| 166 |
+
background: color-mix(in srgb, var(--bg) 40%, transparent);
|
| 167 |
+
border-bottom: 1px solid color-mix(in srgb, var(--border) 92%, transparent);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
.table-ui tbody td {
|
| 171 |
+
padding: 1rem 1.25rem;
|
| 172 |
+
border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
|
| 173 |
+
color: var(--text);
|
| 174 |
+
vertical-align: middle;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
.table-ui tbody tr:hover td {
|
| 178 |
+
background: color-mix(in srgb, var(--card) 18%, transparent);
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
.stream-id {
|
| 182 |
+
max-width: 140px;
|
| 183 |
+
overflow: hidden;
|
| 184 |
+
text-overflow: ellipsis;
|
| 185 |
+
white-space: nowrap;
|
| 186 |
+
display: inline-block;
|
| 187 |
+
vertical-align: bottom;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
.title-cell {
|
| 191 |
+
max-width: 210px;
|
| 192 |
+
overflow: hidden;
|
| 193 |
+
text-overflow: ellipsis;
|
| 194 |
+
white-space: nowrap;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
.empty-state {
|
| 198 |
+
color: var(--text-sec);
|
| 199 |
+
text-align: center;
|
| 200 |
+
padding: 2rem 1rem;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
.mobile-list {
|
| 204 |
+
display: none;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
.mobile-card {
|
| 208 |
+
background: color-mix(in srgb, var(--bg) 70%, transparent);
|
| 209 |
+
border: 1px solid color-mix(in srgb, var(--border) 90%, transparent);
|
| 210 |
+
border-radius: 1.25rem;
|
| 211 |
+
padding: 1rem;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
.mobile-kv {
|
| 215 |
+
display: grid;
|
| 216 |
+
grid-template-columns: 110px 1fr;
|
| 217 |
+
gap: 0.45rem 0.75rem;
|
| 218 |
+
font-size: 0.86rem;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
.mobile-kv .key {
|
| 222 |
+
color: var(--text-sec);
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
.loading-dot {
|
| 226 |
+
display: inline-block;
|
| 227 |
+
width: .5rem;
|
| 228 |
+
height: .5rem;
|
| 229 |
+
border-radius: 9999px;
|
| 230 |
+
background: var(--primary);
|
| 231 |
+
box-shadow: 0 0 12px color-mix(in srgb, var(--primary) 40%, transparent);
|
| 232 |
+
animation: pulseDot 1.2s infinite ease-in-out;
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
@keyframes pulseDot {
|
| 236 |
+
0%, 100% { opacity: .45; transform: scale(.9); }
|
| 237 |
+
50% { opacity: 1; transform: scale(1.1); }
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
@media (max-width: 1024px) {
|
| 241 |
+
.table-ui { min-width: 840px; }
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
@media (max-width: 768px) {
|
| 245 |
+
.desktop-table {
|
| 246 |
+
display: none;
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
.mobile-list {
|
| 250 |
+
display: grid;
|
| 251 |
+
gap: 0.9rem;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
.mobile-kv {
|
| 255 |
+
grid-template-columns: 95px 1fr;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
.btn-ui {
|
| 259 |
+
width: 100%;
|
| 260 |
+
}
|
| 261 |
+
}
|
| 262 |
+
</style>
|
| 263 |
+
|
| 264 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-5 sm:py-8 text-text">
|
| 265 |
+
<div class="glass-card rounded-3xl p-5 sm:p-6 lg:p-8 mb-6 sm:mb-8">
|
| 266 |
+
<div class="flex flex-col lg:flex-row lg:items-end lg:justify-between gap-4">
|
| 267 |
+
<div>
|
| 268 |
+
<div class="flex flex-wrap items-center gap-2 mb-3">
|
| 269 |
+
<span class="pill"><span class="loading-dot"></span> Live admin panel</span>
|
| 270 |
</div>
|
| 271 |
+
<h1 class="section-title text-2xl sm:text-3xl lg:text-4xl">Admin Dashboard</h1>
|
| 272 |
+
<p class="muted mt-2 text-sm sm:text-base">Monitor system health, stream analytics, and flagged dead links from one responsive control panel.</p>
|
| 273 |
</div>
|
| 274 |
|
| 275 |
+
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3 w-full lg:w-auto">
|
| 276 |
+
<button onclick="clearCache()" class="btn-ui btn-danger">
|
| 277 |
+
<i class="fas fa-trash-alt"></i>
|
| 278 |
+
Clear File Cache
|
| 279 |
+
</button>
|
| 280 |
+
<button onclick="clearAnalytics()" class="btn-ui btn-ghost">
|
| 281 |
+
<i class="fas fa-chart-line"></i>
|
| 282 |
+
Clear Analytics
|
| 283 |
+
</button>
|
| 284 |
+
</div>
|
| 285 |
+
</div>
|
| 286 |
+
</div>
|
| 287 |
+
|
| 288 |
+
<div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4 sm:gap-6 mb-6 sm:mb-8" id="stats-container">
|
| 289 |
+
<div class="glass-card metric-card rounded-3xl p-5 sm:p-6">
|
| 290 |
+
<div class="flex items-start gap-4">
|
| 291 |
+
<div class="metric-icon">
|
| 292 |
+
<i class="fas fa-memory text-xl"></i>
|
| 293 |
+
</div>
|
| 294 |
+
<div class="min-w-0">
|
| 295 |
+
<p class="muted text-sm font-semibold">Cached File IDs</p>
|
| 296 |
+
<p class="text-3xl sm:text-4xl font-black tracking-tight mt-2 text-text" id="stat-cache-size">-</p>
|
| 297 |
+
<p class="muted text-xs sm:text-sm mt-2">Current file-id cache entries in memory.</p>
|
| 298 |
</div>
|
| 299 |
</div>
|
| 300 |
</div>
|
| 301 |
|
| 302 |
+
<div class="glass-card metric-card rounded-3xl p-5 sm:p-6">
|
| 303 |
+
<div class="flex items-start gap-4">
|
| 304 |
+
<div class="metric-icon">
|
| 305 |
+
<i class="fas fa-robot text-xl"></i>
|
| 306 |
+
</div>
|
| 307 |
+
<div class="min-w-0">
|
| 308 |
+
<p class="muted text-sm font-semibold">Connected Bots</p>
|
| 309 |
+
<p class="text-3xl sm:text-4xl font-black tracking-tight mt-2 text-text" id="stat-bot-count">-</p>
|
| 310 |
+
<p class="muted text-xs sm:text-sm mt-2">Active Telegram bot clients available right now.</p>
|
| 311 |
</div>
|
| 312 |
</div>
|
| 313 |
+
</div>
|
| 314 |
+
</div>
|
| 315 |
+
|
| 316 |
+
<div class="glass-card rounded-3xl overflow-hidden mb-6 sm:mb-8">
|
| 317 |
+
<div class="px-5 sm:px-6 lg:px-8 py-4 sm:py-5 border-b border-white/10 bg-white/5 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
|
| 318 |
+
<div>
|
| 319 |
+
<h2 class="section-title text-xl sm:text-2xl">Bot Health & Load</h2>
|
| 320 |
+
<p class="muted text-sm mt-1">Track stream load, average speed, and failure trends per bot.</p>
|
| 321 |
</div>
|
| 322 |
+
<span class="pill">Realtime status</span>
|
| 323 |
+
</div>
|
| 324 |
+
|
| 325 |
+
<div id="stat-workloads" class="p-4 sm:p-5 lg:p-6">
|
| 326 |
+
<div class="empty-state">Loading bot data...</div>
|
| 327 |
</div>
|
| 328 |
</div>
|
| 329 |
|
| 330 |
+
<div class="glass-card rounded-3xl overflow-hidden mb-6 sm:mb-8">
|
| 331 |
+
<div class="px-5 sm:px-6 lg:px-8 py-4 sm:py-5 border-b border-white/10 bg-white/5 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
|
| 332 |
+
<div>
|
| 333 |
+
<h2 class="section-title text-xl sm:text-2xl">Recent Stream Analytics</h2>
|
| 334 |
+
<p class="muted text-sm mt-1">Data transferred, speed, duration, and status for recent streams.</p>
|
| 335 |
+
</div>
|
| 336 |
+
<span class="pill">Recent activity</span>
|
|
|
|
| 337 |
</div>
|
| 338 |
|
| 339 |
+
<div class="p-4 sm:p-5 lg:p-6">
|
| 340 |
+
<div class="desktop-table table-shell">
|
| 341 |
+
<div class="table-scroll">
|
| 342 |
+
<table class="table-ui">
|
| 343 |
+
<thead>
|
| 344 |
+
<tr>
|
| 345 |
+
<th>Stream ID</th>
|
| 346 |
+
<th>Title</th>
|
| 347 |
+
<th class="text-center">Bot (DC)</th>
|
| 348 |
+
<th class="text-right">Transferred</th>
|
| 349 |
+
<th class="text-right">Avg / Peak</th>
|
| 350 |
+
<th class="text-center">Duration</th>
|
| 351 |
+
<th class="text-center">Status</th>
|
| 352 |
+
<th class="text-right">Time</th>
|
| 353 |
+
</tr>
|
| 354 |
+
</thead>
|
| 355 |
+
<tbody id="analytics-tbody">
|
| 356 |
+
<tr>
|
| 357 |
+
<td colspan="8" class="empty-state">
|
| 358 |
+
<i class="fas fa-spinner fa-spin mr-2 text-primary"></i> Loading analytics...
|
| 359 |
+
</td>
|
| 360 |
+
</tr>
|
| 361 |
+
</tbody>
|
| 362 |
+
</table>
|
| 363 |
+
</div>
|
| 364 |
+
</div>
|
| 365 |
+
|
| 366 |
+
<div id="analytics-mobile" class="mobile-list">
|
| 367 |
+
<div class="empty-state">
|
| 368 |
+
<i class="fas fa-spinner fa-spin mr-2 text-primary"></i> Loading analytics...
|
| 369 |
+
</div>
|
| 370 |
</div>
|
| 371 |
</div>
|
| 372 |
</div>
|
| 373 |
|
| 374 |
+
<div class="glass-card rounded-3xl overflow-hidden">
|
| 375 |
+
<div class="px-5 sm:px-6 lg:px-8 py-4 sm:py-5 border-b border-white/10 bg-white/5 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
|
| 376 |
+
<div>
|
| 377 |
+
<h2 class="section-title text-xl sm:text-2xl">Flagged Dead Links</h2>
|
| 378 |
+
<p class="muted text-sm mt-1">Purge broken qualities so users no longer see dead content.</p>
|
| 379 |
+
</div>
|
| 380 |
+
<span class="pill">Database cleanup</span>
|
| 381 |
+
</div>
|
| 382 |
+
|
| 383 |
+
<div class="p-4 sm:p-5 lg:p-6">
|
| 384 |
+
<div class="desktop-table table-shell">
|
| 385 |
+
<div class="table-scroll">
|
| 386 |
+
<table class="table-ui">
|
| 387 |
+
<thead>
|
| 388 |
+
<tr>
|
| 389 |
+
<th>Title</th>
|
| 390 |
+
<th>Type</th>
|
| 391 |
+
<th>Quality Details</th>
|
| 392 |
+
<th class="text-center">Date Added</th>
|
| 393 |
+
<th class="text-center">Action</th>
|
| 394 |
+
</tr>
|
| 395 |
+
</thead>
|
| 396 |
+
<tbody id="dead-links-tbody">
|
| 397 |
+
<tr>
|
| 398 |
+
<td colspan="5" class="empty-state">
|
| 399 |
+
<i class="fas fa-spinner fa-spin mr-2 text-primary"></i> Loading dead links...
|
| 400 |
+
</td>
|
| 401 |
+
</tr>
|
| 402 |
+
</tbody>
|
| 403 |
+
</table>
|
| 404 |
+
</div>
|
| 405 |
+
</div>
|
| 406 |
+
|
| 407 |
+
<div id="dead-links-mobile" class="mobile-list">
|
| 408 |
+
<div class="empty-state">
|
| 409 |
+
<i class="fas fa-spinner fa-spin mr-2 text-primary"></i> Loading dead links...
|
| 410 |
+
</div>
|
| 411 |
</div>
|
| 412 |
</div>
|
| 413 |
</div>
|
| 414 |
</div>
|
| 415 |
|
| 416 |
<script>
|
| 417 |
+
function escapeHtml(value) {
|
| 418 |
+
return String(value ?? '')
|
| 419 |
+
.replace(/&/g, '&')
|
| 420 |
+
.replace(/</g, '<')
|
| 421 |
+
.replace(/>/g, '>')
|
| 422 |
+
.replace(/"/g, '"')
|
| 423 |
+
.replace(/'/g, ''');
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
function getStatusBadge(status) {
|
| 427 |
+
const s = String(status || '').toLowerCase();
|
| 428 |
+
if (s === 'degraded' || s === 'cancelled') return 'status-badge status-warn';
|
| 429 |
+
if (s === 'failing' || s === 'error') return 'status-badge status-bad';
|
| 430 |
+
return 'status-badge status-good';
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
async function fetchStats() {
|
| 434 |
try {
|
| 435 |
const res = await fetch('/api/admin/system-stats');
|
| 436 |
+
if (!res.ok) return;
|
| 437 |
+
|
| 438 |
+
const data = await res.json();
|
| 439 |
+
document.getElementById('stat-cache-size').textContent = data.cache_size ?? '-';
|
| 440 |
+
document.getElementById('stat-bot-count').textContent = data.total_bots ?? '-';
|
| 441 |
+
|
| 442 |
+
const workloadsWrap = document.getElementById('stat-workloads');
|
| 443 |
+
|
| 444 |
+
if (data.bot_workloads && data.bot_workloads.length > 0) {
|
| 445 |
+
let html = '<div class="grid grid-cols-1 xl:grid-cols-2 gap-4">';
|
| 446 |
+
data.bot_workloads.forEach(b => {
|
| 447 |
+
html += `
|
| 448 |
+
<div class="workload-row rounded-3xl p-4 sm:p-5">
|
| 449 |
+
<div class="flex flex-col gap-4">
|
| 450 |
+
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
|
| 451 |
+
<div class="min-w-0">
|
| 452 |
+
<div class="text-base sm:text-lg font-bold text-text">${escapeHtml(b.display_name)}</div>
|
| 453 |
+
<div class="muted text-xs sm:text-sm mt-1">Bot performance summary</div>
|
| 454 |
+
</div>
|
| 455 |
+
<span class="${getStatusBadge(b.status)}">${escapeHtml(b.status)}</span>
|
| 456 |
</div>
|
| 457 |
+
|
| 458 |
+
<div class="grid grid-cols-3 sm:grid-cols-3 gap-3">
|
| 459 |
+
<div class="glass-card-soft rounded-2xl p-4">
|
| 460 |
+
<div class="muted text-xs uppercase tracking-wider font-bold">Active Streams</div>
|
| 461 |
+
<div class="text-2xl font-black mt-2 text-text">${b.current_load ?? 0}</div>
|
| 462 |
</div>
|
| 463 |
+
|
| 464 |
+
<div class="glass-card-soft rounded-2xl p-4">
|
| 465 |
+
<div class="muted text-xs uppercase tracking-wider font-bold">Avg Speed</div>
|
| 466 |
+
<div class="text-2xl font-black mt-2 text-text">${Number(b.avg_mbps ?? 0).toFixed(1)}</div>
|
| 467 |
+
<div class="muted text-xs mt-1">MB/s</div>
|
| 468 |
</div>
|
| 469 |
+
|
| 470 |
+
<div class="glass-card-soft rounded-2xl p-4">
|
| 471 |
+
<div class="muted text-xs uppercase tracking-wider font-bold">Recent Failures</div>
|
| 472 |
+
<div class="text-2xl font-black mt-2 ${Number(b.failures ?? 0) > 0 ? 'text-red-400' : 'text-text'}">${b.failures ?? 0}</div>
|
| 473 |
</div>
|
| 474 |
</div>
|
| 475 |
</div>
|
| 476 |
+
</div>
|
| 477 |
+
`;
|
| 478 |
+
});
|
| 479 |
+
html += '</div>';
|
| 480 |
+
workloadsWrap.innerHTML = html;
|
| 481 |
+
} else {
|
| 482 |
+
workloadsWrap.innerHTML = '<div class="empty-state">No bot data available</div>';
|
| 483 |
}
|
| 484 |
} catch (err) {
|
| 485 |
console.error(err);
|
| 486 |
+
showToast('Failed to load system stats.', 'error', 'Load Error');
|
| 487 |
}
|
| 488 |
}
|
| 489 |
|
|
|
|
| 491 |
try {
|
| 492 |
const res = await fetch('/api/admin/stream-analytics');
|
| 493 |
const tbody = document.getElementById('analytics-tbody');
|
| 494 |
+
const mobile = document.getElementById('analytics-mobile');
|
|
|
|
|
|
|
| 495 |
|
| 496 |
+
if (!res.ok) {
|
| 497 |
+
showToast('Failed to load stream analytics.', 'error', 'Load Error');
|
| 498 |
+
return;
|
| 499 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 500 |
|
| 501 |
+
const data = await res.json();
|
| 502 |
+
const streams = data?.data?.recent || [];
|
|
|
|
| 503 |
|
| 504 |
+
if (!streams.length) {
|
| 505 |
+
tbody.innerHTML = '<tr><td colspan="8" class="empty-state">No recent streams recorded.</td></tr>';
|
| 506 |
+
mobile.innerHTML = '<div class="empty-state">No recent streams recorded.</div>';
|
| 507 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 508 |
}
|
| 509 |
+
|
| 510 |
+
let tableHtml = '';
|
| 511 |
+
let mobileHtml = '';
|
| 512 |
+
|
| 513 |
+
streams.forEach(s => {
|
| 514 |
+
const avg = Number(s.avg_mbps ?? 0);
|
| 515 |
+
const peak = Number(s.peak_mbps ?? 0);
|
| 516 |
+
const bytesStr = ((Number(s.total_bytes ?? 0)) / (1024 * 1024)).toFixed(1) + ' MB';
|
| 517 |
+
const timeStr = s.logged_at ? new Date(s.logged_at).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) : '—';
|
| 518 |
+
const durationStr = s.duration_sec ? `${Number(s.duration_sec).toFixed(1)}s` : '—';
|
| 519 |
+
const titleStr = s.title || s.meta?.title || '—';
|
| 520 |
+
const status = s.status || 'unknown';
|
| 521 |
+
|
| 522 |
+
tableHtml += `
|
| 523 |
+
<tr>
|
| 524 |
+
<td><span class="stream-id muted font-mono text-xs" title="${escapeHtml(s.stream_id)}">${escapeHtml(s.stream_id)}</span></td>
|
| 525 |
+
<td><div class="title-cell font-semibold" title="${escapeHtml(titleStr)}">${escapeHtml(titleStr)}</div></td>
|
| 526 |
+
<td class="text-center">Bot ${Number(s.client_index ?? 0) + 1} <span class="muted text-xs ml-1">(DC${escapeHtml(s.dc_id)})</span></td>
|
| 527 |
+
<td class="text-right font-semibold">${bytesStr}</td>
|
| 528 |
+
<td class="text-right font-semibold">${avg.toFixed(1)} <span class="muted">/ ${peak.toFixed(1)} MB/s</span></td>
|
| 529 |
+
<td class="text-center muted">${durationStr}</td>
|
| 530 |
+
<td class="text-center"><span class="${getStatusBadge(status)}">${escapeHtml(status)}</span></td>
|
| 531 |
+
<td class="text-right muted text-xs">${timeStr}</td>
|
| 532 |
+
</tr>
|
| 533 |
+
`;
|
| 534 |
+
|
| 535 |
+
mobileHtml += `
|
| 536 |
+
<div class="mobile-card">
|
| 537 |
+
<div class="flex items-start justify-between gap-3 mb-3">
|
| 538 |
+
<div class="min-w-0">
|
| 539 |
+
<div class="font-bold text-text">${escapeHtml(titleStr)}</div>
|
| 540 |
+
<div class="muted text-xs font-mono mt-1 break-all">${escapeHtml(s.stream_id)}</div>
|
| 541 |
+
</div>
|
| 542 |
+
<span class="${getStatusBadge(status)}">${escapeHtml(status)}</span>
|
| 543 |
+
</div>
|
| 544 |
+
|
| 545 |
+
<div class="mobile-kv">
|
| 546 |
+
<div class="key">Bot</div><div>Bot ${Number(s.client_index ?? 0) + 1} (DC${escapeHtml(s.dc_id)})</div>
|
| 547 |
+
<div class="key">Transferred</div><div>${bytesStr}</div>
|
| 548 |
+
<div class="key">Avg / Peak</div><div>${avg.toFixed(1)} / ${peak.toFixed(1)} MB/s</div>
|
| 549 |
+
<div class="key">Duration</div><div>${durationStr}</div>
|
| 550 |
+
<div class="key">Time</div><div>${timeStr}</div>
|
| 551 |
+
</div>
|
| 552 |
+
</div>
|
| 553 |
+
`;
|
| 554 |
+
});
|
| 555 |
+
|
| 556 |
+
tbody.innerHTML = tableHtml;
|
| 557 |
+
mobile.innerHTML = mobileHtml;
|
| 558 |
} catch (err) {
|
| 559 |
console.error(err);
|
| 560 |
+
showToast('Failed to load stream analytics.', 'error', 'Load Error');
|
| 561 |
}
|
| 562 |
}
|
| 563 |
|
|
|
|
| 565 |
try {
|
| 566 |
const res = await fetch('/api/admin/dead-links');
|
| 567 |
const tbody = document.getElementById('dead-links-tbody');
|
| 568 |
+
const mobile = document.getElementById('dead-links-mobile');
|
|
|
|
|
|
|
| 569 |
|
| 570 |
+
if (!res.ok) {
|
| 571 |
+
showToast('Failed to load dead links.', 'error', 'Load Error');
|
| 572 |
+
return;
|
| 573 |
+
}
|
| 574 |
|
| 575 |
+
const data = await res.json();
|
| 576 |
+
const links = data?.data || [];
|
|
|
|
|
|
|
|
|
|
| 577 |
|
| 578 |
+
if (!links.length) {
|
| 579 |
+
tbody.innerHTML = '<tr><td colspan="5" class="empty-state">No dead links found. All files are healthy!</td></tr>';
|
| 580 |
+
mobile.innerHTML = '<div class="empty-state">No dead links found. All files are healthy!</div>';
|
| 581 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 582 |
}
|
| 583 |
+
|
| 584 |
+
let tableHtml = '';
|
| 585 |
+
let mobileHtml = '';
|
| 586 |
+
|
| 587 |
+
links.forEach(l => {
|
| 588 |
+
const isMovie = l.type === 'movie';
|
| 589 |
+
const typeBadge = isMovie
|
| 590 |
+
? '<span class="status-badge status-good">Movie</span>'
|
| 591 |
+
: '<span class="status-badge status-warn">TV Series</span>';
|
| 592 |
+
|
| 593 |
+
const dateAdded = l.date_added ? new Date(l.date_added).toLocaleDateString() : '—';
|
| 594 |
+
const qualityIdEsc = String(l.quality_id || '').replace(/'/g, "\\'");
|
| 595 |
+
|
| 596 |
+
tableHtml += `
|
| 597 |
+
<tr>
|
| 598 |
+
<td>
|
| 599 |
+
<div class="font-semibold text-text">${escapeHtml(l.title)}</div>
|
| 600 |
+
<div class="muted text-xs mt-1">${escapeHtml(l.year || '')}</div>
|
| 601 |
+
</td>
|
| 602 |
+
<td>${typeBadge}</td>
|
| 603 |
+
<td>
|
| 604 |
+
<div class="font-semibold text-red-400">${escapeHtml(l.quality || 'Unknown')}</div>
|
| 605 |
+
<div class="muted text-xs mt-1">${escapeHtml(l.size || 'Unknown size')}</div>
|
| 606 |
+
</td>
|
| 607 |
+
<td class="text-center muted text-xs">${dateAdded}</td>
|
| 608 |
+
<td class="text-center">
|
| 609 |
+
<button onclick="deleteDeadLink(${l.tmdb_id}, ${l.db_index}, '${escapeHtml(l.type)}', '${qualityIdEsc}', ${l.season || -1}, ${l.episode || -1})"
|
| 610 |
+
class="btn-ui btn-danger px-3 py-2 text-sm w-auto"
|
| 611 |
+
title="Delete from Database">
|
| 612 |
+
<i class="fas fa-trash"></i>
|
| 613 |
+
Delete
|
| 614 |
+
</button>
|
| 615 |
+
</td>
|
| 616 |
+
</tr>
|
| 617 |
+
`;
|
| 618 |
+
|
| 619 |
+
mobileHtml += `
|
| 620 |
+
<div class="mobile-card">
|
| 621 |
+
<div class="flex items-start justify-between gap-3 mb-3">
|
| 622 |
+
<div>
|
| 623 |
+
<div class="font-bold text-text">${escapeHtml(l.title)}</div>
|
| 624 |
+
<div class="muted text-xs mt-1">${escapeHtml(l.year || '')}</div>
|
| 625 |
+
</div>
|
| 626 |
+
${typeBadge}
|
| 627 |
+
</div>
|
| 628 |
+
|
| 629 |
+
<div class="mobile-kv mb-4">
|
| 630 |
+
<div class="key">Quality</div><div class="text-red-400 font-semibold">${escapeHtml(l.quality || 'Unknown')}</div>
|
| 631 |
+
<div class="key">Size</div><div>${escapeHtml(l.size || 'Unknown size')}</div>
|
| 632 |
+
<div class="key">Date Added</div><div>${dateAdded}</div>
|
| 633 |
+
</div>
|
| 634 |
+
|
| 635 |
+
<button onclick="deleteDeadLink(${l.tmdb_id}, ${l.db_index}, '${escapeHtml(l.type)}', '${qualityIdEsc}', ${l.season || -1}, ${l.episode || -1})"
|
| 636 |
+
class="btn-ui btn-danger">
|
| 637 |
+
<i class="fas fa-trash"></i>
|
| 638 |
+
Delete Dead Link
|
| 639 |
+
</button>
|
| 640 |
+
</div>
|
| 641 |
+
`;
|
| 642 |
+
});
|
| 643 |
+
|
| 644 |
+
tbody.innerHTML = tableHtml;
|
| 645 |
+
mobile.innerHTML = mobileHtml;
|
| 646 |
} catch (err) {
|
| 647 |
console.error(err);
|
| 648 |
+
showToast('Failed to load dead links.', 'error', 'Load Error');
|
| 649 |
}
|
| 650 |
}
|
| 651 |
|
|
|
|
| 656 |
const res = await fetch('/api/admin/clear-cache', { method: 'POST' });
|
| 657 |
if (res.ok) {
|
| 658 |
const data = await res.json();
|
| 659 |
+
showToast(data.message || 'Cache cleared successfully.', 'success', 'Cache Cleared');
|
| 660 |
fetchStats();
|
| 661 |
} else {
|
| 662 |
+
showToast('Failed to clear cache.', 'error', 'Request Failed');
|
| 663 |
}
|
| 664 |
} catch (err) {
|
| 665 |
+
showToast('Error clearing cache.', 'error', 'Network Error');
|
| 666 |
}
|
| 667 |
}
|
| 668 |
|
|
|
|
| 673 |
const res = await fetch('/api/admin/clear-analytics', { method: 'POST' });
|
| 674 |
if (res.ok) {
|
| 675 |
const data = await res.json();
|
| 676 |
+
showToast(data.message || 'Analytics cleared successfully.', 'success', 'Analytics Cleared');
|
| 677 |
fetchAnalytics();
|
| 678 |
} else {
|
| 679 |
const err = await res.json().catch(() => ({}));
|
| 680 |
+
showToast(err.detail || 'Failed to clear analytics.', 'error', 'Request Failed');
|
| 681 |
}
|
| 682 |
} catch (err) {
|
| 683 |
+
showToast('Error clearing analytics.', 'error', 'Network Error');
|
| 684 |
}
|
| 685 |
}
|
| 686 |
|
|
|
|
| 697 |
|
| 698 |
const res = await fetch(endpoint, { method: 'DELETE' });
|
| 699 |
if (res.ok) {
|
| 700 |
+
showToast('Dead link deleted successfully.', 'success', 'Cleanup Complete');
|
| 701 |
+
fetchDeadLinks();
|
| 702 |
} else {
|
| 703 |
+
showToast('Failed to delete the dead link.', 'error', 'Delete Failed');
|
| 704 |
}
|
| 705 |
} catch (err) {
|
| 706 |
+
showToast('Error communicating with server.', 'error', 'Network Error');
|
| 707 |
}
|
| 708 |
}
|
| 709 |
|
|
|
|
| 710 |
document.addEventListener('DOMContentLoaded', () => {
|
| 711 |
fetchStats();
|
| 712 |
fetchAnalytics();
|
| 713 |
fetchDeadLinks();
|
|
|
|
| 714 |
setInterval(fetchStats, 10000);
|
| 715 |
setInterval(fetchAnalytics, 15000);
|
| 716 |
});
|
Backend/fastapi/templates/base.html
CHANGED
|
@@ -1,244 +1,428 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en" class="dark">
|
| 3 |
<head>
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 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 |
-
|
| 31 |
-
|
| 32 |
-
background-color: {{ theme.colors.background }};
|
| 33 |
-
color: {{ theme.colors.text }};
|
| 34 |
-
}
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
</head>
|
| 46 |
|
| 47 |
-
<body class="
|
| 48 |
|
| 49 |
-
<
|
| 50 |
-
<nav class="theme-card border-b shadow-sm sticky top-0 z-50 backdrop-blur">
|
| 51 |
-
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
| 52 |
-
<div class="flex justify-between items-center h-16">
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
</a>
|
| 78 |
-
</div>
|
| 79 |
-
{% endif %}
|
| 80 |
-
</div>
|
| 81 |
|
| 82 |
-
<
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
<
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
<
|
| 91 |
-
|
| 92 |
-
</
|
| 93 |
-
{% endfor %}
|
| 94 |
-
</select>
|
| 95 |
-
</form>
|
| 96 |
-
|
| 97 |
-
{% if current_user %}
|
| 98 |
-
<!-- PROFILE DROPDOWN -->
|
| 99 |
-
<div class="relative">
|
| 100 |
-
<button id="profile-btn" class="flex items-center gap-2 text-sm">
|
| 101 |
-
<i class="fas fa-user-circle text-lg"></i>
|
| 102 |
-
<span class="hidden sm:block">{{ current_user }}</span>
|
| 103 |
-
<i class="fas fa-chevron-down text-xs"></i>
|
| 104 |
-
</button>
|
| 105 |
-
|
| 106 |
-
<div id="profile-menu" class="hidden absolute right-0 mt-2 w-40 theme-card border rounded-lg shadow-lg py-2">
|
| 107 |
-
<a href="/logout" class="dropdown-link text-red-500">Logout</a>
|
| 108 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
</div>
|
| 110 |
-
{% else %}
|
| 111 |
-
<a href="/login"
|
| 112 |
-
class="bg-blue-600 text-white px-3 py-1.5 rounded-md hover:bg-blue-700 text-sm transition">
|
| 113 |
-
Login
|
| 114 |
-
</a>
|
| 115 |
-
{% endif %}
|
| 116 |
-
|
| 117 |
-
<!-- MOBILE BUTTON -->
|
| 118 |
-
<button id="menu-btn" class="md:hidden text-xl">
|
| 119 |
-
<i class="fas fa-bars"></i>
|
| 120 |
-
</button>
|
| 121 |
</div>
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
</div>
|
| 124 |
|
| 125 |
-
<
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
<a href="/" class="
|
| 130 |
-
<a href="/
|
| 131 |
-
<a href="/admin/
|
| 132 |
-
<a href="/admin/subscriptions" class="mobile-link">Subscriptions</a>
|
| 133 |
-
<a href="/admin/access" class="mobile-link">Access</a>
|
| 134 |
</div>
|
| 135 |
</div>
|
| 136 |
-
{% endif %}
|
| 137 |
</nav>
|
| 138 |
|
| 139 |
-
<
|
| 140 |
-
<main class="flex-1">
|
| 141 |
{% block content %}{% endblock %}
|
| 142 |
</main>
|
| 143 |
|
| 144 |
-
<
|
| 145 |
-
<
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
<p class="
|
| 149 |
-
<div class="flex gap-4">
|
| 150 |
-
<a href="/status" class="footer-link">Status</a>
|
| 151 |
-
<a href="/stremio" class="footer-link">Stremio Guide</a>
|
| 152 |
-
</div>
|
| 153 |
</div>
|
| 154 |
</div>
|
| 155 |
</footer>
|
| 156 |
-
|
| 157 |
-
<
|
| 158 |
-
<
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
}
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
.
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|
| 204 |
-
|
| 205 |
-
color: var(--tw-color-primary);
|
| 206 |
-
}
|
| 207 |
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
| 211 |
}
|
| 212 |
|
| 213 |
-
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
}
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
}
|
|
|
|
| 230 |
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
});
|
| 235 |
-
}
|
| 236 |
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
});
|
|
|
|
| 242 |
</script>
|
| 243 |
|
| 244 |
</body>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en" class="dark">
|
| 3 |
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>{% block title %}Telegram Stremio{% endblock %}</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 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 |
+
<style>
|
| 12 |
+
:root {
|
| 13 |
+
--primary: {{ theme.colors.primary }};
|
| 14 |
+
--secondary: {{ theme.colors.secondary }};
|
| 15 |
+
--accent: {{ theme.colors.accent }};
|
| 16 |
+
--bg: {{ theme.colors.background }};
|
| 17 |
+
--card: {{ theme.colors.card }};
|
| 18 |
+
--border: {{ theme.colors.border }}; /* Added theme border */
|
| 19 |
+
--text: {{ theme.colors.text }};
|
| 20 |
+
--text-sec: {{ theme.colors.text_secondary }};
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
body {
|
| 24 |
+
background-color: var(--bg);
|
| 25 |
+
color: var(--text);
|
| 26 |
+
background-image:
|
| 27 |
+
radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 40%),
|
| 28 |
+
radial-gradient(circle at 85% 80%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 40%),
|
| 29 |
+
radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--card) 40%, transparent), transparent 60%);
|
| 30 |
+
background-attachment: fixed;
|
| 31 |
+
min-height: 100vh;
|
| 32 |
+
display: flex;
|
| 33 |
+
flex-direction: column;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/* GLASS PANELS */
|
| 37 |
+
.glass-panel {
|
| 38 |
+
background: color-mix(in srgb, var(--card) 45%, transparent);
|
| 39 |
+
backdrop-filter: blur(20px);
|
| 40 |
+
border: 1px solid var(--border);
|
| 41 |
+
box-shadow: 0 8px 32px rgba(0,0,0,0.2);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.glass-pill { border-radius: 9999px; }
|
| 45 |
+
|
| 46 |
+
/* NAV LINKS */
|
| 47 |
+
.nav-link {
|
| 48 |
+
color: var(--text-sec);
|
| 49 |
+
border-radius: 9999px;
|
| 50 |
+
padding: 0.5rem 1.25rem;
|
| 51 |
+
transition: color 0.3s ease;
|
| 52 |
+
position: relative;
|
| 53 |
+
z-index: 1;
|
| 54 |
+
white-space: nowrap;
|
| 55 |
+
font-weight: 600;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/* FIX: Text becomes dark background color when pill is behind it for readability */
|
| 59 |
+
.nav-link:hover, .nav-link.active-page {
|
| 60 |
+
color: var(--bg) !important;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
/* ACTIVE PILL */
|
| 64 |
+
#active-pill {
|
| 65 |
+
position: absolute;
|
| 66 |
+
background: var(--primary);
|
| 67 |
+
border-radius: 9999px;
|
| 68 |
+
transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
|
| 69 |
+
z-index: 0;
|
| 70 |
+
box-shadow: 0 0 15px color-mix(in srgb, var(--primary) 40%, transparent);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
.toast {
|
| 74 |
+
pointer-events: auto;
|
| 75 |
+
min-width: 260px;
|
| 76 |
+
max-width: 360px;
|
| 77 |
+
border: 1px solid var(--border);
|
| 78 |
+
background: color-mix(in srgb, var(--card) 88%, transparent);
|
| 79 |
+
color: var(--text);
|
| 80 |
+
box-shadow: 0 18px 40px rgba(0,0,0,0.2);
|
| 81 |
+
border-radius: 1rem;
|
| 82 |
+
padding: 0.9rem 1rem;
|
| 83 |
+
display: flex;
|
| 84 |
+
align-items: flex-start;
|
| 85 |
+
gap: 0.75rem;
|
| 86 |
+
backdrop-filter: blur(14px);
|
| 87 |
+
animation: toast-in 220ms ease-out;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
.toast.success { border-color: color-mix(in srgb, #22c55e 35%, var(--border)); }
|
| 91 |
+
.toast.error { border-color: color-mix(in srgb, #ef4444 35%, var(--border)); }
|
| 92 |
+
.toast.info { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
|
| 93 |
+
|
| 94 |
+
.toast-title {
|
| 95 |
+
font-weight: 800;
|
| 96 |
+
font-size: 0.9rem;
|
| 97 |
+
line-height: 1.2;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
.toast-message {
|
| 101 |
+
margin-top: 0.15rem;
|
| 102 |
+
font-size: 0.82rem;
|
| 103 |
+
color: var(--text-secondary);
|
| 104 |
+
line-height: 1.35;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
@keyframes toast-in {
|
| 108 |
+
from { opacity: 0; transform: translateY(-10px) scale(0.98); }
|
| 109 |
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
@keyframes toast-out {
|
| 113 |
+
from { opacity: 1; transform: translateY(0) scale(1); }
|
| 114 |
+
to { opacity: 0; transform: translateY(-8px) scale(0.98); }
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
/* Mobile improvement */
|
| 118 |
+
@media (max-width: 640px) {
|
| 119 |
+
#toast-container {
|
| 120 |
+
top: 5rem;
|
| 121 |
+
left: 0.75rem;
|
| 122 |
+
right: 0.75rem;
|
| 123 |
+
}
|
| 124 |
|
| 125 |
+
.toast {
|
| 126 |
+
max-width: none;
|
| 127 |
+
width: 100%;
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
/* THEME SELECT */
|
| 132 |
+
.theme-select {
|
| 133 |
+
appearance: none;
|
| 134 |
+
background: var(--bg);
|
| 135 |
+
color: var(--text);
|
| 136 |
+
border: 1px solid var(--border);
|
| 137 |
+
border-radius: 999px;
|
| 138 |
+
padding: 0.5rem 2rem 0.5rem 1rem;
|
| 139 |
+
font-size: 0.875rem;
|
| 140 |
+
cursor: pointer;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
/* OVERLAY */
|
| 144 |
+
#overlay {
|
| 145 |
+
backdrop-filter: blur(8px);
|
| 146 |
+
background: rgba(0,0,0,0.4);
|
| 147 |
+
transition: opacity 0.3s ease;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
/* SCROLL ANIMATION - Fixed "Jumping" issue */
|
| 151 |
+
.nav-scrolled {
|
| 152 |
+
transform: translate(-50%, -5px) scale(0.97);
|
| 153 |
+
background: color-mix(in srgb, var(--card) 80%, transparent);
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
#mobile-menu { will-change: max-height, opacity; }
|
| 157 |
+
</style>
|
| 158 |
+
|
| 159 |
+
<script>
|
| 160 |
+
tailwind.config = {
|
| 161 |
+
darkMode: 'class',
|
| 162 |
+
theme: {
|
| 163 |
+
extend: {
|
| 164 |
+
colors: {
|
| 165 |
+
primary: 'var(--primary)',
|
| 166 |
+
secondary: 'var(--secondary)',
|
| 167 |
+
accent: 'var(--accent)',
|
| 168 |
+
background: 'var(--bg)',
|
| 169 |
+
card: 'var(--card)',
|
| 170 |
+
border: 'var(--border)',
|
| 171 |
+
text: 'var(--text)',
|
| 172 |
+
'text-secondary': 'var(--text-sec)'
|
| 173 |
+
}
|
| 174 |
}
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
</script>
|
| 178 |
</head>
|
| 179 |
|
| 180 |
+
<body class="pt-24 pb-12 antialiased">
|
| 181 |
|
| 182 |
+
<div id="overlay" class="fixed inset-0 z-40 opacity-0 pointer-events-none"></div>
|
|
|
|
|
|
|
|
|
|
| 183 |
|
| 184 |
+
<nav id="navbar" class="fixed top-6 left-1/2 -translate-x-1/2 w-[95%] max-w-6xl z-50 glass-panel glass-pill px-5 py-3 flex justify-between items-center transition-all duration-300">
|
| 185 |
+
|
| 186 |
+
<a href="/" class="flex items-center gap-3 shrink-0">
|
| 187 |
+
<div class="w-8 h-8 rounded-full bg-primary flex items-center justify-center shadow-[0_0_15px_var(--primary)]">
|
| 188 |
+
<i class="fa-solid fa-play text-white text-xs"></i>
|
| 189 |
+
</div>
|
| 190 |
+
<span class="text-lg md:text-xl font-extrabold tracking-wide text-transparent bg-clip-text bg-gradient-to-r from-primary to-accent">
|
| 191 |
+
TG Stremio
|
| 192 |
+
</span>
|
| 193 |
+
</a>
|
| 194 |
|
| 195 |
+
{% if current_user %}
|
| 196 |
+
<div id="nav-container" class="hidden md:flex absolute left-1/2 -translate-x-1/2 items-center gap-1 p-1 bg-black/10 rounded-full border border-white/5">
|
| 197 |
+
<div id="active-pill" class="pointer-events-none"></div>
|
| 198 |
+
<a href="/" class="nav-link">Home</a>
|
| 199 |
+
<a href="/media/manage" class="nav-link">Media</a>
|
| 200 |
+
<a href="/admin/dashboard" class="nav-link">Admin</a>
|
| 201 |
+
<a href="/admin/subscriptions" class="nav-link">Subs</a>
|
| 202 |
+
<a href="/admin/access" class="nav-link">Access</a>
|
| 203 |
+
</div>
|
| 204 |
+
{% endif %}
|
| 205 |
+
|
| 206 |
+
<div class="flex items-center gap-3">
|
| 207 |
+
{% if current_user %}
|
| 208 |
+
<button id="menu-btn" class="md:hidden w-10 h-10 flex items-center justify-center text-xl hover:bg-white/10 rounded-full transition">
|
| 209 |
+
<i id="menu-icon" class="fa-solid fa-bars"></i>
|
| 210 |
+
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
+
<div class="relative">
|
| 213 |
+
<button id="user-btn" class="w-10 h-10 rounded-full bg-primary/20 hover:bg-primary/30 flex items-center justify-center text-primary text-lg transition border border-primary/30">
|
| 214 |
+
<i class="fa-solid fa-user"></i>
|
| 215 |
+
</button>
|
| 216 |
+
|
| 217 |
+
<div id="user-dropdown" class="absolute right-0 top-14 w-64 glass-panel rounded-2xl p-4 opacity-0 scale-95 pointer-events-none transition-all duration-200 origin-top-right z-50">
|
| 218 |
+
<div class="mb-3 border-b border-white/10 pb-3">
|
| 219 |
+
<p class="text-sm font-bold text-text">{{ current_user }}</p>
|
| 220 |
+
<p class="text-[10px] text-green-400 font-bold uppercase tracking-wider flex items-center gap-1">
|
| 221 |
+
<span class="w-1.5 h-1.5 rounded-full bg-green-400 animate-pulse"></span> Online
|
| 222 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
</div>
|
| 224 |
+
|
| 225 |
+
<form method="post" action="/set-theme" class="mb-4">
|
| 226 |
+
<label class="text-[10px] uppercase text-text-secondary font-bold mb-1 block ml-2">App Theme</label>
|
| 227 |
+
<select name="theme" onchange="this.form.submit()" class="theme-select w-full">
|
| 228 |
+
{% for theme_key, theme_data in themes.items() %}
|
| 229 |
+
<option value="{{ theme_key }}" {% if current_theme==theme_key %}selected{% endif %}>
|
| 230 |
+
{{ theme_data.name }}
|
| 231 |
+
</option>
|
| 232 |
+
{% endfor %}
|
| 233 |
+
</select>
|
| 234 |
+
</form>
|
| 235 |
+
|
| 236 |
+
<a href="/logout" class="block text-center bg-red-500/10 hover:bg-red-500 text-red-500 hover:text-white px-4 py-2.5 rounded-xl text-sm font-bold transition-all">
|
| 237 |
+
Logout
|
| 238 |
+
</a>
|
| 239 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
</div>
|
| 241 |
+
{% else %}
|
| 242 |
+
<a href="/login" class="bg-primary hover:bg-primary/80 text-white px-6 py-2 rounded-full text-sm font-bold transition shadow-lg shadow-primary/20">
|
| 243 |
+
Login
|
| 244 |
+
</a>
|
| 245 |
+
{% endif %}
|
| 246 |
</div>
|
| 247 |
|
| 248 |
+
<div id="mobile-menu" class="absolute top-[calc(100%+12px)] left-0 w-full overflow-hidden max-h-0 opacity-0 transition-all duration-300 ease-in-out md:hidden z-40">
|
| 249 |
+
<div class="glass-panel mx-2 rounded-3xl p-4 flex flex-col gap-2">
|
| 250 |
+
<a href="/" class="px-4 py-3 rounded-xl hover:bg-primary hover:text-background transition flex items-center gap-3 font-semibold"><i class="fa-solid fa-house"></i> Home</a>
|
| 251 |
+
<a href="/media/manage" class="px-4 py-3 rounded-xl hover:bg-primary hover:text-background transition flex items-center gap-3 font-semibold"><i class="fa-solid fa-clapperboard"></i> Media</a>
|
| 252 |
+
<a href="/admin/dashboard" class="px-4 py-3 rounded-xl hover:bg-primary hover:text-background transition flex items-center gap-3 font-semibold"><i class="fa-solid fa-chart-line"></i> Admin</a>
|
| 253 |
+
<a href="/admin/subscriptions" class="px-4 py-3 rounded-xl hover:bg-primary hover:text-background transition flex items-center gap-3 font-semibold"><i class="fa-solid fa-credit-card"></i> Subs</a>
|
| 254 |
+
<a href="/admin/access" class="px-4 py-3 rounded-xl hover:bg-primary hover:text-background transition flex items-center gap-3 font-semibold"><i class="fa-solid fa-shield"></i> Access</a>
|
|
|
|
|
|
|
| 255 |
</div>
|
| 256 |
</div>
|
|
|
|
| 257 |
</nav>
|
| 258 |
|
| 259 |
+
<main class="flex-1 w-full max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 mt-8">
|
|
|
|
| 260 |
{% block content %}{% endblock %}
|
| 261 |
</main>
|
| 262 |
|
| 263 |
+
<footer class="mt-auto w-full max-w-5xl mx-auto px-6 py-8">
|
| 264 |
+
<div class="glass-panel rounded-3xl p-6 flex flex-col md:flex-row justify-between items-center gap-4">
|
| 265 |
+
<div class="flex items-center gap-2">
|
| 266 |
+
<i class="fa-brands fa-telegram text-primary text-xl"></i>
|
| 267 |
+
<p class="text-text-secondary text-sm">© 2026 Telegram Stremio</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
</div>
|
| 269 |
</div>
|
| 270 |
</footer>
|
| 271 |
+
|
| 272 |
+
<div id="toast-container"
|
| 273 |
+
class="fixed top-4 right-4 z-[9999] space-y-3 pointer-events-none"></div>
|
| 274 |
+
|
| 275 |
+
<script>
|
| 276 |
+
const btn = document.getElementById('menu-btn');
|
| 277 |
+
const mobileMenu = document.getElementById('mobile-menu');
|
| 278 |
+
const overlay = document.getElementById('overlay');
|
| 279 |
+
const icon = document.getElementById('menu-icon');
|
| 280 |
+
const navbar = document.getElementById('navbar');
|
| 281 |
+
const userBtn = document.getElementById('user-btn');
|
| 282 |
+
const userDropdown = document.getElementById('user-dropdown');
|
| 283 |
+
const navContainer = document.getElementById('nav-container');
|
| 284 |
+
|
| 285 |
+
let isMenuOpen = false;
|
| 286 |
+
let isUserOpen = false;
|
| 287 |
+
|
| 288 |
+
// --- MENU & DROPDOWN TOGGLE ---
|
| 289 |
+
function toggleMenu() {
|
| 290 |
+
isMenuOpen = !isMenuOpen;
|
| 291 |
+
if(isUserOpen) closeUser();
|
| 292 |
+
if (isMenuOpen) {
|
| 293 |
+
mobileMenu.style.maxHeight = mobileMenu.scrollHeight + "px";
|
| 294 |
+
mobileMenu.style.opacity = "1";
|
| 295 |
+
overlay.style.opacity = "1";
|
| 296 |
+
overlay.classList.remove("pointer-events-none");
|
| 297 |
+
icon.classList.replace("fa-bars","fa-xmark");
|
| 298 |
+
} else closeMenu();
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
function closeMenu() {
|
| 302 |
+
mobileMenu.style.maxHeight = "0px";
|
| 303 |
+
mobileMenu.style.opacity = "0";
|
| 304 |
+
icon.classList.replace("fa-xmark","fa-bars");
|
| 305 |
+
isMenuOpen = false;
|
| 306 |
+
checkOverlay();
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
function toggleUser(e) {
|
| 310 |
+
if(e) e.stopPropagation();
|
| 311 |
+
isUserOpen = !isUserOpen;
|
| 312 |
+
if(isMenuOpen) closeMenu();
|
| 313 |
+
if (isUserOpen) {
|
| 314 |
+
userDropdown.classList.remove("opacity-0", "scale-95", "pointer-events-none");
|
| 315 |
+
overlay.style.opacity = "1";
|
| 316 |
+
overlay.classList.remove("pointer-events-none");
|
| 317 |
+
} else closeUser();
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
function closeUser() {
|
| 321 |
+
if(userDropdown) userDropdown.classList.add("opacity-0", "scale-95", "pointer-events-none");
|
| 322 |
+
isUserOpen = false;
|
| 323 |
+
checkOverlay();
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
function checkOverlay() {
|
| 327 |
+
if (!isMenuOpen && !isUserOpen) {
|
| 328 |
+
overlay.style.opacity = "0";
|
| 329 |
+
overlay.classList.add("pointer-events-none");
|
| 330 |
}
|
| 331 |
+
}
|
| 332 |
+
function showToast(message, type = 'info', title = '') {
|
| 333 |
+
const container = document.getElementById('toast-container');
|
| 334 |
+
if (!container) return;
|
| 335 |
+
|
| 336 |
+
const toast = document.createElement('div');
|
| 337 |
+
toast.className = `toast ${type}`;
|
| 338 |
+
|
| 339 |
+
const icon = type === 'success'
|
| 340 |
+
? 'fa-circle-check'
|
| 341 |
+
: type === 'error'
|
| 342 |
+
? 'fa-triangle-exclamation'
|
| 343 |
+
: 'fa-circle-info';
|
| 344 |
+
|
| 345 |
+
toast.innerHTML = `
|
| 346 |
+
<i class="fa-solid ${icon} mt-0.5"></i>
|
| 347 |
+
<div class="min-w-0">
|
| 348 |
+
${title ? `<div class="toast-title">${escapeHtml(title)}</div>` : ''}
|
| 349 |
+
<div class="toast-message">${escapeHtml(message)}</div>
|
| 350 |
+
</div>
|
| 351 |
+
`;
|
| 352 |
|
| 353 |
+
container.appendChild(toast);
|
|
|
|
|
|
|
| 354 |
|
| 355 |
+
setTimeout(() => {
|
| 356 |
+
toast.style.animation = 'toast-out 180ms ease-in forwards';
|
| 357 |
+
setTimeout(() => {
|
| 358 |
+
if (toast.parentNode) toast.parentNode.removeChild(toast);
|
| 359 |
+
}, 200);
|
| 360 |
+
}, 2600);
|
| 361 |
}
|
| 362 |
|
| 363 |
+
// GLOBAL SAFE ESCAPE (important!)
|
| 364 |
+
function escapeHtml(str) {
|
| 365 |
+
return String(str || '')
|
| 366 |
+
.replace(/&/g, '&')
|
| 367 |
+
.replace(/</g, '<')
|
| 368 |
+
.replace(/>/g, '>')
|
| 369 |
+
.replace(/"/g, '"')
|
| 370 |
+
.replace(/'/g, ''');
|
| 371 |
}
|
| 372 |
+
|
| 373 |
+
// Events
|
| 374 |
+
if(btn) btn.onclick = toggleMenu;
|
| 375 |
+
if(userBtn) userBtn.onclick = toggleUser;
|
| 376 |
+
overlay.onclick = () => { closeMenu(); closeUser(); };
|
| 377 |
+
|
| 378 |
+
window.addEventListener("scroll", () => {
|
| 379 |
+
if (isMenuOpen) closeMenu();
|
| 380 |
+
if (isUserOpen) closeUser();
|
| 381 |
+
navbar.classList.toggle("nav-scrolled", window.scrollY > 20);
|
| 382 |
+
});
|
| 383 |
+
|
| 384 |
+
document.addEventListener("keydown", e => {
|
| 385 |
+
if (e.key === "Escape") { closeMenu(); closeUser(); }
|
| 386 |
+
});
|
| 387 |
+
|
| 388 |
+
if (userDropdown) {
|
| 389 |
+
userDropdown.addEventListener("click", e => e.stopPropagation());
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
// --- SMART ACTIVE PILL LOGIC ---
|
| 393 |
+
const links = document.querySelectorAll(".nav-link");
|
| 394 |
+
const pill = document.getElementById("active-pill");
|
| 395 |
+
let activeLink = null;
|
| 396 |
+
|
| 397 |
+
function movePill(el) {
|
| 398 |
+
if(!pill || !el) return;
|
| 399 |
+
const r = el.getBoundingClientRect();
|
| 400 |
+
const pr = el.parentElement.getBoundingClientRect();
|
| 401 |
+
pill.style.width = r.width + "px";
|
| 402 |
+
pill.style.height = r.height + "px";
|
| 403 |
+
pill.style.left = (r.left - pr.left) + "px";
|
| 404 |
+
pill.style.top = (r.top - pr.top) + "px";
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
window.addEventListener('load', () => {
|
| 408 |
+
const current = window.location.pathname;
|
| 409 |
+
activeLink = [...links].find(l => l.getAttribute("href") === current) || links[0];
|
| 410 |
+
if(activeLink) {
|
| 411 |
+
activeLink.classList.add('active-page');
|
| 412 |
+
movePill(activeLink);
|
| 413 |
}
|
| 414 |
+
});
|
| 415 |
|
| 416 |
+
links.forEach(l => {
|
| 417 |
+
l.addEventListener("mouseenter", () => movePill(l));
|
| 418 |
+
});
|
|
|
|
|
|
|
| 419 |
|
| 420 |
+
// Returns pill to active page when mouse leaves the navbar
|
| 421 |
+
if(navContainer) {
|
| 422 |
+
navContainer.addEventListener("mouseleave", () => {
|
| 423 |
+
if(activeLink) movePill(activeLink);
|
| 424 |
});
|
| 425 |
+
}
|
| 426 |
</script>
|
| 427 |
|
| 428 |
</body>
|
Backend/fastapi/templates/dashboard.html
CHANGED
|
@@ -3,525 +3,451 @@
|
|
| 3 |
{% block title %}Dashboard - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
-
<div class="min-h-screen">
|
| 7 |
-
<
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
</
|
| 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 |
-
<
|
| 30 |
-
<
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 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 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 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 |
-
|
| 74 |
-
|
| 75 |
-
<
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
</div>
|
| 96 |
|
| 97 |
<div class="space-y-4">
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 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 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 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 |
-
|
| 162 |
-
|
| 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 |
-
</
|
| 221 |
-
</div>
|
| 222 |
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 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 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
<
|
| 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 |
-
|
| 256 |
-
<
|
| 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 |
-
</
|
| 270 |
-
|
| 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 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 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 |
-
<
|
| 296 |
-
<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 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 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 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
</div>
|
| 321 |
</div>
|
| 322 |
-
</
|
| 323 |
</div>
|
| 324 |
</div>
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
<
|
| 332 |
-
|
| 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 |
-
<
|
| 339 |
-
|
|
|
|
|
|
|
| 340 |
</div>
|
| 341 |
|
| 342 |
-
<
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 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 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
<span class="absolute right-4 top-3 text-gray-400 text-sm pointer-events-none">GB</span>
|
| 371 |
-
</div>
|
| 372 |
-
</div>
|
| 373 |
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
<span class="absolute right-4 top-3 text-gray-400 text-sm pointer-events-none">GB</span>
|
| 380 |
-
</div>
|
| 381 |
-
</div>
|
| 382 |
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 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
|
| 400 |
<thead>
|
| 401 |
-
<tr class="
|
| 402 |
-
<th class="py-
|
| 403 |
-
<th class="py-
|
| 404 |
-
<th class="py-
|
| 405 |
-
<th class="py-
|
| 406 |
-
<th class="py-
|
| 407 |
</tr>
|
| 408 |
</thead>
|
| 409 |
-
<tbody>
|
| 410 |
{% for token in api_tokens %}
|
| 411 |
-
<tr class="
|
| 412 |
-
<td class="py-
|
| 413 |
-
{{ token.name }}<
|
| 414 |
-
<
|
| 415 |
-
}}
|
| 416 |
-
|
| 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 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
{
|
| 431 |
-
|
| 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 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
</
|
| 451 |
-
<
|
| 452 |
-
|
| 453 |
-
|
| 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 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
class="
|
| 468 |
-
|
| 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 |
-
{%
|
|
|
|
|
|
|
| 477 |
<tr>
|
| 478 |
-
<td colspan="5" class="py-8 text-center
|
| 479 |
-
|
|
|
|
| 480 |
</tr>
|
| 481 |
-
{%
|
| 482 |
</tbody>
|
| 483 |
</table>
|
| 484 |
</div>
|
| 485 |
</div>
|
|
|
|
|
|
|
| 486 |
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
| 518 |
</div>
|
| 519 |
|
| 520 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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');
|
|
@@ -532,30 +458,29 @@
|
|
| 532 |
}
|
| 533 |
}
|
| 534 |
|
| 535 |
-
let currentEditToken = null;
|
| 536 |
-
|
| 537 |
function openEditModal(token, daily, monthly) {
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
|
|
|
| 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({
|
|
@@ -566,43 +491,349 @@
|
|
| 566 |
|
| 567 |
if (response.ok) {
|
| 568 |
closeEditModal();
|
| 569 |
-
|
| 570 |
-
window.location.reload();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 571 |
} else {
|
| 572 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 573 |
}
|
|
|
|
| 574 |
} catch (error) {
|
| 575 |
console.error(error);
|
| 576 |
-
|
| 577 |
}
|
| 578 |
}
|
| 579 |
-
</script>
|
| 580 |
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 584 |
const icon = document.getElementById('refresh-icon');
|
| 585 |
-
if (icon) icon.classList.add('animate-spin');
|
| 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}`);
|
|
@@ -619,26 +850,21 @@
|
|
| 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 |
-
|
| 626 |
-
|
| 627 |
|
| 628 |
-
|
| 629 |
-
|
| 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);
|
|
@@ -647,291 +873,31 @@
|
|
| 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(
|
|
|
|
| 659 |
} finally {
|
| 660 |
-
// Remove spin after short delay to make it visible
|
| 661 |
setTimeout(() => {
|
| 662 |
if (icon) icon.classList.remove('animate-spin');
|
| 663 |
-
},
|
| 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 now = Date.now() / 1000;
|
| 676 |
-
|
| 677 |
-
const liveStreams = allStreams.filter(s =>
|
| 678 |
-
s.status === 'active' &&
|
| 679 |
-
(s.total_bytes || 0) > 0 &&
|
| 680 |
-
(now - (s.start_ts || now)) < 15
|
| 681 |
-
);
|
| 682 |
-
|
| 683 |
-
if (liveStreams.length === 0) {
|
| 684 |
-
container.innerHTML = `<div class="p-8 text-center bg-gray-50 border border-dashed rounded-lg">
|
| 685 |
-
<i class="fas fa-video-slash text-gray-300 text-3xl mb-3"></i>
|
| 686 |
-
<p class="text-gray-500 font-medium">No active streams at the moment</p>
|
| 687 |
-
<p class="text-xs text-gray-400 mt-1">Users are not currently watching any media.</p>
|
| 688 |
-
</div>`;
|
| 689 |
-
} else {
|
| 690 |
-
const escapeHtml = (unsafe) => {
|
| 691 |
-
if (!unsafe) return '';
|
| 692 |
-
return unsafe
|
| 693 |
-
.toString()
|
| 694 |
-
.replace(/&/g, "&")
|
| 695 |
-
.replace(/</g, "<")
|
| 696 |
-
.replace(/>/g, ">")
|
| 697 |
-
.replace(/"/g, """)
|
| 698 |
-
.replace(/'/g, "'");
|
| 699 |
-
};
|
| 700 |
-
|
| 701 |
-
const formatBytesStr = (bytes) => {
|
| 702 |
-
if (bytes === 0) return '0 B';
|
| 703 |
-
const k = 1024;
|
| 704 |
-
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
| 705 |
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
| 706 |
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
| 707 |
-
};
|
| 708 |
-
|
| 709 |
-
container.innerHTML = liveStreams.map(stream => {
|
| 710 |
-
let statusColor = 'bg-red-100 text-red-800';
|
| 711 |
-
let statusPulse = 'hidden';
|
| 712 |
-
if (stream.status === 'active') {
|
| 713 |
-
statusColor = 'bg-green-100 text-green-800';
|
| 714 |
-
statusPulse = '';
|
| 715 |
-
} else if (stream.status === 'cancelled') {
|
| 716 |
-
statusColor = 'bg-yellow-100 text-yellow-800';
|
| 717 |
-
}
|
| 718 |
-
|
| 719 |
-
const streamIdStr = stream.stream_id ? stream.stream_id.substring(0, 8) + '...' : 'Unknown';
|
| 720 |
-
const titleStr = (stream.meta && stream.meta.title) ? stream.meta.title : (stream.title || 'Unknown Stream');
|
| 721 |
-
|
| 722 |
-
return `
|
| 723 |
-
<div class="p-4 bg-gray-50 rounded-lg border-l-4 border-green-500">
|
| 724 |
-
<div class="flex justify-between items-start mb-3">
|
| 725 |
-
<div class="flex items-center gap-2 max-w-[70%]">
|
| 726 |
-
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4 text-primary shrink-0" fill="currentColor" viewBox="0 0 24 24">
|
| 727 |
-
<path d="M8 5v14l11-7z" />
|
| 728 |
-
</svg>
|
| 729 |
-
<div class="truncate">
|
| 730 |
-
<span class="font-semibold" title="${escapeHtml(stream.title || stream.stream_id)}">${escapeHtml(titleStr)}</span>
|
| 731 |
-
<div class="text-[10px] text-gray-500 font-mono mt-0.5" title="${escapeHtml(stream.stream_id)}">
|
| 732 |
-
ID: ${escapeHtml(streamIdStr)}
|
| 733 |
-
</div>
|
| 734 |
-
</div>
|
| 735 |
-
</div>
|
| 736 |
-
<span class="px-2 py-1 rounded text-xs font-semibold shrink-0 uppercase ${statusColor}">
|
| 737 |
-
${escapeHtml(stream.status)}
|
| 738 |
-
</span>
|
| 739 |
-
</div>
|
| 740 |
-
|
| 741 |
-
<div class="grid grid-cols-2 gap-3 mb-3">
|
| 742 |
-
<div class="flex justify-between py-2 px-3 bg-white rounded">
|
| 743 |
-
<span class="text-sm theme-text-secondary">Bot:</span>
|
| 744 |
-
<span class="text-sm font-semibold">Bot${(stream.client_index || 0) + 1} </span>
|
| 745 |
-
</div>
|
| 746 |
-
<div class="flex justify-between py-2 px-3 bg-white rounded">
|
| 747 |
-
<span class="text-sm theme-text-secondary">File:</span>
|
| 748 |
-
<span class="text-sm font-semibold">DC${stream.dc_id || '-'}</span>
|
| 749 |
-
</div>
|
| 750 |
-
<div class="flex justify-between py-2 px-3 bg-white rounded col-span-2">
|
| 751 |
-
<span class="text-sm theme-text-secondary">Duration:</span>
|
| 752 |
-
<span class="text-sm font-semibold">${stream.duration || 0}s</span>
|
| 753 |
-
</div>
|
| 754 |
-
|
| 755 |
-
<div class="flex justify-between py-2 px-3 bg-white rounded col-span-2">
|
| 756 |
-
<span class="text-sm theme-text-secondary">Data Transferred:</span>
|
| 757 |
-
<span class="text-sm font-semibold">${formatBytesStr(stream.total_bytes)}</span>
|
| 758 |
-
</div>
|
| 759 |
-
</div>
|
| 760 |
-
|
| 761 |
-
<div class="grid grid-cols-3 gap-3">
|
| 762 |
-
<div class="text-center py-3 bg-white rounded">
|
| 763 |
-
<div class="text-xs theme-text-secondary mb-1">Instant</div>
|
| 764 |
-
<div class="text-sm font-bold text-primary">${stream.instant_mbps || 0} MB/s</div>
|
| 765 |
-
</div>
|
| 766 |
-
<div class="text-center py-3 bg-white rounded">
|
| 767 |
-
<div class="text-xs theme-text-secondary mb-1">Average</div>
|
| 768 |
-
<div class="text-sm font-bold text-primary">${stream.avg_mbps || 0} MB/s</div>
|
| 769 |
-
</div>
|
| 770 |
-
<div class="text-center py-3 bg-white rounded">
|
| 771 |
-
<div class="text-xs theme-text-secondary mb-1">Peak</div>
|
| 772 |
-
<div class="text-sm font-bold text-primary">${stream.peak_mbps || 0} MB/s</div>
|
| 773 |
-
</div>
|
| 774 |
-
</div>
|
| 775 |
-
</div>
|
| 776 |
-
|
| 777 |
-
${stream.meta && (stream.meta.client_host || stream.meta.user_name) ? `
|
| 778 |
-
<div class="mt-3 pt-3 border-t border-gray-200">
|
| 779 |
-
<div class="flex flex-col gap-1">
|
| 780 |
-
${stream.meta.client_host ? `
|
| 781 |
-
<div class="flex justify-between items-center text-sm">
|
| 782 |
-
<div class="flex items-center gap-2">
|
| 783 |
-
<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">
|
| 784 |
-
<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>
|
| 785 |
-
</svg>
|
| 786 |
-
<span class="theme-text-secondary">Client IPv4:</span>
|
| 787 |
-
</div>
|
| 788 |
-
<span class="font-mono text-xs">${escapeHtml(stream.meta.client_host)}</span>
|
| 789 |
-
</div>
|
| 790 |
-
` : ''}
|
| 791 |
-
${stream.meta.user_name ? `
|
| 792 |
-
<div class="flex justify-between items-center text-sm">
|
| 793 |
-
<div class="flex items-center gap-2">
|
| 794 |
-
<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">
|
| 795 |
-
<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>
|
| 796 |
-
</svg>
|
| 797 |
-
<span class="theme-text-secondary">User:</span>
|
| 798 |
-
</div>
|
| 799 |
-
<span class="font-mono text-xs font-semibold">${escapeHtml(stream.meta.user_name)}</span>
|
| 800 |
-
</div>
|
| 801 |
-
` : ''}
|
| 802 |
-
</div>
|
| 803 |
-
</div>
|
| 804 |
-
` : ''}
|
| 805 |
-
</div>
|
| 806 |
-
`;
|
| 807 |
-
}).join('');
|
| 808 |
-
}
|
| 809 |
-
}
|
| 810 |
-
}
|
| 811 |
-
} catch (error) {
|
| 812 |
-
console.error("Failed to update active streams:", error);
|
| 813 |
-
}
|
| 814 |
-
}
|
| 815 |
-
|
| 816 |
-
// Auto-refresh every 2 minutes
|
| 817 |
-
const statsInterval = setInterval(refreshSystemStats, 120000);
|
| 818 |
-
</script>
|
| 819 |
-
<script>
|
| 820 |
-
async function createToken(event) {
|
| 821 |
-
event.preventDefault();
|
| 822 |
-
const nameInput = document.getElementById('token-name');
|
| 823 |
-
const dailyInput = document.getElementById('daily-limit');
|
| 824 |
-
const monthlyInput = document.getElementById('monthly-limit');
|
| 825 |
-
|
| 826 |
-
const payload = {
|
| 827 |
-
name: nameInput.value,
|
| 828 |
-
daily_limit_gb: dailyInput.value,
|
| 829 |
-
monthly_limit_gb: monthlyInput.value
|
| 830 |
-
};
|
| 831 |
-
|
| 832 |
-
try {
|
| 833 |
-
const response = await fetch('/api/tokens', {
|
| 834 |
-
method: 'POST',
|
| 835 |
-
headers: { 'Content-Type': 'application/json' },
|
| 836 |
-
body: JSON.stringify(payload)
|
| 837 |
-
});
|
| 838 |
-
|
| 839 |
-
if (response.ok) {
|
| 840 |
-
showToast('Token created successfully!');
|
| 841 |
-
setTimeout(() => window.location.reload(), 1000);
|
| 842 |
-
} else {
|
| 843 |
-
const data = await response.json();
|
| 844 |
-
showToast('Error: ' + data.detail);
|
| 845 |
-
}
|
| 846 |
-
} catch (error) {
|
| 847 |
-
showToast('Error creating token');
|
| 848 |
-
}
|
| 849 |
-
}
|
| 850 |
-
|
| 851 |
-
async function revokeToken(token) {
|
| 852 |
-
if (!confirm('Are you sure you want to revoke this token? The user will lose access immediately.')) return;
|
| 853 |
-
|
| 854 |
-
try {
|
| 855 |
-
const response = await fetch('/api/tokens/' + token, {
|
| 856 |
-
method: 'DELETE'
|
| 857 |
-
});
|
| 858 |
-
|
| 859 |
-
if (response.ok) {
|
| 860 |
-
showToast('Token revoked successfully!');
|
| 861 |
-
setTimeout(() => window.location.reload(), 1000);
|
| 862 |
-
} else {
|
| 863 |
-
showToast('Error revoking token');
|
| 864 |
-
}
|
| 865 |
-
} catch (error) {
|
| 866 |
-
showToast('Error revoking token');
|
| 867 |
-
}
|
| 868 |
-
}
|
| 869 |
-
|
| 870 |
-
function copyUrl(url) {
|
| 871 |
-
navigator.clipboard.writeText(url).then(function () {
|
| 872 |
-
showToast('Manifest URL copied to clipboard!');
|
| 873 |
-
});
|
| 874 |
-
}
|
| 875 |
-
</script>
|
| 876 |
-
</main>
|
| 877 |
-
</div>
|
| 878 |
-
|
| 879 |
-
<script>
|
| 880 |
-
function copyToClipboard() {
|
| 881 |
-
const manifestUrl = document.getElementById('manifest-url').value;
|
| 882 |
-
navigator.clipboard.writeText(manifestUrl).then(function () {
|
| 883 |
-
showToast('Manifest URL copied to clipboard!');
|
| 884 |
-
});
|
| 885 |
-
}
|
| 886 |
-
|
| 887 |
-
function showToast(message, duration = 3000) {
|
| 888 |
-
const toast = document.createElement('div');
|
| 889 |
-
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';
|
| 890 |
-
toast.textContent = message;
|
| 891 |
-
document.body.appendChild(toast);
|
| 892 |
-
|
| 893 |
-
setTimeout(() => toast.classList.remove('translate-x-full'), 100);
|
| 894 |
-
setTimeout(() => {
|
| 895 |
-
toast.classList.add('translate-x-full');
|
| 896 |
-
setTimeout(() => document.body.removeChild(toast), 300);
|
| 897 |
-
}, duration);
|
| 898 |
-
}
|
| 899 |
-
|
| 900 |
-
function toggleAccordion(id) {
|
| 901 |
-
const content = document.getElementById(id);
|
| 902 |
-
const icon = document.getElementById(id + '-icon');
|
| 903 |
-
|
| 904 |
-
if (content.classList.contains('hidden')) {
|
| 905 |
-
content.classList.remove('hidden');
|
| 906 |
-
icon.classList.add('rotate-180');
|
| 907 |
-
} else {
|
| 908 |
-
content.classList.add('hidden');
|
| 909 |
-
icon.classList.remove('rotate-180');
|
| 910 |
}
|
| 911 |
}
|
| 912 |
|
| 913 |
-
function
|
| 914 |
-
if (!+bytes) return '0 B';
|
| 915 |
-
const k = 1024;
|
| 916 |
-
const dm = decimals < 0 ? 0 : decimals;
|
| 917 |
-
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
| 918 |
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
| 919 |
-
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
| 920 |
-
}
|
| 921 |
-
|
| 922 |
-
// Auto-format bytes on load
|
| 923 |
-
document.addEventListener("DOMContentLoaded", () => {
|
| 924 |
document.querySelectorAll('[data-bytes]').forEach(el => {
|
| 925 |
-
|
|
|
|
| 926 |
});
|
|
|
|
| 927 |
|
| 928 |
-
|
| 929 |
-
|
| 930 |
-
|
| 931 |
-
|
| 932 |
-
|
| 933 |
-
}
|
| 934 |
-
{% endif %}
|
| 935 |
});
|
| 936 |
</script>
|
| 937 |
{% endblock %}
|
|
|
|
| 3 |
{% block title %}Dashboard - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
+
<div class="min-h-screen pb-12">
|
| 7 |
+
<header class="mb-10">
|
| 8 |
+
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4">
|
| 9 |
+
<div>
|
| 10 |
+
<h1 class="text-3xl font-extrabold tracking-tight text-transparent bg-clip-text bg-gradient-to-r from-primary to-accent">
|
| 11 |
+
System Overview
|
| 12 |
+
</h1>
|
| 13 |
+
<p class="text-text-secondary text-sm mt-1">Real-time performance, live stream activity, and token access management</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
</div>
|
| 15 |
+
|
| 16 |
+
<button onclick="refreshDashboard()"
|
| 17 |
+
class="flex items-center justify-center space-x-2 px-6 py-3 rounded-2xl bg-primary/10 border border-primary/20 hover:bg-primary hover:text-background transition-all group active:scale-95">
|
| 18 |
+
<i id="refresh-icon" class="fa-solid fa-arrows-rotate group-hover:rotate-180 transition-transform duration-700"></i>
|
| 19 |
+
<span class="font-bold text-sm uppercase tracking-wider">Refresh Data</span>
|
| 20 |
+
</button>
|
| 21 |
</div>
|
| 22 |
</header>
|
| 23 |
|
| 24 |
+
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-8">
|
| 25 |
+
<div class="glass-panel p-5 rounded-[2rem] flex items-center gap-4">
|
| 26 |
+
<div class="w-12 h-12 rounded-2xl bg-primary/10 flex items-center justify-center text-primary shadow-glow">
|
| 27 |
+
<i class="fa-solid fa-clock"></i>
|
| 28 |
+
</div>
|
| 29 |
+
<div>
|
| 30 |
+
<p class="text-[10px] uppercase font-bold text-text-secondary tracking-widest">Uptime</p>
|
| 31 |
+
<p id="sys-uptime" class="text-lg font-bold text-text">{{ system_stats.uptime or 'N/A' }}</p>
|
| 32 |
+
</div>
|
| 33 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
+
<div class="glass-panel p-5 rounded-[2rem] flex items-center gap-4">
|
| 36 |
+
<div class="w-12 h-12 rounded-2xl bg-accent/10 flex items-center justify-center text-accent shadow-[0_0_15px_rgba(var(--accent-rgb),0.3)]">
|
| 37 |
+
<i class="fa-solid fa-robot"></i>
|
| 38 |
+
</div>
|
| 39 |
+
<div>
|
| 40 |
+
<p class="text-[10px] uppercase font-bold text-text-secondary tracking-widest">Active Bots</p>
|
| 41 |
+
<p id="sys-bots-count" class="text-lg font-bold text-text">{{ system_stats.connected_bots|default(0) }} Nodes</p>
|
| 42 |
+
</div>
|
| 43 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
<div class="glass-panel p-5 rounded-[2rem] flex items-center gap-4">
|
| 46 |
+
<div class="w-12 h-12 rounded-2xl bg-primary/10 flex items-center justify-center text-primary shadow-glow">
|
| 47 |
+
<i class="fa-solid fa-tower-broadcast"></i>
|
| 48 |
+
</div>
|
| 49 |
+
<div>
|
| 50 |
+
<p class="text-[10px] uppercase font-bold text-text-secondary tracking-widest">Live Streams</p>
|
| 51 |
+
<p id="sys-live-streams" class="text-lg font-bold text-text">{{ system_stats.total_active_streams }} Active</p>
|
| 52 |
+
</div>
|
| 53 |
+
</div>
|
| 54 |
+
|
| 55 |
+
<div class="glass-panel p-5 rounded-[2rem] flex items-center gap-4">
|
| 56 |
+
<div class="w-12 h-12 rounded-2xl bg-white/5 flex items-center justify-center text-text-secondary">
|
| 57 |
+
<i class="fa-solid fa-code-branch"></i>
|
| 58 |
+
</div>
|
| 59 |
+
<div>
|
| 60 |
+
<p class="text-[10px] uppercase font-bold text-text-secondary tracking-widest">Version</p>
|
| 61 |
+
<p id="sys-version" class="text-lg font-bold text-text">v{{ system_stats.version or '1.0.0' }}</p>
|
| 62 |
+
</div>
|
| 63 |
+
</div>
|
| 64 |
+
</div>
|
| 65 |
+
|
| 66 |
+
<div class="grid lg:grid-cols-3 gap-8">
|
| 67 |
+
<div class="lg:col-span-2 space-y-8">
|
| 68 |
+
<section>
|
| 69 |
+
<h3 class="flex items-center gap-2 text-lg font-bold mb-4 ml-2">
|
| 70 |
+
<i class="fa-solid fa-database text-primary"></i> Storage Nodes
|
| 71 |
+
</h3>
|
| 72 |
+
|
| 73 |
+
<div class="grid md:grid-cols-2 gap-4">
|
| 74 |
+
{% for db_stat in system_stats.databases %}
|
| 75 |
+
<div class="glass-panel p-6 rounded-[2rem] border-white/5 bg-card/10">
|
| 76 |
+
<div class="flex justify-between items-start mb-6">
|
| 77 |
+
<h4 class="font-bold text-text">{{ db_stat.db_name.replace("storage_", "Node ") }}</h4>
|
| 78 |
+
<span class="text-[10px] bg-primary/10 text-primary px-2 py-1 rounded-lg font-bold uppercase">Online</span>
|
| 79 |
</div>
|
| 80 |
|
| 81 |
<div class="space-y-4">
|
| 82 |
+
<div class="flex justify-between text-sm">
|
| 83 |
+
<span class="text-text-secondary">Movies / TV</span>
|
| 84 |
+
<span class="font-bold text-text">{{ db_stat.movie_count }} / {{ db_stat.tv_count }}</span>
|
| 85 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
+
<div class="space-y-2">
|
| 88 |
+
<div class="flex justify-between text-xs font-bold uppercase tracking-widest">
|
| 89 |
+
<span class="text-text-secondary">Disk Usage</span>
|
| 90 |
+
<span class="text-primary">{{ "%.1f"|format(db_stat.storageSize / 1024 / 1024) }} MB</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
</div>
|
| 92 |
+
<div class="w-full h-1.5 bg-white/5 rounded-full overflow-hidden">
|
| 93 |
+
{% set storage_percent = (db_stat.storageSize / (500 * 1024 * 1024) * 100) | round %}
|
| 94 |
+
<div class="h-full bg-gradient-to-r from-primary to-accent transition-all duration-1000" style="width: {{ storage_percent }}%"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
</div>
|
|
|
|
| 96 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
</div>
|
| 98 |
</div>
|
| 99 |
+
{% endfor %}
|
| 100 |
</div>
|
| 101 |
+
</section>
|
|
|
|
| 102 |
|
| 103 |
+
<section class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
| 104 |
+
<a href="/media/manage?media_type=movie" class="glass-panel p-6 rounded-[2rem] hover:bg-primary/5 transition-all group border border-white/5">
|
| 105 |
+
<div class="flex items-center gap-4">
|
| 106 |
+
<div class="w-14 h-14 rounded-2xl bg-primary/10 flex items-center justify-center text-primary group-hover:scale-110 transition-transform">
|
| 107 |
+
<i class="fa-solid fa-film text-2xl"></i>
|
| 108 |
+
</div>
|
| 109 |
+
<div>
|
| 110 |
+
<h4 class="font-bold text-text">Manage Movies</h4>
|
| 111 |
+
<p class="text-xs text-text-secondary">Organize and edit library</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
</div>
|
| 113 |
+
<i class="fa-solid fa-chevron-right ml-auto text-white/20 group-hover:text-primary group-hover:translate-x-1 transition-all"></i>
|
| 114 |
</div>
|
| 115 |
+
</a>
|
| 116 |
|
| 117 |
+
<a href="/media/manage?media_type=tv" class="glass-panel p-6 rounded-[2rem] hover:bg-accent/5 transition-all group border border-white/5">
|
| 118 |
+
<div class="flex items-center gap-4">
|
| 119 |
+
<div class="w-14 h-14 rounded-2xl bg-accent/10 flex items-center justify-center text-accent group-hover:scale-110 transition-transform">
|
| 120 |
+
<i class="fa-solid fa-tv text-2xl"></i>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
</div>
|
| 122 |
+
<div>
|
| 123 |
+
<h4 class="font-bold text-text">Manage TV Shows</h4>
|
| 124 |
+
<p class="text-xs text-text-secondary">Handle series and episodes</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
</div>
|
| 126 |
+
<i class="fa-solid fa-chevron-right ml-auto text-white/20 group-hover:text-accent group-hover:translate-x-1 transition-all"></i>
|
| 127 |
</div>
|
| 128 |
+
</a>
|
| 129 |
+
</section>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
</div>
|
| 131 |
|
| 132 |
+
<div class="lg:col-span-1">
|
| 133 |
+
<div class="glass-panel rounded-[2.5rem] overflow-hidden h-full">
|
| 134 |
+
<div class="p-6 border-b border-white/5">
|
| 135 |
+
<div class="flex items-center justify-between gap-3 mb-2">
|
| 136 |
+
<h3 class="flex items-center gap-2 text-lg font-bold">
|
| 137 |
+
<i class="fa-solid fa-circle-play text-red-500 animate-pulse"></i> Live Network
|
| 138 |
+
</h3>
|
| 139 |
+
<span id="live-stream-count" class="text-[10px] font-bold uppercase tracking-[0.2em] text-primary bg-primary/10 px-3 py-1 rounded-full">
|
| 140 |
+
{{ system_stats.total_active_streams or 0 }} Active
|
| 141 |
+
</span>
|
| 142 |
+
</div>
|
| 143 |
+
<p class="text-sm text-text-secondary">Current sessions only</p>
|
| 144 |
+
</div>
|
| 145 |
|
| 146 |
+
<div class="p-6 space-y-6">
|
| 147 |
+
<div class="grid grid-cols-2 gap-3">
|
| 148 |
+
<div class="glass-panel p-4 rounded-2xl">
|
| 149 |
+
<p class="text-[10px] uppercase font-bold tracking-widest text-text-secondary">Live Now</p>
|
| 150 |
+
<p id="live-now-count" class="text-2xl font-extrabold mt-1 text-text">{{ system_stats.total_active_streams or 0 }}</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
</div>
|
| 152 |
+
<div class="glass-panel p-4 rounded-2xl">
|
| 153 |
+
<p class="text-[10px] uppercase font-bold tracking-widest text-text-secondary">Recent</p>
|
| 154 |
+
<p id="recent-stream-count" class="text-2xl font-extrabold mt-1 text-text">0</p>
|
|
|
|
|
|
|
| 155 |
</div>
|
| 156 |
</div>
|
|
|
|
| 157 |
|
| 158 |
+
<div>
|
| 159 |
+
<div class="flex items-center justify-between mb-3">
|
| 160 |
+
<h4 class="text-sm font-bold text-text">Active Streams</h4>
|
| 161 |
+
<span class="text-[10px] uppercase tracking-widest text-text-secondary">Real-time</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
</div>
|
| 163 |
+
<div id="active-streams-container" class="space-y-4">
|
| 164 |
+
{% if system_stats.active_streams %}
|
| 165 |
+
{% for stream in system_stats.active_streams %}
|
| 166 |
+
<div class="stream-card rounded-[2rem] p-5">
|
| 167 |
+
<div class="flex justify-between items-start gap-3">
|
| 168 |
+
<div class="min-w-0 pr-2">
|
| 169 |
+
<h5 class="font-bold text-sm text-text truncate">{{ stream.title or stream.meta.get('title') or 'Unknown Stream' }}</h5>
|
| 170 |
+
<div class="mt-1 flex flex-wrap items-center gap-2 text-[10px] uppercase tracking-widest text-text-secondary">
|
| 171 |
+
<span>Bot {{ (stream.client_index or 0) + 1 }}</span>
|
| 172 |
+
<span>•</span>
|
| 173 |
+
<span>DC {{ stream.dc_id or '-' }}</span>
|
| 174 |
+
<span>•</span>
|
| 175 |
+
<span class="font-mono">{{ stream.stream_id[:12] if stream.stream_id else 'Unknown' }}{% if stream.stream_id %}…{% endif %}</span>
|
| 176 |
+
</div>
|
| 177 |
+
</div>
|
| 178 |
+
<span class="text-[10px] font-bold px-2 py-1 rounded-lg uppercase whitespace-nowrap stream-badge-live">
|
| 179 |
+
Live
|
| 180 |
+
</span>
|
| 181 |
+
</div>
|
| 182 |
+
|
| 183 |
+
<div class="grid grid-cols-2 gap-3 mt-4 pt-4 border-t border-white/5">
|
| 184 |
+
<div class="text-center">
|
| 185 |
+
<p class="text-[9px] text-text-secondary uppercase tracking-widest font-bold">Speed</p>
|
| 186 |
+
<p class="text-xs font-bold text-text">{{ "%.3f"|format(stream.avg_mbps or 0) }} MB/s</p>
|
| 187 |
+
</div>
|
| 188 |
+
<div class="text-center">
|
| 189 |
+
<p class="text-[9px] text-text-secondary uppercase tracking-widest font-bold">Total</p>
|
| 190 |
+
<p class="text-xs font-bold text-text">{{ "%.1f"|format((stream.total_bytes or 0) / 1024 / 1024) }} MB</p>
|
| 191 |
+
</div>
|
| 192 |
+
<div class="text-center">
|
| 193 |
+
<p class="text-[9px] text-text-secondary uppercase tracking-widest font-bold">Duration</p>
|
| 194 |
+
<p class="text-xs font-bold text-text live-duration" data-start-ts="{{ stream.start_ts or 0 }}">0s</p>
|
| 195 |
+
</div>
|
| 196 |
+
<div class="text-center">
|
| 197 |
+
<p class="text-[9px] text-text-secondary uppercase tracking-widest font-bold">Status</p>
|
| 198 |
+
<p class="text-xs font-bold text-text">{{ stream.status or 'active' }}</p>
|
| 199 |
+
</div>
|
| 200 |
+
</div>
|
| 201 |
+
|
| 202 |
+
<div class="mt-4 pt-4 border-t border-white/5 space-y-2">
|
| 203 |
+
<div class="flex items-center justify-between text-xs gap-3">
|
| 204 |
+
<span class="text-text-secondary">Started</span>
|
| 205 |
+
<span class="text-text text-right truncate max-w-[65%] live-started" data-start-ts="{{ stream.start_ts or 0 }}">—</span>
|
| 206 |
+
</div>
|
| 207 |
+
<div class="flex items-center justify-between text-xs gap-3">
|
| 208 |
+
<span class="text-text-secondary">Stream ID</span>
|
| 209 |
+
<span class="font-mono text-text text-right truncate max-w-[65%]">{{ stream.stream_id or 'Unknown' }}</span>
|
| 210 |
+
</div>
|
| 211 |
+
</div>
|
| 212 |
+
</div>
|
| 213 |
+
{% endfor %}
|
| 214 |
+
{% else %}
|
| 215 |
+
<div class="glass-panel p-8 rounded-[2rem] text-center border-dashed border-white/10">
|
| 216 |
+
<i class="fa-solid fa-satellite-dish text-4xl text-white/10 mb-3"></i>
|
| 217 |
+
<p class="text-sm text-text-secondary font-medium">No active streams right now</p>
|
| 218 |
+
<p class="text-xs text-text-secondary mt-1">The live network is idle at the moment.</p>
|
| 219 |
+
</div>
|
| 220 |
+
{% endif %}
|
| 221 |
</div>
|
| 222 |
</div>
|
| 223 |
+
</div>
|
| 224 |
</div>
|
| 225 |
</div>
|
| 226 |
+
</div>
|
| 227 |
+
|
| 228 |
+
<section class="mt-12">
|
| 229 |
+
<div class="glass-panel rounded-[2.5rem] overflow-hidden">
|
| 230 |
+
<div class="p-8 border-b border-white/5 flex flex-col md:flex-row justify-between items-center gap-4">
|
| 231 |
+
<div>
|
| 232 |
+
<h3 class="text-xl font-bold text-text">Access Management</h3>
|
| 233 |
+
<p class="text-sm text-text-secondary">Control API tokens, daily quotas, and monthly quotas</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
</div>
|
| 235 |
+
<button onclick="toggleCreateForm()" id="create-btn-container"
|
| 236 |
+
class="px-6 py-3 bg-primary text-background font-bold rounded-2xl hover:brightness-110 transition-all flex items-center gap-2">
|
| 237 |
+
<i class="fa-solid fa-plus"></i> New Token
|
| 238 |
+
</button>
|
| 239 |
</div>
|
| 240 |
|
| 241 |
+
<div id="create-form-container" class="hidden p-8 bg-white/5 border-b border-white/5 animate-in fade-in slide-in-from-top-4">
|
| 242 |
+
<form onsubmit="createToken(event)" class="grid grid-cols-1 md:grid-cols-5 gap-4 items-end">
|
| 243 |
+
<div class="md:col-span-2">
|
| 244 |
+
<label class="text-[10px] font-bold uppercase text-text-secondary tracking-widest ml-2 mb-1 block">Token Alias</label>
|
| 245 |
+
<input type="text" id="token-name" placeholder="E.g., Living Room TV" required
|
| 246 |
+
class="w-full px-4 py-3 rounded-xl border border-white/10 focus:border-primary outline-none text-sm text-text placeholder:text-text-secondary bg-[color-mix(in_srgb,var(--card)_88%,var(--background)_12%)]">
|
| 247 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
|
| 249 |
+
<div>
|
| 250 |
+
<label class="text-[10px] font-bold uppercase text-text-secondary tracking-widest ml-2 mb-1 block">Daily (GB)</label>
|
| 251 |
+
<input type="number" id="daily-limit" value="0" step="0.1" min="0"
|
| 252 |
+
class="w-full px-4 py-3 rounded-xl border border-white/10 focus:border-primary outline-none text-sm text-text placeholder:text-text-secondary bg-[color-mix(in_srgb,var(--card)_88%,var(--background)_12%)]">
|
| 253 |
+
</div>
|
|
|
|
|
|
|
|
|
|
| 254 |
|
| 255 |
+
<div>
|
| 256 |
+
<label class="text-[10px] font-bold uppercase text-text-secondary tracking-widest ml-2 mb-1 block">Monthly (GB)</label>
|
| 257 |
+
<input type="number" id="monthly-limit" value="0" step="0.1" min="0"
|
| 258 |
+
class="w-full px-4 py-3 rounded-xl border border-white/10 focus:border-primary outline-none text-sm text-text placeholder:text-text-secondary bg-[color-mix(in_srgb,var(--card)_88%,var(--background)_12%)]">
|
| 259 |
+
</div>
|
|
|
|
|
|
|
|
|
|
| 260 |
|
| 261 |
+
<div class="flex gap-2">
|
| 262 |
+
<button type="submit" class="flex-1 py-3 bg-primary text-background font-bold rounded-xl text-sm">Create</button>
|
| 263 |
+
<button type="button" onclick="toggleCreateForm()" class="px-4 py-3 bg-white/5 text-text-secondary rounded-xl hover:bg-white/10 transition-colors">
|
| 264 |
+
<i class="fa-solid fa-xmark"></i>
|
| 265 |
+
</button>
|
| 266 |
+
</div>
|
| 267 |
+
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
</div>
|
| 269 |
|
|
|
|
| 270 |
<div class="overflow-x-auto">
|
| 271 |
+
<table class="w-full text-left">
|
| 272 |
<thead>
|
| 273 |
+
<tr class="bg-white/5 text-[10px] uppercase tracking-[0.2em] font-bold text-text-secondary">
|
| 274 |
+
<th class="py-5 px-8">Client Name</th>
|
| 275 |
+
<th class="py-5 px-8">Usage</th>
|
| 276 |
+
<th class="py-5 px-8">Limits</th>
|
| 277 |
+
<th class="py-5 px-8">Manifest Link</th>
|
| 278 |
+
<th class="py-5 px-8 text-right">Actions</th>
|
| 279 |
</tr>
|
| 280 |
</thead>
|
| 281 |
+
<tbody class="divide-y divide-white/5">
|
| 282 |
{% for token in api_tokens %}
|
| 283 |
+
<tr class="group hover:bg-white/[0.02] transition-colors" id="token-row-{{ loop.index0 }}">
|
| 284 |
+
<td class="py-6 px-8">
|
| 285 |
+
<p class="font-bold text-text">{{ token.name }}</p>
|
| 286 |
+
<p class="text-[10px] text-text-secondary uppercase mt-1">
|
| 287 |
+
{{ token.created_at.strftime('%Y-%m-%d') if token.created_at else 'Unknown date' }}
|
| 288 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
</td>
|
| 290 |
+
|
| 291 |
+
<td class="py-6 px-8">
|
| 292 |
+
<div class="flex flex-col gap-1">
|
| 293 |
+
<span class="text-xs text-text font-medium">
|
| 294 |
+
Daily: <span class="text-primary" data-bytes="{{ token.usage.daily.bytes|default(0) }}"></span>
|
| 295 |
+
</span>
|
| 296 |
+
<span class="text-xs text-text font-medium">
|
| 297 |
+
Monthly: <span class="text-accent" data-bytes="{{ token.usage.monthly.bytes|default(0) }}"></span>
|
| 298 |
+
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
</div>
|
| 300 |
</td>
|
| 301 |
+
|
| 302 |
+
<td class="py-6 px-8">
|
| 303 |
+
<div class="flex flex-col gap-1">
|
| 304 |
+
<span class="text-[10px] text-text-secondary uppercase">
|
| 305 |
+
Daily Limit: {{ token.limits.daily_limit_gb or '∞' }} GB
|
| 306 |
+
</span>
|
| 307 |
+
<span class="text-[10px] text-text-secondary uppercase">
|
| 308 |
+
Monthly Limit: {{ token.limits.monthly_limit_gb or '∞' }} GB
|
| 309 |
+
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 310 |
</div>
|
| 311 |
</td>
|
| 312 |
+
|
| 313 |
+
<td class="py-6 px-8">
|
| 314 |
+
<button onclick='copyUrl({{ ((request.base_url|string).replace("http:", "https:") ~ "stremio/" ~ token.token ~ "/manifest.json")|tojson }})'
|
| 315 |
+
class="flex items-center gap-2 px-3 py-1.5 bg-background/50 rounded-lg border border-white/5 text-[10px] font-bold text-text-secondary hover:text-primary hover:border-primary/30 transition-all">
|
| 316 |
+
<i class="fa-solid fa-link text-[8px]"></i> COPY MANIFEST
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
</button>
|
| 318 |
</td>
|
| 319 |
+
|
| 320 |
+
<td class="py-6 px-8 text-right">
|
| 321 |
+
<div class="flex justify-end gap-2">
|
| 322 |
+
<button onclick='openEditModal({{ token.token|tojson }}, {{ token.limits.daily_limit_gb|default(0)|tojson }}, {{ token.limits.monthly_limit_gb|default(0)|tojson }})'
|
| 323 |
+
class="w-8 h-8 rounded-lg bg-white/5 flex items-center justify-center text-text-secondary hover:bg-blue-500 hover:text-white transition-all token-action-btn">
|
| 324 |
+
<i class="fa-solid fa-pen-to-square text-xs"></i>
|
| 325 |
+
</button>
|
| 326 |
+
<button onclick='revokeToken({{ token.token|tojson }})'
|
| 327 |
+
class="w-8 h-8 rounded-lg bg-white/5 flex items-center justify-center text-text-secondary hover:bg-red-500 hover:text-white transition-all token-action-btn">
|
| 328 |
+
<i class="fa-solid fa-trash text-xs"></i>
|
| 329 |
+
</button>
|
| 330 |
+
</div>
|
| 331 |
+
</td>
|
| 332 |
</tr>
|
| 333 |
+
{% endfor %}
|
| 334 |
+
|
| 335 |
+
{% if not api_tokens %}
|
| 336 |
<tr>
|
| 337 |
+
<td colspan="5" class="py-10 px-8 text-center text-text-secondary">
|
| 338 |
+
No tokens found.
|
| 339 |
+
</td>
|
| 340 |
</tr>
|
| 341 |
+
{% endif %}
|
| 342 |
</tbody>
|
| 343 |
</table>
|
| 344 |
</div>
|
| 345 |
</div>
|
| 346 |
+
</section>
|
| 347 |
+
</div>
|
| 348 |
|
| 349 |
+
<div id="edit-modal" class="fixed inset-0 bg-background/80 backdrop-blur-md hidden flex items-center justify-center z-50 p-4">
|
| 350 |
+
<div class="glass-panel rounded-[2rem] p-8 w-full max-w-md border border-white/10 shadow-2xl">
|
| 351 |
+
<h3 class="text-xl font-bold mb-2">Edit Limits</h3>
|
| 352 |
+
<p class="text-sm text-text-secondary mb-6">Modify daily and monthly data quotas for this token.</p>
|
| 353 |
+
|
| 354 |
+
<input type="hidden" id="edit-token-id">
|
| 355 |
+
<div class="space-y-4">
|
| 356 |
+
<div>
|
| 357 |
+
<label class="text-[10px] font-bold uppercase text-text-secondary tracking-widest ml-1 mb-1 block">Daily Limit (GB)</label>
|
| 358 |
+
<input type="number" id="edit-daily" step="0.1" min="0"
|
| 359 |
+
class="w-full px-4 py-3 rounded-xl border border-white/10 focus:border-primary outline-none text-text placeholder:text-text-secondary bg-[color-mix(in_srgb,var(--card)_88%,var(--background)_12%)]">
|
| 360 |
+
</div>
|
| 361 |
+
<div>
|
| 362 |
+
<label class="text-[10px] font-bold uppercase text-text-secondary tracking-widest ml-1 mb-1 block">Monthly Limit (GB)</label>
|
| 363 |
+
<input type="number" id="edit-monthly" step="0.1" min="0"
|
| 364 |
+
class="w-full px-4 py-3 rounded-xl border border-white/10 focus:border-primary outline-none text-text placeholder:text-text-secondary bg-[color-mix(in_srgb,var(--card)_88%,var(--background)_12%)]">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
</div>
|
| 366 |
</div>
|
| 367 |
|
| 368 |
+
<div class="mt-8 flex gap-3">
|
| 369 |
+
<button onclick="closeEditModal()" class="flex-1 py-3 bg-white/5 hover:bg-white/10 text-text rounded-xl font-bold transition-all">Cancel</button>
|
| 370 |
+
<button onclick="saveTokenLimits()" class="flex-1 py-3 bg-primary text-background rounded-xl font-bold transition-all">Save Changes</button>
|
| 371 |
+
</div>
|
| 372 |
+
</div>
|
| 373 |
</div>
|
| 374 |
|
| 375 |
+
|
| 376 |
+
<style>
|
| 377 |
+
.shadow-glow {
|
| 378 |
+
filter: drop-shadow(0 0 8px rgba(var(--primary-rgb), 0.4));
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
.stream-card {
|
| 382 |
+
background: color-mix(in srgb, var(--card) 55%, transparent);
|
| 383 |
+
border: 1px solid var(--border);
|
| 384 |
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
.stream-badge-live {
|
| 388 |
+
background: color-mix(in srgb, var(--primary) 18%, transparent);
|
| 389 |
+
color: var(--primary);
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
.stream-badge-recent {
|
| 393 |
+
background: color-mix(in srgb, var(--accent) 16%, transparent);
|
| 394 |
+
color: var(--accent);
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
input[type="text"],
|
| 398 |
+
input[type="number"],
|
| 399 |
+
input[type="email"],
|
| 400 |
+
input[type="password"],
|
| 401 |
+
input[type="search"],
|
| 402 |
+
input[type="url"],
|
| 403 |
+
textarea,
|
| 404 |
+
select {
|
| 405 |
+
color: var(--text) !important;
|
| 406 |
+
border-color: var(--border) !important;
|
| 407 |
+
caret-color: var(--primary);
|
| 408 |
+
background: color-mix(in srgb, var(--card) 88%, var(--background) 12%);
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
input[type="text"]::placeholder,
|
| 412 |
+
input[type="number"]::placeholder,
|
| 413 |
+
input[type="email"]::placeholder,
|
| 414 |
+
input[type="password"]::placeholder,
|
| 415 |
+
input[type="search"]::placeholder,
|
| 416 |
+
input[type="url"]::placeholder,
|
| 417 |
+
textarea::placeholder {
|
| 418 |
+
color: var(--text-secondary);
|
| 419 |
+
opacity: 0.95;
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
input:focus,
|
| 423 |
+
textarea:focus,
|
| 424 |
+
select:focus {
|
| 425 |
+
outline: none;
|
| 426 |
+
border-color: var(--primary) !important;
|
| 427 |
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
input:-webkit-autofill,
|
| 431 |
+
input:-webkit-autofill:hover,
|
| 432 |
+
input:-webkit-autofill:focus {
|
| 433 |
+
-webkit-text-fill-color: var(--text) !important;
|
| 434 |
+
box-shadow: 0 0 0px 1000px color-mix(in srgb, var(--card) 88%, var(--background) 12%) inset !important;
|
| 435 |
+
transition: background-color 9999s ease-in-out 0s;
|
| 436 |
+
}
|
| 437 |
+
|
| 438 |
+
|
| 439 |
+
</style>
|
| 440 |
+
|
| 441 |
<script>
|
| 442 |
+
const streamState = {
|
| 443 |
+
currentEditToken: null,
|
| 444 |
+
activeStreams: []
|
| 445 |
+
};
|
| 446 |
+
|
| 447 |
function toggleCreateForm() {
|
| 448 |
const formContainer = document.getElementById('create-form-container');
|
| 449 |
const btnContainer = document.getElementById('create-btn-container');
|
| 450 |
+
if (!formContainer || !btnContainer) return;
|
| 451 |
|
| 452 |
if (formContainer.classList.contains('hidden')) {
|
| 453 |
formContainer.classList.remove('hidden');
|
|
|
|
| 458 |
}
|
| 459 |
}
|
| 460 |
|
|
|
|
|
|
|
| 461 |
function openEditModal(token, daily, monthly) {
|
| 462 |
+
const tokenStr = String(token || '');
|
| 463 |
+
streamState.currentEditToken = tokenStr;
|
| 464 |
+
document.getElementById('edit-token-id').value = tokenStr;
|
| 465 |
+
document.getElementById('edit-daily').value = (daily === null || daily === undefined) ? 0 : daily;
|
| 466 |
+
document.getElementById('edit-monthly').value = (monthly === null || monthly === undefined) ? 0 : monthly;
|
| 467 |
+
const modal = document.getElementById('edit-modal');
|
| 468 |
+
modal.classList.remove('hidden');
|
| 469 |
}
|
| 470 |
|
| 471 |
function closeEditModal() {
|
| 472 |
document.getElementById('edit-modal').classList.add('hidden');
|
| 473 |
+
streamState.currentEditToken = null;
|
| 474 |
}
|
| 475 |
|
| 476 |
async function saveTokenLimits() {
|
| 477 |
+
if (!streamState.currentEditToken) return;
|
| 478 |
|
| 479 |
+
const daily = Number(document.getElementById('edit-daily').value || 0);
|
| 480 |
+
const monthly = Number(document.getElementById('edit-monthly').value || 0);
|
| 481 |
|
| 482 |
try {
|
| 483 |
+
const response = await fetch('/api/tokens/' + encodeURIComponent(streamState.currentEditToken), {
|
| 484 |
method: 'PUT',
|
| 485 |
headers: { 'Content-Type': 'application/json' },
|
| 486 |
body: JSON.stringify({
|
|
|
|
| 491 |
|
| 492 |
if (response.ok) {
|
| 493 |
closeEditModal();
|
| 494 |
+
showToast('Token limits updated successfully.', 'success', 'Updated');
|
| 495 |
+
setTimeout(() => window.location.reload(), 500);
|
| 496 |
+
return;
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
let message = 'Failed to update limits';
|
| 500 |
+
try {
|
| 501 |
+
const data = await response.json();
|
| 502 |
+
message = data.detail || data.message || message;
|
| 503 |
+
} catch (_) {}
|
| 504 |
+
showToast(message, 'error', 'Update failed');
|
| 505 |
+
} catch (error) {
|
| 506 |
+
console.error(error);
|
| 507 |
+
showToast('Error updating limits', 'error', 'Update failed');
|
| 508 |
+
}
|
| 509 |
+
}
|
| 510 |
+
|
| 511 |
+
async function createToken(event) {
|
| 512 |
+
event.preventDefault();
|
| 513 |
+
|
| 514 |
+
const nameInput = document.getElementById('token-name');
|
| 515 |
+
const dailyInput = document.getElementById('daily-limit');
|
| 516 |
+
const monthlyInput = document.getElementById('monthly-limit');
|
| 517 |
+
|
| 518 |
+
const payload = {
|
| 519 |
+
name: nameInput.value.trim(),
|
| 520 |
+
daily_limit_gb: Number(dailyInput.value || 0),
|
| 521 |
+
monthly_limit_gb: Number(monthlyInput.value || 0)
|
| 522 |
+
};
|
| 523 |
+
|
| 524 |
+
if (!payload.name) {
|
| 525 |
+
showToast('Token alias is required.', 'error', 'Validation');
|
| 526 |
+
return;
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
try {
|
| 530 |
+
const response = await fetch('/api/tokens', {
|
| 531 |
+
method: 'POST',
|
| 532 |
+
headers: { 'Content-Type': 'application/json' },
|
| 533 |
+
body: JSON.stringify(payload)
|
| 534 |
+
});
|
| 535 |
+
|
| 536 |
+
if (response.ok) {
|
| 537 |
+
showToast('Token created successfully.', 'success', 'Created');
|
| 538 |
+
setTimeout(() => window.location.reload(), 500);
|
| 539 |
+
return;
|
| 540 |
+
}
|
| 541 |
+
|
| 542 |
+
let message = 'Error creating token';
|
| 543 |
+
try {
|
| 544 |
+
const data = await response.json();
|
| 545 |
+
message = data.detail || data.message || message;
|
| 546 |
+
} catch (_) {}
|
| 547 |
+
showToast(message, 'error', 'Create failed');
|
| 548 |
+
} catch (error) {
|
| 549 |
+
console.error(error);
|
| 550 |
+
showToast('Error creating token', 'error', 'Create failed');
|
| 551 |
+
}
|
| 552 |
+
}
|
| 553 |
+
|
| 554 |
+
async function revokeToken(token) {
|
| 555 |
+
if (!confirm('Are you sure you want to revoke this token? The user will lose access immediately.')) return;
|
| 556 |
+
|
| 557 |
+
try {
|
| 558 |
+
const response = await fetch('/api/tokens/' + encodeURIComponent(String(token || '')), {
|
| 559 |
+
method: 'DELETE'
|
| 560 |
+
});
|
| 561 |
+
|
| 562 |
+
if (response.ok) {
|
| 563 |
+
showToast('Token deleted successfully.', 'success', 'Deleted');
|
| 564 |
+
setTimeout(() => window.location.reload(), 500);
|
| 565 |
+
return;
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
let message = 'Error deleting token';
|
| 569 |
+
try {
|
| 570 |
+
const data = await response.json();
|
| 571 |
+
message = data.detail || data.message || message;
|
| 572 |
+
} catch (_) {}
|
| 573 |
+
showToast(message, 'error', 'Delete failed');
|
| 574 |
+
} catch (error) {
|
| 575 |
+
console.error(error);
|
| 576 |
+
showToast('Error deleting token', 'error', 'Delete failed');
|
| 577 |
+
}
|
| 578 |
+
}
|
| 579 |
+
|
| 580 |
+
async function copyUrl(url) {
|
| 581 |
+
const text = String(url || '');
|
| 582 |
+
try {
|
| 583 |
+
if (navigator.clipboard && window.isSecureContext) {
|
| 584 |
+
await navigator.clipboard.writeText(text);
|
| 585 |
} else {
|
| 586 |
+
const temp = document.createElement('textarea');
|
| 587 |
+
temp.value = text;
|
| 588 |
+
temp.setAttribute('readonly', '');
|
| 589 |
+
temp.style.position = 'fixed';
|
| 590 |
+
temp.style.left = '-9999px';
|
| 591 |
+
temp.style.top = '0';
|
| 592 |
+
document.body.appendChild(temp);
|
| 593 |
+
temp.focus();
|
| 594 |
+
temp.select();
|
| 595 |
+
const ok = document.execCommand('copy');
|
| 596 |
+
document.body.removeChild(temp);
|
| 597 |
+
if (!ok) throw new Error('copy failed');
|
| 598 |
}
|
| 599 |
+
showToast('Manifest URL copied to clipboard.', 'success', 'Copied');
|
| 600 |
} catch (error) {
|
| 601 |
console.error(error);
|
| 602 |
+
showToast('Failed to copy manifest URL.', 'error', 'Copy failed');
|
| 603 |
}
|
| 604 |
}
|
|
|
|
| 605 |
|
| 606 |
+
function escapeHtml(unsafe) {
|
| 607 |
+
if (unsafe === null || unsafe === undefined) return '';
|
| 608 |
+
return String(unsafe)
|
| 609 |
+
.replace(/&/g, '&')
|
| 610 |
+
.replace(/</g, '<')
|
| 611 |
+
.replace(/>/g, '>')
|
| 612 |
+
.replace(/"/g, '"')
|
| 613 |
+
.replace(/'/g, ''');
|
| 614 |
+
}
|
| 615 |
+
|
| 616 |
+
function formatBytes(bytes) {
|
| 617 |
+
const value = Number(bytes || 0);
|
| 618 |
+
if (!value) return '0 B';
|
| 619 |
+
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
| 620 |
+
const index = Math.min(Math.floor(Math.log(value) / Math.log(1024)), units.length - 1);
|
| 621 |
+
return (value / Math.pow(1024, index)).toFixed(index === 0 ? 0 : 2) + ' ' + units[index];
|
| 622 |
+
}
|
| 623 |
+
|
| 624 |
+
function formatDuration(seconds) {
|
| 625 |
+
const value = Math.max(0, Number(seconds || 0));
|
| 626 |
+
const total = Math.floor(value);
|
| 627 |
+
|
| 628 |
+
const h = Math.floor(total / 3600);
|
| 629 |
+
const m = Math.floor((total % 3600) / 60);
|
| 630 |
+
const s = total % 60;
|
| 631 |
+
|
| 632 |
+
if (h > 0) {
|
| 633 |
+
return `${h}h ${m}m ${s}s`;
|
| 634 |
+
}
|
| 635 |
+
if (m > 0) {
|
| 636 |
+
return `${m}m ${s}s`;
|
| 637 |
+
}
|
| 638 |
+
return `${s}s`;
|
| 639 |
+
}
|
| 640 |
+
|
| 641 |
+
function formatTimestamp(ts) {
|
| 642 |
+
const value = Number(ts || 0);
|
| 643 |
+
if (!value) return '—';
|
| 644 |
+
const date = new Date(value * 1000);
|
| 645 |
+
if (Number.isNaN(date.getTime())) return '—';
|
| 646 |
+
return date.toLocaleString();
|
| 647 |
+
}
|
| 648 |
+
|
| 649 |
+
function getStreamTitle(stream) {
|
| 650 |
+
return stream?.title || stream?.meta?.title || 'Unknown Stream';
|
| 651 |
+
}
|
| 652 |
+
|
| 653 |
+
function getClientLabel(stream) {
|
| 654 |
+
const parts = [];
|
| 655 |
+
if (stream?.client_index !== null && stream?.client_index !== undefined) {
|
| 656 |
+
parts.push('Bot ' + (Number(stream.client_index) + 1));
|
| 657 |
+
}
|
| 658 |
+
if (stream?.dc_id !== null && stream?.dc_id !== undefined) {
|
| 659 |
+
parts.push('DC ' + stream.dc_id);
|
| 660 |
+
}
|
| 661 |
+
return parts.length ? parts.join(' • ') : 'Unknown node';
|
| 662 |
+
}
|
| 663 |
+
|
| 664 |
+
function getStatusBadge(status) {
|
| 665 |
+
const normalized = String(status || '').toLowerCase();
|
| 666 |
+
|
| 667 |
+
if (normalized === 'active') {
|
| 668 |
+
return { className: 'stream-badge-live', text: 'Live' };
|
| 669 |
+
}
|
| 670 |
+
if (normalized === 'cancelled') {
|
| 671 |
+
return { className: 'bg-yellow-500/15 text-yellow-300', text: 'Cancelled' };
|
| 672 |
+
}
|
| 673 |
+
if (normalized === 'completed' || normalized === 'finished') {
|
| 674 |
+
return { className: 'bg-green-500/15 text-green-300', text: 'Completed' };
|
| 675 |
+
}
|
| 676 |
+
if (normalized === 'failed' || normalized === 'error') {
|
| 677 |
+
return { className: 'bg-red-500/15 text-red-300', text: normalized.charAt(0).toUpperCase() + normalized.slice(1) };
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
return {
|
| 681 |
+
className: 'stream-badge-recent',
|
| 682 |
+
text: normalized ? normalized.charAt(0).toUpperCase() + normalized.slice(1) : 'Live'
|
| 683 |
+
};
|
| 684 |
+
}
|
| 685 |
+
|
| 686 |
+
function getLiveDuration(stream) {
|
| 687 |
+
const startTs = Number(stream?.start_ts || 0);
|
| 688 |
+
if (!startTs) return '0s';
|
| 689 |
+
const now = Date.now() / 1000;
|
| 690 |
+
return formatDuration(now - startTs);
|
| 691 |
+
}
|
| 692 |
+
|
| 693 |
+
function renderStreamCard(stream) {
|
| 694 |
+
const status = getStatusBadge(stream?.status);
|
| 695 |
+
const title = escapeHtml(getStreamTitle(stream));
|
| 696 |
+
const streamId = escapeHtml(stream?.stream_id ? String(stream.stream_id).slice(0, 12) + '…' : 'Unknown');
|
| 697 |
+
const label = escapeHtml(getClientLabel(stream));
|
| 698 |
+
const totalBytes = formatBytes(stream?.total_bytes || 0);
|
| 699 |
+
const avgSpeed = stream?.avg_mbps !== null && stream?.avg_mbps !== undefined
|
| 700 |
+
? Number(stream.avg_mbps).toFixed(3) + ' MB/s'
|
| 701 |
+
: '—';
|
| 702 |
+
const started = formatTimestamp(stream?.start_ts);
|
| 703 |
+
const liveDuration = getLiveDuration(stream);
|
| 704 |
+
|
| 705 |
+
return `
|
| 706 |
+
<div class="stream-card rounded-[2rem] p-5">
|
| 707 |
+
<div class="flex justify-between items-start gap-3">
|
| 708 |
+
<div class="min-w-0 pr-2">
|
| 709 |
+
<h5 class="font-bold text-sm text-text truncate">${title}</h5>
|
| 710 |
+
<div class="mt-1 flex flex-wrap items-center gap-2 text-[10px] uppercase tracking-widest text-text-secondary">
|
| 711 |
+
<span>${label}</span>
|
| 712 |
+
<span>•</span>
|
| 713 |
+
<span>${streamId}</span>
|
| 714 |
+
</div>
|
| 715 |
+
</div>
|
| 716 |
+
<span class="text-[10px] font-bold px-2 py-1 rounded-lg uppercase whitespace-nowrap ${status.className}">
|
| 717 |
+
${escapeHtml(status.text)}
|
| 718 |
+
</span>
|
| 719 |
+
</div>
|
| 720 |
+
|
| 721 |
+
<div class="grid grid-cols-2 gap-3 mt-4 pt-4 border-t border-white/5">
|
| 722 |
+
<div class="text-center">
|
| 723 |
+
<p class="text-[9px] text-text-secondary uppercase tracking-widest font-bold">Speed</p>
|
| 724 |
+
<p class="text-xs font-bold text-text">${avgSpeed}</p>
|
| 725 |
+
</div>
|
| 726 |
+
<div class="text-center">
|
| 727 |
+
<p class="text-[9px] text-text-secondary uppercase tracking-widest font-bold">Total</p>
|
| 728 |
+
<p class="text-xs font-bold text-text">${escapeHtml(totalBytes)}</p>
|
| 729 |
+
</div>
|
| 730 |
+
<div class="text-center">
|
| 731 |
+
<p class="text-[9px] text-text-secondary uppercase tracking-widest font-bold">Duration</p>
|
| 732 |
+
<p class="text-xs font-bold text-text live-duration">${escapeHtml(liveDuration)}</p>
|
| 733 |
+
</div>
|
| 734 |
+
<div class="text-center">
|
| 735 |
+
<p class="text-[9px] text-text-secondary uppercase tracking-widest font-bold">Started</p>
|
| 736 |
+
<p class="text-xs font-bold text-text truncate live-started">${escapeHtml(started)}</p>
|
| 737 |
+
</div>
|
| 738 |
+
</div>
|
| 739 |
+
|
| 740 |
+
<div class="mt-4 pt-4 border-t border-white/5 space-y-2">
|
| 741 |
+
<div class="flex items-center justify-between text-xs gap-3">
|
| 742 |
+
<span class="text-text-secondary">Stream ID</span>
|
| 743 |
+
<span class="font-mono text-text text-right truncate max-w-[65%]">${streamId}</span>
|
| 744 |
+
</div>
|
| 745 |
+
<div class="flex items-center justify-between text-xs gap-3">
|
| 746 |
+
<span class="text-text-secondary">Status</span>
|
| 747 |
+
<span class="text-text text-right truncate max-w-[65%]">${escapeHtml(stream?.status || 'active')}</span>
|
| 748 |
+
</div>
|
| 749 |
+
</div>
|
| 750 |
+
</div>
|
| 751 |
+
`;
|
| 752 |
+
}
|
| 753 |
+
|
| 754 |
+
function renderEmptyState(icon, title, subtitle) {
|
| 755 |
+
return `
|
| 756 |
+
<div class="glass-panel p-8 rounded-[2rem] text-center border-dashed border-white/10">
|
| 757 |
+
<i class="${icon} text-4xl text-white/10 mb-3"></i>
|
| 758 |
+
<p class="text-sm text-text-secondary font-medium">${escapeHtml(title)}</p>
|
| 759 |
+
<p class="text-xs text-text-secondary mt-1">${escapeHtml(subtitle)}</p>
|
| 760 |
+
</div>
|
| 761 |
+
`;
|
| 762 |
+
}
|
| 763 |
+
|
| 764 |
+
async function loadStreamStats() {
|
| 765 |
+
const activeContainer = document.getElementById('active-streams-container');
|
| 766 |
+
const liveCount = document.getElementById('live-stream-count');
|
| 767 |
+
const liveNowCount = document.getElementById('live-now-count');
|
| 768 |
+
const recentCount = document.getElementById('recent-stream-count');
|
| 769 |
+
|
| 770 |
+
try {
|
| 771 |
+
const response = await fetch('/stream/stats', { cache: 'no-store' });
|
| 772 |
+
if (!response.ok) throw new Error('Failed to load stream stats');
|
| 773 |
+
|
| 774 |
+
const data = await response.json();
|
| 775 |
+
const activeStreams = Array.isArray(data.active_streams) ? data.active_streams : [];
|
| 776 |
+
const recentStreams = Array.isArray(data.recent_streams) ? data.recent_streams : [];
|
| 777 |
+
|
| 778 |
+
streamState.activeStreams = activeStreams;
|
| 779 |
+
|
| 780 |
+
if (liveCount) liveCount.textContent = activeStreams.length + ' Active';
|
| 781 |
+
if (liveNowCount) liveNowCount.textContent = String(activeStreams.length);
|
| 782 |
+
if (recentCount) recentCount.textContent = String(recentStreams.length);
|
| 783 |
+
|
| 784 |
+
if (activeContainer) {
|
| 785 |
+
activeContainer.innerHTML = activeStreams.length
|
| 786 |
+
? activeStreams.map(stream => renderStreamCard(stream)).join('')
|
| 787 |
+
: renderEmptyState(
|
| 788 |
+
'fa-solid fa-satellite-dish',
|
| 789 |
+
'No active streams right now',
|
| 790 |
+
'The live network is idle at the moment.'
|
| 791 |
+
);
|
| 792 |
+
}
|
| 793 |
+
} catch (error) {
|
| 794 |
+
console.error(error);
|
| 795 |
+
if (activeContainer) {
|
| 796 |
+
activeContainer.innerHTML = renderEmptyState(
|
| 797 |
+
'fa-solid fa-triangle-exclamation',
|
| 798 |
+
'Unable to load live network',
|
| 799 |
+
'Please try refreshing the page.'
|
| 800 |
+
);
|
| 801 |
+
}
|
| 802 |
+
}
|
| 803 |
+
}
|
| 804 |
+
|
| 805 |
+
function refreshLiveDurations() {
|
| 806 |
+
const cards = document.querySelectorAll('#active-streams-container .stream-card');
|
| 807 |
+
cards.forEach((card, index) => {
|
| 808 |
+
const durationEl = card.querySelector('.live-duration');
|
| 809 |
+
const stream = streamState.activeStreams[index];
|
| 810 |
+
if (durationEl && stream) {
|
| 811 |
+
durationEl.textContent = getLiveDuration(stream);
|
| 812 |
+
}
|
| 813 |
+
});
|
| 814 |
+
}
|
| 815 |
+
|
| 816 |
+
async function refreshDashboard() {
|
| 817 |
const icon = document.getElementById('refresh-icon');
|
| 818 |
+
if (icon) icon.classList.add('animate-spin');
|
| 819 |
|
| 820 |
try {
|
| 821 |
+
const response = await fetch('/api/system/stats', { cache: 'no-store' });
|
| 822 |
if (response.ok) {
|
| 823 |
const stats = await response.json();
|
| 824 |
|
|
|
|
| 825 |
const elUptime = document.getElementById('sys-uptime');
|
| 826 |
+
if (elUptime) elUptime.innerText = stats.uptime || 'N/A';
|
|
|
|
|
|
|
|
|
|
| 827 |
|
| 828 |
const elBotCount = document.getElementById('sys-bots-count');
|
| 829 |
+
if (elBotCount) elBotCount.innerText = (stats.connected_bots ?? 0) + ' Nodes';
|
| 830 |
+
|
| 831 |
+
const elLive = document.getElementById('sys-live-streams');
|
| 832 |
+
if (elLive) elLive.innerText = (stats.total_active_streams ?? 0) + ' Active';
|
| 833 |
|
| 834 |
const elVersion = document.getElementById('sys-version');
|
| 835 |
+
if (elVersion) elVersion.innerText = 'v' + (stats.version || '1.0.0');
|
| 836 |
|
|
|
|
| 837 |
if (stats.databases && Array.isArray(stats.databases)) {
|
| 838 |
stats.databases.forEach((db, index) => {
|
| 839 |
const elMovies = document.getElementById(`db-movies-${index}`);
|
|
|
|
| 850 |
});
|
| 851 |
}
|
| 852 |
|
|
|
|
| 853 |
if (stats.api_tokens && Array.isArray(stats.api_tokens)) {
|
| 854 |
+
const rows = document.querySelectorAll('tbody tr');
|
| 855 |
stats.api_tokens.forEach((token, index) => {
|
| 856 |
+
if (rows.length > index && !rows[index].querySelector('[colspan]')) {
|
| 857 |
+
const row = rows[index];
|
| 858 |
|
| 859 |
+
const dailyUsageSpan = row.querySelector('td:nth-child(2) span[data-bytes]');
|
| 860 |
+
const monthlyUsageSpan = row.querySelectorAll('td:nth-child(2) span[data-bytes]')[1];
|
|
|
|
| 861 |
|
|
|
|
|
|
|
| 862 |
if (dailyUsageSpan && token.usage && token.usage.daily) {
|
| 863 |
const dailyBytes = token.usage.daily.bytes || 0;
|
| 864 |
dailyUsageSpan.setAttribute('data-bytes', dailyBytes);
|
| 865 |
dailyUsageSpan.textContent = formatBytes(dailyBytes);
|
| 866 |
}
|
| 867 |
|
|
|
|
|
|
|
| 868 |
if (monthlyUsageSpan && token.usage && token.usage.monthly) {
|
| 869 |
const monthlyBytes = token.usage.monthly.bytes || 0;
|
| 870 |
monthlyUsageSpan.setAttribute('data-bytes', monthlyBytes);
|
|
|
|
| 873 |
}
|
| 874 |
});
|
| 875 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 876 |
}
|
| 877 |
+
|
| 878 |
+
await loadStreamStats();
|
| 879 |
} catch (error) {
|
| 880 |
+
console.error('Failed to refresh dashboard:', error);
|
| 881 |
+
showToast('Dashboard refresh failed.', 'error', 'Refresh failed');
|
| 882 |
} finally {
|
|
|
|
| 883 |
setTimeout(() => {
|
| 884 |
if (icon) icon.classList.remove('animate-spin');
|
| 885 |
+
}, 450);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 886 |
}
|
| 887 |
}
|
| 888 |
|
| 889 |
+
function formatInitialBytes() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 890 |
document.querySelectorAll('[data-bytes]').forEach(el => {
|
| 891 |
+
const raw = el.getAttribute('data-bytes');
|
| 892 |
+
el.textContent = formatBytes(raw);
|
| 893 |
});
|
| 894 |
+
}
|
| 895 |
|
| 896 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 897 |
+
formatInitialBytes();
|
| 898 |
+
loadStreamStats();
|
| 899 |
+
setInterval(loadStreamStats, 30000);
|
| 900 |
+
setInterval(refreshLiveDurations, 1000);
|
|
|
|
|
|
|
| 901 |
});
|
| 902 |
</script>
|
| 903 |
{% endblock %}
|
Backend/fastapi/templates/login.html
CHANGED
|
@@ -3,72 +3,105 @@
|
|
| 3 |
{% block title %}Login - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
-
<div class="flex items-center justify-center
|
| 7 |
-
|
| 8 |
-
<div class="max-w-md
|
| 9 |
-
|
| 10 |
-
<div class="
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
</div>
|
| 16 |
-
<h2 class="text-3xl md:text-4xl font-extrabold text-transparent bg-clip-text bg-gradient-to-r from-blue-400 to-purple-500 tracking-tight">Admin Login</h2>
|
| 17 |
-
<p class="mt-2 text-gray-400 font-medium">Sign in to access the admin dashboard</p>
|
| 18 |
-
</div>
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
<
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
-
<div class="absolute -top-20 -right-20 w-40 h-40 bg-purple-500/20 rounded-full blur-[60px] pointer-events-none"></div>
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
<
|
|
|
|
|
|
|
| 35 |
</div>
|
| 36 |
-
<input type="text" id="username" name="username" required placeholder="Enter your username"
|
| 37 |
-
class="w-full glass-input rounded-xl pl-11 pr-4 py-3 text-sm placeholder-gray-500 focus:ring-2 focus:ring-purple-500/30 transition-all">
|
| 38 |
</div>
|
| 39 |
-
</div>
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
</div>
|
| 47 |
-
<input type="password" id="password" name="password" required placeholder="Enter your password"
|
| 48 |
-
class="w-full glass-input rounded-xl pl-11 pr-4 py-3 text-sm placeholder-gray-500 focus:ring-2 focus:ring-purple-500/30 transition-all">
|
| 49 |
</div>
|
| 50 |
-
</div>
|
| 51 |
|
| 52 |
-
<div class="pt-2 relative z-10">
|
| 53 |
<button type="submit"
|
| 54 |
-
class="w-full
|
| 55 |
-
<
|
| 56 |
-
|
| 57 |
</button>
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
<div class="text-center relative z-10 mt-8">
|
| 62 |
-
<p class="text-gray-500 text-sm font-medium flex flex-wrap items-center justify-center gap-4">
|
| 63 |
-
<a href="/status" class="text-blue-400 hover:text-blue-300 transition-colors flex items-center gap-1.5 px-2 py-1 rounded-lg hover:bg-white/5">
|
| 64 |
-
<i class="fas fa-server"></i> System Status
|
| 65 |
-
</a>
|
| 66 |
-
<span class="text-white/10 hidden sm:inline">•</span>
|
| 67 |
-
<a href="/stremio" class="text-purple-400 hover:text-purple-300 transition-colors flex items-center gap-1.5 px-2 py-1 rounded-lg hover:bg-white/5">
|
| 68 |
-
<i class="fas fa-book"></i> Stremio Guide
|
| 69 |
-
</a>
|
| 70 |
-
</p>
|
| 71 |
</div>
|
| 72 |
</div>
|
| 73 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
{% endblock %}
|
|
|
|
| 3 |
{% block title %}Login - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
+
<div class="flex-1 flex items-center justify-center py-4 min-h-0">
|
| 7 |
+
|
| 8 |
+
<div class="w-full max-w-md rounded-[2rem] overflow-hidden glass-panel self-center">
|
| 9 |
+
|
| 10 |
+
<div class="p-6 sm:p-10 flex flex-col justify-center bg-card/20">
|
| 11 |
|
| 12 |
+
<div class="flex items-center gap-3 justify-center mb-6">
|
| 13 |
+
<div class="w-10 h-10 rounded-full bg-primary flex items-center justify-center shadow-[0_0_15px_var(--primary)]">
|
| 14 |
+
<i class="fa-solid fa-play text-white text-sm"></i>
|
| 15 |
+
</div>
|
| 16 |
+
<span class="text-2xl font-extrabold tracking-wide text-transparent bg-clip-text bg-gradient-to-r from-primary to-accent">
|
| 17 |
+
TG Stremio
|
| 18 |
+
</span>
|
| 19 |
</div>
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
<div class="text-center mb-6">
|
| 22 |
+
<h2 class="text-lg font-bold tracking-tight text-text">Admin Authentication</h2>
|
| 23 |
+
<p class="text-text-secondary text-xs mt-1">Access your management console</p>
|
| 24 |
+
</div>
|
| 25 |
+
|
| 26 |
+
{% if error %}
|
| 27 |
+
<div class="flex items-center gap-3 bg-red-500/10 border border-red-500/20 text-red-400 px-4 py-2.5 rounded-xl mb-6 animate-pulse">
|
| 28 |
+
<i class="fa-solid fa-circle-exclamation text-xs"></i>
|
| 29 |
+
<p class="text-xs font-medium">{{ error }}</p>
|
| 30 |
+
</div>
|
| 31 |
+
{% endif %}
|
| 32 |
|
| 33 |
+
<form method="post" class="space-y-4">
|
|
|
|
| 34 |
|
| 35 |
+
<div class="space-y-1.5">
|
| 36 |
+
<label class="text-[10px] font-bold uppercase tracking-widest text-text-secondary ml-1">Username</label>
|
| 37 |
+
<div class="relative group">
|
| 38 |
+
<i class="fa-solid fa-user absolute left-4 top-1/2 -translate-y-1/2 text-text-secondary group-focus-within:text-primary transition-colors text-sm"></i>
|
| 39 |
+
<input type="text" name="username" required
|
| 40 |
+
class="w-full pl-11 pr-4 py-3 bg-background/50 rounded-2xl border border-white/5 focus:border-primary/50 focus:ring-4 focus:ring-primary/10 outline-none transition-all text-text text-sm"
|
| 41 |
+
placeholder="Admin ID">
|
| 42 |
</div>
|
|
|
|
|
|
|
| 43 |
</div>
|
|
|
|
| 44 |
|
| 45 |
+
<div class="space-y-1.5">
|
| 46 |
+
<label class="text-[10px] font-bold uppercase tracking-widest text-text-secondary ml-1">Password</label>
|
| 47 |
+
<div class="relative group">
|
| 48 |
+
<i class="fa-solid fa-lock absolute left-4 top-1/2 -translate-y-1/2 text-text-secondary group-focus-within:text-primary transition-colors text-sm"></i>
|
| 49 |
+
|
| 50 |
+
<input type="password" id="password" name="password" required
|
| 51 |
+
class="w-full pl-11 pr-11 py-3 bg-background/50 rounded-2xl border border-white/5 focus:border-primary/50 focus:ring-4 focus:ring-primary/10 outline-none transition-all text-text text-sm"
|
| 52 |
+
placeholder="••••••••">
|
| 53 |
+
|
| 54 |
+
<button type="button" onclick="togglePassword()"
|
| 55 |
+
class="absolute right-4 top-1/2 -translate-y-1/2 text-text-secondary hover:text-primary transition-colors">
|
| 56 |
+
<i id="eyeIcon" class="fa-solid fa-eye text-xs"></i>
|
| 57 |
+
</button>
|
| 58 |
</div>
|
|
|
|
|
|
|
| 59 |
</div>
|
|
|
|
| 60 |
|
|
|
|
| 61 |
<button type="submit"
|
| 62 |
+
class="w-full py-3.5 rounded-2xl bg-primary hover:brightness-110 text-background font-bold transition-all shadow-lg shadow-primary/20 flex items-center justify-center gap-3 mt-4">
|
| 63 |
+
<i class="fa-solid fa-right-to-bracket text-sm"></i>
|
| 64 |
+
Sign In
|
| 65 |
</button>
|
| 66 |
+
|
| 67 |
+
</form>
|
| 68 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
</div>
|
| 70 |
</div>
|
| 71 |
</div>
|
| 72 |
+
|
| 73 |
+
<style>
|
| 74 |
+
/* Strictly disable scrolling on the login screen */
|
| 75 |
+
html, body {
|
| 76 |
+
height: 100%;
|
| 77 |
+
overflow: hidden !important;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
/* Ensure the 'main' block from base.html takes full height */
|
| 81 |
+
main {
|
| 82 |
+
display: flex;
|
| 83 |
+
flex-direction: column;
|
| 84 |
+
height: 100%;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
input::placeholder {
|
| 88 |
+
color: color-mix(in srgb, var(--text-sec) 40%, transparent);
|
| 89 |
+
}
|
| 90 |
+
</style>
|
| 91 |
+
|
| 92 |
+
<script>
|
| 93 |
+
function togglePassword() {
|
| 94 |
+
const input = document.getElementById("password");
|
| 95 |
+
const icon = document.getElementById("eyeIcon");
|
| 96 |
+
|
| 97 |
+
if (input.type === "password") {
|
| 98 |
+
input.type = "text";
|
| 99 |
+
icon.classList.replace("fa-eye", "fa-eye-slash");
|
| 100 |
+
} else {
|
| 101 |
+
input.type = "password";
|
| 102 |
+
icon.classList.replace("fa-eye-slash", "fa-eye");
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
</script>
|
| 106 |
+
|
| 107 |
{% endblock %}
|
Backend/fastapi/templates/media_edit.html
CHANGED
|
@@ -3,347 +3,478 @@
|
|
| 3 |
{% block title %}Edit {{ media_type|title }} - Fyvio Backend{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
-
<
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
<a href="/media/manage?media_type={{ media_type }}"
|
| 11 |
-
|
| 12 |
-
<svg class="w-4 h-4 sm:w-5 sm:h-5
|
| 13 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 14 |
-
|
| 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 |
-
|
| 25 |
-
|
| 26 |
-
|
| 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 |
-
|
|
|
|
|
|
|
| 55 |
{% if media_details.backdrop %}
|
| 56 |
-
<
|
| 57 |
-
|
| 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 |
-
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 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 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 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 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
</div>
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 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="
|
| 125 |
-
<h3 class="text-
|
| 126 |
-
<p class="
|
| 127 |
</div>
|
| 128 |
{% endif %}
|
| 129 |
</div>
|
| 130 |
{% endif %}
|
| 131 |
|
| 132 |
-
<
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
| 135 |
<form onsubmit="updateMedia(event)" id="edit-form">
|
| 136 |
-
<div class="grid grid-cols-1
|
| 137 |
-
<div class="
|
| 138 |
-
<label class="
|
| 139 |
-
<input type="text" id="title" name="title"
|
| 140 |
-
|
| 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="
|
| 146 |
<input type="number" id="release_year" name="release_year"
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
required>
|
| 150 |
</div>
|
|
|
|
| 151 |
<div>
|
| 152 |
-
<label class="
|
| 153 |
<input type="number" step="0.1" min="0" max="10" id="rating" name="rating"
|
| 154 |
-
|
| 155 |
-
|
| 156 |
</div>
|
| 157 |
-
|
| 158 |
-
|
|
|
|
| 159 |
<input type="url" id="logo" name="logo" value="{{ media_details.logo if media_details else '' }}"
|
| 160 |
-
|
| 161 |
</div>
|
| 162 |
|
| 163 |
-
<div class="
|
| 164 |
-
<label class="
|
| 165 |
-
<input type="url" id="poster" name="poster"
|
| 166 |
-
|
| 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 |
-
|
| 170 |
-
|
|
|
|
| 171 |
<input type="url" id="backdrop" name="backdrop"
|
| 172 |
-
|
| 173 |
-
|
| 174 |
</div>
|
| 175 |
</div>
|
| 176 |
|
| 177 |
<div class="mb-6">
|
| 178 |
-
<label class="
|
| 179 |
-
<textarea id="description" name="description" rows="
|
| 180 |
-
|
| 181 |
</div>
|
| 182 |
|
| 183 |
<div class="mb-6">
|
| 184 |
-
<label class="
|
| 185 |
<input type="text" id="genres" name="genres"
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
placeholder="Action, Comedy, Drama">
|
| 189 |
</div>
|
| 190 |
|
| 191 |
-
<div class="flex flex-col sm:flex-row justify-end gap-
|
| 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="
|
| 207 |
-
<
|
|
|
|
|
|
|
|
|
|
| 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
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
<
|
| 247 |
-
<div class="space-y-4 sm:space-y-6">
|
| 248 |
{% for season in media_details.seasons|sort(attribute='season_number') %}
|
| 249 |
-
<div class="
|
| 250 |
-
<
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 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-
|
| 275 |
{% for episode in season.episodes|sort(attribute='episode_number') %}
|
| 276 |
-
<div class="p-
|
| 277 |
-
<div class="flex flex-col
|
| 278 |
-
<
|
| 279 |
-
|
| 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 |
-
<
|
| 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
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
<
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 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-
|
| 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 |
-
<
|
| 344 |
-
|
| 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>
|
|
@@ -352,48 +483,110 @@
|
|
| 352 |
{% endfor %}
|
| 353 |
</div>
|
| 354 |
{% else %}
|
| 355 |
-
<div class="text-center py-
|
| 356 |
-
<svg class="mx-auto h-12 w-12 text-
|
| 357 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 358 |
-
|
| 359 |
</svg>
|
| 360 |
-
<p class="
|
| 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 |
-
|
| 378 |
-
|
|
|
|
| 379 |
arrow.style.transform = 'rotate(0deg)';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 380 |
} else {
|
| 381 |
-
content.style.
|
| 382 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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(
|
| 397 |
} else if (key === 'rating' || key === 'release_year' || key === 'runtime') {
|
| 398 |
updateData[key] = value ? parseFloat(value) : null;
|
| 399 |
} else {
|
|
@@ -404,17 +597,15 @@
|
|
| 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(),
|
| 416 |
} else {
|
| 417 |
-
const error = await response.json();
|
| 418 |
showErrorMessage(`Error updating media: ${error.detail || 'Unknown error'}`);
|
| 419 |
}
|
| 420 |
} catch (error) {
|
|
@@ -423,9 +614,8 @@
|
|
| 423 |
}
|
| 424 |
}
|
| 425 |
|
| 426 |
-
// Delete name from movie
|
| 427 |
async function deleteQuality(id) {
|
| 428 |
-
if (!confirm(`Are you sure you want to delete
|
| 429 |
|
| 430 |
try {
|
| 431 |
const response = await fetch(`/api/media/delete-quality?tmdb_id=${tmdbId}&db_index=${dbIndex}&id=${encodeURIComponent(id)}`, {
|
|
@@ -434,20 +624,19 @@
|
|
| 434 |
|
| 435 |
if (response.ok) {
|
| 436 |
showSuccessMessage(`${id} deleted successfully`);
|
| 437 |
-
setTimeout(() => location.reload(),
|
| 438 |
} else {
|
| 439 |
-
const error = await response.json();
|
| 440 |
-
showErrorMessage(`Error deleting
|
| 441 |
}
|
| 442 |
} catch (error) {
|
| 443 |
-
console.error('Error deleting
|
| 444 |
-
showErrorMessage('Error deleting
|
| 445 |
}
|
| 446 |
}
|
| 447 |
|
| 448 |
-
// Delete TV quality
|
| 449 |
async function deleteTVQuality(season, episode, id) {
|
| 450 |
-
if (!confirm(`Are you sure you want to delete
|
| 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)}`, {
|
|
@@ -456,20 +645,19 @@
|
|
| 456 |
|
| 457 |
if (response.ok) {
|
| 458 |
showSuccessMessage(`${id} deleted successfully`);
|
| 459 |
-
setTimeout(() => location.reload(),
|
| 460 |
} else {
|
| 461 |
-
const error = await response.json();
|
| 462 |
-
showErrorMessage(`Error deleting
|
| 463 |
}
|
| 464 |
} catch (error) {
|
| 465 |
-
console.error('Error deleting
|
| 466 |
showErrorMessage('Error deleting. Please try again.');
|
| 467 |
}
|
| 468 |
}
|
| 469 |
|
| 470 |
-
// Delete TV episode
|
| 471 |
async function deleteTVEpisode(season, episode) {
|
| 472 |
-
if (!confirm(`
|
| 473 |
|
| 474 |
try {
|
| 475 |
const response = await fetch(`/api/media/delete-tv-episode?tmdb_id=${tmdbId}&db_index=${dbIndex}&season=${season}&episode=${episode}`, {
|
|
@@ -478,9 +666,9 @@
|
|
| 478 |
|
| 479 |
if (response.ok) {
|
| 480 |
showSuccessMessage(`Episode ${episode} deleted successfully`);
|
| 481 |
-
setTimeout(() => location.reload(),
|
| 482 |
} else {
|
| 483 |
-
const error = await response.json();
|
| 484 |
showErrorMessage(`Error deleting episode: ${error.detail || 'Unknown error'}`);
|
| 485 |
}
|
| 486 |
} catch (error) {
|
|
@@ -489,9 +677,8 @@
|
|
| 489 |
}
|
| 490 |
}
|
| 491 |
|
| 492 |
-
// Delete TV season
|
| 493 |
async function deleteTVSeason(season) {
|
| 494 |
-
if (!confirm(`
|
| 495 |
|
| 496 |
try {
|
| 497 |
const response = await fetch(`/api/media/delete-tv-season?tmdb_id=${tmdbId}&db_index=${dbIndex}&season=${season}`, {
|
|
@@ -500,9 +687,9 @@
|
|
| 500 |
|
| 501 |
if (response.ok) {
|
| 502 |
showSuccessMessage(`Season ${season} deleted successfully`);
|
| 503 |
-
setTimeout(() => location.reload(),
|
| 504 |
} else {
|
| 505 |
-
const error = await response.json();
|
| 506 |
showErrorMessage(`Error deleting season: ${error.detail || 'Unknown error'}`);
|
| 507 |
}
|
| 508 |
} catch (error) {
|
|
@@ -511,61 +698,18 @@
|
|
| 511 |
}
|
| 512 |
}
|
| 513 |
|
| 514 |
-
// Show success message
|
| 515 |
function showSuccessMessage(message) {
|
| 516 |
-
|
| 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 |
-
|
| 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;
|
|
@@ -573,117 +717,33 @@
|
|
| 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 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 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;
|
|
@@ -721,28 +781,32 @@
|
|
| 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-
|
| 728 |
-
if (ms < 100) return 'text-
|
| 729 |
-
if (ms < 300) return 'text-
|
| 730 |
-
return 'text-
|
| 731 |
}
|
| 732 |
|
| 733 |
function _speedClass(mbps) {
|
| 734 |
-
if (mbps === null) return 'text-
|
| 735 |
-
if (mbps >= 20) return 'text-
|
| 736 |
-
if (mbps >= 5) return 'text-
|
| 737 |
-
return 'text-
|
| 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-
|
| 744 |
-
|
| 745 |
-
|
| 746 |
}
|
| 747 |
|
| 748 |
async function _exec() {
|
|
@@ -750,10 +814,9 @@
|
|
| 750 |
quality_id: _stQualityId,
|
| 751 |
tmdb_id: tmdbId,
|
| 752 |
db_index: dbIndex,
|
| 753 |
-
media_type:
|
| 754 |
});
|
| 755 |
|
| 756 |
-
// Close any old connection
|
| 757 |
if (window._stEventSource) {
|
| 758 |
window._stEventSource.close();
|
| 759 |
window._stEventSource = null;
|
|
@@ -771,8 +834,10 @@
|
|
| 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
|
| 776 |
} else {
|
| 777 |
summaryEl.textContent = `${completedCount}/${totalCount} client(s) done`;
|
| 778 |
}
|
|
@@ -788,6 +853,7 @@
|
|
| 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 |
|
|
@@ -806,12 +872,12 @@
|
|
| 806 |
const tr = document.createElement('tr');
|
| 807 |
tr.className = 'animate-pulse';
|
| 808 |
tr.innerHTML = `
|
| 809 |
-
<td class="px-4 py-3 font-medium text-
|
| 810 |
-
<td class="px-4 py-3"><span class="text-
|
| 811 |
-
<td class="px-4 py-3"><span class="text-
|
| 812 |
-
<td class="px-4 py-3 text-
|
| 813 |
-
<td class="px-4 py-3 text-
|
| 814 |
-
<td class="px-4 py-3"><span class="px-2 py-0.5 rounded-full text-xs bg-
|
| 815 |
tbody.appendChild(tr);
|
| 816 |
pendingRows[i] = tr;
|
| 817 |
}
|
|
@@ -823,76 +889,48 @@
|
|
| 823 |
const tr = pendingRows[r.client_index];
|
| 824 |
if (tr) {
|
| 825 |
maxSpeed = Math.max(maxSpeed, r.speed_mbps || 0, 1);
|
| 826 |
-
|
| 827 |
-
const
|
|
|
|
|
|
|
| 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-
|
| 831 |
-
: '<span class="text-
|
| 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 |
-
|
| 836 |
-
|
| 837 |
-
|
| 838 |
-
|
| 839 |
-
|
| 840 |
-
|
| 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 |
-
|
| 847 |
-
|
| 848 |
-
|
| 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 |
|
|
@@ -900,49 +938,51 @@
|
|
| 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}
|
| 904 |
-
const ping = r.ping_ms !== null ? `<span class="${_pingClass(r.ping_ms)}">${r.ping_ms} ms</span>` : '<span class="text-
|
| 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-
|
| 908 |
-
: '<span class="text-
|
| 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-
|
| 913 |
-
: `<span class="px-2 py-0.5 rounded-full text-xs font-medium bg-
|
| 914 |
|
| 915 |
const tr = document.createElement('tr');
|
| 916 |
-
tr.className = `
|
| 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-
|
| 921 |
-
<td class="px-4 py-3 text-
|
| 922 |
-
<td class="px-4 py-3 text-
|
| 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 = (
|
| 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 |
-
|
| 945 |
-
|
|
|
|
| 946 |
</script>
|
| 947 |
-
|
| 948 |
-
{% endblock %}
|
|
|
|
| 3 |
{% block title %}Edit {{ media_type|title }} - Fyvio Backend{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
+
<style>
|
| 7 |
+
.glass-card {
|
| 8 |
+
background: color-mix(in srgb, var(--card) 52%, transparent);
|
| 9 |
+
border: 1px solid color-mix(in srgb, var(--border) 95%, transparent);
|
| 10 |
+
backdrop-filter: blur(22px);
|
| 11 |
+
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
.glass-card-soft {
|
| 15 |
+
background: color-mix(in srgb, var(--card) 40%, transparent);
|
| 16 |
+
border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
|
| 17 |
+
backdrop-filter: blur(18px);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
.section-title {
|
| 21 |
+
color: var(--text);
|
| 22 |
+
font-weight: 800;
|
| 23 |
+
letter-spacing: -0.02em;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
.muted {
|
| 27 |
+
color: var(--text-sec);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
.field-label {
|
| 31 |
+
display: block;
|
| 32 |
+
font-size: 0.875rem;
|
| 33 |
+
font-weight: 700;
|
| 34 |
+
margin-bottom: 0.5rem;
|
| 35 |
+
color: var(--text);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.field-input, .field-textarea {
|
| 39 |
+
width: 100%;
|
| 40 |
+
border-radius: 1rem;
|
| 41 |
+
border: 1px solid color-mix(in srgb, var(--border) 95%, transparent);
|
| 42 |
+
background: color-mix(in srgb, var(--bg) 76%, transparent);
|
| 43 |
+
color: var(--text);
|
| 44 |
+
padding: 0.9rem 1rem;
|
| 45 |
+
outline: none;
|
| 46 |
+
transition: all 0.2s ease;
|
| 47 |
+
box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.field-input::placeholder,
|
| 51 |
+
.field-textarea::placeholder {
|
| 52 |
+
color: color-mix(in srgb, var(--text-sec) 85%, transparent);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
.field-input:focus, .field-textarea:focus {
|
| 56 |
+
border-color: var(--primary);
|
| 57 |
+
box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
.hero-wrap {
|
| 61 |
+
position: relative;
|
| 62 |
+
overflow: hidden;
|
| 63 |
+
isolation: isolate;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.hero-backdrop {
|
| 67 |
+
position: absolute;
|
| 68 |
+
inset: 0;
|
| 69 |
+
width: 100%;
|
| 70 |
+
height: 100%;
|
| 71 |
+
object-fit: cover;
|
| 72 |
+
opacity: .34;
|
| 73 |
+
transform: scale(1.04);
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
.hero-gradient {
|
| 77 |
+
position: absolute;
|
| 78 |
+
inset: 0;
|
| 79 |
+
background:
|
| 80 |
+
linear-gradient(180deg, color-mix(in srgb, var(--bg) 10%, transparent) 0%, color-mix(in srgb, var(--bg) 52%, transparent) 60%, color-mix(in srgb, var(--bg) 96%, transparent) 100%),
|
| 81 |
+
radial-gradient(circle at top left, color-mix(in srgb, var(--primary) 18%, transparent), transparent 42%),
|
| 82 |
+
radial-gradient(circle at bottom right, color-mix(in srgb, var(--accent) 16%, transparent), transparent 38%);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
.pill {
|
| 86 |
+
display: inline-flex;
|
| 87 |
+
align-items: center;
|
| 88 |
+
gap: 0.35rem;
|
| 89 |
+
padding: 0.4rem 0.8rem;
|
| 90 |
+
border-radius: 9999px;
|
| 91 |
+
font-size: 0.82rem;
|
| 92 |
+
font-weight: 700;
|
| 93 |
+
border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
|
| 94 |
+
background: color-mix(in srgb, var(--bg) 66%, transparent);
|
| 95 |
+
color: var(--text);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
.quality-row {
|
| 99 |
+
background: color-mix(in srgb, var(--bg) 70%, transparent);
|
| 100 |
+
border: 1px solid color-mix(in srgb, var(--border) 92%, transparent);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
.quality-badge {
|
| 104 |
+
border-radius: 9999px;
|
| 105 |
+
padding: 0.35rem 0.8rem;
|
| 106 |
+
font-size: 0.75rem;
|
| 107 |
+
font-weight: 800;
|
| 108 |
+
letter-spacing: .02em;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
.btn-ui {
|
| 112 |
+
display: inline-flex;
|
| 113 |
+
align-items: center;
|
| 114 |
+
justify-content: center;
|
| 115 |
+
gap: 0.45rem;
|
| 116 |
+
border-radius: 1rem;
|
| 117 |
+
padding: 0.8rem 1.15rem;
|
| 118 |
+
font-size: 0.92rem;
|
| 119 |
+
font-weight: 800;
|
| 120 |
+
transition: all 0.2s ease;
|
| 121 |
+
border: 1px solid transparent;
|
| 122 |
+
white-space: nowrap;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
.btn-ui:hover {
|
| 126 |
+
transform: translateY(-1px);
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
.btn-primary {
|
| 130 |
+
background: var(--primary);
|
| 131 |
+
color: white;
|
| 132 |
+
box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 26%, transparent);
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
.btn-primary:hover { filter: brightness(1.03); }
|
| 136 |
+
|
| 137 |
+
.btn-ghost {
|
| 138 |
+
background: color-mix(in srgb, var(--bg) 74%, transparent);
|
| 139 |
+
color: var(--text);
|
| 140 |
+
border-color: color-mix(in srgb, var(--border) 95%, transparent);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
.btn-danger {
|
| 144 |
+
background: color-mix(in srgb, rgb(239 68 68) 16%, transparent);
|
| 145 |
+
color: rgb(248 113 113);
|
| 146 |
+
border-color: color-mix(in srgb, rgb(239 68 68) 26%, transparent);
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
.btn-success {
|
| 150 |
+
background: color-mix(in srgb, rgb(34 197 94) 16%, transparent);
|
| 151 |
+
color: rgb(74 222 128);
|
| 152 |
+
border-color: color-mix(in srgb, rgb(34 197 94) 26%, transparent);
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
.btn-info {
|
| 156 |
+
background: color-mix(in srgb, rgb(59 130 246) 16%, transparent);
|
| 157 |
+
color: rgb(96 165 250);
|
| 158 |
+
border-color: color-mix(in srgb, rgb(59 130 246) 26%, transparent);
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
.season-content {
|
| 162 |
+
transition: max-height 0.32s ease, opacity 0.25s ease, transform 0.25s ease;
|
| 163 |
+
overflow: hidden;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
.season-collapsed {
|
| 167 |
+
max-height: 0 !important;
|
| 168 |
+
opacity: 0;
|
| 169 |
+
transform: translateY(-4px);
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
.break-all {
|
| 173 |
+
word-break: break-all;
|
| 174 |
+
overflow-wrap: anywhere;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
@keyframes spin {
|
| 178 |
+
to { transform: rotate(360deg); }
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
.st-spin {
|
| 182 |
+
animation: spin 1s linear infinite;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
.speed-modal-shell {
|
| 186 |
+
width: min(100%, 56rem);
|
| 187 |
+
max-height: calc(100dvh - 1rem);
|
| 188 |
+
overflow: hidden;
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
.speed-modal-body {
|
| 192 |
+
max-height: calc(100dvh - 11rem);
|
| 193 |
+
overflow-y: auto;
|
| 194 |
+
-webkit-overflow-scrolling: touch;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
@media (max-width: 640px) {
|
| 198 |
+
.btn-ui { width: 100%; }
|
| 199 |
+
.speed-modal-shell {
|
| 200 |
+
width: calc(100vw - 0.75rem);
|
| 201 |
+
max-height: calc(100dvh - 0.75rem);
|
| 202 |
+
border-radius: 1.25rem;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
.speed-modal-body {
|
| 206 |
+
max-height: calc(100dvh - 9.5rem);
|
| 207 |
+
}
|
| 208 |
+
}
|
| 209 |
+
</style>
|
| 210 |
+
|
| 211 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-5 sm:py-8">
|
| 212 |
+
<div class="glass-card rounded-3xl p-5 sm:p-6 mb-6 sm:mb-8">
|
| 213 |
+
<div class="flex flex-col gap-4">
|
| 214 |
<a href="/media/manage?media_type={{ media_type }}"
|
| 215 |
+
class="inline-flex items-center gap-2 text-primary font-semibold hover:opacity-90 w-fit">
|
| 216 |
+
<svg class="w-4 h-4 sm:w-5 sm:h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 217 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 218 |
+
d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
|
| 219 |
</svg>
|
| 220 |
Back to {{ media_type|title }}s
|
| 221 |
</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
|
| 223 |
+
<div class="flex flex-col lg:flex-row lg:items-end lg:justify-between gap-3">
|
| 224 |
+
<div>
|
| 225 |
+
<h1 class="section-title text-2xl sm:text-3xl lg:text-4xl">Edit {{ media_type|title }}</h1>
|
| 226 |
+
<p class="muted mt-1 text-sm sm:text-base">TMDB ID: {{ tmdb_id }} · DB Index: {{ db_index }}</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
</div>
|
| 228 |
</div>
|
| 229 |
+
</div>
|
| 230 |
+
</div>
|
| 231 |
|
| 232 |
+
{% if media_details %}
|
| 233 |
+
<div class="glass-card rounded-3xl overflow-hidden mb-6 sm:mb-8">
|
| 234 |
+
<div class="hero-wrap">
|
| 235 |
{% if media_details.backdrop %}
|
| 236 |
+
<img src="{{ media_details.backdrop }}" alt="{{ media_details.title }} backdrop" class="hero-backdrop"
|
| 237 |
+
onerror="this.style.display='none'">
|
|
|
|
|
|
|
|
|
|
| 238 |
{% endif %}
|
| 239 |
+
<div class="hero-gradient"></div>
|
| 240 |
|
| 241 |
+
<div class="relative z-10 p-5 sm:p-6 lg:p-8">
|
| 242 |
+
<div class="flex flex-col md:flex-row md:items-end gap-5 sm:gap-6">
|
| 243 |
+
<div class="mx-auto md:mx-0 flex-shrink-0">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
<img src="{{ media_details.poster or '/static/placeholder.jpg' }}"
|
| 245 |
+
alt="{{ media_details.title }}"
|
| 246 |
+
class="w-36 sm:w-40 md:w-48 h-54 sm:h-60 md:h-72 object-cover rounded-2xl shadow-2xl border border-white/20"
|
| 247 |
+
onerror="this.src='https://via.placeholder.com/300x450/e5e7eb/9ca3af?text=No+Image'">
|
| 248 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
|
| 250 |
+
<div class="flex-1 min-w-0 text-center md:text-left">
|
| 251 |
+
<h2 class="text-2xl sm:text-3xl md:text-4xl font-black tracking-tight text-white drop-shadow">
|
| 252 |
+
{{ media_details.title }}
|
| 253 |
+
</h2>
|
| 254 |
+
|
| 255 |
+
<div class="flex flex-wrap justify-center md:justify-start items-center gap-2 sm:gap-3 mt-4">
|
| 256 |
+
{% if media_details.rating %}
|
| 257 |
+
<span class="inline-flex items-center gap-1 px-3 py-1 rounded-full bg-yellow-400 text-black text-sm font-extrabold shadow-sm">
|
| 258 |
+
⭐ {{ media_details.rating }}
|
| 259 |
+
</span>
|
| 260 |
+
{% endif %}
|
| 261 |
+
<span class="inline-flex items-center px-3 py-1 rounded-full bg-white/15 text-white text-sm font-semibold backdrop-blur-md border border-white/15">
|
| 262 |
+
{{ media_details.release_year }}
|
| 263 |
+
</span>
|
| 264 |
+
{% if media_details.genres %}
|
| 265 |
+
<span class="inline-flex items-center px-3 py-1 rounded-full bg-white/15 text-white text-sm font-semibold backdrop-blur-md border border-white/15">
|
| 266 |
+
{{ media_details.genres|length }} genre{{ 's' if media_details.genres|length != 1 else '' }}
|
| 267 |
+
</span>
|
| 268 |
+
{% endif %}
|
| 269 |
</div>
|
| 270 |
+
|
| 271 |
+
{% if media_details.genres %}
|
| 272 |
+
<div class="flex flex-wrap justify-center md:justify-start gap-2 mt-4">
|
| 273 |
+
{% for genre in media_details.genres[:8] %}
|
| 274 |
+
<span class="pill">{{ genre }}</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
{% endfor %}
|
| 276 |
</div>
|
| 277 |
+
{% endif %}
|
| 278 |
</div>
|
| 279 |
</div>
|
| 280 |
</div>
|
|
|
|
| 281 |
</div>
|
| 282 |
|
|
|
|
| 283 |
{% if media_details.description %}
|
| 284 |
+
<div class="border-t border-white/10 p-5 sm:p-6 lg:p-8">
|
| 285 |
+
<h3 class="section-title text-lg sm:text-xl mb-3">Overview</h3>
|
| 286 |
+
<p class="muted leading-7 text-sm sm:text-base">{{ media_details.description }}</p>
|
| 287 |
</div>
|
| 288 |
{% endif %}
|
| 289 |
</div>
|
| 290 |
{% endif %}
|
| 291 |
|
| 292 |
+
<div class="glass-card rounded-3xl p-5 sm:p-6 lg:p-8 mb-6 sm:mb-8">
|
| 293 |
+
<div class="flex items-center justify-between gap-3 mb-5 sm:mb-6">
|
| 294 |
+
<h3 class="section-title text-xl sm:text-2xl">Edit Details</h3>
|
| 295 |
+
</div>
|
| 296 |
+
|
| 297 |
<form onsubmit="updateMedia(event)" id="edit-form">
|
| 298 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 sm:gap-5 lg:gap-6 mb-6">
|
| 299 |
+
<div class="md:col-span-2">
|
| 300 |
+
<label class="field-label">Title *</label>
|
| 301 |
+
<input type="text" id="title" name="title" value="{{ media_details.title if media_details else '' }}"
|
| 302 |
+
class="field-input" required>
|
|
|
|
|
|
|
| 303 |
</div>
|
| 304 |
+
|
| 305 |
<div>
|
| 306 |
+
<label class="field-label">Release Year *</label>
|
| 307 |
<input type="number" id="release_year" name="release_year"
|
| 308 |
+
value="{{ media_details.release_year if media_details else '' }}"
|
| 309 |
+
class="field-input" required>
|
|
|
|
| 310 |
</div>
|
| 311 |
+
|
| 312 |
<div>
|
| 313 |
+
<label class="field-label">Rating (0-10)</label>
|
| 314 |
<input type="number" step="0.1" min="0" max="10" id="rating" name="rating"
|
| 315 |
+
value="{{ media_details.rating if media_details else '' }}"
|
| 316 |
+
class="field-input">
|
| 317 |
</div>
|
| 318 |
+
|
| 319 |
+
<div class="md:col-span-2">
|
| 320 |
+
<label class="field-label">Logo URL</label>
|
| 321 |
<input type="url" id="logo" name="logo" value="{{ media_details.logo if media_details else '' }}"
|
| 322 |
+
class="field-input">
|
| 323 |
</div>
|
| 324 |
|
| 325 |
+
<div class="md:col-span-2">
|
| 326 |
+
<label class="field-label">Poster URL</label>
|
| 327 |
+
<input type="url" id="poster" name="poster" value="{{ media_details.poster if media_details else '' }}"
|
| 328 |
+
class="field-input">
|
|
|
|
| 329 |
</div>
|
| 330 |
+
|
| 331 |
+
<div class="md:col-span-2">
|
| 332 |
+
<label class="field-label">Backdrop URL</label>
|
| 333 |
<input type="url" id="backdrop" name="backdrop"
|
| 334 |
+
value="{{ media_details.backdrop if media_details else '' }}"
|
| 335 |
+
class="field-input">
|
| 336 |
</div>
|
| 337 |
</div>
|
| 338 |
|
| 339 |
<div class="mb-6">
|
| 340 |
+
<label class="field-label">Description</label>
|
| 341 |
+
<textarea id="description" name="description" rows="4"
|
| 342 |
+
class="field-textarea resize-y">{{ media_details.description if media_details else '' }}</textarea>
|
| 343 |
</div>
|
| 344 |
|
| 345 |
<div class="mb-6">
|
| 346 |
+
<label class="field-label">Genres (comma-separated)</label>
|
| 347 |
<input type="text" id="genres" name="genres"
|
| 348 |
+
value="{% if media_details and media_details.genres %}{{ media_details.genres|join(', ') }}{% endif %}"
|
| 349 |
+
class="field-input" placeholder="Action, Comedy, Drama">
|
|
|
|
| 350 |
</div>
|
| 351 |
|
| 352 |
+
<div class="flex flex-col sm:flex-row justify-end gap-3">
|
| 353 |
+
<button type="button" onclick="window.history.back()" class="btn-ui btn-ghost">
|
|
|
|
| 354 |
Cancel
|
| 355 |
</button>
|
| 356 |
+
<button type="submit" class="btn-ui btn-primary">
|
|
|
|
| 357 |
Save Changes
|
| 358 |
</button>
|
| 359 |
</div>
|
| 360 |
</form>
|
| 361 |
</div>
|
| 362 |
|
|
|
|
| 363 |
{% if media_details %}
|
| 364 |
+
<div class="glass-card rounded-3xl p-5 sm:p-6 lg:p-8">
|
| 365 |
+
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-5 sm:mb-6">
|
| 366 |
+
<h3 class="section-title text-xl sm:text-2xl">Available Content</h3>
|
| 367 |
+
<span class="pill">Manage streams, episodes, and seasons</span>
|
| 368 |
+
</div>
|
| 369 |
|
| 370 |
{% if media_type == 'movie' and media_details.telegram %}
|
|
|
|
| 371 |
<div class="space-y-3">
|
| 372 |
{% set sorted_qualities = media_details.telegram|sort(attribute='quality') %}
|
| 373 |
{% for quality in sorted_qualities %}
|
| 374 |
+
<div class="quality-row rounded-2xl p-4 sm:p-5">
|
| 375 |
+
<div class="flex flex-col xl:flex-row xl:items-center justify-between gap-4">
|
| 376 |
+
<div class="min-w-0 flex-1">
|
| 377 |
+
<div class="flex flex-wrap items-center gap-2 sm:gap-3">
|
| 378 |
+
<span class="quality-badge bg-blue-500/15 text-blue-300 border border-blue-500/20">
|
| 379 |
+
{{ quality.quality }}
|
| 380 |
+
</span>
|
| 381 |
+
<span class="pill">{{ quality.size }}</span>
|
| 382 |
+
</div>
|
| 383 |
+
<p class="muted mt-3 text-sm break-all">{{ quality.name }}</p>
|
| 384 |
+
</div>
|
| 385 |
+
|
| 386 |
+
<div class="grid grid-cols-1 sm:grid-cols-3 gap-2 w-full sm:w-auto xl:min-w-[24rem]">
|
| 387 |
+
<button onclick="copyStreamLink('{{ quality.id }}', '{{ quality.name }}')" class="btn-ui btn-success w-full" title="Copy direct stream link">
|
| 388 |
+
📋 Copy Link
|
| 389 |
+
</button>
|
| 390 |
+
<button onclick="runSpeedTest('{{ quality.id }}', 'movie', '{{ quality.quality }}')" class="btn-ui btn-info w-full">
|
| 391 |
+
🚀 Speed Test
|
| 392 |
+
</button>
|
| 393 |
+
<button onclick="deleteQuality('{{ quality.id }}')" class="btn-ui btn-danger w-full">
|
| 394 |
+
Delete
|
| 395 |
+
</button>
|
| 396 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
</div>
|
| 398 |
</div>
|
| 399 |
{% endfor %}
|
| 400 |
</div>
|
| 401 |
|
| 402 |
{% elif media_type == 'tv' and media_details.seasons %}
|
| 403 |
+
<div class="space-y-4 sm:space-y-5">
|
|
|
|
| 404 |
{% for season in media_details.seasons|sort(attribute='season_number') %}
|
| 405 |
+
<div class="glass-card-soft rounded-3xl overflow-hidden border border-white/10">
|
| 406 |
+
<div class="px-4 sm:px-5 lg:px-6 py-4 sm:py-5 border-b border-white/10 bg-white/5">
|
| 407 |
+
<div class="flex items-center justify-between gap-3">
|
| 408 |
+
<div>
|
| 409 |
+
<h4 class="section-title text-base sm:text-lg lg:text-xl">Season {{ season.season_number }}</h4>
|
| 410 |
+
<p class="muted text-xs sm:text-sm mt-1">{{ season.episodes|length }} episode{{ 's' if season.episodes|length != 1 else '' }}</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
</div>
|
| 412 |
+
|
| 413 |
+
<button type="button" onclick="toggleSeason({{ loop.index0 }})" class="btn-ui btn-ghost px-3 py-2">
|
| 414 |
+
<svg id="season-arrow-{{ loop.index0 }}" class="w-4 h-4 transition-transform duration-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 415 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
|
| 416 |
+
</svg>
|
| 417 |
+
</button>
|
| 418 |
</div>
|
| 419 |
</div>
|
| 420 |
|
|
|
|
| 421 |
<div id="season-content-{{ loop.index0 }}" class="season-content">
|
| 422 |
+
<div class="divide-y divide-white/10">
|
| 423 |
{% for episode in season.episodes|sort(attribute='episode_number') %}
|
| 424 |
+
<div class="p-4 sm:p-5">
|
| 425 |
+
<div class="flex flex-col xl:flex-row xl:items-start gap-4">
|
| 426 |
+
<div class="flex-shrink-0 w-12 h-12 rounded-2xl bg-primary/15 border border-primary/20 flex items-center justify-center mx-auto xl:mx-0">
|
| 427 |
+
<span class="text-sm font-black text-primary">{{ episode.episode_number }}</span>
|
|
|
|
|
|
|
| 428 |
</div>
|
| 429 |
|
|
|
|
| 430 |
<div class="flex-1 min-w-0">
|
| 431 |
+
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-2 mb-3">
|
| 432 |
+
<h5 class="text-sm sm:text-base font-semibold text-white text-center sm:text-left">{{ episode.title }}</h5>
|
| 433 |
+
<button onclick="deleteTVEpisode({{ season.season_number }}, {{ episode.episode_number }})" class="btn-ui btn-danger px-3 py-2 text-xs sm:text-sm w-full sm:w-auto">
|
| 434 |
+
Delete Episode
|
| 435 |
+
</button>
|
| 436 |
+
</div>
|
| 437 |
|
|
|
|
| 438 |
{% if episode.telegram %}
|
| 439 |
<div class="space-y-2">
|
| 440 |
{% set sorted_episode_qualities = episode.telegram|sort(attribute='quality') %}
|
| 441 |
{% for quality in sorted_episode_qualities %}
|
| 442 |
+
<div class="quality-row rounded-2xl p-3 sm:p-4">
|
| 443 |
+
<div class="flex flex-col xl:flex-row xl:items-center justify-between gap-3">
|
| 444 |
+
<div class="min-w-0 flex-1">
|
| 445 |
+
<div class="flex flex-wrap items-center gap-2 sm:gap-3">
|
| 446 |
+
<span class="quality-badge bg-green-500/15 text-green-300 border border-green-500/20">{{ quality.quality }}</span>
|
| 447 |
+
<span class="pill">{{ quality.size }}</span>
|
| 448 |
+
</div>
|
| 449 |
+
<p class="muted text-xs sm:text-sm mt-2 break-all">{{ quality.name }}</p>
|
| 450 |
+
</div>
|
| 451 |
+
|
| 452 |
+
<div class="grid grid-cols-1 sm:grid-cols-3 gap-2 w-full sm:w-auto xl:min-w-[22rem]">
|
| 453 |
+
<button onclick="copyStreamLink('{{ quality.id }}', '{{ quality.name }}')" class="btn-ui btn-success w-full text-xs sm:text-sm">
|
| 454 |
+
📋 Copy
|
| 455 |
+
</button>
|
| 456 |
+
<button onclick="runSpeedTest('{{ quality.id }}', 'tv', '{{ quality.quality }}')" class="btn-ui btn-info w-full text-xs sm:text-sm">
|
| 457 |
+
🚀 Speed Test
|
| 458 |
+
</button>
|
| 459 |
+
<button onclick="deleteTVQuality({{ season.season_number }}, {{ episode.episode_number }}, '{{ quality.id }}')" class="btn-ui btn-danger w-full text-xs sm:text-sm">
|
| 460 |
+
Delete
|
| 461 |
+
</button>
|
| 462 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 463 |
</div>
|
| 464 |
</div>
|
| 465 |
{% endfor %}
|
| 466 |
</div>
|
| 467 |
{% else %}
|
| 468 |
+
<p class="muted text-xs sm:text-sm text-center sm:text-left">No qualities available</p>
|
| 469 |
{% endif %}
|
| 470 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 471 |
</div>
|
| 472 |
</div>
|
| 473 |
{% endfor %}
|
| 474 |
</div>
|
| 475 |
|
| 476 |
+
<div class="px-4 sm:px-5 lg:px-6 py-4 border-t border-white/10 bg-white/5 flex justify-center sm:justify-start">
|
| 477 |
+
<button onclick="deleteTVSeason({{ season.season_number }})" class="btn-ui btn-danger px-4 py-2 text-sm">
|
|
|
|
|
|
|
| 478 |
Delete Entire Season
|
| 479 |
</button>
|
| 480 |
</div>
|
|
|
|
| 483 |
{% endfor %}
|
| 484 |
</div>
|
| 485 |
{% else %}
|
| 486 |
+
<div class="text-center py-10">
|
| 487 |
+
<svg class="mx-auto h-12 w-12 text-white/25 mb-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 488 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 489 |
+
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" />
|
| 490 |
</svg>
|
| 491 |
+
<p class="muted text-sm sm:text-base">No content available</p>
|
| 492 |
</div>
|
| 493 |
{% endif %}
|
| 494 |
</div>
|
| 495 |
{% endif %}
|
| 496 |
</div>
|
| 497 |
|
| 498 |
+
<div id="speed-test-modal" class="fixed inset-0 z-50 hidden" aria-modal="true" role="dialog">
|
| 499 |
+
<div class="absolute inset-0 bg-black/60 backdrop-blur-sm" onclick="closeSpeedTest()"></div>
|
| 500 |
+
|
| 501 |
+
<div class="absolute inset-0 flex items-center justify-center p-2 sm:p-4">
|
| 502 |
+
<div class="glass-card speed-modal-shell rounded-2xl sm:rounded-3xl">
|
| 503 |
+
<div class="flex items-start sm:items-center justify-between gap-3 px-4 sm:px-6 py-4 border-b border-white/10 bg-white/5">
|
| 504 |
+
<div class="min-w-0">
|
| 505 |
+
<h2 class="text-base sm:text-xl font-black text-white leading-tight">🚀 DC Speed Test</h2>
|
| 506 |
+
<p id="st-label" class="text-[11px] sm:text-sm text-white/70 mt-1 break-all"></p>
|
| 507 |
+
</div>
|
| 508 |
+
<button onclick="closeSpeedTest()" class="flex-shrink-0 text-white/70 hover:text-white text-3xl leading-none transition-colors">×</button>
|
| 509 |
+
</div>
|
| 510 |
+
|
| 511 |
+
<div class="speed-modal-body px-4 sm:px-6 py-5 sm:py-6">
|
| 512 |
+
<div id="st-spinner" class="flex flex-col items-center gap-4 py-8 sm:py-10">
|
| 513 |
+
<div class="w-12 h-12 sm:w-14 sm:h-14 rounded-full border-4 border-white/15 border-t-primary st-spin"></div>
|
| 514 |
+
<p class="text-sm text-white/75 text-center">Testing all DC clients simultaneously…</p>
|
| 515 |
+
<p class="text-xs text-white/50 text-center max-w-md">Downloading 100 MB from each bot client</p>
|
| 516 |
+
</div>
|
| 517 |
+
|
| 518 |
+
<div id="st-results" class="hidden">
|
| 519 |
+
<div class="overflow-x-auto rounded-2xl border border-white/10">
|
| 520 |
+
<table class="w-full min-w-[760px] text-sm">
|
| 521 |
+
<thead class="bg-white/5 text-left">
|
| 522 |
+
<tr class="text-white/70">
|
| 523 |
+
<th class="px-4 py-3 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">Bot / DC</th>
|
| 524 |
+
<th class="px-4 py-3 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">Ping</th>
|
| 525 |
+
<th class="px-4 py-3 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">Speed</th>
|
| 526 |
+
<th class="px-4 py-3 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">Time</th>
|
| 527 |
+
<th class="px-4 py-3 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">Downloaded</th>
|
| 528 |
+
<th class="px-4 py-3 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">Status</th>
|
| 529 |
+
</tr>
|
| 530 |
+
</thead>
|
| 531 |
+
<tbody id="st-tbody" class="divide-y divide-white/10 bg-white/5"></tbody>
|
| 532 |
+
</table>
|
| 533 |
+
</div>
|
| 534 |
+
<p id="st-summary" class="text-xs text-white/50 mt-3 text-right"></p>
|
| 535 |
+
</div>
|
| 536 |
+
|
| 537 |
+
<div id="st-error" class="hidden mt-2 rounded-2xl border border-red-500/25 bg-red-500/10 px-4 py-3 text-sm text-red-200"></div>
|
| 538 |
+
</div>
|
| 539 |
+
|
| 540 |
+
<div class="flex flex-col sm:flex-row justify-end gap-3 px-4 sm:px-6 py-4 border-t border-white/10 bg-white/5">
|
| 541 |
+
<button id="st-rerun-btn" onclick="rerunSpeedTest()" class="hidden btn-ui btn-primary">
|
| 542 |
+
🔄 Re-run
|
| 543 |
+
</button>
|
| 544 |
+
<button onclick="closeSpeedTest()" class="btn-ui btn-ghost">
|
| 545 |
+
Close
|
| 546 |
+
</button>
|
| 547 |
+
</div>
|
| 548 |
+
</div>
|
| 549 |
+
</div>
|
| 550 |
+
</div>
|
| 551 |
+
|
| 552 |
<script>
|
| 553 |
const tmdbId = {{ tmdb_id }};
|
| 554 |
const dbIndex = {{ db_index }};
|
| 555 |
const mediaType = '{{ media_type }}';
|
| 556 |
|
|
|
|
| 557 |
function toggleSeason(seasonIndex) {
|
| 558 |
const content = document.getElementById(`season-content-${seasonIndex}`);
|
| 559 |
const arrow = document.getElementById(`season-arrow-${seasonIndex}`);
|
| 560 |
+
if (!content || !arrow) return;
|
| 561 |
|
| 562 |
+
const collapsed = content.classList.contains('season-collapsed');
|
| 563 |
+
if (collapsed) {
|
| 564 |
+
content.classList.remove('season-collapsed');
|
| 565 |
arrow.style.transform = 'rotate(0deg)';
|
| 566 |
+
requestAnimationFrame(() => {
|
| 567 |
+
content.style.maxHeight = content.scrollHeight + 'px';
|
| 568 |
+
content.style.opacity = '1';
|
| 569 |
+
});
|
| 570 |
} else {
|
| 571 |
+
content.style.maxHeight = content.scrollHeight + 'px';
|
| 572 |
+
requestAnimationFrame(() => {
|
| 573 |
+
content.classList.add('season-collapsed');
|
| 574 |
+
content.style.maxHeight = '0px';
|
| 575 |
+
content.style.opacity = '0';
|
| 576 |
+
arrow.style.transform = 'rotate(-90deg)';
|
| 577 |
+
});
|
| 578 |
}
|
| 579 |
}
|
| 580 |
|
|
|
|
| 581 |
async function updateMedia(event) {
|
| 582 |
event.preventDefault();
|
| 583 |
|
| 584 |
const formData = new FormData(event.target);
|
| 585 |
const updateData = {};
|
| 586 |
|
|
|
|
| 587 |
for (let [key, value] of formData.entries()) {
|
| 588 |
if (key === 'genres') {
|
| 589 |
+
updateData[key] = value.split(',').map(g => g.trim()).filter(Boolean);
|
| 590 |
} else if (key === 'rating' || key === 'release_year' || key === 'runtime') {
|
| 591 |
updateData[key] = value ? parseFloat(value) : null;
|
| 592 |
} else {
|
|
|
|
| 597 |
try {
|
| 598 |
const response = await fetch(`/api/media/update?tmdb_id=${tmdbId}&db_index=${dbIndex}&media_type=${mediaType}`, {
|
| 599 |
method: 'PUT',
|
| 600 |
+
headers: { 'Content-Type': 'application/json' },
|
|
|
|
|
|
|
| 601 |
body: JSON.stringify(updateData)
|
| 602 |
});
|
| 603 |
|
| 604 |
if (response.ok) {
|
| 605 |
showSuccessMessage('Media updated successfully');
|
| 606 |
+
setTimeout(() => location.reload(), 900);
|
| 607 |
} else {
|
| 608 |
+
const error = await response.json().catch(() => ({}));
|
| 609 |
showErrorMessage(`Error updating media: ${error.detail || 'Unknown error'}`);
|
| 610 |
}
|
| 611 |
} catch (error) {
|
|
|
|
| 614 |
}
|
| 615 |
}
|
| 616 |
|
|
|
|
| 617 |
async function deleteQuality(id) {
|
| 618 |
+
if (!confirm(`Are you sure you want to delete ${id}?`)) return;
|
| 619 |
|
| 620 |
try {
|
| 621 |
const response = await fetch(`/api/media/delete-quality?tmdb_id=${tmdbId}&db_index=${dbIndex}&id=${encodeURIComponent(id)}`, {
|
|
|
|
| 624 |
|
| 625 |
if (response.ok) {
|
| 626 |
showSuccessMessage(`${id} deleted successfully`);
|
| 627 |
+
setTimeout(() => location.reload(), 900);
|
| 628 |
} else {
|
| 629 |
+
const error = await response.json().catch(() => ({}));
|
| 630 |
+
showErrorMessage(`Error deleting: ${error.detail || 'Unknown error'}`);
|
| 631 |
}
|
| 632 |
} catch (error) {
|
| 633 |
+
console.error('Error deleting:', error);
|
| 634 |
+
showErrorMessage('Error deleting. Please try again.');
|
| 635 |
}
|
| 636 |
}
|
| 637 |
|
|
|
|
| 638 |
async function deleteTVQuality(season, episode, id) {
|
| 639 |
+
if (!confirm(`Are you sure you want to delete ${id} from Season ${season} Episode ${episode}?`)) return;
|
| 640 |
|
| 641 |
try {
|
| 642 |
const response = await fetch(`/api/media/delete-tv-quality?tmdb_id=${tmdbId}&db_index=${dbIndex}&season=${season}&episode=${episode}&id=${encodeURIComponent(id)}`, {
|
|
|
|
| 645 |
|
| 646 |
if (response.ok) {
|
| 647 |
showSuccessMessage(`${id} deleted successfully`);
|
| 648 |
+
setTimeout(() => location.reload(), 900);
|
| 649 |
} else {
|
| 650 |
+
const error = await response.json().catch(() => ({}));
|
| 651 |
+
showErrorMessage(`Error deleting: ${error.detail || 'Unknown error'}`);
|
| 652 |
}
|
| 653 |
} catch (error) {
|
| 654 |
+
console.error('Error deleting:', error);
|
| 655 |
showErrorMessage('Error deleting. Please try again.');
|
| 656 |
}
|
| 657 |
}
|
| 658 |
|
|
|
|
| 659 |
async function deleteTVEpisode(season, episode) {
|
| 660 |
+
if (!confirm(`Delete Season ${season} Episode ${episode}? This removes the episode and all its qualities.`)) return;
|
| 661 |
|
| 662 |
try {
|
| 663 |
const response = await fetch(`/api/media/delete-tv-episode?tmdb_id=${tmdbId}&db_index=${dbIndex}&season=${season}&episode=${episode}`, {
|
|
|
|
| 666 |
|
| 667 |
if (response.ok) {
|
| 668 |
showSuccessMessage(`Episode ${episode} deleted successfully`);
|
| 669 |
+
setTimeout(() => location.reload(), 900);
|
| 670 |
} else {
|
| 671 |
+
const error = await response.json().catch(() => ({}));
|
| 672 |
showErrorMessage(`Error deleting episode: ${error.detail || 'Unknown error'}`);
|
| 673 |
}
|
| 674 |
} catch (error) {
|
|
|
|
| 677 |
}
|
| 678 |
}
|
| 679 |
|
|
|
|
| 680 |
async function deleteTVSeason(season) {
|
| 681 |
+
if (!confirm(`Delete the entire Season ${season}? This action cannot be undone.`)) return;
|
| 682 |
|
| 683 |
try {
|
| 684 |
const response = await fetch(`/api/media/delete-tv-season?tmdb_id=${tmdbId}&db_index=${dbIndex}&season=${season}`, {
|
|
|
|
| 687 |
|
| 688 |
if (response.ok) {
|
| 689 |
showSuccessMessage(`Season ${season} deleted successfully`);
|
| 690 |
+
setTimeout(() => location.reload(), 900);
|
| 691 |
} else {
|
| 692 |
+
const error = await response.json().catch(() => ({}));
|
| 693 |
showErrorMessage(`Error deleting season: ${error.detail || 'Unknown error'}`);
|
| 694 |
}
|
| 695 |
} catch (error) {
|
|
|
|
| 698 |
}
|
| 699 |
}
|
| 700 |
|
|
|
|
| 701 |
function showSuccessMessage(message) {
|
| 702 |
+
showToast(message, 'success', 'Success');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 703 |
}
|
| 704 |
|
|
|
|
| 705 |
function showErrorMessage(message) {
|
| 706 |
+
showToast(message, 'error', 'Error');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 707 |
}
|
| 708 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 709 |
function copyStreamLink(qualityId, fileName) {
|
|
|
|
|
|
|
| 710 |
const base = window.location.origin;
|
|
|
|
|
|
|
| 711 |
const token = getCopylinkToken();
|
| 712 |
+
|
| 713 |
if (!token) {
|
| 714 |
showErrorMessage('No API token found. Please copy the link from the Dashboard page.');
|
| 715 |
return;
|
|
|
|
| 717 |
|
| 718 |
const encodedName = encodeURIComponent(fileName || 'stream');
|
| 719 |
const url = `${base}/dl/${token}/${qualityId}/${encodedName}`;
|
| 720 |
+
|
| 721 |
navigator.clipboard.writeText(url).then(() => {
|
| 722 |
showSuccessMessage('Stream link copied to clipboard!');
|
| 723 |
}).catch(() => {
|
|
|
|
| 724 |
prompt('Copy this stream link:', url);
|
| 725 |
});
|
| 726 |
}
|
| 727 |
|
| 728 |
function getCopylinkToken() {
|
|
|
|
| 729 |
return sessionStorage.getItem('api_token') || localStorage.getItem('api_token') || null;
|
| 730 |
}
|
|
|
|
| 731 |
|
| 732 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 733 |
+
document.querySelectorAll('.season-content').forEach((content, index) => {
|
| 734 |
+
if (index > 0) {
|
| 735 |
+
content.classList.add('season-collapsed');
|
| 736 |
+
content.style.maxHeight = '0px';
|
| 737 |
+
content.style.opacity = '0';
|
| 738 |
+
const arrow = document.getElementById(`season-arrow-${index}`);
|
| 739 |
+
if (arrow) arrow.style.transform = 'rotate(-90deg)';
|
| 740 |
+
} else {
|
| 741 |
+
content.style.maxHeight = content.scrollHeight + 'px';
|
| 742 |
+
content.style.opacity = '1';
|
| 743 |
+
}
|
| 744 |
+
});
|
| 745 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 746 |
|
|
|
|
|
|
|
| 747 |
let _stQualityId = null;
|
| 748 |
let _stMediaType = null;
|
| 749 |
let _stLabel = null;
|
|
|
|
| 781 |
function closeSpeedTest() {
|
| 782 |
document.getElementById('speed-test-modal').classList.add('hidden');
|
| 783 |
document.body.style.overflow = '';
|
| 784 |
+
if (window._stEventSource) {
|
| 785 |
+
window._stEventSource.close();
|
| 786 |
+
window._stEventSource = null;
|
| 787 |
+
}
|
| 788 |
}
|
| 789 |
|
| 790 |
function _pingClass(ms) {
|
| 791 |
+
if (ms === null) return 'text-white/60';
|
| 792 |
+
if (ms < 100) return 'text-emerald-300 font-semibold';
|
| 793 |
+
if (ms < 300) return 'text-amber-300 font-semibold';
|
| 794 |
+
return 'text-rose-300 font-semibold';
|
| 795 |
}
|
| 796 |
|
| 797 |
function _speedClass(mbps) {
|
| 798 |
+
if (mbps === null) return 'text-white/60';
|
| 799 |
+
if (mbps >= 20) return 'text-emerald-300 font-bold';
|
| 800 |
+
if (mbps >= 5) return 'text-amber-300 font-bold';
|
| 801 |
+
return 'text-rose-300 font-bold';
|
| 802 |
}
|
| 803 |
|
| 804 |
function _miniBar(value, max, color) {
|
| 805 |
if (!value || !max) return '';
|
| 806 |
const pct = Math.min(100, (value / max) * 100).toFixed(1);
|
| 807 |
+
return `<div class="w-full bg-white/10 rounded-full h-1.5 mt-1 overflow-hidden">
|
| 808 |
+
<div class="${color} h-1.5 rounded-full transition-all" style="width:${pct}%"></div>
|
| 809 |
+
</div>`;
|
| 810 |
}
|
| 811 |
|
| 812 |
async function _exec() {
|
|
|
|
| 814 |
quality_id: _stQualityId,
|
| 815 |
tmdb_id: tmdbId,
|
| 816 |
db_index: dbIndex,
|
| 817 |
+
media_type: _stMediaType || mediaType
|
| 818 |
});
|
| 819 |
|
|
|
|
| 820 |
if (window._stEventSource) {
|
| 821 |
window._stEventSource.close();
|
| 822 |
window._stEventSource = null;
|
|
|
|
| 834 |
function updateSummary() {
|
| 835 |
const best = allResults.filter(r => r.speed_mbps).sort((a, b) => b.speed_mbps - a.speed_mbps)[0];
|
| 836 |
const summaryEl = document.getElementById('st-summary');
|
| 837 |
+
if (!summaryEl) return;
|
| 838 |
+
|
| 839 |
if (best) {
|
| 840 |
+
summaryEl.textContent = `🏆 Fastest: DC ${best.dc_id} — ${best.speed_mbps.toFixed(2)} MB/s | ${completedCount}/${totalCount} client(s) done`;
|
| 841 |
} else {
|
| 842 |
summaryEl.textContent = `${completedCount}/${totalCount} client(s) done`;
|
| 843 |
}
|
|
|
|
| 853 |
document.getElementById('st-error').textContent = `Speed test stream error: ${msg.message}`;
|
| 854 |
document.getElementById('st-error').classList.remove('hidden');
|
| 855 |
document.getElementById('st-rerun-btn').classList.remove('hidden');
|
| 856 |
+
showToast(msg.message || 'Speed test failed.', 'error', 'Speed Test Error');
|
| 857 |
return;
|
| 858 |
}
|
| 859 |
|
|
|
|
| 872 |
const tr = document.createElement('tr');
|
| 873 |
tr.className = 'animate-pulse';
|
| 874 |
tr.innerHTML = `
|
| 875 |
+
<td class="px-4 py-3 font-medium text-white/40">🔄 Bot ${i + 1}</td>
|
| 876 |
+
<td class="px-4 py-3"><span class="text-white/30">testing…</span></td>
|
| 877 |
+
<td class="px-4 py-3"><span class="text-white/30">testing…</span></td>
|
| 878 |
+
<td class="px-4 py-3 text-white/30">—</td>
|
| 879 |
+
<td class="px-4 py-3 text-white/30">—</td>
|
| 880 |
+
<td class="px-4 py-3"><span class="px-2 py-0.5 rounded-full text-xs bg-white/10 text-white/50">Pending</span></td>`;
|
| 881 |
tbody.appendChild(tr);
|
| 882 |
pendingRows[i] = tr;
|
| 883 |
}
|
|
|
|
| 889 |
const tr = pendingRows[r.client_index];
|
| 890 |
if (tr) {
|
| 891 |
maxSpeed = Math.max(maxSpeed, r.speed_mbps || 0, 1);
|
| 892 |
+
const isErr = !!r.error && !r.speed_mbps;
|
| 893 |
+
const medal = '';
|
| 894 |
+
const dc = `Bot ${r.client_index + 1} <span class="text-xs text-white/45">(DC ${r.dc_id})</span>`;
|
| 895 |
+
const ping = r.ping_ms !== null ? `<span class="${_pingClass(r.ping_ms)}">${r.ping_ms} ms</span>` : '<span class="text-white/60">—</span>';
|
| 896 |
const speed = r.speed_mbps !== null
|
| 897 |
? `<span class="${_speedClass(r.speed_mbps)}">${r.speed_mbps.toFixed(2)} MB/s</span>
|
| 898 |
+
${_miniBar(r.speed_mbps, maxSpeed, r.speed_mbps >= 20 ? 'bg-emerald-400' : r.speed_mbps >= 5 ? 'bg-amber-300' : 'bg-rose-300')}`
|
| 899 |
+
: '<span class="text-white/60">—</span>';
|
| 900 |
const taken = r.time_taken_sec !== null ? `${r.time_taken_sec.toFixed(2)}s` : '—';
|
| 901 |
const bytes = r.bytes_downloaded ? `${(r.bytes_downloaded / 1048576).toFixed(2)} MB` : '—';
|
| 902 |
+
const badge = isErr
|
| 903 |
+
? `<span class="px-2 py-0.5 rounded-full text-xs font-medium bg-rose-500/15 text-rose-200 border border-rose-500/20">Error</span>`
|
| 904 |
+
: `<span class="px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-500/15 text-emerald-200 border border-emerald-500/20">✓ OK</span>`;
|
| 905 |
+
|
| 906 |
+
const newTr = document.createElement('tr');
|
| 907 |
+
newTr.className = `transition-colors ${isErr ? 'opacity-70' : ''}`;
|
| 908 |
+
newTr.innerHTML = `
|
| 909 |
+
<td class="px-4 py-3 font-medium text-white">${medal}${dc}</td>
|
| 910 |
+
<td class="px-4 py-3 text-white/90">${ping}</td>
|
| 911 |
+
<td class="px-4 py-3 text-white/90">${speed}${isErr ? `<div class="text-xs text-rose-300 mt-1">${r.error}</div>` : ''}</td>
|
| 912 |
+
<td class="px-4 py-3 text-white/70 text-sm">${taken}</td>
|
| 913 |
+
<td class="px-4 py-3 text-white/60 text-xs">${bytes}</td>
|
| 914 |
+
<td class="px-4 py-3">${badge}</td>`;
|
| 915 |
|
| 916 |
+
if (pendingRows[r.client_index]) {
|
| 917 |
+
pendingRows[r.client_index].replaceWith(newTr);
|
| 918 |
+
delete pendingRows[r.client_index];
|
| 919 |
+
} else {
|
| 920 |
+
document.getElementById('st-tbody').appendChild(newTr);
|
| 921 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 922 |
|
| 923 |
+
allResults.push(r);
|
| 924 |
+
completedCount += 1;
|
| 925 |
+
updateSummary();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 926 |
}
|
|
|
|
|
|
|
| 927 |
}
|
| 928 |
|
| 929 |
if (msg.type === 'done') {
|
| 930 |
es.close();
|
| 931 |
window._stEventSource = null;
|
| 932 |
|
|
|
|
| 933 |
allResults.sort((a, b) => (b.speed_mbps || 0) - (a.speed_mbps || 0));
|
|
|
|
| 934 |
const tbody = document.getElementById('st-tbody');
|
| 935 |
tbody.innerHTML = '';
|
| 936 |
|
|
|
|
| 938 |
const r = allResults[i];
|
| 939 |
const isErr = !!r.error && !r.speed_mbps;
|
| 940 |
const medal = i === 0 && !isErr ? '🥇 ' : '';
|
| 941 |
+
const dc = `Bot ${r.client_index + 1} <span class="text-xs text-white/45">(DC ${r.dc_id})</span>`;
|
| 942 |
+
const ping = r.ping_ms !== null ? `<span class="${_pingClass(r.ping_ms)}">${r.ping_ms} ms</span>` : '<span class="text-white/60">—</span>';
|
| 943 |
const speed = r.speed_mbps !== null
|
| 944 |
? `<span class="${_speedClass(r.speed_mbps)}">${r.speed_mbps.toFixed(2)} MB/s</span>
|
| 945 |
+
${_miniBar(r.speed_mbps, maxSpeed, r.speed_mbps >= 20 ? 'bg-emerald-400' : r.speed_mbps >= 5 ? 'bg-amber-300' : 'bg-rose-300')}`
|
| 946 |
+
: '<span class="text-white/60">—</span>';
|
| 947 |
const taken = r.time_taken_sec !== null ? `${r.time_taken_sec.toFixed(2)}s` : '—';
|
| 948 |
const bytes = r.bytes_downloaded ? `${(r.bytes_downloaded / 1048576).toFixed(2)} MB` : '—';
|
| 949 |
const badge = isErr
|
| 950 |
+
? `<span class="px-2 py-0.5 rounded-full text-xs font-medium bg-rose-500/15 text-rose-200 border border-rose-500/20">Error</span>`
|
| 951 |
+
: `<span class="px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-500/15 text-emerald-200 border border-emerald-500/20">✓ OK</span>`;
|
| 952 |
|
| 953 |
const tr = document.createElement('tr');
|
| 954 |
+
tr.className = `transition-colors ${isErr ? 'opacity-70' : ''}`;
|
| 955 |
tr.innerHTML = `
|
| 956 |
+
<td class="px-4 py-3 font-medium text-white">${medal}${dc}</td>
|
| 957 |
+
<td class="px-4 py-3 text-white/90">${ping}</td>
|
| 958 |
+
<td class="px-4 py-3 text-white/90">${speed}${isErr ? `<div class="text-xs text-rose-300 mt-1">${r.error}</div>` : ''}</td>
|
| 959 |
+
<td class="px-4 py-3 text-white/70 text-sm">${taken}</td>
|
| 960 |
+
<td class="px-4 py-3 text-white/60 text-xs">${bytes}</td>
|
| 961 |
<td class="px-4 py-3">${badge}</td>`;
|
| 962 |
tbody.appendChild(tr);
|
| 963 |
}
|
| 964 |
|
| 965 |
document.getElementById('st-rerun-btn').classList.remove('hidden');
|
| 966 |
updateSummary();
|
| 967 |
+
showToast('Speed test completed.', 'success', 'Speed Test');
|
| 968 |
}
|
| 969 |
};
|
| 970 |
|
| 971 |
+
es.onerror = () => {
|
| 972 |
es.close();
|
| 973 |
window._stEventSource = null;
|
| 974 |
if (completedCount === 0) {
|
| 975 |
document.getElementById('st-spinner').classList.add('hidden');
|
| 976 |
document.getElementById('st-error').textContent = 'Live tracking connection failed or interrupted.';
|
| 977 |
document.getElementById('st-error').classList.remove('hidden');
|
| 978 |
+
showToast('Live tracking connection failed or interrupted.', 'error', 'Speed Test Error');
|
| 979 |
}
|
| 980 |
document.getElementById('st-rerun-btn').classList.remove('hidden');
|
| 981 |
};
|
| 982 |
}
|
| 983 |
|
| 984 |
+
document.addEventListener('keydown', e => {
|
| 985 |
+
if (e.key === 'Escape') closeSpeedTest();
|
| 986 |
+
});
|
| 987 |
</script>
|
| 988 |
+
{% endblock %}
|
|
|
Backend/fastapi/templates/media_management.html
CHANGED
|
@@ -3,109 +3,162 @@
|
|
| 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 |
-
<
|
| 9 |
-
<div>
|
| 10 |
-
<
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
| 23 |
</div>
|
| 24 |
-
</
|
| 25 |
|
| 26 |
<!-- Search and Filters -->
|
| 27 |
-
<
|
| 28 |
-
<div class="flex flex-col
|
| 29 |
<div class="flex-1">
|
| 30 |
-
<
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
</div>
|
| 33 |
-
|
|
|
|
| 34 |
<button onclick="searchMedia()"
|
| 35 |
-
|
|
|
|
| 36 |
Search
|
| 37 |
</button>
|
| 38 |
<button onclick="clearSearch()"
|
| 39 |
-
|
|
|
|
| 40 |
Clear
|
| 41 |
</button>
|
| 42 |
</div>
|
| 43 |
</div>
|
| 44 |
-
</
|
| 45 |
|
| 46 |
<!-- Loading Indicator -->
|
| 47 |
-
<div id="loading" class="text-center py-
|
| 48 |
-
<div class="inline-
|
| 49 |
-
|
|
|
|
|
|
|
| 50 |
</div>
|
| 51 |
|
| 52 |
<!-- Error Display -->
|
| 53 |
-
<div id="error-display" class="hidden mb-8">
|
| 54 |
-
<div class="
|
| 55 |
-
<div class="flex items-
|
| 56 |
-
<
|
| 57 |
-
<
|
| 58 |
-
|
| 59 |
-
<
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 73 |
-
<!-- Media items will be loaded here
|
| 74 |
</div>
|
| 75 |
|
| 76 |
-
<!-- No Results
|
| 77 |
-
<div id="no-results" class="text-center py-
|
| 78 |
-
<div class="
|
| 79 |
-
<
|
| 80 |
-
<
|
| 81 |
-
|
| 82 |
-
</
|
| 83 |
-
<
|
| 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 |
-
|
|
|
|
| 93 |
Show All {{ media_type|title }}s
|
| 94 |
</button>
|
| 95 |
</div>
|
| 96 |
</div>
|
| 97 |
|
| 98 |
<!-- Pagination -->
|
| 99 |
-
<div id="pagination" class="
|
| 100 |
-
<
|
|
|
|
|
|
|
| 101 |
</div>
|
| 102 |
|
| 103 |
<!-- Media Info -->
|
| 104 |
-
<div id="media-info" class="
|
| 105 |
-
<div
|
| 106 |
-
class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-2 text-sm
|
| 107 |
-
|
| 108 |
-
|
|
|
|
| 109 |
</div>
|
| 110 |
</div>
|
| 111 |
</div>
|
|
@@ -116,7 +169,6 @@
|
|
| 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');
|
|
@@ -127,25 +179,24 @@
|
|
| 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;
|
| 149 |
|
| 150 |
showLoading();
|
| 151 |
currentPage = page;
|
|
@@ -153,8 +204,6 @@
|
|
| 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',
|
|
@@ -164,8 +213,6 @@
|
|
| 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';
|
|
@@ -175,8 +222,6 @@
|
|
| 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');
|
|
@@ -192,58 +237,59 @@
|
|
| 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 |
-
|
| 213 |
function createMediaCard(item) {
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
<
|
| 235 |
-
|
| 236 |
-
<span>${
|
| 237 |
-
${rating ? `<span>${rating}</span>` : ''}
|
| 238 |
</div>
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
|
|
|
| 243 |
</a>
|
| 244 |
-
<button onclick="deleteMedia(
|
| 245 |
-
|
| 246 |
-
|
|
|
|
|
|
|
|
|
|
| 247 |
</button>
|
| 248 |
</div>
|
| 249 |
</div>
|
|
@@ -251,179 +297,168 @@
|
|
| 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 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 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 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
if (startPage > 2) {
|
| 289 |
-
paginationHTML += `<span class="px-
|
| 290 |
}
|
| 291 |
}
|
| 292 |
|
| 293 |
-
// Page range
|
| 294 |
for (let i = startPage; i <= endPage; i++) {
|
| 295 |
const isActive = i === currentPage;
|
| 296 |
paginationHTML += `
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
|
|
|
|
|
|
| 303 |
}
|
| 304 |
|
| 305 |
-
// Last page
|
| 306 |
if (endPage < totalPages) {
|
| 307 |
if (endPage < totalPages - 1) {
|
| 308 |
-
paginationHTML += `<span class="px-
|
| 309 |
}
|
| 310 |
paginationHTML += `
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
}
|
| 317 |
|
| 318 |
-
// Next button
|
| 319 |
if (currentPage < totalPages) {
|
| 320 |
paginationHTML += `
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
}
|
| 327 |
|
| 328 |
-
|
| 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
|
| 338 |
-
const
|
|
|
|
|
|
|
|
|
|
| 339 |
|
| 340 |
-
resultsInfo.textContent = `Showing ${startItem}-${endItem} of ${
|
| 341 |
|
| 342 |
if (data.databases_checked && data.databases_checked.length > 0) {
|
| 343 |
-
dbInfo.textContent = `
|
|
|
|
|
|
|
| 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 |
-
|
| 368 |
-
|
| 369 |
-
|
|
|
|
| 370 |
|
| 371 |
-
|
| 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 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 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 |
-
}
|
| 399 |
-
|
| 400 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 401 |
}
|
|
|
|
|
|
|
|
|
|
| 402 |
}
|
|
|
|
| 403 |
|
| 404 |
-
// Initialize page
|
| 405 |
document.addEventListener('DOMContentLoaded', () => {
|
| 406 |
-
// Load media on page load
|
| 407 |
loadMedia();
|
| 408 |
|
| 409 |
-
|
| 410 |
-
|
|
|
|
| 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 |
-
|
| 420 |
clearTimeout(searchTimeout);
|
| 421 |
const searchValue = e.target.value.trim();
|
| 422 |
|
| 423 |
if (searchValue.length === 0) {
|
| 424 |
searchTimeout = setTimeout(() => {
|
| 425 |
loadMedia(1, '');
|
| 426 |
-
},
|
| 427 |
}
|
| 428 |
});
|
| 429 |
});
|
|
@@ -437,44 +472,22 @@
|
|
| 437 |
overflow: hidden;
|
| 438 |
}
|
| 439 |
|
| 440 |
-
.aspect-
|
| 441 |
-
|
| 442 |
-
padding-bottom: 150%;
|
| 443 |
-
/* 2:3 aspect ratio */
|
| 444 |
}
|
| 445 |
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
width: 100%;
|
| 450 |
-
top: 0;
|
| 451 |
-
right: 0;
|
| 452 |
-
bottom: 0;
|
| 453 |
-
left: 0;
|
| 454 |
}
|
| 455 |
|
| 456 |
-
|
| 457 |
-
|
| 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 |
-
.
|
| 477 |
-
|
|
|
|
| 478 |
}
|
| 479 |
</style>
|
| 480 |
-
{% endblock %}
|
|
|
|
| 3 |
{% block title %}Media Management - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
+
<div class="w-full max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
| 7 |
<!-- Header -->
|
| 8 |
+
<section class="glass-panel rounded-3xl p-5 sm:p-6 lg:p-8 mb-6 sm:mb-8">
|
| 9 |
+
<div class="flex flex-col gap-5">
|
| 10 |
+
<div class="flex flex-col md:flex-row md:items-end md:justify-between gap-4">
|
| 11 |
+
<div>
|
| 12 |
+
<div class="inline-flex items-center gap-2 px-3 py-1 rounded-full border border-white/10 bg-white/5 text-xs font-semibold text-text-secondary mb-3">
|
| 13 |
+
<i class="fa-solid fa-clapperboard text-primary"></i>
|
| 14 |
+
Library Control
|
| 15 |
+
</div>
|
| 16 |
+
<h1 class="text-2xl sm:text-3xl lg:text-4xl font-extrabold tracking-tight text-text">
|
| 17 |
+
Media Management
|
| 18 |
+
</h1>
|
| 19 |
+
<p class="mt-2 text-sm sm:text-base text-text-secondary max-w-2xl">
|
| 20 |
+
Manage your movie and TV show collections with search, filters, edit, and delete controls.
|
| 21 |
+
</p>
|
| 22 |
+
</div>
|
| 23 |
+
|
| 24 |
+
<div class="flex flex-wrap gap-2">
|
| 25 |
+
<a href="/media/manage?media_type=movie"
|
| 26 |
+
class="inline-flex items-center gap-2 px-4 py-2.5 rounded-full text-sm font-bold transition border
|
| 27 |
+
{% if media_type == 'movie' %}
|
| 28 |
+
bg-primary text-white border-primary shadow-lg shadow-primary/20
|
| 29 |
+
{% else %}
|
| 30 |
+
glass-panel text-text hover:bg-white/10 border-white/10
|
| 31 |
+
{% endif %}">
|
| 32 |
+
<i class="fa-solid fa-film"></i>
|
| 33 |
+
Movies
|
| 34 |
+
</a>
|
| 35 |
+
<a href="/media/manage?media_type=tv"
|
| 36 |
+
class="inline-flex items-center gap-2 px-4 py-2.5 rounded-full text-sm font-bold transition border
|
| 37 |
+
{% if media_type == 'tv' %}
|
| 38 |
+
bg-primary text-white border-primary shadow-lg shadow-primary/20
|
| 39 |
+
{% else %}
|
| 40 |
+
glass-panel text-text hover:bg-white/10 border-white/10
|
| 41 |
+
{% endif %}">
|
| 42 |
+
<i class="fa-solid fa-tv"></i>
|
| 43 |
+
TV Shows
|
| 44 |
+
</a>
|
| 45 |
+
</div>
|
| 46 |
+
</div>
|
| 47 |
|
| 48 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-3">
|
| 49 |
+
<div class="rounded-2xl border border-white/10 bg-white/5 px-4 py-3">
|
| 50 |
+
<p class="text-[11px] uppercase tracking-wider text-text-secondary font-bold">Current view</p>
|
| 51 |
+
<p class="mt-1 text-sm font-semibold text-text capitalize">{{ media_type }}</p>
|
| 52 |
+
</div>
|
| 53 |
+
<div class="rounded-2xl border border-white/10 bg-white/5 px-4 py-3">
|
| 54 |
+
<p class="text-[11px] uppercase tracking-wider text-text-secondary font-bold">Actions</p>
|
| 55 |
+
<p class="mt-1 text-sm font-semibold text-text">Search, Edit, Delete</p>
|
| 56 |
+
</div>
|
| 57 |
+
</div>
|
| 58 |
</div>
|
| 59 |
+
</section>
|
| 60 |
|
| 61 |
<!-- Search and Filters -->
|
| 62 |
+
<section class="glass-panel rounded-3xl p-4 sm:p-6 mb-6 sm:mb-8">
|
| 63 |
+
<div class="flex flex-col lg:flex-row gap-4 lg:items-center">
|
| 64 |
<div class="flex-1">
|
| 65 |
+
<label for="search-input" class="block text-xs font-bold uppercase tracking-wider text-text-secondary mb-2">
|
| 66 |
+
Search {{ media_type|title }}
|
| 67 |
+
</label>
|
| 68 |
+
<div class="relative">
|
| 69 |
+
<i class="fa-solid fa-magnifying-glass absolute left-4 top-1/2 -translate-y-1/2 text-text-secondary text-sm"></i>
|
| 70 |
+
<input type="text"
|
| 71 |
+
id="search-input"
|
| 72 |
+
placeholder="Search {{ media_type }}s by title..."
|
| 73 |
+
class="w-full pl-11 pr-4 py-3 rounded-2xl bg-background text-text placeholder:text-text-secondary border border-border focus:outline-none focus:ring-2 focus:ring-primary/60 focus:border-primary transition shadow-sm">
|
| 74 |
+
</div>
|
| 75 |
</div>
|
| 76 |
+
|
| 77 |
+
<div class="flex flex-col sm:flex-row gap-3 lg:pt-7">
|
| 78 |
<button onclick="searchMedia()"
|
| 79 |
+
class="inline-flex justify-center items-center gap-2 bg-primary hover:bg-primary/90 text-white px-5 py-3 rounded-2xl transition font-bold shadow-lg shadow-primary/20">
|
| 80 |
+
<i class="fa-solid fa-magnifying-glass"></i>
|
| 81 |
Search
|
| 82 |
</button>
|
| 83 |
<button onclick="clearSearch()"
|
| 84 |
+
class="inline-flex justify-center items-center gap-2 glass-panel hover:bg-white/10 text-text px-5 py-3 rounded-2xl transition font-bold border border-white/10">
|
| 85 |
+
<i class="fa-solid fa-rotate-left"></i>
|
| 86 |
Clear
|
| 87 |
</button>
|
| 88 |
</div>
|
| 89 |
</div>
|
| 90 |
+
</section>
|
| 91 |
|
| 92 |
<!-- Loading Indicator -->
|
| 93 |
+
<div id="loading" class="hidden text-center py-16">
|
| 94 |
+
<div class="inline-flex items-center justify-center w-14 h-14 rounded-full border border-white/10 glass-panel mb-4">
|
| 95 |
+
<div class="animate-spin rounded-full h-7 w-7 border-b-2 border-primary"></div>
|
| 96 |
+
</div>
|
| 97 |
+
<p class="text-text-secondary">Loading {{ media_type }}s...</p>
|
| 98 |
</div>
|
| 99 |
|
| 100 |
<!-- Error Display -->
|
| 101 |
+
<div id="error-display" class="hidden mb-6 sm:mb-8">
|
| 102 |
+
<div class="glass-panel rounded-3xl p-5 sm:p-6 border border-red-500/30">
|
| 103 |
+
<div class="flex items-start gap-3">
|
| 104 |
+
<div class="w-11 h-11 rounded-2xl bg-red-500/15 flex items-center justify-center shrink-0">
|
| 105 |
+
<i class="fa-solid fa-triangle-exclamation text-red-400"></i>
|
| 106 |
+
</div>
|
| 107 |
+
<div class="flex-1">
|
| 108 |
+
<h3 class="text-lg font-bold text-red-300">Error Loading Media</h3>
|
| 109 |
+
<p id="error-message" class="mt-2 text-sm text-red-200/90"></p>
|
| 110 |
+
<button onclick="retryLoad()"
|
| 111 |
+
class="mt-4 inline-flex items-center gap-2 bg-primary hover:bg-primary/90 text-white px-4 py-2.5 rounded-2xl transition font-bold shadow-lg shadow-primary/20">
|
| 112 |
+
<i class="fa-solid fa-rotate-right"></i>
|
| 113 |
+
Try Again
|
| 114 |
+
</button>
|
| 115 |
+
</div>
|
| 116 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
</div>
|
| 118 |
</div>
|
| 119 |
|
| 120 |
<!-- Media Grid -->
|
| 121 |
<div id="media-grid"
|
| 122 |
+
class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4 sm:gap-5 mb-6 sm:mb-8">
|
| 123 |
+
<!-- Media items will be loaded here -->
|
| 124 |
</div>
|
| 125 |
|
| 126 |
+
<!-- No Results -->
|
| 127 |
+
<div id="no-results" class="hidden text-center py-16">
|
| 128 |
+
<div class="glass-panel rounded-3xl p-8 max-w-xl mx-auto">
|
| 129 |
+
<div class="mx-auto w-16 h-16 rounded-2xl bg-white/5 flex items-center justify-center mb-4 border border-white/10">
|
| 130 |
+
<i class="fa-solid fa-box-open text-3xl text-text-secondary"></i>
|
| 131 |
+
</div>
|
| 132 |
+
<h3 class="text-xl font-bold text-text mb-2">No {{ media_type }}s found</h3>
|
| 133 |
+
<p class="text-sm text-text-secondary mb-6">
|
|
|
|
| 134 |
{% if media_type == 'movie' %}
|
| 135 |
+
No movies match your search criteria.
|
| 136 |
{% else %}
|
| 137 |
+
No TV shows match your search criteria.
|
| 138 |
{% endif %}
|
| 139 |
</p>
|
| 140 |
<button onclick="clearSearch()"
|
| 141 |
+
class="inline-flex items-center gap-2 bg-primary hover:bg-primary/90 text-white px-5 py-3 rounded-2xl transition font-bold shadow-lg shadow-primary/20">
|
| 142 |
+
<i class="fa-solid fa-clapperboard"></i>
|
| 143 |
Show All {{ media_type|title }}s
|
| 144 |
</button>
|
| 145 |
</div>
|
| 146 |
</div>
|
| 147 |
|
| 148 |
<!-- Pagination -->
|
| 149 |
+
<div id="pagination" class="hidden mt-6 sm:mt-8">
|
| 150 |
+
<div class="glass-panel rounded-3xl p-3 sm:p-4 overflow-x-auto">
|
| 151 |
+
<div class="flex justify-center items-center gap-2 min-w-max px-1" id="pagination-inner"></div>
|
| 152 |
+
</div>
|
| 153 |
</div>
|
| 154 |
|
| 155 |
<!-- Media Info -->
|
| 156 |
+
<div id="media-info" class="hidden mt-6">
|
| 157 |
+
<div class="glass-panel rounded-3xl p-4 sm:p-5">
|
| 158 |
+
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-2 text-sm text-text-secondary">
|
| 159 |
+
<span id="results-info"></span>
|
| 160 |
+
<span id="db-info"></span>
|
| 161 |
+
</div>
|
| 162 |
</div>
|
| 163 |
</div>
|
| 164 |
</div>
|
|
|
|
| 169 |
let isLoading = false;
|
| 170 |
const mediaType = '{{ media_type }}';
|
| 171 |
|
|
|
|
| 172 |
function showLoading() {
|
| 173 |
isLoading = true;
|
| 174 |
document.getElementById('loading').classList.remove('hidden');
|
|
|
|
| 179 |
document.getElementById('error-display').classList.add('hidden');
|
| 180 |
}
|
| 181 |
|
|
|
|
| 182 |
function hideLoading() {
|
| 183 |
isLoading = false;
|
| 184 |
document.getElementById('loading').classList.add('hidden');
|
| 185 |
document.getElementById('media-grid').classList.remove('hidden');
|
| 186 |
}
|
| 187 |
|
|
|
|
| 188 |
function showError(message) {
|
| 189 |
document.getElementById('error-message').textContent = message;
|
| 190 |
document.getElementById('error-display').classList.remove('hidden');
|
| 191 |
document.getElementById('loading').classList.add('hidden');
|
| 192 |
document.getElementById('media-grid').classList.add('hidden');
|
| 193 |
document.getElementById('no-results').classList.add('hidden');
|
| 194 |
+
document.getElementById('pagination').classList.add('hidden');
|
| 195 |
+
document.getElementById('media-info').classList.add('hidden');
|
| 196 |
}
|
| 197 |
|
|
|
|
| 198 |
async function loadMedia(page = 1, search = '') {
|
| 199 |
+
if (isLoading) return;
|
| 200 |
|
| 201 |
showLoading();
|
| 202 |
currentPage = page;
|
|
|
|
| 204 |
|
| 205 |
try {
|
| 206 |
const url = `/api/media/list?media_type=${mediaType}&page=${page}&page_size=24&search=${encodeURIComponent(search)}`;
|
|
|
|
|
|
|
| 207 |
const response = await fetch(url, {
|
| 208 |
method: 'GET',
|
| 209 |
credentials: 'same-origin',
|
|
|
|
| 213 |
}
|
| 214 |
});
|
| 215 |
|
|
|
|
|
|
|
| 216 |
if (!response.ok) {
|
| 217 |
if (response.status === 401) {
|
| 218 |
window.location.href = '/login';
|
|
|
|
| 222 |
}
|
| 223 |
|
| 224 |
const data = await response.json();
|
|
|
|
|
|
|
| 225 |
hideLoading();
|
| 226 |
|
| 227 |
const grid = document.getElementById('media-grid');
|
|
|
|
| 237 |
}
|
| 238 |
|
| 239 |
document.getElementById('no-results').classList.add('hidden');
|
|
|
|
|
|
|
| 240 |
grid.innerHTML = mediaItems.map(item => createMediaCard(item)).join('');
|
|
|
|
|
|
|
| 241 |
updatePagination(data.current_page || page, data.total_pages || 1);
|
|
|
|
|
|
|
| 242 |
updateMediaInfo(data);
|
| 243 |
|
| 244 |
} catch (error) {
|
| 245 |
console.error('Error loading media:', error);
|
| 246 |
hideLoading();
|
| 247 |
showError(`Failed to load ${mediaType}s: ${error.message}`);
|
| 248 |
+
showToast(`Failed to load ${mediaType}s.`, 'error', 'Load Error');
|
| 249 |
}
|
| 250 |
}
|
| 251 |
|
| 252 |
+
|
| 253 |
function createMediaCard(item) {
|
| 254 |
+
const title = item.title || item.name || 'Unknown Title';
|
| 255 |
+
const year = item.release_year || 'Unknown Year';
|
| 256 |
+
const rating = item.rating ? `⭐ ${parseFloat(item.rating).toFixed(1)}` : '';
|
| 257 |
+
const poster = item.poster || 'https://via.placeholder.com/300x450/e5e7eb/9ca3af?text=No+Image';
|
| 258 |
+
|
| 259 |
+
// Escape title for data attribute safety
|
| 260 |
+
const safeTitle = title.replace(/"/g, '"');
|
| 261 |
+
|
| 262 |
+
return `
|
| 263 |
+
<div class="group overflow-hidden rounded-3xl glass-panel border border-white/10 hover:border-primary/30 transition-all duration-300 hover:-translate-y-1 hover:shadow-2xl">
|
| 264 |
+
<div class="relative overflow-hidden">
|
| 265 |
+
<img src="${poster}" alt="${title}" class="w-full aspect-[2/3] object-cover transition duration-300 group-hover:scale-105" onerror="this.src='https://via.placeholder.com/300x450/e5e7eb/9ca3af?text=No+Image'" loading="lazy">
|
| 266 |
+
<div class="absolute inset-0 bg-gradient-to-t from-black/80 via-black/10 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div>
|
| 267 |
+
|
| 268 |
+
<div class="absolute top-3 left-3">
|
| 269 |
+
<span class="inline-flex items-center gap-1 px-2.5 py-1 rounded-full bg-black/60 text-white text-[11px] font-bold backdrop-blur-md border border-white/10">
|
| 270 |
+
<i class="fa-solid fa-calendar-days"></i> ${year}
|
| 271 |
+
</span>
|
| 272 |
</div>
|
|
|
|
| 273 |
</div>
|
| 274 |
+
|
| 275 |
+
<div class="p-4">
|
| 276 |
+
<h3 class="font-bold text-sm sm:text-base text-text line-clamp-2 min-h-[2.75rem]" title="${title}">${title}</h3>
|
| 277 |
+
<div class="mt-2 flex items-center justify-between text-xs text-text-secondary">
|
| 278 |
+
<span>DB #${item.db_index ?? '-'}</span>
|
| 279 |
+
<span>${mediaType === 'movie' ? 'Movie' : 'TV Show'}</span>
|
|
|
|
| 280 |
</div>
|
| 281 |
+
|
| 282 |
+
<div class="mt-4 flex gap-2">
|
| 283 |
+
<a href="/media/edit?tmdb_id=${encodeURIComponent(item.tmdb_id)}&db_index=${encodeURIComponent(item.db_index)}&media_type=${encodeURIComponent(mediaType)}"
|
| 284 |
+
class="flex-1 inline-flex items-center justify-center gap-2 px-3 py-2 rounded-2xl bg-primary hover:bg-primary/90 text-white text-xs font-bold transition shadow-lg shadow-primary/20">
|
| 285 |
+
<i class="fa-solid fa-pen-to-square"></i> Edit
|
| 286 |
</a>
|
| 287 |
+
<button onclick="deleteMedia(this)"
|
| 288 |
+
data-tmdb-id="${item.tmdb_id}"
|
| 289 |
+
data-db-index="${item.db_index ?? ''}"
|
| 290 |
+
data-title="${safeTitle}"
|
| 291 |
+
class="inline-flex items-center justify-center gap-2 px-3 py-2 rounded-2xl glass-panel hover:bg-red-500/10 text-red-300 text-xs font-bold transition border border-white/10">
|
| 292 |
+
<i class="fa-solid fa-trash"></i>
|
| 293 |
</button>
|
| 294 |
</div>
|
| 295 |
</div>
|
|
|
|
| 297 |
`;
|
| 298 |
}
|
| 299 |
|
|
|
|
| 300 |
function updatePagination(currentPage, totalPages) {
|
| 301 |
const pagination = document.getElementById('pagination');
|
| 302 |
+
const paginationInner = document.getElementById('pagination-inner');
|
| 303 |
|
| 304 |
if (totalPages <= 1) {
|
| 305 |
pagination.classList.add('hidden');
|
| 306 |
+
paginationInner.innerHTML = '';
|
| 307 |
return;
|
| 308 |
}
|
| 309 |
|
| 310 |
pagination.classList.remove('hidden');
|
| 311 |
let paginationHTML = '';
|
| 312 |
|
|
|
|
| 313 |
if (currentPage > 1) {
|
| 314 |
paginationHTML += `
|
| 315 |
+
<button onclick='loadMedia(${currentPage - 1}, ${JSON.stringify(currentSearch)})'
|
| 316 |
+
class="px-4 py-2 rounded-2xl glass-panel hover:bg-white/10 text-text text-sm font-bold transition border border-white/10">
|
| 317 |
+
Previous
|
| 318 |
+
</button>
|
| 319 |
+
`;
|
| 320 |
}
|
| 321 |
|
|
|
|
| 322 |
const startPage = Math.max(1, currentPage - 2);
|
| 323 |
const endPage = Math.min(totalPages, currentPage + 2);
|
| 324 |
|
|
|
|
| 325 |
if (startPage > 1) {
|
| 326 |
paginationHTML += `
|
| 327 |
+
<button onclick='loadMedia(1, ${JSON.stringify(currentSearch)})'
|
| 328 |
+
class="px-4 py-2 rounded-2xl glass-panel hover:bg-white/10 text-text text-sm font-bold transition border border-white/10">
|
| 329 |
+
1
|
| 330 |
+
</button>
|
| 331 |
+
`;
|
| 332 |
if (startPage > 2) {
|
| 333 |
+
paginationHTML += `<span class="px-2 text-text-secondary text-sm">...</span>`;
|
| 334 |
}
|
| 335 |
}
|
| 336 |
|
|
|
|
| 337 |
for (let i = startPage; i <= endPage; i++) {
|
| 338 |
const isActive = i === currentPage;
|
| 339 |
paginationHTML += `
|
| 340 |
+
<button onclick='loadMedia(${i}, ${JSON.stringify(currentSearch)})'
|
| 341 |
+
class="px-4 py-2 rounded-2xl text-sm font-bold transition border
|
| 342 |
+
${isActive
|
| 343 |
+
? 'bg-primary text-white border-primary shadow-lg shadow-primary/20'
|
| 344 |
+
: 'glass-panel hover:bg-white/10 text-text border-white/10'}">
|
| 345 |
+
${i}
|
| 346 |
+
</button>
|
| 347 |
+
`;
|
| 348 |
}
|
| 349 |
|
|
|
|
| 350 |
if (endPage < totalPages) {
|
| 351 |
if (endPage < totalPages - 1) {
|
| 352 |
+
paginationHTML += `<span class="px-2 text-text-secondary text-sm">...</span>`;
|
| 353 |
}
|
| 354 |
paginationHTML += `
|
| 355 |
+
<button onclick='loadMedia(${totalPages}, ${JSON.stringify(currentSearch)})'
|
| 356 |
+
class="px-4 py-2 rounded-2xl glass-panel hover:bg-white/10 text-text text-sm font-bold transition border border-white/10">
|
| 357 |
+
${totalPages}
|
| 358 |
+
</button>
|
| 359 |
+
`;
|
| 360 |
}
|
| 361 |
|
|
|
|
| 362 |
if (currentPage < totalPages) {
|
| 363 |
paginationHTML += `
|
| 364 |
+
<button onclick='loadMedia(${currentPage + 1}, ${JSON.stringify(currentSearch)})'
|
| 365 |
+
class="px-4 py-2 rounded-2xl glass-panel hover:bg-white/10 text-text text-sm font-bold transition border border-white/10">
|
| 366 |
+
Next
|
| 367 |
+
</button>
|
| 368 |
+
`;
|
| 369 |
}
|
| 370 |
|
| 371 |
+
paginationInner.innerHTML = paginationHTML;
|
| 372 |
}
|
| 373 |
|
|
|
|
| 374 |
function updateMediaInfo(data) {
|
| 375 |
const mediaInfo = document.getElementById('media-info');
|
| 376 |
const resultsInfo = document.getElementById('results-info');
|
| 377 |
const dbInfo = document.getElementById('db-info');
|
| 378 |
|
| 379 |
+
const totalCount = data.total_count || 0;
|
| 380 |
+
const pageSize = 24;
|
| 381 |
+
const current = data.current_page || 1;
|
| 382 |
+
const startItem = totalCount === 0 ? 0 : ((current - 1) * pageSize) + 1;
|
| 383 |
+
const endItem = Math.min(current * pageSize, totalCount);
|
| 384 |
|
| 385 |
+
resultsInfo.textContent = `Showing ${startItem}-${endItem} of ${totalCount} ${mediaType}s`;
|
| 386 |
|
| 387 |
if (data.databases_checked && data.databases_checked.length > 0) {
|
| 388 |
+
dbInfo.textContent = `Databases checked: ${data.databases_checked.join(', ')}`;
|
| 389 |
+
} else {
|
| 390 |
+
dbInfo.textContent = '';
|
| 391 |
}
|
| 392 |
|
| 393 |
mediaInfo.classList.remove('hidden');
|
| 394 |
}
|
| 395 |
|
|
|
|
| 396 |
function searchMedia() {
|
| 397 |
const searchInput = document.getElementById('search-input');
|
| 398 |
const search = searchInput.value.trim();
|
| 399 |
loadMedia(1, search);
|
| 400 |
}
|
| 401 |
|
|
|
|
| 402 |
function clearSearch() {
|
| 403 |
document.getElementById('search-input').value = '';
|
| 404 |
loadMedia(1, '');
|
| 405 |
}
|
| 406 |
|
|
|
|
| 407 |
function retryLoad() {
|
| 408 |
loadMedia(currentPage, currentSearch);
|
| 409 |
}
|
| 410 |
|
| 411 |
+
async function deleteMedia(buttonElement) {
|
| 412 |
+
const tmdbId = buttonElement.getAttribute('data-tmdb-id');
|
| 413 |
+
const dbIndex = buttonElement.getAttribute('data-db-index');
|
| 414 |
+
const title = buttonElement.getAttribute('data-title');
|
| 415 |
|
| 416 |
+
if (!confirm(`Are you sure you want to delete "${title}"?\n\nThis action cannot be undone.`)) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 417 |
|
| 418 |
+
try {
|
| 419 |
+
const response = await fetch(`/api/media/delete?tmdb_id=${encodeURIComponent(tmdbId)}&db_index=${encodeURIComponent(dbIndex)}&media_type=${encodeURIComponent(mediaType)}`, {
|
| 420 |
+
method: 'DELETE',
|
| 421 |
+
credentials: 'same-origin',
|
| 422 |
+
headers: {
|
| 423 |
+
'Accept': 'application/json',
|
| 424 |
+
'Content-Type': 'application/json'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 425 |
}
|
| 426 |
+
});
|
| 427 |
+
|
| 428 |
+
if (response.ok) {
|
| 429 |
+
showToast(`"${title}" deleted successfully`, 'success', 'Deleted');
|
| 430 |
+
loadMedia(currentPage, currentSearch); // Refresh grid
|
| 431 |
+
} else {
|
| 432 |
+
const error = await response.json().catch(() => ({}));
|
| 433 |
+
showToast(error.detail || `Error deleting "${title}"`, 'error', 'Delete Failed');
|
| 434 |
}
|
| 435 |
+
} catch (error) {
|
| 436 |
+
console.error('Error deleting media:', error);
|
| 437 |
+
showToast(`Error deleting "${title}": ${error.message}`, 'error', 'Network Error');
|
| 438 |
}
|
| 439 |
+
}
|
| 440 |
|
|
|
|
| 441 |
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
| 442 |
loadMedia();
|
| 443 |
|
| 444 |
+
const searchInput = document.getElementById('search-input');
|
| 445 |
+
|
| 446 |
+
searchInput.addEventListener('keypress', (e) => {
|
| 447 |
if (e.key === 'Enter') {
|
| 448 |
e.preventDefault();
|
| 449 |
searchMedia();
|
| 450 |
}
|
| 451 |
});
|
| 452 |
|
|
|
|
| 453 |
let searchTimeout;
|
| 454 |
+
searchInput.addEventListener('input', (e) => {
|
| 455 |
clearTimeout(searchTimeout);
|
| 456 |
const searchValue = e.target.value.trim();
|
| 457 |
|
| 458 |
if (searchValue.length === 0) {
|
| 459 |
searchTimeout = setTimeout(() => {
|
| 460 |
loadMedia(1, '');
|
| 461 |
+
}, 250);
|
| 462 |
}
|
| 463 |
});
|
| 464 |
});
|
|
|
|
| 472 |
overflow: hidden;
|
| 473 |
}
|
| 474 |
|
| 475 |
+
.aspect-\[2\/3\] {
|
| 476 |
+
aspect-ratio: 2 / 3;
|
|
|
|
|
|
|
| 477 |
}
|
| 478 |
|
| 479 |
+
/* Better mobile scrolling for pagination */
|
| 480 |
+
#pagination .overflow-x-auto {
|
| 481 |
+
scrollbar-width: thin;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 482 |
}
|
| 483 |
|
| 484 |
+
#pagination .overflow-x-auto::-webkit-scrollbar {
|
| 485 |
+
height: 6px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 486 |
}
|
| 487 |
|
| 488 |
+
#pagination .overflow-x-auto::-webkit-scrollbar-thumb {
|
| 489 |
+
border-radius: 999px;
|
| 490 |
+
background: rgba(255, 255, 255, 0.2);
|
| 491 |
}
|
| 492 |
</style>
|
| 493 |
+
{% endblock %}
|
Backend/fastapi/templates/public_status.html
DELETED
|
@@ -1,71 +0,0 @@
|
|
| 1 |
-
{% extends "base.html" %}
|
| 2 |
-
|
| 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
DELETED
|
@@ -1,114 +0,0 @@
|
|
| 1 |
-
{% extends "base.html" %}
|
| 2 |
-
|
| 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,192 +3,670 @@
|
|
| 3 |
{% block title %}Subscription Management - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
-
<
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
</div>
|
| 13 |
-
</
|
| 14 |
|
| 15 |
-
<!--
|
| 16 |
-
<
|
| 17 |
-
<div class="flex items-center justify-between mb-
|
| 18 |
-
<
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
<i class="fas fa-plus mr-2"></i> Add Plan
|
| 22 |
-
</button>
|
| 23 |
</div>
|
| 24 |
-
|
| 25 |
-
|
|
|
|
| 26 |
<i class="fas fa-spinner fa-spin mr-2"></i> Loading plans...
|
| 27 |
</div>
|
| 28 |
</div>
|
| 29 |
-
</
|
| 30 |
|
| 31 |
-
<!--
|
| 32 |
-
<
|
| 33 |
-
<div class="flex items-
|
| 34 |
-
<
|
| 35 |
-
|
| 36 |
-
class="
|
| 37 |
-
|
| 38 |
-
</button>
|
| 39 |
-
</div>
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
<
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
<
|
| 59 |
-
</
|
| 60 |
</div>
|
| 61 |
|
| 62 |
-
<
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
| 66 |
<tr>
|
| 67 |
-
<th class="px-6 py-4 font-semibold">User Details</th>
|
| 68 |
-
<th class="px-6 py-4
|
| 69 |
-
<th class="px-6 py-4
|
| 70 |
-
<th class="px-6 py-4
|
| 71 |
</tr>
|
| 72 |
</thead>
|
| 73 |
-
<tbody id="subscribers-tbody"
|
| 74 |
<tr>
|
| 75 |
-
<td colspan="4" class="px-6 py-8 text-center text-
|
| 76 |
-
|
|
|
|
| 77 |
</tr>
|
| 78 |
</tbody>
|
| 79 |
</table>
|
| 80 |
</div>
|
| 81 |
</div>
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
<!-- Pagination -->
|
| 84 |
-
<div class="
|
| 85 |
-
<
|
| 86 |
-
<div class="
|
| 87 |
<button id="sub-btn-prev" onclick="subChangePage(-1)"
|
| 88 |
-
class="
|
| 89 |
-
|
|
|
|
|
|
|
| 90 |
<button id="sub-btn-next" onclick="subChangePage(1)"
|
| 91 |
-
class="
|
|
|
|
|
|
|
| 92 |
</div>
|
| 93 |
</div>
|
| 94 |
-
</
|
| 95 |
</div>
|
| 96 |
|
| 97 |
<!-- Plan Modal -->
|
| 98 |
-
<div id="plan-modal" class="fixed inset-0
|
| 99 |
-
<div class="
|
| 100 |
-
<div class="
|
| 101 |
-
<
|
| 102 |
-
Plan</h3>
|
| 103 |
-
|
| 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
|
| 133 |
-
<div class="
|
| 134 |
-
<div class="
|
| 135 |
-
<
|
| 136 |
-
User</h3>
|
| 137 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
async function fetchPlans() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
try {
|
| 165 |
const res = await fetch('/api/admin/subscriptions/plans');
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
}
|
| 193 |
|
| 194 |
function openPlanModal(id = '', days = '', price = '') {
|
|
@@ -196,33 +674,63 @@
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 = {
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
}
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 220 |
-
|
| 221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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);
|
|
@@ -231,113 +739,290 @@
|
|
| 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 |
-
|
|
|
|
| 240 |
const slice = filtered.slice(start, start + pageSize);
|
| 241 |
|
| 242 |
-
document.getElementById('sub-page-info').textContent =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 248 |
-
|
| 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 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 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) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
|
| 290 |
async function fetchSubscribers() {
|
| 291 |
-
document.getElementById('subscribers-tbody').innerHTML =
|
| 292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
try {
|
| 294 |
const res = await fetch('/api/admin/subscriptions/users');
|
| 295 |
-
if (res.ok)
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
} catch (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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
if (action === 'extend') {
|
| 309 |
-
title = 'Extend Subscription';
|
| 310 |
-
|
|
|
|
|
|
|
| 311 |
} else if (action === 'reduce') {
|
| 312 |
-
title = 'Reduce Subscription';
|
| 313 |
-
|
|
|
|
|
|
|
| 314 |
} else {
|
| 315 |
-
title = 'Revoke Subscription';
|
| 316 |
-
|
|
|
|
|
|
|
| 317 |
}
|
|
|
|
| 318 |
document.getElementById('user-modal-title').innerText = title;
|
| 319 |
document.getElementById('user-modal-desc').innerHTML = desc;
|
| 320 |
-
document.getElementById('days-input-group').
|
| 321 |
-
document.getElementById('btn-user-save').className =
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
}
|
| 326 |
|
| 327 |
-
function closeUserModal() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 339 |
}
|
| 340 |
|
| 341 |
-
document.addEventListener('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
</script>
|
| 343 |
-
{% endblock %}
|
|
|
|
| 3 |
{% block title %}Subscription Management - Telegram Stremio{% endblock %}
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
+
<style>
|
| 7 |
+
.subs-shell {
|
| 8 |
+
display: flex;
|
| 9 |
+
flex-direction: column;
|
| 10 |
+
gap: 1.5rem;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
.page-hero,
|
| 14 |
+
.section-panel,
|
| 15 |
+
.table-shell,
|
| 16 |
+
.mobile-user-card,
|
| 17 |
+
.empty-state,
|
| 18 |
+
.modal-glass {
|
| 19 |
+
background: color-mix(in srgb, var(--card) 50%, transparent);
|
| 20 |
+
backdrop-filter: blur(20px);
|
| 21 |
+
-webkit-backdrop-filter: blur(20px);
|
| 22 |
+
border: 1px solid var(--border);
|
| 23 |
+
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
.page-hero,
|
| 27 |
+
.section-panel,
|
| 28 |
+
.table-shell,
|
| 29 |
+
.empty-state {
|
| 30 |
+
border-radius: 1.5rem;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
.hero-glow {
|
| 34 |
+
position: relative;
|
| 35 |
+
overflow: hidden;
|
| 36 |
+
isolation: isolate;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.hero-glow::before {
|
| 40 |
+
content: "";
|
| 41 |
+
position: absolute;
|
| 42 |
+
inset: -30% auto auto -10%;
|
| 43 |
+
width: 16rem;
|
| 44 |
+
height: 16rem;
|
| 45 |
+
border-radius: 9999px;
|
| 46 |
+
background: color-mix(in srgb, var(--primary) 18%, transparent);
|
| 47 |
+
filter: blur(50px);
|
| 48 |
+
z-index: -1;
|
| 49 |
+
pointer-events: none;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
.hero-glow::after {
|
| 53 |
+
content: "";
|
| 54 |
+
position: absolute;
|
| 55 |
+
inset: auto -5% -35% auto;
|
| 56 |
+
width: 14rem;
|
| 57 |
+
height: 14rem;
|
| 58 |
+
border-radius: 9999px;
|
| 59 |
+
background: color-mix(in srgb, var(--accent) 16%, transparent);
|
| 60 |
+
filter: blur(50px);
|
| 61 |
+
z-index: -1;
|
| 62 |
+
pointer-events: none;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.section-title {
|
| 66 |
+
color: var(--text);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
.section-muted {
|
| 70 |
+
color: var(--text-sec);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
.glass-btn {
|
| 74 |
+
border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
|
| 75 |
+
background: color-mix(in srgb, var(--card) 70%, transparent);
|
| 76 |
+
color: var(--text);
|
| 77 |
+
backdrop-filter: blur(14px);
|
| 78 |
+
-webkit-backdrop-filter: blur(14px);
|
| 79 |
+
transition: all 0.25s ease;
|
| 80 |
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
.glass-btn:hover {
|
| 84 |
+
transform: translateY(-1px);
|
| 85 |
+
border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
|
| 86 |
+
box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
.glass-btn-primary {
|
| 90 |
+
background: linear-gradient(
|
| 91 |
+
135deg,
|
| 92 |
+
color-mix(in srgb, var(--primary) 88%, white 8%),
|
| 93 |
+
color-mix(in srgb, var(--accent) 82%, var(--primary) 18%)
|
| 94 |
+
);
|
| 95 |
+
color: white;
|
| 96 |
+
border: 1px solid color-mix(in srgb, var(--primary) 50%, transparent);
|
| 97 |
+
box-shadow: 0 10px 26px color-mix(in srgb, var(--primary) 22%, transparent);
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
.glass-btn-primary:hover {
|
| 101 |
+
filter: brightness(1.05);
|
| 102 |
+
box-shadow: 0 14px 34px color-mix(in srgb, var(--primary) 28%, transparent);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.glass-btn-danger {
|
| 106 |
+
background: color-mix(in srgb, #ef4444 20%, transparent);
|
| 107 |
+
color: #fecaca;
|
| 108 |
+
border-color: color-mix(in srgb, #ef4444 40%, transparent);
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
.glass-btn-warning {
|
| 112 |
+
background: color-mix(in srgb, #f59e0b 20%, transparent);
|
| 113 |
+
color: #fde68a;
|
| 114 |
+
border-color: color-mix(in srgb, #f59e0b 40%, transparent);
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
.glass-btn-success {
|
| 118 |
+
background: color-mix(in srgb, #22c55e 18%, transparent);
|
| 119 |
+
color: #bbf7d0;
|
| 120 |
+
border-color: color-mix(in srgb, #22c55e 40%, transparent);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
.glass-input,
|
| 124 |
+
.glass-select {
|
| 125 |
+
width: 100%;
|
| 126 |
+
border-radius: 1rem;
|
| 127 |
+
border: 1px solid color-mix(in srgb, var(--border) 90%, transparent);
|
| 128 |
+
background: color-mix(in srgb, var(--bg) 68%, transparent);
|
| 129 |
+
color: var(--text);
|
| 130 |
+
padding: 0.85rem 1rem;
|
| 131 |
+
outline: none;
|
| 132 |
+
transition: all 0.2s ease;
|
| 133 |
+
box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
.glass-input::placeholder {
|
| 137 |
+
color: color-mix(in srgb, var(--text-sec) 85%, transparent);
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
.glass-input:focus,
|
| 141 |
+
.glass-select:focus {
|
| 142 |
+
border-color: color-mix(in srgb, var(--primary) 65%, var(--border));
|
| 143 |
+
box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 12%, transparent);
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
.plan-card {
|
| 147 |
+
position: relative;
|
| 148 |
+
overflow: hidden;
|
| 149 |
+
border-radius: 1.5rem;
|
| 150 |
+
background: linear-gradient(
|
| 151 |
+
180deg,
|
| 152 |
+
color-mix(in srgb, var(--card) 72%, transparent),
|
| 153 |
+
color-mix(in srgb, var(--card) 48%, transparent)
|
| 154 |
+
);
|
| 155 |
+
border: 1px solid color-mix(in srgb, var(--border) 90%, transparent);
|
| 156 |
+
backdrop-filter: blur(18px);
|
| 157 |
+
-webkit-backdrop-filter: blur(18px);
|
| 158 |
+
box-shadow: 0 12px 30px rgba(0,0,0,0.18);
|
| 159 |
+
transition: transform 0.28s ease, border-color 0.28s ease, box-shadow 0.28s ease;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
.plan-card::before {
|
| 163 |
+
content: "";
|
| 164 |
+
position: absolute;
|
| 165 |
+
inset: -25% auto auto -5%;
|
| 166 |
+
width: 8rem;
|
| 167 |
+
height: 8rem;
|
| 168 |
+
border-radius: 9999px;
|
| 169 |
+
background: color-mix(in srgb, var(--primary) 18%, transparent);
|
| 170 |
+
filter: blur(36px);
|
| 171 |
+
pointer-events: none;
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
.plan-card:hover {
|
| 175 |
+
transform: translateY(-4px);
|
| 176 |
+
border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
|
| 177 |
+
box-shadow: 0 18px 42px rgba(0,0,0,0.24);
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
.plan-actions {
|
| 181 |
+
opacity: 0;
|
| 182 |
+
transform: translateY(-4px);
|
| 183 |
+
transition: all 0.22s ease;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
.plan-card:hover .plan-actions {
|
| 187 |
+
opacity: 1;
|
| 188 |
+
transform: translateY(0);
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
.metric-badge {
|
| 192 |
+
display: inline-flex;
|
| 193 |
+
align-items: center;
|
| 194 |
+
gap: 0.45rem;
|
| 195 |
+
padding: 0.45rem 0.8rem;
|
| 196 |
+
border-radius: 9999px;
|
| 197 |
+
font-size: 0.78rem;
|
| 198 |
+
font-weight: 700;
|
| 199 |
+
letter-spacing: 0.03em;
|
| 200 |
+
border: 1px solid transparent;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
.badge-active {
|
| 204 |
+
background: color-mix(in srgb, #22c55e 16%, transparent);
|
| 205 |
+
color: #86efac;
|
| 206 |
+
border-color: color-mix(in srgb, #22c55e 28%, transparent);
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
.badge-expired {
|
| 210 |
+
background: color-mix(in srgb, #ef4444 14%, transparent);
|
| 211 |
+
color: #fca5a5;
|
| 212 |
+
border-color: color-mix(in srgb, #ef4444 26%, transparent);
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
.table-shell {
|
| 216 |
+
overflow: hidden;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
.subs-table {
|
| 220 |
+
width: 100%;
|
| 221 |
+
border-collapse: separate;
|
| 222 |
+
border-spacing: 0;
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
.subs-table thead th {
|
| 226 |
+
background: color-mix(in srgb, var(--bg) 65%, transparent);
|
| 227 |
+
color: var(--text-sec);
|
| 228 |
+
font-size: 0.72rem;
|
| 229 |
+
text-transform: uppercase;
|
| 230 |
+
letter-spacing: 0.08em;
|
| 231 |
+
border-bottom: 1px solid color-mix(in srgb, var(--border) 92%, transparent);
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
.subs-table tbody tr {
|
| 235 |
+
transition: background 0.22s ease;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
.subs-table tbody tr:hover {
|
| 239 |
+
background: color-mix(in srgb, var(--primary) 6%, transparent);
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
.subs-table td {
|
| 243 |
+
border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
|
| 244 |
+
color: var(--text);
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
.subs-table tbody tr:last-child td {
|
| 248 |
+
border-bottom: none;
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
.action-chip {
|
| 252 |
+
border-radius: 9999px;
|
| 253 |
+
padding: 0.45rem 0.8rem;
|
| 254 |
+
font-size: 0.72rem;
|
| 255 |
+
font-weight: 700;
|
| 256 |
+
border: 1px solid transparent;
|
| 257 |
+
transition: all 0.2s ease;
|
| 258 |
+
white-space: nowrap;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
.action-chip:hover {
|
| 262 |
+
transform: translateY(-1px);
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
.mobile-user-card {
|
| 266 |
+
border-radius: 1.35rem;
|
| 267 |
+
padding: 1rem;
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
.mobile-user-card + .mobile-user-card {
|
| 271 |
+
margin-top: 0.9rem;
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
.mobile-grid {
|
| 275 |
+
display: none;
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
.pagination-shell {
|
| 279 |
+
display: flex;
|
| 280 |
+
align-items: center;
|
| 281 |
+
justify-content: space-between;
|
| 282 |
+
gap: 1rem;
|
| 283 |
+
flex-wrap: wrap;
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
.pagination-text {
|
| 287 |
+
color: var(--text-sec);
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
.pagination-btn {
|
| 291 |
+
min-width: 92px;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
.modal-backdrop {
|
| 295 |
+
background: rgba(4, 8, 18, 0.58);
|
| 296 |
+
backdrop-filter: blur(10px);
|
| 297 |
+
-webkit-backdrop-filter: blur(10px);
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
.modal-glass {
|
| 301 |
+
border-radius: 1.6rem;
|
| 302 |
+
padding: 1.4rem;
|
| 303 |
+
border: 1px solid color-mix(in srgb, var(--border) 95%, transparent);
|
| 304 |
+
width: min(92vw, 30rem);
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
.modal-field label {
|
| 308 |
+
color: var(--text-sec);
|
| 309 |
+
font-size: 0.82rem;
|
| 310 |
+
font-weight: 700;
|
| 311 |
+
margin-bottom: 0.55rem;
|
| 312 |
+
display: block;
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
.text-soft {
|
| 316 |
+
color: var(--text-sec);
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
.no-scrollbar::-webkit-scrollbar {
|
| 320 |
+
display: none;
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
.no-scrollbar {
|
| 324 |
+
-ms-overflow-style: none;
|
| 325 |
+
scrollbar-width: none;
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
@media (max-width: 1024px) {
|
| 329 |
+
.subs-table th,
|
| 330 |
+
.subs-table td {
|
| 331 |
+
padding-left: 1rem;
|
| 332 |
+
padding-right: 1rem;
|
| 333 |
+
}
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
@media (max-width: 767px) {
|
| 337 |
+
.desktop-table-wrap {
|
| 338 |
+
display: none;
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
.mobile-grid {
|
| 342 |
+
display: block;
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
.page-hero {
|
| 346 |
+
padding: 1.25rem;
|
| 347 |
+
border-radius: 1.35rem;
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
.section-panel {
|
| 351 |
+
padding: 1rem;
|
| 352 |
+
border-radius: 1.35rem;
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
.pagination-shell {
|
| 356 |
+
flex-direction: column;
|
| 357 |
+
align-items: stretch;
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
.pagination-shell .controls {
|
| 361 |
+
width: 100%;
|
| 362 |
+
display: grid;
|
| 363 |
+
grid-template-columns: 1fr auto 1fr;
|
| 364 |
+
gap: 0.6rem;
|
| 365 |
+
align-items: center;
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
.pagination-btn {
|
| 369 |
+
width: 100%;
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
.plan-actions {
|
| 373 |
+
opacity: 1;
|
| 374 |
+
transform: none;
|
| 375 |
+
}
|
| 376 |
+
}
|
| 377 |
+
</style>
|
| 378 |
+
|
| 379 |
+
<div class="subs-shell py-2 sm:py-4">
|
| 380 |
+
<!-- Hero -->
|
| 381 |
+
<section class="page-hero hero-glow p-5 sm:p-6 lg:p-8">
|
| 382 |
+
<div class="flex flex-col gap-5 lg:flex-row lg:items-center lg:justify-between">
|
| 383 |
+
<div>
|
| 384 |
+
<div class="inline-flex items-center gap-2 rounded-full border px-3 py-1 text-xs font-bold tracking-[0.18em] uppercase mb-3"
|
| 385 |
+
style="border-color: color-mix(in srgb, var(--primary) 28%, var(--border)); color: var(--text-sec); background: color-mix(in srgb, var(--primary) 10%, transparent);">
|
| 386 |
+
<i class="fas fa-layer-group text-[11px]" style="color: var(--primary);"></i>
|
| 387 |
+
Subscription Control Center
|
| 388 |
+
</div>
|
| 389 |
+
<h1 class="text-2xl sm:text-3xl lg:text-4xl font-extrabold tracking-tight section-title">
|
| 390 |
+
Subscription Management
|
| 391 |
+
</h1>
|
| 392 |
+
<p class="mt-2 text-sm sm:text-base section-muted max-w-2xl">
|
| 393 |
+
Create plans, manage users, and monitor active or expired subscriptions.
|
| 394 |
+
</p>
|
| 395 |
+
</div>
|
| 396 |
+
|
| 397 |
+
<div class="flex flex-wrap gap-3">
|
| 398 |
+
<button onclick="openPlanModal()" class="glass-btn glass-btn-primary rounded-2xl px-5 py-3 text-sm font-bold inline-flex items-center gap-2">
|
| 399 |
+
<i class="fas fa-plus"></i>
|
| 400 |
+
Add Plan
|
| 401 |
+
</button>
|
| 402 |
+
<button onclick="fetchSubscribers()" class="glass-btn rounded-2xl px-5 py-3 text-sm font-bold inline-flex items-center gap-2">
|
| 403 |
+
<i class="fas fa-rotate-right"></i>
|
| 404 |
+
Refresh Users
|
| 405 |
+
</button>
|
| 406 |
+
</div>
|
| 407 |
</div>
|
| 408 |
+
</section>
|
| 409 |
|
| 410 |
+
<!-- Plans -->
|
| 411 |
+
<section class="section-panel p-4 sm:p-5 lg:p-6">
|
| 412 |
+
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-5">
|
| 413 |
+
<div>
|
| 414 |
+
<h2 class="text-lg sm:text-xl font-bold section-title">Subscription Plans</h2>
|
| 415 |
+
</div>
|
|
|
|
|
|
|
| 416 |
</div>
|
| 417 |
+
|
| 418 |
+
<div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4 sm:gap-5" id="plans-container">
|
| 419 |
+
<div class="empty-state col-span-full text-center px-6 py-10 text-soft">
|
| 420 |
<i class="fas fa-spinner fa-spin mr-2"></i> Loading plans...
|
| 421 |
</div>
|
| 422 |
</div>
|
| 423 |
+
</section>
|
| 424 |
|
| 425 |
+
<!-- Users -->
|
| 426 |
+
<section class="section-panel p-4 sm:p-5 lg:p-6">
|
| 427 |
+
<div class="flex flex-col lg:flex-row lg:items-end lg:justify-between gap-4 mb-5">
|
| 428 |
+
<div>
|
| 429 |
+
<h2 class="text-lg sm:text-xl font-bold section-title">User Subscriptions</h2>
|
| 430 |
+
<p class="text-sm section-muted mt-1">Search, filter, paginate, and manage subscription access.</p>
|
| 431 |
+
</div>
|
|
|
|
|
|
|
| 432 |
|
| 433 |
+
<div class="w-full lg:w-auto grid grid-cols-1 sm:grid-cols-3 gap-3">
|
| 434 |
+
<input
|
| 435 |
+
id="sub-search"
|
| 436 |
+
type="text"
|
| 437 |
+
placeholder="Search by name, username or ID..."
|
| 438 |
+
class="glass-input"
|
| 439 |
+
oninput="subPage=1; renderSubPage()"
|
| 440 |
+
>
|
| 441 |
+
<select id="sub-filter" class="glass-select" onchange="subPage=1; renderSubPage()">
|
| 442 |
+
<option value="all">All Status</option>
|
| 443 |
+
<option value="active">Active</option>
|
| 444 |
+
<option value="expired">Expired</option>
|
| 445 |
+
</select>
|
| 446 |
+
<select id="sub-page-size" class="glass-select" onchange="subPage=1; renderSubPage()">
|
| 447 |
+
<option value="10">10 / page</option>
|
| 448 |
+
<option value="25">25 / page</option>
|
| 449 |
+
<option value="50">50 / page</option>
|
| 450 |
+
</select>
|
| 451 |
+
</div>
|
| 452 |
</div>
|
| 453 |
|
| 454 |
+
<!-- Desktop table -->
|
| 455 |
+
<div class="desktop-table-wrap table-shell">
|
| 456 |
+
<div class="overflow-x-auto no-scrollbar">
|
| 457 |
+
<table class="subs-table min-w-[780px] text-sm">
|
| 458 |
+
<thead>
|
| 459 |
<tr>
|
| 460 |
+
<th class="px-6 py-4 text-left font-semibold">User Details</th>
|
| 461 |
+
<th class="px-6 py-4 text-center font-semibold">Status</th>
|
| 462 |
+
<th class="px-6 py-4 text-center font-semibold">Expiry</th>
|
| 463 |
+
<th class="px-6 py-4 text-right font-semibold">Actions</th>
|
| 464 |
</tr>
|
| 465 |
</thead>
|
| 466 |
+
<tbody id="subscribers-tbody">
|
| 467 |
<tr>
|
| 468 |
+
<td colspan="4" class="px-6 py-8 text-center text-soft">
|
| 469 |
+
<i class="fas fa-spinner fa-spin mr-2"></i> Loading...
|
| 470 |
+
</td>
|
| 471 |
</tr>
|
| 472 |
</tbody>
|
| 473 |
</table>
|
| 474 |
</div>
|
| 475 |
</div>
|
| 476 |
|
| 477 |
+
<!-- Mobile cards -->
|
| 478 |
+
<div id="subscribers-mobile" class="mobile-grid mt-1">
|
| 479 |
+
<div class="empty-state text-center px-4 py-8 text-soft">
|
| 480 |
+
<i class="fas fa-spinner fa-spin mr-2"></i> Loading...
|
| 481 |
+
</div>
|
| 482 |
+
</div>
|
| 483 |
+
|
| 484 |
<!-- Pagination -->
|
| 485 |
+
<div class="pagination-shell mt-5" id="sub-pagination">
|
| 486 |
+
<div id="sub-page-info" class="pagination-text text-sm"></div>
|
| 487 |
+
<div class="controls">
|
| 488 |
<button id="sub-btn-prev" onclick="subChangePage(-1)"
|
| 489 |
+
class="glass-btn pagination-btn rounded-xl px-4 py-2.5 text-sm font-semibold">
|
| 490 |
+
‹ Prev
|
| 491 |
+
</button>
|
| 492 |
+
<span id="sub-page-num" class="text-sm font-bold text-center section-title px-2"></span>
|
| 493 |
<button id="sub-btn-next" onclick="subChangePage(1)"
|
| 494 |
+
class="glass-btn pagination-btn rounded-xl px-4 py-2.5 text-sm font-semibold">
|
| 495 |
+
Next ›
|
| 496 |
+
</button>
|
| 497 |
</div>
|
| 498 |
</div>
|
| 499 |
+
</section>
|
| 500 |
</div>
|
| 501 |
|
| 502 |
<!-- Plan Modal -->
|
| 503 |
+
<div id="plan-modal" class="fixed inset-0 hidden z-50 modal-backdrop items-center justify-center p-4">
|
| 504 |
+
<div class="modal-glass">
|
| 505 |
+
<div class="flex items-start justify-between gap-4 mb-5">
|
| 506 |
+
<div>
|
| 507 |
+
<h3 class="text-xl font-bold section-title" id="plan-modal-title">Add New Plan</h3>
|
| 508 |
+
<p class="text-sm text-soft mt-1">Create or update a subscription plan.</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 509 |
</div>
|
| 510 |
+
<button onclick="closePlanModal()" class="glass-btn rounded-full w-10 h-10 flex items-center justify-center">
|
| 511 |
+
<i class="fas fa-xmark"></i>
|
| 512 |
+
</button>
|
| 513 |
</div>
|
| 514 |
+
|
| 515 |
+
<form id="plan-form" onsubmit="submitPlanForm(event)" class="space-y-4">
|
| 516 |
+
<input type="hidden" id="plan-id">
|
| 517 |
+
|
| 518 |
+
<div class="modal-field">
|
| 519 |
+
<label for="plan-days">Duration (Days)</label>
|
| 520 |
+
<input type="number" id="plan-days" class="glass-input" required min="1">
|
| 521 |
+
</div>
|
| 522 |
+
|
| 523 |
+
<div class="modal-field">
|
| 524 |
+
<label for="plan-price">Price (₹)</label>
|
| 525 |
+
<input type="number" id="plan-price" class="glass-input" required min="0" step="0.01">
|
| 526 |
+
</div>
|
| 527 |
+
|
| 528 |
+
<div class="flex flex-col-reverse sm:flex-row justify-end gap-3 pt-2">
|
| 529 |
+
<button type="button" onclick="closePlanModal()" class="glass-btn rounded-2xl px-5 py-3 text-sm font-bold">
|
| 530 |
+
Cancel
|
| 531 |
+
</button>
|
| 532 |
+
<button type="submit" class="glass-btn glass-btn-primary rounded-2xl px-5 py-3 text-sm font-bold">
|
| 533 |
+
Save Plan
|
| 534 |
+
</button>
|
| 535 |
+
</div>
|
| 536 |
+
</form>
|
| 537 |
</div>
|
| 538 |
</div>
|
| 539 |
|
| 540 |
<!-- User Action Modal -->
|
| 541 |
+
<div id="user-modal" class="fixed inset-0 hidden z-50 modal-backdrop items-center justify-center p-4">
|
| 542 |
+
<div class="modal-glass">
|
| 543 |
+
<div class="flex items-start justify-between gap-4 mb-5">
|
| 544 |
+
<div>
|
| 545 |
+
<h3 class="text-xl font-bold section-title" id="user-modal-title">Manage User</h3>
|
| 546 |
+
<div class="text-sm text-soft mt-1" id="user-modal-desc"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 547 |
</div>
|
| 548 |
+
<button onclick="closeUserModal()" class="glass-btn rounded-full w-10 h-10 flex items-center justify-center">
|
| 549 |
+
<i class="fas fa-xmark"></i>
|
| 550 |
+
</button>
|
| 551 |
</div>
|
| 552 |
+
|
| 553 |
+
<form id="user-form" onsubmit="submitUserForm(event)" class="space-y-4">
|
| 554 |
+
<input type="hidden" id="manage-user-id">
|
| 555 |
+
<input type="hidden" id="manage-action">
|
| 556 |
+
|
| 557 |
+
<div class="modal-field" id="days-input-group">
|
| 558 |
+
<label for="manage-days">Days to <span id="days-action-label"></span></label>
|
| 559 |
+
<input type="number" id="manage-days" class="glass-input" min="1" value="30">
|
| 560 |
+
</div>
|
| 561 |
+
|
| 562 |
+
<div class="flex flex-col-reverse sm:flex-row justify-end gap-3 pt-2">
|
| 563 |
+
<button type="button" onclick="closeUserModal()" class="glass-btn rounded-2xl px-5 py-3 text-sm font-bold">
|
| 564 |
+
Cancel
|
| 565 |
+
</button>
|
| 566 |
+
<button type="submit" class="glass-btn glass-btn-primary rounded-2xl px-5 py-3 text-sm font-bold" id="btn-user-save">
|
| 567 |
+
Confirm
|
| 568 |
+
</button>
|
| 569 |
+
</div>
|
| 570 |
+
</form>
|
| 571 |
</div>
|
| 572 |
</div>
|
| 573 |
|
| 574 |
<script>
|
| 575 |
+
let allUsers = [];
|
| 576 |
+
let subPage = 1;
|
| 577 |
+
|
| 578 |
+
function formatExpiry(expiryValue) {
|
| 579 |
+
if (!expiryValue) return 'N/A';
|
| 580 |
+
const d = new Date(expiryValue);
|
| 581 |
+
return d.toLocaleDateString('en-IN', {
|
| 582 |
+
timeZone: 'Asia/Kolkata',
|
| 583 |
+
day: '2-digit',
|
| 584 |
+
month: 'short',
|
| 585 |
+
year: 'numeric'
|
| 586 |
+
}) + ' ' + d.toLocaleTimeString('en-IN', {
|
| 587 |
+
timeZone: 'Asia/Kolkata',
|
| 588 |
+
hour: '2-digit',
|
| 589 |
+
minute: '2-digit'
|
| 590 |
+
});
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
function getUserDisplayName(u) {
|
| 594 |
+
let name = u.first_name || '';
|
| 595 |
+
if (u.username) name += (name ? ' ' : '') + `(@${u.username})`;
|
| 596 |
+
if (!name) name = `User ${u._id}`;
|
| 597 |
+
return name;
|
| 598 |
+
}
|
| 599 |
+
|
| 600 |
+
function getStatusBadge(status) {
|
| 601 |
+
return status === 'active'
|
| 602 |
+
? '<span class="metric-badge badge-active"><i class="fas fa-circle text-[8px]"></i> Active</span>'
|
| 603 |
+
: '<span class="metric-badge badge-expired"><i class="fas fa-circle text-[8px]"></i> Expired</span>';
|
| 604 |
+
}
|
| 605 |
+
|
| 606 |
async function fetchPlans() {
|
| 607 |
+
const container = document.getElementById('plans-container');
|
| 608 |
+
container.innerHTML = `
|
| 609 |
+
<div class="empty-state col-span-full text-center px-6 py-10 text-soft">
|
| 610 |
+
<i class="fas fa-spinner fa-spin mr-2"></i> Loading plans...
|
| 611 |
+
</div>
|
| 612 |
+
`;
|
| 613 |
try {
|
| 614 |
const res = await fetch('/api/admin/subscriptions/plans');
|
| 615 |
+
if (!res.ok) throw new Error('Failed to fetch plans');
|
| 616 |
+
|
| 617 |
+
const data = await res.json();
|
| 618 |
+
const plans = data.data || data.plans || [];
|
| 619 |
+
|
| 620 |
+
if (!plans.length) {
|
| 621 |
+
container.innerHTML = `
|
| 622 |
+
<div class="empty-state col-span-full text-center px-6 py-10 text-soft">
|
| 623 |
+
<i class="fas fa-box-open text-2xl mb-3"></i>
|
| 624 |
+
<div class="font-semibold mb-1">No plans found</div>
|
| 625 |
+
<div class="text-sm">Create your first subscription plan.</div>
|
| 626 |
+
</div>
|
| 627 |
+
`;
|
| 628 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 629 |
}
|
| 630 |
+
|
| 631 |
+
container.innerHTML = plans.map(p => `
|
| 632 |
+
<div class="plan-card p-5 sm:p-6">
|
| 633 |
+
<div class="plan-actions absolute right-4 top-4 flex gap-2">
|
| 634 |
+
<button onclick="openPlanModal('${p._id}', ${p.days}, ${p.price})"
|
| 635 |
+
class="glass-btn rounded-full w-9 h-9 flex items-center justify-center" title="Edit plan">
|
| 636 |
+
<i class="fas fa-pen text-sm"></i>
|
| 637 |
+
</button>
|
| 638 |
+
<button onclick="deletePlan('${p._id}')"
|
| 639 |
+
class="glass-btn glass-btn-danger rounded-full w-9 h-9 flex items-center justify-center" title="Delete plan">
|
| 640 |
+
<i class="fas fa-trash text-sm"></i>
|
| 641 |
+
</button>
|
| 642 |
+
</div>
|
| 643 |
+
|
| 644 |
+
<div class="flex items-start gap-4">
|
| 645 |
+
<div class="w-14 h-14 rounded-2xl flex items-center justify-center shrink-0"
|
| 646 |
+
style="background: color-mix(in srgb, var(--primary) 16%, transparent); border: 1px solid color-mix(in srgb, var(--primary) 24%, transparent);">
|
| 647 |
+
<i class="fas fa-calendar-alt text-xl" style="color: var(--primary);"></i>
|
| 648 |
+
</div>
|
| 649 |
+
|
| 650 |
+
<div class="min-w-0">
|
| 651 |
+
<div class="text-sm font-semibold section-muted">${p.days} Days Plan</div>
|
| 652 |
+
<div class="mt-1 text-3xl font-extrabold section-title tracking-tight">₹${p.price}</div>
|
| 653 |
+
<div class="mt-3 inline-flex items-center gap-2 text-xs font-bold rounded-full px-3 py-1"
|
| 654 |
+
style="background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text-sec); border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);">
|
| 655 |
+
<i class="fas fa-bolt" style="color: var(--accent);"></i>
|
| 656 |
+
Premium Access
|
| 657 |
+
</div>
|
| 658 |
+
</div>
|
| 659 |
+
</div>
|
| 660 |
+
</div>
|
| 661 |
+
`).join('');
|
| 662 |
+
} catch (err) {
|
| 663 |
+
console.error(err);
|
| 664 |
+
container.innerHTML = `
|
| 665 |
+
<div class="empty-state col-span-full text-center px-6 py-10 text-soft">
|
| 666 |
+
<i class="fas fa-triangle-exclamation mr-2"></i> Failed to load plans.
|
| 667 |
+
</div>
|
| 668 |
+
`;
|
| 669 |
+
}
|
| 670 |
}
|
| 671 |
|
| 672 |
function openPlanModal(id = '', days = '', price = '') {
|
|
|
|
| 674 |
document.getElementById('plan-days').value = days;
|
| 675 |
document.getElementById('plan-price').value = price;
|
| 676 |
document.getElementById('plan-modal-title').innerText = id ? 'Edit Plan' : 'Add New Plan';
|
| 677 |
+
|
| 678 |
+
const modal = document.getElementById('plan-modal');
|
| 679 |
+
modal.classList.remove('hidden');
|
| 680 |
+
modal.classList.add('flex');
|
| 681 |
+
document.body.classList.add('overflow-hidden');
|
| 682 |
+
}
|
| 683 |
+
|
| 684 |
+
function closePlanModal() {
|
| 685 |
+
const modal = document.getElementById('plan-modal');
|
| 686 |
+
modal.classList.add('hidden');
|
| 687 |
+
modal.classList.remove('flex');
|
| 688 |
+
document.body.classList.remove('overflow-hidden');
|
| 689 |
}
|
|
|
|
| 690 |
|
| 691 |
async function submitPlanForm(e) {
|
| 692 |
e.preventDefault();
|
| 693 |
+
|
| 694 |
const id = document.getElementById('plan-id').value;
|
| 695 |
+
const payload = {
|
| 696 |
+
days: parseInt(document.getElementById('plan-days').value),
|
| 697 |
+
price: parseFloat(document.getElementById('plan-price').value)
|
| 698 |
+
};
|
| 699 |
+
|
| 700 |
+
try {
|
| 701 |
+
const res = await fetch(id ? `/api/admin/subscriptions/plans/${id}` : '/api/admin/subscriptions/plans', {
|
| 702 |
+
method: id ? 'PUT' : 'POST',
|
| 703 |
+
headers: { 'Content-Type': 'application/json' },
|
| 704 |
+
body: JSON.stringify(payload)
|
| 705 |
+
});
|
| 706 |
+
|
| 707 |
+
if (!res.ok) throw new Error('Failed to save plan');
|
| 708 |
+
|
| 709 |
+
closePlanModal();
|
| 710 |
+
fetchPlans();
|
| 711 |
+
} catch (err) {
|
| 712 |
+
console.error(err);
|
| 713 |
+
showToast('Failed to save plan.', 'error', 'Save Failed');
|
| 714 |
+
}
|
| 715 |
}
|
| 716 |
|
| 717 |
async function deletePlan(id) {
|
| 718 |
if (!confirm('Delete this plan?')) return;
|
|
|
|
|
|
|
|
|
|
| 719 |
|
| 720 |
+
try {
|
| 721 |
+
const res = await fetch(`/api/admin/subscriptions/plans/${id}`, { method: 'DELETE' });
|
| 722 |
+
if (!res.ok) throw new Error('Failed');
|
| 723 |
+
fetchPlans();
|
| 724 |
+
} catch (err) {
|
| 725 |
+
console.error(err);
|
| 726 |
+
showToast('Failed to delete plan.', 'error', 'Delete Failed');
|
| 727 |
+
}
|
| 728 |
+
}
|
| 729 |
|
| 730 |
function getSubFiltered() {
|
| 731 |
+
const q = document.getElementById('sub-search').value.toLowerCase().trim();
|
| 732 |
const status = document.getElementById('sub-filter').value;
|
| 733 |
+
|
| 734 |
return allUsers.filter(u => {
|
| 735 |
const name = ((u.first_name || '') + ' ' + (u.username || '') + ' ' + (u._id || '')).toLowerCase();
|
| 736 |
const matchQ = !q || name.includes(q);
|
|
|
|
| 739 |
});
|
| 740 |
}
|
| 741 |
|
| 742 |
+
function renderDesktopRows(slice) {
|
| 743 |
+
const tbody = document.getElementById('subscribers-tbody');
|
| 744 |
+
|
| 745 |
+
if (!slice.length) {
|
| 746 |
+
tbody.innerHTML = `
|
| 747 |
+
<tr>
|
| 748 |
+
<td colspan="4" class="px-6 py-10 text-center text-soft">
|
| 749 |
+
No users match your search.
|
| 750 |
+
</td>
|
| 751 |
+
</tr>
|
| 752 |
+
`;
|
| 753 |
+
return;
|
| 754 |
+
}
|
| 755 |
+
|
| 756 |
+
tbody.innerHTML = slice.map(u => {
|
| 757 |
+
const expiry = formatExpiry(u.subscription_expiry);
|
| 758 |
+
const name = getUserDisplayName(u);
|
| 759 |
+
const safeName = name.replace(/'/g, "\\'");
|
| 760 |
+
const statusBadge = getStatusBadge(u.subscription_status);
|
| 761 |
+
|
| 762 |
+
return `
|
| 763 |
+
<tr>
|
| 764 |
+
<td class="px-6 py-4">
|
| 765 |
+
<div class="font-semibold section-title">${name}</div>
|
| 766 |
+
<div class="text-xs text-soft mt-1">ID: ${u._id}</div>
|
| 767 |
+
</td>
|
| 768 |
+
<td class="px-6 py-4 text-center">${statusBadge}</td>
|
| 769 |
+
<td class="px-6 py-4 text-center text-sm section-title">${expiry}</td>
|
| 770 |
+
<td class="px-6 py-4">
|
| 771 |
+
<div class="flex justify-end gap-2 flex-wrap">
|
| 772 |
+
<button onclick="openUserModal(${u._id}, '${safeName}', 'extend')"
|
| 773 |
+
class="action-chip glass-btn-success">
|
| 774 |
+
Extend
|
| 775 |
+
</button>
|
| 776 |
+
<button onclick="openUserModal(${u._id}, '${safeName}', 'reduce')"
|
| 777 |
+
class="action-chip glass-btn-warning">
|
| 778 |
+
Reduce
|
| 779 |
+
</button>
|
| 780 |
+
<button onclick="openUserModal(${u._id}, '${safeName}', 'delete')"
|
| 781 |
+
class="action-chip glass-btn-danger">
|
| 782 |
+
Revoke
|
| 783 |
+
</button>
|
| 784 |
+
</div>
|
| 785 |
+
</td>
|
| 786 |
+
</tr>
|
| 787 |
+
`;
|
| 788 |
+
}).join('');
|
| 789 |
+
}
|
| 790 |
+
|
| 791 |
+
function renderMobileCards(slice) {
|
| 792 |
+
const mobileWrap = document.getElementById('subscribers-mobile');
|
| 793 |
+
|
| 794 |
+
if (!slice.length) {
|
| 795 |
+
mobileWrap.innerHTML = `
|
| 796 |
+
<div class="empty-state text-center px-4 py-8 text-soft">
|
| 797 |
+
No users match your search.
|
| 798 |
+
</div>
|
| 799 |
+
`;
|
| 800 |
+
return;
|
| 801 |
+
}
|
| 802 |
+
|
| 803 |
+
mobileWrap.innerHTML = slice.map(u => {
|
| 804 |
+
const expiry = formatExpiry(u.subscription_expiry);
|
| 805 |
+
const name = getUserDisplayName(u);
|
| 806 |
+
const safeName = name.replace(/'/g, "\\'");
|
| 807 |
+
const statusBadge = getStatusBadge(u.subscription_status);
|
| 808 |
+
|
| 809 |
+
return `
|
| 810 |
+
<div class="mobile-user-card">
|
| 811 |
+
<div class="flex items-start justify-between gap-3 mb-3">
|
| 812 |
+
<div class="min-w-0">
|
| 813 |
+
<div class="font-semibold section-title break-words">${name}</div>
|
| 814 |
+
<div class="text-xs text-soft mt-1 break-all">ID: ${u._id}</div>
|
| 815 |
+
</div>
|
| 816 |
+
<div class="shrink-0">${statusBadge}</div>
|
| 817 |
+
</div>
|
| 818 |
+
|
| 819 |
+
<div class="grid grid-cols-1 gap-3 mb-4">
|
| 820 |
+
<div class="rounded-2xl px-4 py-3"
|
| 821 |
+
style="background: color-mix(in srgb, var(--bg) 55%, transparent); border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);">
|
| 822 |
+
<div class="text-[11px] uppercase tracking-[0.14em] text-soft font-bold mb-1">Expiry</div>
|
| 823 |
+
<div class="text-sm font-semibold section-title">${expiry}</div>
|
| 824 |
+
</div>
|
| 825 |
+
</div>
|
| 826 |
+
|
| 827 |
+
<div class="grid grid-cols-3 gap-2">
|
| 828 |
+
<button onclick="openUserModal(${u._id}, '${safeName}', 'extend')"
|
| 829 |
+
class="action-chip glass-btn-success w-full">
|
| 830 |
+
Extend
|
| 831 |
+
</button>
|
| 832 |
+
<button onclick="openUserModal(${u._id}, '${safeName}', 'reduce')"
|
| 833 |
+
class="action-chip glass-btn-warning w-full">
|
| 834 |
+
Reduce
|
| 835 |
+
</button>
|
| 836 |
+
<button onclick="openUserModal(${u._id}, '${safeName}', 'delete')"
|
| 837 |
+
class="action-chip glass-btn-danger w-full">
|
| 838 |
+
Revoke
|
| 839 |
+
</button>
|
| 840 |
+
</div>
|
| 841 |
+
</div>
|
| 842 |
+
`;
|
| 843 |
+
}).join('');
|
| 844 |
+
}
|
| 845 |
+
|
| 846 |
function renderSubPage() {
|
| 847 |
const filtered = getSubFiltered();
|
| 848 |
const pageSize = parseInt(document.getElementById('sub-page-size').value);
|
| 849 |
const totalPages = Math.max(1, Math.ceil(filtered.length / pageSize));
|
| 850 |
if (subPage > totalPages) subPage = totalPages;
|
| 851 |
+
|
| 852 |
+
const start = filtered.length ? (subPage - 1) * pageSize : 0;
|
| 853 |
const slice = filtered.slice(start, start + pageSize);
|
| 854 |
|
| 855 |
+
document.getElementById('sub-page-info').textContent =
|
| 856 |
+
filtered.length
|
| 857 |
+
? `Showing ${start + 1}–${Math.min(start + pageSize, filtered.length)} of ${filtered.length}`
|
| 858 |
+
: 'Showing 0 of 0';
|
| 859 |
+
|
| 860 |
document.getElementById('sub-page-num').textContent = `Page ${subPage} / ${totalPages}`;
|
|
|
|
|
|
|
| 861 |
|
| 862 |
+
const prevBtn = document.getElementById('sub-btn-prev');
|
| 863 |
+
const nextBtn = document.getElementById('sub-btn-next');
|
|
|
|
|
|
|
|
|
|
| 864 |
|
| 865 |
+
prevBtn.disabled = subPage <= 1;
|
| 866 |
+
nextBtn.disabled = subPage >= totalPages;
|
| 867 |
+
|
| 868 |
+
prevBtn.style.opacity = subPage <= 1 ? '0.45' : '1';
|
| 869 |
+
nextBtn.style.opacity = subPage >= totalPages ? '0.45' : '1';
|
| 870 |
+
|
| 871 |
+
renderDesktopRows(slice);
|
| 872 |
+
renderMobileCards(slice);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 873 |
}
|
| 874 |
|
| 875 |
+
function subChangePage(dir) {
|
| 876 |
+
const filtered = getSubFiltered();
|
| 877 |
+
const pageSize = parseInt(document.getElementById('sub-page-size').value);
|
| 878 |
+
const totalPages = Math.max(1, Math.ceil(filtered.length / pageSize));
|
| 879 |
+
|
| 880 |
+
subPage += dir;
|
| 881 |
+
if (subPage < 1) subPage = 1;
|
| 882 |
+
if (subPage > totalPages) subPage = totalPages;
|
| 883 |
+
|
| 884 |
+
renderSubPage();
|
| 885 |
+
}
|
| 886 |
|
| 887 |
async function fetchSubscribers() {
|
| 888 |
+
document.getElementById('subscribers-tbody').innerHTML = `
|
| 889 |
+
<tr>
|
| 890 |
+
<td colspan="4" class="px-6 py-8 text-center text-soft">
|
| 891 |
+
<i class="fas fa-spinner fa-spin mr-2"></i> Loading...
|
| 892 |
+
</td>
|
| 893 |
+
</tr>
|
| 894 |
+
`;
|
| 895 |
+
|
| 896 |
+
document.getElementById('subscribers-mobile').innerHTML = `
|
| 897 |
+
<div class="empty-state text-center px-4 py-8 text-soft">
|
| 898 |
+
<i class="fas fa-spinner fa-spin mr-2"></i> Loading...
|
| 899 |
+
</div>
|
| 900 |
+
`;
|
| 901 |
+
|
| 902 |
try {
|
| 903 |
const res = await fetch('/api/admin/subscriptions/users');
|
| 904 |
+
if (!res.ok) throw new Error('Failed to fetch users');
|
| 905 |
+
|
| 906 |
+
const data = await res.json();
|
| 907 |
+
allUsers = data.data || [];
|
| 908 |
+
subPage = 1;
|
| 909 |
+
renderSubPage();
|
| 910 |
+
} catch (err) {
|
| 911 |
+
console.error(err);
|
| 912 |
+
|
| 913 |
+
document.getElementById('subscribers-tbody').innerHTML = `
|
| 914 |
+
<tr>
|
| 915 |
+
<td colspan="4" class="px-6 py-8 text-center text-soft">
|
| 916 |
+
<i class="fas fa-triangle-exclamation mr-2"></i> Failed to load users.
|
| 917 |
+
</td>
|
| 918 |
+
</tr>
|
| 919 |
+
`;
|
| 920 |
+
|
| 921 |
+
document.getElementById('subscribers-mobile').innerHTML = `
|
| 922 |
+
<div class="empty-state text-center px-4 py-8 text-soft">
|
| 923 |
+
<i class="fas fa-triangle-exclamation mr-2"></i> Failed to load users.
|
| 924 |
+
</div>
|
| 925 |
+
`;
|
| 926 |
+
}
|
| 927 |
}
|
| 928 |
|
| 929 |
function openUserModal(userId, userName, action) {
|
| 930 |
document.getElementById('manage-user-id').value = userId;
|
| 931 |
document.getElementById('manage-action').value = action;
|
| 932 |
+
|
| 933 |
+
let title = '';
|
| 934 |
+
let desc = '';
|
| 935 |
+
let btnClasses = 'glass-btn glass-btn-primary rounded-2xl px-5 py-3 text-sm font-bold';
|
| 936 |
+
let showDays = true;
|
| 937 |
+
|
| 938 |
if (action === 'extend') {
|
| 939 |
+
title = 'Extend Subscription';
|
| 940 |
+
desc = `Add extra days to <b>${userName}</b>'s subscription.`;
|
| 941 |
+
document.getElementById('days-action-label').innerText = 'add';
|
| 942 |
+
btnClasses = 'glass-btn glass-btn-success rounded-2xl px-5 py-3 text-sm font-bold';
|
| 943 |
} else if (action === 'reduce') {
|
| 944 |
+
title = 'Reduce Subscription';
|
| 945 |
+
desc = `Subtract days from <b>${userName}</b>'s subscription.`;
|
| 946 |
+
document.getElementById('days-action-label').innerText = 'subtract';
|
| 947 |
+
btnClasses = 'glass-btn glass-btn-warning rounded-2xl px-5 py-3 text-sm font-bold';
|
| 948 |
} else {
|
| 949 |
+
title = 'Revoke Subscription';
|
| 950 |
+
desc = `<b>Warning:</b> This will remove <b>${userName}</b>'s subscription access completely.`;
|
| 951 |
+
showDays = false;
|
| 952 |
+
btnClasses = 'glass-btn glass-btn-danger rounded-2xl px-5 py-3 text-sm font-bold';
|
| 953 |
}
|
| 954 |
+
|
| 955 |
document.getElementById('user-modal-title').innerText = title;
|
| 956 |
document.getElementById('user-modal-desc').innerHTML = desc;
|
| 957 |
+
document.getElementById('days-input-group').style.display = showDays ? 'block' : 'none';
|
| 958 |
+
document.getElementById('btn-user-save').className = btnClasses;
|
| 959 |
+
|
| 960 |
+
if (!showDays) {
|
| 961 |
+
document.getElementById('manage-days').value = 0;
|
| 962 |
+
document.getElementById('manage-days').removeAttribute('required');
|
| 963 |
+
} else {
|
| 964 |
+
document.getElementById('manage-days').setAttribute('required', 'required');
|
| 965 |
+
if (!document.getElementById('manage-days').value || document.getElementById('manage-days').value === '0') {
|
| 966 |
+
document.getElementById('manage-days').value = 30;
|
| 967 |
+
}
|
| 968 |
+
}
|
| 969 |
+
|
| 970 |
+
const modal = document.getElementById('user-modal');
|
| 971 |
+
modal.classList.remove('hidden');
|
| 972 |
+
modal.classList.add('flex');
|
| 973 |
+
document.body.classList.add('overflow-hidden');
|
| 974 |
}
|
| 975 |
|
| 976 |
+
function closeUserModal() {
|
| 977 |
+
const modal = document.getElementById('user-modal');
|
| 978 |
+
modal.classList.add('hidden');
|
| 979 |
+
modal.classList.remove('flex');
|
| 980 |
+
document.body.classList.remove('overflow-hidden');
|
| 981 |
+
}
|
| 982 |
|
| 983 |
async function submitUserForm(e) {
|
| 984 |
e.preventDefault();
|
| 985 |
+
|
| 986 |
const userId = document.getElementById('manage-user-id').value;
|
| 987 |
const action = document.getElementById('manage-action').value;
|
| 988 |
const days = document.getElementById('manage-days').value;
|
| 989 |
+
|
| 990 |
+
try {
|
| 991 |
+
const res = await fetch(`/api/admin/subscriptions/users/${userId}/manage`, {
|
| 992 |
+
method: 'POST',
|
| 993 |
+
headers: { 'Content-Type': 'application/json' },
|
| 994 |
+
body: JSON.stringify({ action, days: parseInt(days) || 0 })
|
| 995 |
+
});
|
| 996 |
+
|
| 997 |
+
if (!res.ok) throw new Error('Failed to update user');
|
| 998 |
+
|
| 999 |
+
closeUserModal();
|
| 1000 |
+
showToast('Subscription updated successfully.', 'success', 'Updated');
|
| 1001 |
+
fetchSubscribers();
|
| 1002 |
+
} catch (err) {
|
| 1003 |
+
console.error(err);
|
| 1004 |
+
showToast('Failed to update user subscription.', 'error', 'Update Failed');
|
| 1005 |
+
}
|
| 1006 |
}
|
| 1007 |
|
| 1008 |
+
document.addEventListener('click', (e) => {
|
| 1009 |
+
const planModal = document.getElementById('plan-modal');
|
| 1010 |
+
const userModal = document.getElementById('user-modal');
|
| 1011 |
+
|
| 1012 |
+
if (e.target === planModal) closePlanModal();
|
| 1013 |
+
if (e.target === userModal) closeUserModal();
|
| 1014 |
+
});
|
| 1015 |
+
|
| 1016 |
+
document.addEventListener('keydown', (e) => {
|
| 1017 |
+
if (e.key === 'Escape') {
|
| 1018 |
+
closePlanModal();
|
| 1019 |
+
closeUserModal();
|
| 1020 |
+
}
|
| 1021 |
+
});
|
| 1022 |
+
|
| 1023 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 1024 |
+
fetchPlans();
|
| 1025 |
+
fetchSubscribers();
|
| 1026 |
+
});
|
| 1027 |
</script>
|
| 1028 |
+
{% endblock %}
|
Backend/fastapi/themes.py
CHANGED
|
@@ -1,14 +1,28 @@
|
|
| 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 |
-
"
|
|
|
|
| 12 |
"text_secondary": "#64748B"
|
| 13 |
},
|
| 14 |
"css_classes": "theme-purple-gradient"
|
|
@@ -16,191 +30,94 @@ THEMES = {
|
|
| 16 |
"blue_navy": {
|
| 17 |
"name": "Navy Blue",
|
| 18 |
"colors": {
|
| 19 |
-
"primary": "#
|
| 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": "#
|
| 101 |
-
"card": "#
|
|
|
|
| 102 |
"text": "#FFFFFF",
|
| 103 |
-
"text_secondary": "#
|
| 104 |
},
|
| 105 |
"css_classes": "theme-cyber-neon"
|
| 106 |
},
|
| 107 |
-
"
|
| 108 |
-
"name": "
|
| 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": "#
|
| 137 |
-
"secondary": "#
|
| 138 |
-
"accent": "#
|
| 139 |
-
"background": "#
|
| 140 |
-
"card": "#
|
| 141 |
-
"
|
| 142 |
-
"
|
|
|
|
| 143 |
},
|
| 144 |
-
"css_classes": "theme-
|
| 145 |
},
|
| 146 |
-
"
|
| 147 |
-
"name": "
|
| 148 |
"colors": {
|
| 149 |
-
"primary": "#
|
| 150 |
-
"secondary": "#
|
| 151 |
-
"accent": "#
|
| 152 |
-
"background": "#
|
| 153 |
"card": "#FFFFFF",
|
| 154 |
-
"
|
| 155 |
-
"
|
|
|
|
| 156 |
},
|
| 157 |
-
"css_classes": "theme-
|
| 158 |
},
|
| 159 |
-
|
| 160 |
-
|
|
|
|
| 161 |
"colors": {
|
| 162 |
-
"primary": "#
|
| 163 |
-
"secondary": "#
|
| 164 |
-
"accent": "#
|
| 165 |
-
"background": "#
|
| 166 |
-
"card": "#FFFFFF",
|
| 167 |
-
"
|
| 168 |
-
"
|
|
|
|
| 169 |
},
|
| 170 |
-
"css_classes": "theme-
|
| 171 |
},
|
| 172 |
-
"
|
| 173 |
-
"name": "
|
| 174 |
"colors": {
|
| 175 |
-
"primary": "#
|
| 176 |
-
"secondary": "#
|
| 177 |
-
"accent": "#
|
| 178 |
-
"background": "#
|
| 179 |
-
"card": "#FFFFFF",
|
| 180 |
-
"
|
|
|
|
| 181 |
"text_secondary": "#4B5563"
|
| 182 |
},
|
| 183 |
-
"css_classes": "theme-
|
| 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 |
-
|
| 202 |
-
return THEMES.get(theme_name, THEMES["
|
| 203 |
-
|
| 204 |
|
| 205 |
def get_all_themes():
|
|
|
|
| 206 |
return THEMES
|
|
|
|
|
|
|
| 1 |
THEMES = {
|
| 2 |
+
"dark_professional": {
|
| 3 |
+
"name": "Dark Professional",
|
| 4 |
+
"colors": {
|
| 5 |
+
"primary": "#06B6D4",
|
| 6 |
+
"secondary": "#0891B2",
|
| 7 |
+
"accent": "#22D3EE",
|
| 8 |
+
"background": "#0F172A",
|
| 9 |
+
"card": "#1E293B",
|
| 10 |
+
"border": "#334155",
|
| 11 |
+
"text": "#F8FAFC",
|
| 12 |
+
"text_secondary": "#94A3B8"
|
| 13 |
+
},
|
| 14 |
+
"css_classes": "theme-dark-professional"
|
| 15 |
+
},
|
| 16 |
"purple_gradient": {
|
| 17 |
"name": "Purple Gradient",
|
| 18 |
"colors": {
|
| 19 |
"primary": "#A855F7",
|
| 20 |
+
"secondary": "#7C3AED",
|
| 21 |
"accent": "#C084FC",
|
| 22 |
"background": "#F8FAFC",
|
| 23 |
"card": "#FFFFFF",
|
| 24 |
+
"border": "#E2E8F0",
|
| 25 |
+
"text": "#0F172A",
|
| 26 |
"text_secondary": "#64748B"
|
| 27 |
},
|
| 28 |
"css_classes": "theme-purple-gradient"
|
|
|
|
| 30 |
"blue_navy": {
|
| 31 |
"name": "Navy Blue",
|
| 32 |
"colors": {
|
| 33 |
+
"primary": "#2563EB",
|
| 34 |
"secondary": "#1E3A8A",
|
| 35 |
"accent": "#3B82F6",
|
| 36 |
"background": "#F1F5F9",
|
| 37 |
"card": "#FFFFFF",
|
| 38 |
+
"border": "#CBD5E1",
|
| 39 |
"text": "#1E293B",
|
| 40 |
"text_secondary": "#475569"
|
| 41 |
},
|
| 42 |
"css_classes": "theme-blue-navy"
|
| 43 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
"cyber_neon": {
|
| 45 |
"name": "Cyber Neon",
|
| 46 |
"colors": {
|
| 47 |
"primary": "#00FFF0",
|
| 48 |
"secondary": "#FF00FF",
|
| 49 |
"accent": "#00FF88",
|
| 50 |
+
"background": "#050714",
|
| 51 |
+
"card": "#0D1127",
|
| 52 |
+
"border": "#1A1F3A",
|
| 53 |
"text": "#FFFFFF",
|
| 54 |
+
"text_secondary": "#8B95B3"
|
| 55 |
},
|
| 56 |
"css_classes": "theme-cyber-neon"
|
| 57 |
},
|
| 58 |
+
"midnight_carbon": {
|
| 59 |
+
"name": "Midnight Carbon",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
"colors": {
|
| 61 |
+
"primary": "#3B82F6",
|
| 62 |
+
"secondary": "#1D4ED8",
|
| 63 |
+
"accent": "#60A5FA",
|
| 64 |
+
"background": "#030712",
|
| 65 |
+
"card": "#111827",
|
| 66 |
+
"border": "#1F2937",
|
| 67 |
+
"text": "#F9FAFB",
|
| 68 |
+
"text_secondary": "#9CA3AF"
|
| 69 |
},
|
| 70 |
+
"css_classes": "theme-midnight-carbon"
|
| 71 |
},
|
| 72 |
+
"ocean_mint": {
|
| 73 |
+
"name": "Ocean Mint",
|
| 74 |
"colors": {
|
| 75 |
+
"primary": "#10B981",
|
| 76 |
+
"secondary": "#059669",
|
| 77 |
+
"accent": "#06B6D4",
|
| 78 |
+
"background": "#F0FDF4",
|
| 79 |
"card": "#FFFFFF",
|
| 80 |
+
"border": "#DCFCE7",
|
| 81 |
+
"text": "#064E3B",
|
| 82 |
+
"text_secondary": "#374151"
|
| 83 |
},
|
| 84 |
+
"css_classes": "theme-ocean-mint"
|
| 85 |
},
|
| 86 |
+
|
| 87 |
+
"sunset_warm": {
|
| 88 |
+
"name": "Sunset Warm",
|
| 89 |
"colors": {
|
| 90 |
+
"primary": "#F59E0B",
|
| 91 |
+
"secondary": "#DC2626",
|
| 92 |
+
"accent": "#EC4899",
|
| 93 |
+
"background": "#FFFBEB",
|
| 94 |
+
"card": "#FFFFFF",
|
| 95 |
+
"border": "#FEF3C7",
|
| 96 |
+
"text": "#451A03",
|
| 97 |
+
"text_secondary": "#78350F"
|
| 98 |
},
|
| 99 |
+
"css_classes": "theme-sunset-warm"
|
| 100 |
},
|
| 101 |
+
"forest_earth": {
|
| 102 |
+
"name": "Forest Earth",
|
| 103 |
"colors": {
|
| 104 |
+
"primary": "#166534",
|
| 105 |
+
"secondary": "#064E3B",
|
| 106 |
+
"accent": "#86A789",
|
| 107 |
+
"background": "#F7F7F2",
|
| 108 |
+
"card": "#FFFFFF",
|
| 109 |
+
"border": "#E5E7EB",
|
| 110 |
+
"text": "#14532D",
|
| 111 |
"text_secondary": "#4B5563"
|
| 112 |
},
|
| 113 |
+
"css_classes": "theme-forest-earth"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
}
|
| 115 |
}
|
| 116 |
|
| 117 |
+
def get_theme(theme_name: str = "dark_professional"):
|
| 118 |
+
"""Returns the dictionary for the requested theme or the default."""
|
| 119 |
+
return THEMES.get(theme_name, THEMES["dark_professional"])
|
|
|
|
| 120 |
|
| 121 |
def get_all_themes():
|
| 122 |
+
"""Returns all available theme configurations."""
|
| 123 |
return THEMES
|
sample_config.env
CHANGED
|
@@ -4,26 +4,41 @@ API_HASH=""
|
|
| 4 |
BOT_TOKEN=""
|
| 5 |
HELPER_BOT_TOKEN=""
|
| 6 |
OWNER_ID=""
|
| 7 |
-
REPLACE_MODE=""
|
| 8 |
-
HIDE_CATALOG=""
|
| 9 |
PARALLEL="4"
|
| 10 |
PRE_FETCH="3"
|
|
|
|
|
|
|
| 11 |
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=""
|
| 19 |
ADMIN_PASSWORD=""
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
APPROVER_IDS= #without ""
|
| 23 |
-
SUBSCRIPTION_URL=""
|
| 24 |
-
|
| 25 |
-
#
|
| 26 |
Proxy=True
|
| 27 |
ProxyType=HTTPS
|
| 28 |
-
HTTP_Proxy_URL=""
|
| 29 |
-
SHOW_ProxyAndNonProxyBoth=True
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
BOT_TOKEN=""
|
| 5 |
HELPER_BOT_TOKEN=""
|
| 6 |
OWNER_ID=""
|
| 7 |
+
REPLACE_MODE="true"
|
| 8 |
+
HIDE_CATALOG="false"
|
| 9 |
PARALLEL="4"
|
| 10 |
PRE_FETCH="3"
|
| 11 |
+
|
| 12 |
+
# STORAGE
|
| 13 |
AUTH_CHANNEL=""
|
| 14 |
DATABASE=""
|
| 15 |
+
|
| 16 |
+
# API
|
| 17 |
TMDB_API=""
|
| 18 |
+
|
| 19 |
+
# SERVER
|
| 20 |
BASE_URL=""
|
| 21 |
+
PORT="8000"
|
| 22 |
+
|
| 23 |
+
# UPDATE REPO
|
| 24 |
UPSTREAM_REPO="https://github.com/weebzone/Telegram-Stremio"
|
| 25 |
UPSTREAM_BRANCH="master"
|
| 26 |
+
|
| 27 |
+
# ADMIN PANNEL
|
| 28 |
ADMIN_USERNAME=""
|
| 29 |
ADMIN_PASSWORD=""
|
| 30 |
+
|
| 31 |
+
# SUBSCRIPTION CONFIG
|
| 32 |
+
SUBSCRIPTION=False #without ""
|
| 33 |
+
SUBSCRIPTION_GROUP_ID= #without ""
|
| 34 |
APPROVER_IDS= #without ""
|
| 35 |
+
SUBSCRIPTION_URL="" #telegram bot url like https://t.me/username
|
| 36 |
+
|
| 37 |
+
# PROXY CONFIG
|
| 38 |
Proxy=True
|
| 39 |
ProxyType=HTTPS
|
| 40 |
+
HTTP_Proxy_URL="" #example https://PROXYURL/?url=
|
| 41 |
+
SHOW_ProxyAndNonProxyBoth=True #this will show both link proxy and non proxy both
|
| 42 |
+
|
| 43 |
+
# MULTI TOKEN CONFIG
|
| 44 |
+
MULTI_TOKEN1=""
|