Spaces:
Sleeping
Sleeping
Nathan commited on
Commit ·
d816aa5
1
Parent(s): 0d95d18
Major UI & Admin Overhaul: Premium aesthetics and advanced pricing controls
Browse filesFiles changed (2)
- dashboard/admin.html+104-147
- dashboard/index.html+145-88
5 unmodified lines67891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891903 unmodified lines1941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262274 unmodified lines2322332342352362372382395 unmodified lines<title>Admin Control Center — ViralFlow AI</title><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&family=Outfit:wght@500;700;900&display=swap" rel="stylesheet"><style>:root {--bg: #0a0a0c;--panel: rgba(255, 255, 255, 0.03);--accent: #818cf8;--danger: #ef4444;--text: #ffffff;--text-dim: #94a3b8;}body {background-color: var(--bg);color: var(--text);font-family: 'Inter', sans-serif;margin: 0;padding: 40px;}.header {display: flex;justify-content: space-between;align-items: center;margin-bottom: 40px;}h1 { font-family: 'Outfit', sans-serif; font-size: 2rem; margin: 0; }.admin-table {width: 100%;border-collapse: collapse;background: var(--panel);border-radius: 20px;overflow: hidden;border: 1px solid rgba(255,255,255,0.05);}th {text-align: left;padding: 20px;background: rgba(255,255,255,0.05);color: var(--text-dim);font-size: 0.8rem;text-transform: uppercase;letter-spacing: 1px;}td {padding: 20px;border-bottom: 1px solid rgba(255,255,255,0.05);}.badge {padding: 4px 10px;border-radius: 20px;font-size: 0.75rem;font-weight: 700;}.badge-free { background: rgba(148, 163, 184, 0.1); color: #94a3b8; }.badge-premium { background: rgba(129, 140, 248, 0.1); color: #818cf8; border: 1px solid rgba(129, 140, 248, 0.2); }.badge-ultra { background: rgba(245, 158, 11, 0.1); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.2); }.btn-action {cursor: pointer;border: none;padding: 8px 16px;border-radius: 10px;font-weight: 700;color: white;font-size: 0.8rem;}.btn-back {color: var(--text-dim);text-decoration: none;font-size: 0.9rem;display: flex;align-items: center;gap: 8px;}</style></head><body><div class="header"><div><a href="index.html" class="btn-back">← Back to Dashboard</a><h1>Admin Control Center (Iron Fist 🛡️)</h1></div><div style="display: flex; gap: 30px; text-align: center;"><div><div style="font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase;">Total Creators</div><div id="stat-users" style="font-size: 1.5rem; font-weight: 800; color: var(--accent);">0</div></div><div><div style="font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase;">Active Channels</div><div id="stat-active" style="font-size: 1.5rem; font-weight: 800; color: #10b981;">0</div></div><div><div style="font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase;">Total Videos</div><div id="stat-videos" style="font-size: 1.5rem; font-weight: 800; color: #fff;">0</div></div></div></div><div class="panel"><h3 class="panel-title">Revenue Control Center</h3><div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px;"><div class="input-group"><label>Monthly Price (₹)</label><input type="number" id="price-monthly" value="299"></div><div class="input-group"><label>Yearly Price (₹)</label><input type="number" id="price-yearly" value="2999"></div><div class="input-group"><label>Discount (%)</label><input type="number" id="discount-pct" value="20"></div><div class="input-group"><label>Sale Text</label><input type="text" id="sale-text" value="Launch Sale!"></div></div><div style="display: flex; gap: 20px; margin-top: 15px; flex-wrap: wrap;"><label style="cursor: pointer; display: flex; align-items: center; gap: 8px;"><input type="checkbox" id="m-sale-active" style="width: auto;"> Monthly Sale Active</label><label style="cursor: pointer; display: flex; align-items: center; gap: 8px;"><input type="checkbox" id="y-sale-active" style="width: auto;"> Yearly Sale Active</label><button class="btn-primary" onclick="savePricing()" style="margin-left: auto;">Save Pricing Engine</button></div></div><table class="admin-table"><thead><tr><th>User Email</th><th>Connected Channel</th><th>Plan</th><th>Status</th><th>Moderate</th></tr></thead><tbody id="user-list"><!-- Loaded via JS --></tbody></table><script>const authToken = localStorage.getItem('saas_token');async function loadAdminData() {if (!authToken) { window.location.href = 'index.html'; return; }// Load Global Statsconst statsRes = await fetch('/api/admin/global-stats', { headers: { 'Authorization': `Bearer ${authToken}` } });const stats = await statsRes.json();document.getElementById('stat-users').innerText = stats.totalUsers || 0;document.getElementById('stat-active').innerText = stats.activeChannels || 0;document.getElementById('stat-videos').innerText = stats.totalVideos || 0;const res = await fetch('/api/admin/users', {headers: { 'Authorization': `Bearer ${authToken}` }});if (!res.ok) {alert('Access Denied: Only Super Admins can see this page.');window.location.href = 'index.html';return;}const users = await res.json();const list = document.getElementById('user-list');list.innerHTML = users.map(u => `<tr><td style="font-weight: 600;">${u.email}</td><td><div style="font-weight: 700; color: #fff;">${u.channels?.[0]?.channel_name || '❌ Not Connected'}</div><div style="font-size: 0.7rem; color: var(--text-dim);">${u.channels?.[0]?.channel_id || ''}</div></td><td><span class="badge ${u.plan === 'ultra' ? 'badge-ultra' : (u.plan === 'premium' ? 'badge-premium' : 'badge-free')}">${u.plan === 'ultra' ? 'GOD MODE' : (u.plan === 'premium' ? 'PRO' : 'FREE')}</span></td><td><div style="display: flex; align-items: center; gap: 6px; font-size: 0.8rem;"><div style="width: 8px; height: 8px; border-radius: 50%; background: ${u.channels?.[0]?.is_active ? '#10b981' : '#94a3b8'};"></div>${u.channels?.[0]?.is_active ? 'Connected' : 'Waiting'}</div></td><td><div style="display: flex; gap: 10px;"><button class="btn-action" onclick="adminAction('${u.id}', 'ultra')" style="background: #f59e0b;">☢️ ULTRA</button><button class="btn-action" onclick="adminAction('${u.id}', 'release')" style="background: var(--accent);">Release</button><button class="btn-action" onclick="adminAction('${u.id}', 'ban')" style="background: var(--danger);">☢️ BAN</button></div></td></tr>`).join('');3 unmodified linesconst res = await fetch('/api/platform/pricing');const p = await res.json();if (p) {document.getElementById('price-monthly').value = p.pro_monthly || 299;document.getElementById('price-yearly').value = p.pro_yearly || 2999;document.getElementById('discount-pct').value = p.discount_percent || 0;document.getElementById('sale-text').value = p.discount_text || "Launch Sale!";document.getElementById('m-sale-active').checked = p.m_discount_active || false;document.getElementById('y-sale-active').checked = p.y_discount_active || false;}}async function adminAction(userId, type) {if (!confirm(`Are you sure you want to perform ${type} on this user?`)) return;const res = await fetch('/api/admin/action', {method: 'POST',headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${authToken}` },body: JSON.stringify({ userId, type })});if (res.ok) {alert(`Action ${type} completed! 🛡️`);loadAdminData();} else {alert("Action failed.");}}async function savePricing() {const pricing = {pro_monthly: parseInt(document.getElementById('price-monthly').value),pro_yearly: parseInt(document.getElementById('price-yearly').value),discount_percent: parseInt(document.getElementById('discount-pct').value),discount_text: document.getElementById('sale-text').value,m_discount_active: document.getElementById('m-sale-active').checked,4 unmodified linesheaders: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${authToken}` },body: JSON.stringify({ pricing })});if (res.ok) alert("Pricing Engine Updated! 🚀");else alert("Failed to update pricing.");}loadAdminPricing();5 unmodified lines67891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581593 unmodified lines1631641651661671681691701711721731741751761771781791801811821831841854 unmodified lines1901911921931941951965 unmodified lines<title>Admin Control Center — ViralFlow AI</title><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800;900&family=Plus+Jakarta+Sans:wght@300;400;600;700&display=swap" rel="stylesheet"><script src="https://unpkg.com/lucide@latest"></script><style>:root {--bg: #020617;--surface: rgba(15, 23, 42, 0.6);--accent: #6366f1;--success: #10b981;--danger: #ef4444;--text: #f8fafc;--text-dim: #94a3b8;--glass-border: rgba(255, 255, 255, 0.08);}* { box-sizing: border-box; transition: all 0.3s ease; }body {background: radial-gradient(circle at 50% -20%, #1e1b4b 0%, var(--bg) 80%);color: var(--text);font-family: 'Plus Jakarta Sans', sans-serif;margin: 0; padding: 40px;}.glass-panel {background: var(--surface); backdrop-filter: blur(20px);border-radius: 32px; border: 1px solid var(--glass-border);padding: 40px; margin-bottom: 30px;}.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px; }h1 { font-family: 'Outfit', sans-serif; font-size: 2.2rem; font-weight: 900; margin: 0; }.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }.input-group { margin-bottom: 20px; }label { display: block; margin-bottom: 10px; font-size: 0.8rem; font-weight: 800; color: var(--text-dim); text-transform: uppercase; }input {width: 100%; background: rgba(0,0,0,0.3); border: 1px solid var(--glass-border);padding: 15px 20px; border-radius: 15px; color: #fff; outline: none;}/* --- Toggle Switch --- */.switch { position: relative; display: inline-block; width: 60px; height: 34px; }.switch input { opacity: 0; width: 0; height: 0; }.slider {position: absolute; cursor: pointer; inset: 0; background-color: #334155;transition: .4s; border-radius: 34px;}.slider:before {position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px;background-color: white; transition: .4s; border-radius: 50%;}input:checked + .slider { background-color: var(--accent); }input:checked + .slider:before { transform: translateX(26px); }.admin-table {width: 100%; border-collapse: collapse; margin-top: 30px;}th { text-align: left; padding: 20px; color: var(--text-dim); font-size: 0.8rem; text-transform: uppercase; border-bottom: 1px solid var(--glass-border); }td { padding: 20px; border-bottom: 1px solid var(--glass-border); }.badge { padding: 6px 14px; border-radius: 20px; font-size: 0.75rem; font-weight: 900; }.badge-free { background: rgba(148, 163, 184, 0.1); color: #94a3b8; }.badge-premium { background: rgba(129, 140, 248, 0.1); color: #818cf8; }.badge-ultra { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }.btn-primary {cursor: pointer; border: none; padding: 14px 28px; border-radius: 18px;background: var(--accent); color: #fff; font-weight: 800;}</style></head><body><div class="header"><div><a href="index.html" style="color: var(--text-dim); text-decoration: none; font-size: 0.9rem; font-weight: 700;">← Exit Admin</a><h1>Revenue Control Center 💰</h1></div><div style="display: flex; gap: 40px;"><div style="text-align: center;"><div style="font-size: 0.7rem; color: var(--text-dim);">USERS</div><div id="stat-users" style="font-size: 1.8rem; font-weight: 900;">0</div></div><div style="text-align: center;"><div style="font-size: 0.7rem; color: var(--text-dim);">CHANNELS</div><div id="stat-active" style="font-size: 1.8rem; font-weight: 900; color: var(--success);">0</div></div></div></div><div class="glass-panel"><h3 style="margin-top: 0; font-family: 'Outfit', sans-serif;">Advanced Pricing Engine</h3><div class="pricing-grid"><div class="input-group"><label>Monthly Sale Price (₹)</label><input type="number" id="price-monthly"></div><div class="input-group"><label>Monthly Old Price (₹)</label><input type="number" id="old-price-monthly"></div><div class="input-group"><label>Yearly Sale Price (₹)</label><input type="number" id="price-yearly"></div><div class="input-group"><label>Yearly Old Price (₹)</label><input type="number" id="old-price-yearly"></div></div><div class="pricing-grid" style="margin-top: 20px;"><div class="input-group"><label>Discount Percent (%)</label><input type="number" id="discount-pct"></div><div class="input-group"><label>Sale Badge Text</label><input type="text" id="sale-text"></div><div class="input-group"><label>Monthly Sale Active</label><label class="switch"><input type="checkbox" id="m-sale-active"><span class="slider"></span></label></div><div class="input-group"><label>Yearly Sale Active</label><label class="switch"><input type="checkbox" id="y-sale-active"><span class="slider"></span></label></div></div><div style="text-align: right; margin-top: 20px;"><button class="btn-primary" onclick="savePricing()">Apply Global Price Changes 🚀</button></div></div><div class="glass-panel" style="padding: 0; overflow: hidden;"><table class="admin-table"><thead><tr><th>Agency Owner</th><th>YouTube Channel</th><th>Current Tier</th><th>Automation Status</th><th>Actions</th></tr></thead><tbody id="user-list"></tbody></table></div><script>const authToken = localStorage.getItem('saas_token');async function loadAdminData() {if (!authToken) { window.location.href = 'index.html'; return; }const statsRes = await fetch('/api/admin/global-stats', { headers: { 'Authorization': `Bearer ${authToken}` } });const stats = await statsRes.json();document.getElementById('stat-users').innerText = stats.totalUsers || 0;document.getElementById('stat-active').innerText = stats.activeChannels || 0;const res = await fetch('/api/admin/users', { headers: { 'Authorization': `Bearer ${authToken}` } });const users = await res.json();const list = document.getElementById('user-list');list.innerHTML = users.map(u => `<tr><td style="font-weight: 800;">${u.email}</td><td><div style="font-weight: 700;">${u.channels?.[0]?.channel_name || '❌ Unlinked'}</div></td><td><span class="badge ${u.plan === 'ultra' ? 'badge-ultra' : (u.plan === 'premium' ? 'badge-premium' : 'badge-free')}">${u.plan?.toUpperCase() || 'FREE'}</span></td><td><div style="display: flex; align-items: center; gap: 8px;"><div style="width: 10px; height: 10px; border-radius: 50%; background: ${u.channels?.[0]?.is_active ? 'var(--success)' : '#475569'};"></div>${u.channels?.[0]?.is_active ? 'Active' : 'Offline'}</div></td><td><button onclick="adminAction('${u.id}', 'ultra')" style="background: rgba(245, 158, 11, 0.1); color: #f59e0b; border: 1px solid #f59e0b; padding: 6px 12px; border-radius: 10px; cursor: pointer; font-weight: 800;">GOD MODE</button></td></tr>`).join('');3 unmodified linesconst res = await fetch('/api/platform/pricing');const p = await res.json();if (p) {document.getElementById('price-monthly').value = p.pro_monthly || 0;document.getElementById('old-price-monthly').value = p.old_pro_monthly || 0;document.getElementById('price-yearly').value = p.pro_yearly || 0;document.getElementById('old-price-yearly').value = p.old_pro_yearly || 0;document.getElementById('discount-pct').value = p.discount_percent || 0;document.getElementById('sale-text').value = p.discount_text || "";document.getElementById('m-sale-active').checked = p.m_discount_active || false;document.getElementById('y-sale-active').checked = p.y_discount_active || false;}}async function savePricing() {const pricing = {pro_monthly: parseInt(document.getElementById('price-monthly').value),old_pro_monthly: parseInt(document.getElementById('old-price-monthly').value),pro_yearly: parseInt(document.getElementById('price-yearly').value),old_pro_yearly: parseInt(document.getElementById('old-price-yearly').value),discount_percent: parseInt(document.getElementById('discount-pct').value),discount_text: document.getElementById('sale-text').value,m_discount_active: document.getElementById('m-sale-active').checked,4 unmodified linesheaders: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${authToken}` },body: JSON.stringify({ pricing })});if (res.ok) alert("Global Pricing Engine Updated! ⚡");}loadAdminPricing();
2 unmodified lines34567892 unmodified lines1213141516171819202122232425262728292 unmodified lines323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716813 unmodified lines1821831841851861871881891901911921931941959 unmodified lines2052062072082092102112122132142152162172182192202215 unmodified lines2272282292302312324 unmodified lines2372382392402412422432442452462472483 unmodified lines2522532542552562572582592602612622633 unmodified lines2672682692702712722732742752762772782792802812822832843 unmodified lines2882892902912922932 unmodified lines<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>ViralFlow AI — Premium Dashboard</title><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800;900&family=Plus+Jakarta+Sans:wght@300;400;600;700&display=swap" rel="stylesheet">2 unmodified lines<style>:root {--bg: #020617;--surface: rgba(15, 23, 42, 0.6);--accent: #6366f1;--accent-light: #818cf8;--success: #10b981;--danger: #ef4444;--text: #f8fafc;--text-dim: #94a3b8;--glass-border: rgba(255, 255, 255, 0.08);--card-glow: rgba(99, 102, 241, 0.15);}* { box-sizing: border-box; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); }body {background: radial-gradient(circle at 50% -20%, #1e1b4b 0%, var(--bg) 80%);color: var(--text);2 unmodified linesoverflow-x: hidden;}.container { max-width: 1300px; margin: 0 auto; padding: 40px 20px; display: none; animation: slideUp 0.6s ease-out; }header {display: flex; justify-content: space-between; align-items: center;background: var(--surface); backdrop-filter: blur(20px);padding: 15px 30px; border-radius: 24px; border: 1px solid var(--glass-border);margin-bottom: 40px; box-shadow: 0 10px 30px rgba(0,0,0,0.5);}.logo-group { display: flex; align-items: center; gap: 15px; }.logo-text { font-family: 'Outfit', sans-serif; font-size: 1.8rem; font-weight: 900; background: linear-gradient(135deg, #fff 0%, var(--accent-light) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: -1px; }.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 30px; }.stat-card {background: var(--surface); padding: 25px; border-radius: 28px; border: 1px solid var(--glass-border);position: relative; overflow: hidden;}.stat-card i { position: absolute; right: -10px; bottom: -10px; font-size: 5rem; opacity: 0.05; color: var(--accent); }.stat-label { font-size: 0.85rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }.stat-value { font-size: 2.5rem; font-weight: 900; font-family: 'Outfit', sans-serif; margin-top: 5px; }.main-grid { display: grid; grid-template-columns: 1fr 1.5fr; gap: 30px; }.panel { background: var(--surface); border-radius: 36px; padding: 35px; border: 1px solid var(--glass-border); position: relative; margin-bottom: 30px; }.panel-title { font-family: 'Outfit', sans-serif; font-size: 1.4rem; font-weight: 800; margin: 0 0 25px 0; display: flex; align-items: center; gap: 10px; }.input-group { margin-bottom: 25px; }label { display: block; margin-bottom: 10px; font-size: 0.9rem; font-weight: 700; color: var(--text-dim); }input {width: 100%; background: rgba(0,0,0,0.4); border: 1px solid var(--glass-border);padding: 16px 20px; border-radius: 18px; color: #fff; font-size: 1rem; outline: none;}.btn-primary {cursor: pointer; border: none; padding: 14px 28px; border-radius: 18px;background: var(--accent); color: #fff; font-weight: 800; font-size: 1rem;display: inline-flex; align-items: center; gap: 10px;}.btn-full { width: 100%; justify-content: center; }.log-container {background: rgba(0,0,0,0.5); border-radius: 24px; padding: 20px; height: 350px; overflow-y: auto;font-family: monospace; font-size: 0.85rem; border: 1px solid var(--glass-border);}.log-item { padding: 8px; border-bottom: 1px solid rgba(255,255,255,0.03); }html.is-authed .auth-overlay { display: none !important; }html.is-authed .container { display: block !important; }.auth-overlay { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 2000; }.auth-card { background: var(--surface); padding: 40px; border-radius: 36px; width: 400px; }</style></head><body><div class="auth-overlay" id="auth-overlay"><div class="auth-card"><div id="login-form"><h2>Login</h2><div class="input-group"><label>Email</label><input type="email" id="login-email"></div><div class="input-group"><label>Password</label><input type="password" id="login-pass"></div><button class="btn-primary btn-full" onclick="login()">Sign In</button><p onclick="toggleAuth()" style="cursor:pointer; text-align:center; margin-top:15px;">Need an account?</p></div><div id="signup-form" style="display:none;"><h2>Sign Up</h2><div class="input-group"><label>Email</label><input type="email" id="signup-email"></div><div class="input-group"><label>Password</label><input type="password" id="signup-pass"></div><button class="btn-primary btn-full" onclick="signup()">Create Account</button><p onclick="toggleAuth()" style="cursor:pointer; text-align:center; margin-top:15px;">Already have one?</p></div></div></div><div class="container" id="dashboard-container"><header><div class="logo-group"><div class="logo-text">ViralFlow AI</div><div class="tag" id="user-plan">🛡️ FREE</div></div><div style="display:flex; gap:15px; align-items:center;"><span id="user-email"></span><button class="btn-primary" onclick="logout()">Logout</button></div></header><div class="stats-grid"><div class="stat-card"><div class="stat-label">Videos Produced</div><div class="stat-value" id="stat-generated">0</div></div><div class="stat-card"><div class="stat-label">Views</div><div class="stat-value" id="stat-views">0</div></div><div class="stat-card"><div class="stat-label">Subs</div><div class="stat-value" id="stat-subs">0</div></div><div class="stat-card"><div class="stat-label">IST Time</div><div class="stat-value" id="server-time">00:00</div></div></div><div class="main-grid"><div class="left-col"><div class="panel"><h3 class="panel-title">Content Engine</h3><div style="display:flex; gap:10px; margin-bottom:20px;"><button class="btn-primary" onclick="saveSettings(this)">Save Settings</button><button class="btn-primary" onclick="generateNow()" style="background:var(--success);">🎬 Create Video Now</button></div><div class="input-group"><label>Niches</label><input type="text" id="setting-niche"></div><div class="input-group"><label>Google Client ID</label><input type="text" id="setting-client-id"></div><div class="input-group"><label>Google Client Secret</label><input type="password" id="setting-client-secret"></div><button class="btn-primary btn-full" onclick="connectYouTube()">Connect YouTube</button><div id="channel-list" style="margin-top:15px;"></div></div></div><div class="right-col"><div class="panel"><h3 class="panel-title">Recent Productions</h3><div id="video-gallery" style="display:grid; gap:10px;"></div></div><div class="panel"><h3 class="panel-title">Cloud Logs</h3><div class="log-container" id="activity-log"></div><div style="margin-top:10px; display:flex; gap:10px;"><button class="btn-primary" onclick="testDatabaseLink()" style="font-size:0.7rem;">🔧 Test DB</button><button class="btn-primary" onclick="updateLogs()" style="font-size:0.7rem;">🔄 Sync</button></div></div></div></div>13 unmodified linesconst email = document.getElementById('login-email').value, pass = document.getElementById('login-pass').value;const res = await fetch('/api/auth/login', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ email, password: pass })});const d = await res.json();if (d.token) { localStorage.setItem('saas_token', d.token); location.reload(); } else alert("Login Failed");}async function signup() {const email = document.getElementById('signup-email').value, pass = document.getElementById('signup-pass').value;const res = await fetch('/api/auth/signup', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ email, password: pass })});const d = await res.json();if (d.token) { localStorage.setItem('saas_token', d.token); location.reload(); } else alert("Signup Failed");}function logout() { localStorage.removeItem('saas_token'); location.reload(); }9 unmodified linesconst vids = logs.filter(l => l.type === 'VIDEO_PUBLISHED');if (vids.length > 0) {gallery.innerHTML = vids.map(v => `<div style="background:rgba(255,255,255,0.05); padding:10px; border-radius:10px;"><div style="font-weight:700; font-size:0.8rem;">${v.msg}</div><a href="${v.metadata?.url}" target="_blank" style="color:var(--accent); font-size:0.7rem;">Watch on YouTube</a></div>`).join('');}logs.forEach(l => {const item = document.createElement('div');item.className = 'log-item';item.innerHTML = `<span style="color:var(--accent)">[${new Date(l.time).toLocaleTimeString()}]</span> ${l.msg}`;logList.appendChild(item);});} catch (e) { console.error(e); }5 unmodified linesdocument.getElementById('stat-generated').innerText = d.videosProduced || 0;document.getElementById('stat-views').innerText = d.totalViews?.toLocaleString() || 0;document.getElementById('stat-subs').innerText = d.subscribers?.toLocaleString() || 0;document.getElementById('setting-niche').value = d.niche || '';document.getElementById('setting-client-id').value = d.custom_client_id || '';document.getElementById('setting-client-secret').value = d.custom_client_secret || '';4 unmodified lineslist.innerHTML = '';if (yt.connected && yt.channels) {yt.channels.forEach(c => {list.innerHTML += `<div style="background:var(--success); color:white; padding:10px; border-radius:10px; margin-bottom:5px;">✅ ${c.channel_name}</div>`;});}}async function saveSettings(btn) {await fetch('/api/settings', {method: 'POST',headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${authToken}` },3 unmodified linescustom_client_secret: document.getElementById('setting-client-secret').value})});alert("Saved!");}async function generateNow() {await fetch('/api/generate', { method: 'POST', headers: { 'Authorization': `Bearer ${authToken}` } });alert("Production Started!");updateLogs();}3 unmodified linesif (d.url) window.open(d.url, '_blank');}async function testDatabaseLink() {await fetch('/api/test-db', { method: 'POST', headers: { 'Authorization': `Bearer ${authToken}` } });updateLogs();}async function checkAuth() {if (!authToken) return;const res = await fetch('/api/auth/me', { headers: { 'Authorization': `Bearer ${authToken}` } });const d = await res.json();if (d.loggedIn) {document.getElementById('user-email').innerText = d.email;document.getElementById('user-plan').innerText = d.plan === 'ultra' ? '☢️ GOD MODE' : '🛡️ FREE';initDashboard();updateLogs();}3 unmodified linesdocument.getElementById('server-time').innerText = new Date().toLocaleTimeString('en-IN', { timeZone: 'Asia/Kolkata', hour: '2-digit', minute: '2-digit' });}, 1000);checkAuth();lucide.createIcons();</script>2 unmodified lines34567892 unmodified lines1213141516171819202122232425262728292 unmodified lines323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321413 unmodified lines2282292302312322332342352362372382392402419 unmodified lines2512522532542552562572582592602612622632642652662672682692702715 unmodified lines2772782792802812822834 unmodified lines2882892902912922932942952962972982993003013023033043 unmodified lines3083093103113123133143153163173183193203213223 unmodified lines3263273283293303313323333343353363373383393 unmodified lines3433443453463473483493502 unmodified lines<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>ViralFlow AI — Next-Gen Automation</title><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800;900&family=Plus+Jakarta+Sans:wght@300;400;600;700&display=swap" rel="stylesheet">2 unmodified lines<style>:root {--bg: #020617;--surface: rgba(15, 23, 42, 0.4);--accent: #6366f1;--accent-glow: rgba(99, 102, 241, 0.3);--success: #10b981;--danger: #ef4444;--text: #f8fafc;--text-dim: #94a3b8;--glass-border: rgba(255, 255, 255, 0.05);--card-glow: rgba(99, 102, 241, 0.1);}* { box-sizing: border-box; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }body {background: radial-gradient(circle at 50% -20%, #1e1b4b 0%, var(--bg) 80%);color: var(--text);2 unmodified linesoverflow-x: hidden;}.container { max-width: 1400px; margin: 0 auto; padding: 40px 20px; display: none; animation: slideUp 0.8s ease-out; }/* --- Glass Components --- */.glass-panel {background: var(--surface); backdrop-filter: blur(25px);border-radius: 32px; border: 1px solid var(--glass-border);box-shadow: 0 20px 50px rgba(0,0,0,0.3);}header {display: flex; justify-content: space-between; align-items: center;padding: 20px 40px; margin-bottom: 40px;}.logo-text {font-family: 'Outfit', sans-serif; font-size: 2rem; font-weight: 900;background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);-webkit-background-clip: text; -webkit-text-fill-color: transparent;letter-spacing: -1.5px;}.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 25px; margin-bottom: 40px; }.stat-card {padding: 30px; position: relative; overflow: hidden;}.stat-card:hover { transform: translateY(-8px); border-color: var(--accent); box-shadow: 0 20px 40px var(--accent-glow); }.stat-card i { position: absolute; right: -10px; bottom: -10px; font-size: 6rem; opacity: 0.03; color: var(--accent); }.stat-label { font-size: 0.8rem; font-weight: 800; color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; }.stat-value { font-size: 2.8rem; font-weight: 900; font-family: 'Outfit', sans-serif; margin-top: 5px; }.main-grid { display: grid; grid-template-columns: 1fr 1.8fr; gap: 30px; }.panel { padding: 40px; }.panel-title { font-family: 'Outfit', sans-serif; font-size: 1.6rem; font-weight: 800; margin-bottom: 30px; display: flex; align-items: center; gap: 15px; }/* --- Form Elements --- */.input-group { margin-bottom: 25px; }label { display: block; margin-bottom: 12px; font-size: 0.85rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; }input {width: 100%; background: rgba(0,0,0,0.3); border: 1px solid var(--glass-border);padding: 18px 25px; border-radius: 20px; color: #fff; font-size: 1rem; outline: none;}input:focus { border-color: var(--accent); box-shadow: 0 0 20px var(--accent-glow); }.btn-primary {cursor: pointer; border: none; padding: 16px 32px; border-radius: 20px;background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);color: #fff; font-weight: 800; font-size: 1rem;display: inline-flex; align-items: center; gap: 12px;box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);}.btn-primary:hover { transform: scale(1.05); box-shadow: 0 15px 35px rgba(99, 102, 241, 0.6); }.btn-full { width: 100%; justify-content: center; }/* --- Logs --- */.log-container {background: rgba(0,0,0,0.4); border-radius: 28px; padding: 25px; height: 450px; overflow-y: auto;font-family: 'JetBrains Mono', monospace; font-size: 0.9rem; border: 1px solid var(--glass-border);}.log-item { padding: 12px; border-bottom: 1px solid rgba(255,255,255,0.03); animation: fadeIn 0.3s ease-out; }.log-time { color: var(--accent); font-weight: 700; margin-right: 10px; }/* --- Gallery --- */.video-item {background: rgba(255,255,255,0.03); padding: 20px; border-radius: 24px; border: 1px solid var(--glass-border);display: flex; align-items: center; gap: 20px;}.video-item:hover { background: rgba(255,255,255,0.07); transform: scale(1.02); }.play-icon { width: 50px; height: 50px; background: var(--accent); border-radius: 15px; display: flex; align-items: center; justify-content: center; color: white; }/* --- Auth Overlay --- */.auth-overlay { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 2000; }.auth-card { padding: 50px; width: 450px; text-align: center; }@keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }html.is-authed .auth-overlay { display: none !important; }html.is-authed .container { display: block !important; }.tag { background: rgba(99, 102, 241, 0.15); color: var(--accent-light); padding: 6px 14px; border-radius: 20px; font-size: 0.75rem; font-weight: 900; }</style></head><body><div class="auth-overlay" id="auth-overlay"><div class="auth-card glass-panel"><div id="login-form"><h1 style="font-family: 'Outfit', sans-serif; margin-bottom: 10px;">Welcome Back</h1><p style="color: var(--text-dim); margin-bottom: 40px;">Enter your credentials to access ViralFlow</p><div class="input-group"><label>Email Address</label><input type="email" id="login-email" placeholder="name@company.com"></div><div class="input-group"><label>Password</label><input type="password" id="login-pass" placeholder="••••••••"></div><button class="btn-primary btn-full" onclick="login()"><i data-lucide="log-in"></i> Sign In to Dashboard</button><p style="margin-top: 25px; color: var(--text-dim);">New here? <span onclick="toggleAuth()" style="color: var(--accent); cursor: pointer; font-weight: 800;">Create Agency Account</span></p></div><div id="signup-form" style="display:none;"><h1 style="font-family: 'Outfit', sans-serif; margin-bottom: 10px;">Get Started</h1><p style="color: var(--text-dim); margin-bottom: 40px;">Launch your autonomous content agency</p><div class="input-group"><label>Email Address</label><input type="email" id="signup-email"></div><div class="input-group"><label>Password</label><input type="password" id="signup-pass"></div><button class="btn-primary btn-full" onclick="signup()"><i data-lucide="sparkles"></i> Create Free Account</button><p style="margin-top: 25px; color: var(--text-dim);">Already a member? <span onclick="toggleAuth()" style="color: var(--accent); cursor: pointer; font-weight: 800;">Sign In</span></p></div></div></div><div class="container" id="dashboard-container"><header class="glass-panel"><div class="logo-group"><div class="logo-text">ViralFlow AI</div><div class="tag" id="user-plan" style="margin-left: 15px;">🛡️ FREE CREATOR</div></div><div style="display:flex; gap:25px; align-items:center;"><div style="text-align: right;"><div id="user-email" style="font-weight: 800; font-size: 0.9rem;"></div><div style="font-size: 0.7rem; color: var(--text-dim);">Active Session</div></div><button class="btn-primary" style="background: rgba(239, 68, 68, 0.1); color: var(--danger); box-shadow: none;" onclick="logout()">Logout</button></div></header><div class="stats-grid"><div class="stat-card glass-panel"><div class="stat-label">Videos Produced</div><div class="stat-value" id="stat-generated">0</div><i data-lucide="video"></i></div><div class="stat-card glass-panel"><div class="stat-label">Total Views</div><div class="stat-value" id="stat-views">0</div><i data-lucide="eye"></i></div><div class="stat-card glass-panel"><div class="stat-label">Subscribers</div><div class="stat-value" id="stat-subs">0</div><i data-lucide="users"></i></div><div class="stat-card glass-panel"><div class="stat-label">System Time (IST)</div><div class="stat-value" id="server-time">00:00</div><i data-lucide="clock"></i></div></div><div class="main-grid"><div class="left-col"><div class="panel glass-panel"><h3 class="panel-title"><i data-lucide="cpu" style="color: var(--accent);"></i> Content Engine</h3><div style="display:flex; gap:12px; margin-bottom:30px;"><button class="btn-primary" onclick="saveSettings(this)" style="flex: 1;"><i data-lucide="save"></i> Save</button><button class="btn-primary" onclick="generateNow()" style="flex: 1.5; background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid var(--success); box-shadow: none;">🎬 Production Now</button></div><div class="input-group"><label>AI Niches</label><input type="text" id="setting-niche" placeholder="Facts, Tech, Motivation"></div><div style="padding: 25px; background: rgba(255,255,255,0.02); border-radius: 24px; border: 1px dashed var(--glass-border); margin-bottom: 25px;"><h4 style="font-size: 0.8rem; letter-spacing: 1px; color: var(--accent); margin-bottom: 20px;">SECURITY VAULT</h4><div class="input-group"><label>Google Client ID</label><input type="text" id="setting-client-id"></div><div class="input-group"><label>Google Secret</label><input type="password" id="setting-client-secret"></div></div><button class="btn-primary btn-full" onclick="connectYouTube()" style="background: #ef4444;"><i data-lucide="youtube"></i> Connect Channel</button><div id="channel-list" style="margin-top:20px; display: grid; gap: 10px;"></div></div></div><div class="right-col"><div class="panel glass-panel" style="margin-bottom: 30px;"><h3 class="panel-title"><i data-lucide="layout" style="color: var(--accent);"></i> Recent Publications</h3><div id="video-gallery" style="display:grid; grid-template-columns: 1fr 1fr; gap:20px;"><div style="grid-column: span 2; text-align: center; color: var(--text-dim); padding: 40px;">No videos in gallery yet.</div></div></div><div class="panel glass-panel"><h3 class="panel-title"><i data-lucide="terminal" style="color: var(--accent);"></i> Cloud Execution Logs</h3><div class="log-container" id="activity-log"></div></div></div></div>13 unmodified linesconst email = document.getElementById('login-email').value, pass = document.getElementById('login-pass').value;const res = await fetch('/api/auth/login', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ email, password: pass })});const d = await res.json();if (d.token) { localStorage.setItem('saas_token', d.token); location.reload(); } else alert("Login Failed: Check credentials");}async function signup() {const email = document.getElementById('signup-email').value, pass = document.getElementById('signup-pass').value;const res = await fetch('/api/auth/signup', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ email, password: pass })});const d = await res.json();if (d.token) { localStorage.setItem('saas_token', d.token); location.reload(); } else alert("Signup Failed: " + (d.error || "Email may exist"));}function logout() { localStorage.removeItem('saas_token'); location.reload(); }9 unmodified linesconst vids = logs.filter(l => l.type === 'VIDEO_PUBLISHED');if (vids.length > 0) {gallery.innerHTML = vids.map(v => `<div class="video-item"><div class="play-icon"><i data-lucide="play"></i></div><div><div style="font-weight:800; font-size:0.9rem; margin-bottom: 5px;">${v.msg}</div><a href="${v.metadata?.url}" target="_blank" style="color:var(--accent); font-size:0.75rem; font-weight: 700; text-decoration: none;">View on YouTube ↗</a></div></div>`).join('');lucide.createIcons();}logs.forEach(l => {const item = document.createElement('div');item.className = 'log-item';item.innerHTML = `<span class="log-time">[${new Date(l.time).toLocaleTimeString()}]</span> ${l.msg}`;logList.appendChild(item);});} catch (e) { console.error(e); }5 unmodified linesdocument.getElementById('stat-generated').innerText = d.videosProduced || 0;document.getElementById('stat-views').innerText = d.totalViews?.toLocaleString() || 0;document.getElementById('stat-subs').innerText = d.subscribers?.toLocaleString() || 0;document.getElementById('setting-niche').value = d.niche || '';document.getElementById('setting-client-id').value = d.custom_client_id || '';document.getElementById('setting-client-secret').value = d.custom_client_secret || '';4 unmodified lineslist.innerHTML = '';if (yt.connected && yt.channels) {yt.channels.forEach(c => {list.innerHTML += `<div style="background: rgba(16, 185, 129, 0.1); color: var(--success); padding: 15px; border-radius: 18px; border: 1px solid var(--success); font-weight: 800; display: flex; align-items: center; gap: 10px;"><i data-lucide="check-circle"></i> ${c.channel_name}</div>`;});lucide.createIcons();}}async function saveSettings(btn) {const original = btn.innerHTML;btn.innerHTML = '<i data-lucide="loader-2" class="animate-spin"></i> Saving...';lucide.createIcons();await fetch('/api/settings', {method: 'POST',headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${authToken}` },3 unmodified linescustom_client_secret: document.getElementById('setting-client-secret').value})});btn.innerHTML = '<i data-lucide="check"></i> Saved!';setTimeout(() => { btn.innerHTML = original; lucide.createIcons(); }, 2000);}async function generateNow() {if(!confirm("Start AI Production Now?")) return;await fetch('/api/generate', { method: 'POST', headers: { 'Authorization': `Bearer ${authToken}` } });alert("🚀 Production Engine Triggered!");updateLogs();}3 unmodified linesif (d.url) window.open(d.url, '_blank');}async function checkAuth() {if (!authToken) return;const res = await fetch('/api/auth/me', { headers: { 'Authorization': `Bearer ${authToken}` } });const d = await res.json();if (d.loggedIn) {document.getElementById('user-email').innerText = d.email;document.getElementById('user-plan').innerText = d.plan === 'ultra' ? '☢️ GOD MODE' : '🛡️ FREE CREATOR';if(d.plan === 'ultra') document.getElementById('user-plan').style.color = '#f59e0b';initDashboard();updateLogs();}3 unmodified linesdocument.getElementById('server-time').innerText = new Date().toLocaleTimeString('en-IN', { timeZone: 'Asia/Kolkata', hour: '2-digit', minute: '2-digit' });}, 1000);setInterval(() => { if(authToken) { initDashboard(); updateLogs(); } }, 30000);checkAuth();lucide.createIcons();</script>
dashboard/admin.html+104-147
dashboard/index.html+145-88