Karan Adhikari commited on
Fix Dashboard UI
Browse files
Backend/fastapi/templates/dashboard.html
CHANGED
|
@@ -4,17 +4,17 @@
|
|
| 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>
|
|
@@ -227,18 +227,18 @@
|
|
| 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>
|
|
@@ -267,7 +267,7 @@
|
|
| 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">
|
|
@@ -342,6 +342,59 @@
|
|
| 342 |
</tbody>
|
| 343 |
</table>
|
| 344 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
</div>
|
| 346 |
</section>
|
| 347 |
</div>
|
|
@@ -853,24 +906,42 @@
|
|
| 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 &&
|
| 863 |
-
const dailyBytes = token.usage.daily.bytes || 0;
|
| 864 |
dailyUsageSpan.setAttribute('data-bytes', dailyBytes);
|
| 865 |
dailyUsageSpan.textContent = formatBytes(dailyBytes);
|
| 866 |
}
|
| 867 |
|
| 868 |
-
if (monthlyUsageSpan &&
|
| 869 |
-
const monthlyBytes = token.usage.monthly.bytes || 0;
|
| 870 |
monthlyUsageSpan.setAttribute('data-bytes', monthlyBytes);
|
| 871 |
monthlyUsageSpan.textContent = formatBytes(monthlyBytes);
|
| 872 |
}
|
| 873 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 874 |
});
|
| 875 |
}
|
| 876 |
}
|
|
|
|
| 4 |
|
| 5 |
{% block content %}
|
| 6 |
<div class="min-h-screen pb-12">
|
| 7 |
+
<header class="mb-8 sm:mb-10">
|
| 8 |
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4">
|
| 9 |
<div>
|
| 10 |
+
<h1 class="text-2xl sm: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-xs sm:text-sm mt-1">Real-time performance, live stream activity, and token access management</p>
|
| 14 |
</div>
|
| 15 |
|
| 16 |
<button onclick="refreshDashboard()"
|
| 17 |
+
class="w-full md:w-auto 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>
|
|
|
|
| 227 |
|
| 228 |
<section class="mt-12">
|
| 229 |
<div class="glass-panel rounded-[2.5rem] overflow-hidden">
|
| 230 |
+
<div class="p-5 sm:p-8 border-b border-white/5 flex flex-col md:flex-row md:justify-between md:items-center gap-4">
|
| 231 |
<div>
|
| 232 |
+
<h3 class="text-lg sm:text-xl font-bold text-text">Access Management</h3>
|
| 233 |
+
<p class="text-xs sm: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="w-full md:w-auto justify-center 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-5 sm: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>
|
|
|
|
| 267 |
</form>
|
| 268 |
</div>
|
| 269 |
|
| 270 |
+
<div class="overflow-x-auto hidden md:block">
|
| 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">
|
|
|
|
| 342 |
</tbody>
|
| 343 |
</table>
|
| 344 |
</div>
|
| 345 |
+
|
| 346 |
+
<div class="md:hidden divide-y divide-white/5">
|
| 347 |
+
{% for token in api_tokens %}
|
| 348 |
+
<div class="p-5 space-y-4" id="token-card-{{ loop.index0 }}">
|
| 349 |
+
<div class="flex items-start justify-between gap-3">
|
| 350 |
+
<div class="min-w-0">
|
| 351 |
+
<p class="font-bold text-text truncate">{{ token.name }}</p>
|
| 352 |
+
<p class="text-[10px] text-text-secondary uppercase mt-1">
|
| 353 |
+
{{ token.created_at.strftime('%Y-%m-%d') if token.created_at else 'Unknown date' }}
|
| 354 |
+
</p>
|
| 355 |
+
</div>
|
| 356 |
+
<div class="flex gap-2 shrink-0">
|
| 357 |
+
<button onclick='openEditModal({{ token.token|tojson }}, {{ token.limits.daily_limit_gb|default(0)|tojson }}, {{ token.limits.monthly_limit_gb|default(0)|tojson }})'
|
| 358 |
+
class="w-9 h-9 rounded-lg bg-white/5 flex items-center justify-center text-text-secondary hover:bg-blue-500 hover:text-white transition-all">
|
| 359 |
+
<i class="fa-solid fa-pen-to-square text-xs"></i>
|
| 360 |
+
</button>
|
| 361 |
+
<button onclick='revokeToken({{ token.token|tojson }})'
|
| 362 |
+
class="w-9 h-9 rounded-lg bg-white/5 flex items-center justify-center text-text-secondary hover:bg-red-500 hover:text-white transition-all">
|
| 363 |
+
<i class="fa-solid fa-trash text-xs"></i>
|
| 364 |
+
</button>
|
| 365 |
+
</div>
|
| 366 |
+
</div>
|
| 367 |
+
|
| 368 |
+
<div class="grid grid-cols-2 gap-3 pt-3 border-t border-white/5">
|
| 369 |
+
<div>
|
| 370 |
+
<p class="text-[10px] uppercase font-bold tracking-widest text-text-secondary mb-1">Daily</p>
|
| 371 |
+
<p class="text-xs font-medium text-text">
|
| 372 |
+
<span class="text-primary" data-bytes="{{ token.usage.daily.bytes|default(0) }}"></span>
|
| 373 |
+
<span class="text-text-secondary"> / {{ token.limits.daily_limit_gb or '∞' }} GB</span>
|
| 374 |
+
</p>
|
| 375 |
+
</div>
|
| 376 |
+
<div>
|
| 377 |
+
<p class="text-[10px] uppercase font-bold tracking-widest text-text-secondary mb-1">Monthly</p>
|
| 378 |
+
<p class="text-xs font-medium text-text">
|
| 379 |
+
<span class="text-accent" data-bytes="{{ token.usage.monthly.bytes|default(0) }}"></span>
|
| 380 |
+
<span class="text-text-secondary"> / {{ token.limits.monthly_limit_gb or '∞' }} GB</span>
|
| 381 |
+
</p>
|
| 382 |
+
</div>
|
| 383 |
+
</div>
|
| 384 |
+
|
| 385 |
+
<button onclick='copyUrl({{ ((request.base_url|string).replace("http:", "https:") ~ "stremio/" ~ token.token ~ "/manifest.json")|tojson }})'
|
| 386 |
+
class="w-full flex items-center justify-center gap-2 px-3 py-2.5 bg-background/50 rounded-xl border border-white/5 text-[10px] font-bold text-text-secondary hover:text-primary hover:border-primary/30 transition-all">
|
| 387 |
+
<i class="fa-solid fa-link text-[8px]"></i> COPY MANIFEST
|
| 388 |
+
</button>
|
| 389 |
+
</div>
|
| 390 |
+
{% endfor %}
|
| 391 |
+
|
| 392 |
+
{% if not api_tokens %}
|
| 393 |
+
<div class="p-10 text-center text-text-secondary">
|
| 394 |
+
No tokens found.
|
| 395 |
+
</div>
|
| 396 |
+
{% endif %}
|
| 397 |
+
</div>
|
| 398 |
</div>
|
| 399 |
</section>
|
| 400 |
</div>
|
|
|
|
| 906 |
if (stats.api_tokens && Array.isArray(stats.api_tokens)) {
|
| 907 |
const rows = document.querySelectorAll('tbody tr');
|
| 908 |
stats.api_tokens.forEach((token, index) => {
|
| 909 |
+
const dailyBytes = (token.usage && token.usage.daily) ? (token.usage.daily.bytes || 0) : null;
|
| 910 |
+
const monthlyBytes = (token.usage && token.usage.monthly) ? (token.usage.monthly.bytes || 0) : null;
|
| 911 |
+
|
| 912 |
if (rows.length > index && !rows[index].querySelector('[colspan]')) {
|
| 913 |
const row = rows[index];
|
| 914 |
|
| 915 |
const dailyUsageSpan = row.querySelector('td:nth-child(2) span[data-bytes]');
|
| 916 |
const monthlyUsageSpan = row.querySelectorAll('td:nth-child(2) span[data-bytes]')[1];
|
| 917 |
|
| 918 |
+
if (dailyUsageSpan && dailyBytes !== null) {
|
|
|
|
| 919 |
dailyUsageSpan.setAttribute('data-bytes', dailyBytes);
|
| 920 |
dailyUsageSpan.textContent = formatBytes(dailyBytes);
|
| 921 |
}
|
| 922 |
|
| 923 |
+
if (monthlyUsageSpan && monthlyBytes !== null) {
|
|
|
|
| 924 |
monthlyUsageSpan.setAttribute('data-bytes', monthlyBytes);
|
| 925 |
monthlyUsageSpan.textContent = formatBytes(monthlyBytes);
|
| 926 |
}
|
| 927 |
}
|
| 928 |
+
|
| 929 |
+
// Keep the mobile card view in sync as well
|
| 930 |
+
const card = document.getElementById(`token-card-${index}`);
|
| 931 |
+
if (card) {
|
| 932 |
+
const cardDaily = card.querySelector('span.text-primary[data-bytes]');
|
| 933 |
+
const cardMonthly = card.querySelector('span.text-accent[data-bytes]');
|
| 934 |
+
|
| 935 |
+
if (cardDaily && dailyBytes !== null) {
|
| 936 |
+
cardDaily.setAttribute('data-bytes', dailyBytes);
|
| 937 |
+
cardDaily.textContent = formatBytes(dailyBytes);
|
| 938 |
+
}
|
| 939 |
+
|
| 940 |
+
if (cardMonthly && monthlyBytes !== null) {
|
| 941 |
+
cardMonthly.setAttribute('data-bytes', monthlyBytes);
|
| 942 |
+
cardMonthly.textContent = formatBytes(monthlyBytes);
|
| 943 |
+
}
|
| 944 |
+
}
|
| 945 |
});
|
| 946 |
}
|
| 947 |
}
|