Spaces:
Sleeping
Sleeping
Nathan commited on
Commit ·
4913893
1
Parent(s): 60d5ca5
UI: Vault Edition - Restored Stats, Removed Banner, Added Cloud Video Folder
Browse filesFiles changed (2)
- dashboard/index.html+87-162
- server.js+17
2 unmodified lines34567894 unmodified lines141516171819201 unmodified line222324252627282930313233346 unmodified lines41424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889902 unmodified lines939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661674 unmodified lines1721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972 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 — Live 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">4 unmodified lines--bg: #020617;--surface: rgba(15, 23, 42, 0.4);--accent: #6366f1;--accent-glow: rgba(99, 102, 241, 0.4);--success: #10b981;--danger: #ef4444;--text: #f8fafc;1 unmodified line--glass-border: rgba(255, 255, 255, 0.08);}* { box-sizing: border-box; transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }body {background: radial-gradient(circle at 50% -20%, #1e1b4b 0%, var(--bg) 100%);color: var(--text);font-family: 'Plus Jakarta Sans', sans-serif;margin: 0; min-height: 100vh;overflow-x: hidden;}.container { max-width: 1400px; margin: 0 auto; padding: 20px; display: none; }6 unmodified linesbox-shadow: 0 20px 60px rgba(0,0,0,0.5);}header {display: flex; justify-content: space-between; align-items: center;padding: 15px 30px; margin-bottom: 25px;}.logo-text { font-family: 'Outfit', sans-serif; font-size: 1.8rem; font-weight: 900; color: #fff; letter-spacing: -1.5px; }.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 25px; }.stat-card { padding: 25px; position: relative; overflow: hidden; }.stat-label { font-size: 0.75rem; font-weight: 800; color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; }.stat-value { font-size: 2.2rem; font-weight: 900; font-family: 'Outfit', sans-serif; margin-top: 5px; }.main-grid { display: grid; grid-template-columns: 1fr 1.6fr; gap: 20px; }@media (max-width: 1024px) { .main-grid { grid-template-columns: 1fr; } }.panel { padding: 35px; }.panel-title { font-family: 'Outfit', sans-serif; font-size: 1.5rem; font-weight: 800; margin-bottom: 30px; display: flex; align-items: center; gap: 12px; }.btn-primary {cursor: pointer; border: none; padding: 16px 30px; border-radius: 18px;background: var(--accent); color: #fff; font-weight: 800; font-size: 1rem;display: inline-flex; align-items: center; gap: 12px;}.btn-full { width: 100%; justify-content: center; }.input-group { margin-bottom: 25px; }label { display: block; margin-bottom: 12px; font-size: 0.8rem; font-weight: 800; color: var(--text-dim); text-transform: uppercase; }input {width: 100%; background: rgba(0,0,0,0.4); border: 1px solid var(--glass-border);padding: 18px; border-radius: 18px; color: #fff; font-size: 1rem; outline: none;}#latest-video-panel { border: 1px solid var(--success); margin-bottom: 20px; padding: 25px; display: none; }.log-container {background: rgba(0,0,0,0.5); border-radius: 28px; padding: 25px; height: 500px; 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); display: flex; gap: 15px; }.log-time { color: var(--accent); font-weight: 800; font-size: 0.8rem; }.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; }.tag { background: rgba(99, 102, 241, 0.2); color: var(--accent-light); padding: 6px 14px; border-radius: 15px; font-size: 0.75rem; font-weight: 900; border: 1px solid var(--accent); }</style></head><body>2 unmodified lines<div class="auth-card glass-panel"><div id="login-form"><h1 style="font-family: 'Outfit', sans-serif; font-size: 2.2rem; margin-bottom: 30px;">ViralFlow AI</h1><div class="input-group"><label>Email</label><input type="email" id="login-email" placeholder="agent@viralflow.ai"></div><div class="input-group"><label>Password</label><input type="password" id="login-pass" placeholder="••••••••"></div><button class="btn-primary btn-full" onclick="login()">Enter Dashboard</button><p onclick="toggleAuth()" style="cursor:pointer; margin-top:25px; color:var(--text-dim);">Need Access? <span style="color:var(--accent)">Register</span></p></div><div id="signup-form" style="display:none;"><h1 style="font-family: 'Outfit', sans-serif; font-size: 2.2rem; margin-bottom: 30px;">Initialize</h1><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; margin-top:25px; color:var(--text-dim);">Back to <span style="color:var(--accent)">Login</span></p></div></div></div><div class="container" id="dashboard-container"><header class="glass-panel"><div class="logo-group" style="display: flex; align-items: center;"><div class="logo-text">ViralFlow AI</div><div class="tag" id="user-plan" style="margin-left: 15px;">🛡️ FREE</div></div><div style="display:flex; gap:20px; 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(--success); font-weight: 800;">System Active</div></div><button class="btn-primary" style="background: rgba(239, 68, 68, 0.1); color: var(--danger);" onclick="logout()">Logout</button></div></header><div id="latest-video-panel" class="glass-panel"><div style="display:flex; align-items:center; justify-content:space-between; flex-wrap: wrap; gap: 20px;"><div style="font-weight:900; font-size:1.1rem;" id="latest-video-title">Latest Video Ready! 🎬</div><a id="latest-video-link" href="#" target="_blank" class="btn-primary" style="background:var(--success);">Watch Now</a></div></div><div class="stats-grid"><div class="stat-card glass-panel"><div class="stat-label">Videos</div><div class="stat-value" id="stat-generated">0</div></div><div class="stat-card glass-panel"><div class="stat-label">System</div><div class="stat-value" style="color:var(--success);">LIVE</div></div><div class="stat-card glass-panel"><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 glass-panel"><h3 class="panel-title">Automation Vault</h3><div style="display:flex; gap:15px; margin-bottom:30px;"><button class="btn-primary" style="flex:1;" onclick="saveSettings(this)">Save</button><button class="btn-primary" style="flex:1.5; background:var(--success);" onclick="generateNow()">🎬 Create Now</button></div><div class="input-group"><label>AI Niches</label><input type="text" id="setting-niche"></div><div class="input-group"><label>Production Schedule</label><div id="schedule-list" style="display:flex; flex-wrap:wrap; gap:10px; margin-bottom:20px;"></div><div style="display:flex; gap:10px;"><input type="time" id="new-time" style="flex:1;"><button class="btn-primary" onclick="addTimeSlot()">+</button></div></div><div style="padding:20px; background:rgba(0,0,0,0.2); border-radius:20px; margin-bottom:20px;"><label>Google Keys</label><input type="text" id="setting-client-id" placeholder="Client ID" style="margin-bottom:10px;"><input type="password" id="setting-client-secret" placeholder="Secret"></div><button id="connect-btn" class="btn-primary btn-full" onclick="connectYouTube()" style="background:#ef4444;">Connect YouTube</button><div id="channel-list" style="margin-top:20px;"></div></div></div><div class="right-col"><div class="panel glass-panel"><h3 class="panel-title">Live Cloud Logs</h3><div class="log-container" id="activity-log"></div></div></div>4 unmodified lineslet authToken = localStorage.getItem('saas_token');let preferredHours = [];let userPlan = 'free';let supabaseClient = null;if (authToken) {document.documentElement.classList.add('is-authed');checkAuth();}function toggleAuth() {const l = document.getElementById('login-form'), s = document.getElementById('signup-form');l.style.display = l.style.display === 'none' ? 'block' : 'none';s.style.display = s.style.display === 'none' ? 'block' : 'none';}async function login() {const email = document.getElementById('login-email').value, pass = document.getElementById('login-pass').value;try {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);authToken = d.token;document.documentElement.classList.add('is-authed');await checkAuth();} else {alert("Login Error: " + (d.error || "Invalid Credentials"));}} catch(e) { alert("Network Error"); }}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(); }async function initRealtime() {try {const configRes = await fetch('/api/config');const config = await configRes.json();supabaseClient = supabase.createClient(config.supabaseUrl, config.supabaseKey);supabaseClient.channel('activity-updates').on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'activity' }, () => { updateLogs(); initDashboard(); }).subscribe();} catch(e) { console.error("Realtime Init Failed", e); }}async function updateLogs() {try {const res = await fetch('/api/logs', { headers: { 'Authorization': `Bearer ${authToken}` } });const logs = await res.json();const logList = document.getElementById('activity-log');logList.innerHTML = logs.map(l => `<div class="log-item"><span class="log-time">${new Date(l.time).toLocaleTimeString()}</span><span>${l.msg}</span></div>`).join('');const lastVid = logs.find(l => l.type === 'VIDEO_PUBLISHED');if (lastVid) {document.getElementById('latest-video-panel').style.display = 'block';document.getElementById('latest-video-title').innerText = lastVid.msg;document.getElementById('latest-video-link').href = lastVid.metadata?.url || '#';}} catch (e) { console.error(e); }}async function initDashboard() {try {const res = await fetch('/api/stats', { headers: { 'Authorization': `Bearer ${authToken}` } });const d = await res.json();document.getElementById('stat-generated').innerText = d.videosProduced || 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 || '';preferredHours = d.preferred_hours || [];updateScheduleUI();const ytRes = await fetch('/api/youtube', { headers: { 'Authorization': `Bearer ${authToken}` } });const yt = await ytRes.json();const list = document.getElementById('channel-list');const connectBtn = document.getElementById('connect-btn');list.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:15px; border:1px solid var(--success); font-weight:800; margin-bottom:10px;">✅ ${c.channel_name}</div>`; });if (yt.channels.length >= (userPlan === 'ultra' ? 999 : 1)) { connectBtn.innerHTML = `Slot Full`; connectBtn.disabled = true; connectBtn.style.opacity = '0.5'; }}} catch(e) { console.error(e); }}function updateScheduleUI() {document.getElementById('schedule-list').innerHTML = preferredHours.map((t, i) => `<div class="time-tag">${t} <span style="cursor:pointer; color:var(--danger);" onclick="removeTime(${i})">×</span></div>`).join('');}function addTimeSlot() { const t = document.getElementById('new-time').value; if (t && !preferredHours.includes(t)) { preferredHours.push(t); updateScheduleUI(); } }function removeTime(i) { preferredHours.splice(i, 1); updateScheduleUI(); }async function saveSettings(btn) {const orig = btn.innerHTML; btn.innerHTML = 'Syncing...';await fetch('/api/settings', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${authToken}` }, body: JSON.stringify({ niche: document.getElementById('setting-niche').value, preferred_hours: preferredHours, custom_client_id: document.getElementById('setting-client-id').value, custom_client_secret: document.getElementById('setting-client-secret').value }) });btn.innerHTML = 'Saved!'; setTimeout(() => { btn.innerHTML = orig; }, 2000);}async function generateNow() { if(!confirm("Start?")) return; await fetch('/api/generate', { method: 'POST', headers: { 'Authorization': `Bearer ${authToken}` } }); }async function connectYouTube() { const res = await fetch('/api/auth/url', { headers: { 'Authorization': `Bearer ${authToken}` } }); const d = await res.json(); if (d.url) window.open(d.url, '_blank'); }async function checkAuth() {if (!authToken) return;try {const res = await fetch('/api/auth/me', { headers: { 'Authorization': `Bearer ${authToken}` } });const d = await res.json();if (d.loggedIn) {userPlan = d.plan || 'free';document.getElementById('user-plan').innerText = userPlan === 'ultra' ? '☢️ GOD MODE' : '🛡️ FREE';document.getElementById('user-email').innerText = d.email;document.documentElement.classList.add('is-authed');initDashboard(); updateLogs(); initRealtime();} else { localStorage.removeItem('saas_token'); document.documentElement.classList.remove('is-authed'); }} catch (e) { document.documentElement.classList.add('is-authed'); }}setInterval(() => { document.getElementById('server-time').innerText = new Date().toLocaleTimeString('en-IN', { timeZone: 'Asia/Kolkata', hour: '2-digit', minute: '2-digit', second: '2-digit' }); }, 1000);lucide.createIcons();</script>2 unmodified lines34567894 unmodified lines1415161718191 unmodified line21222324252627282930316 unmodified lines3839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687882 unmodified lines9192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471484 unmodified lines1531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222 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 — The Cloud Vault</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">4 unmodified lines--bg: #020617;--surface: rgba(15, 23, 42, 0.4);--accent: #6366f1;--success: #10b981;--danger: #ef4444;--text: #f8fafc;1 unmodified line--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) 100%);color: var(--text); font-family: 'Plus Jakarta Sans', sans-serif;margin: 0; min-height: 100vh; overflow-x: hidden;}.container { max-width: 1400px; margin: 0 auto; padding: 20px; display: none; }6 unmodified linesbox-shadow: 0 20px 60px rgba(0,0,0,0.5);}header { display: flex; justify-content: space-between; align-items: center; padding: 15px 30px; margin-bottom: 25px; }.logo-text { font-family: 'Outfit', sans-serif; font-size: 1.8rem; font-weight: 900; color: #fff; letter-spacing: -1.5px; }.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 25px; }.stat-card { padding: 25px; position: relative; }.stat-label { font-size: 0.7rem; font-weight: 800; color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; }.stat-value { font-size: 2rem; font-weight: 900; font-family: 'Outfit', sans-serif; margin-top: 5px; }.main-grid { display: grid; grid-template-columns: 1fr 1.6fr; gap: 20px; }@media (max-width: 1024px) { .main-grid { grid-template-columns: 1fr; } }.panel { padding: 30px; }.panel-title { font-family: 'Outfit', sans-serif; font-size: 1.4rem; font-weight: 800; margin-bottom: 25px; display: flex; align-items: center; gap: 12px; }.btn-primary {cursor: pointer; border: none; padding: 15px 25px; border-radius: 18px;background: var(--accent); color: #fff; font-weight: 800; font-size: 0.9rem;display: inline-flex; align-items: center; gap: 10px;}.btn-full { width: 100%; justify-content: center; }.input-group { margin-bottom: 20px; }label { display: block; margin-bottom: 10px; font-size: 0.75rem; font-weight: 800; color: var(--text-dim); text-transform: uppercase; }input {width: 100%; background: rgba(0,0,0,0.4); border: 1px solid var(--glass-border);padding: 18px; border-radius: 18px; color: #fff; outline: none;}.log-container {background: rgba(0,0,0,0.5); border-radius: 28px; padding: 25px; height: 350px; overflow-y: auto;font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; border: 1px solid var(--glass-border);}.log-item { padding: 10px; border-bottom: 1px solid rgba(255,255,255,0.03); display: flex; gap: 15px; }.video-list { display: grid; gap: 10px; height: 300px; overflow-y: auto; padding-right: 10px; }.video-item {background: rgba(255,255,255,0.03); padding: 15px; border-radius: 15px; border: 1px solid var(--glass-border);display: flex; justify-content: space-between; align-items: center;}.video-item:hover { background: rgba(255,255,255,0.07); }.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; }.tag { background: rgba(99, 102, 241, 0.2); color: var(--accent-light); padding: 5px 12px; border-radius: 15px; font-size: 0.7rem; font-weight: 900; }</style></head><body>2 unmodified lines<div class="auth-card glass-panel"><div id="login-form"><h1 style="font-family: 'Outfit', sans-serif; font-size: 2.2rem; margin-bottom: 30px;">ViralFlow AI</h1><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()">Enter Dashboard</button></div></div></div><div class="container" id="dashboard-container"><header class="glass-panel"><div style="display: flex; align-items: center;"><div class="logo-text">ViralFlow</div><div class="tag" id="user-plan" style="margin-left: 15px;">🛡️ FREE</div></div><div style="display:flex; gap:20px; align-items:center;"><div id="user-email" style="font-weight: 800; font-size: 0.85rem;"></div><button class="btn-primary" style="background: rgba(239, 68, 68, 0.1); color: var(--danger);" onclick="logout()">Logout</button></div></header><div class="stats-grid"><div class="stat-card glass-panel"><div class="stat-label">Videos</div><div class="stat-value" id="stat-generated">0</div></div><div class="stat-card glass-panel"><div class="stat-label">Views</div><div class="stat-value" id="stat-views">0</div></div><div class="stat-card glass-panel"><div class="stat-label">Subs</div><div class="stat-value" id="stat-subs">0</div></div><div class="stat-card glass-panel"><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 glass-panel" style="margin-bottom:20px;"><h3 class="panel-title"><i data-lucide="folder"></i> Cloud Video Folder</h3><div class="video-list" id="cloud-video-list"></div><button class="btn-primary btn-full" style="margin-top:15px; background:var(--success);" onclick="loadVideos()"><i data-lucide="refresh-cw"></i> Refresh Folder</button></div><div class="panel glass-panel"><h3 class="panel-title">Automation Engine</h3><div style="display:flex; gap:10px; margin-bottom:25px;"><button class="btn-primary" style="flex:1;" onclick="saveSettings(this)">Save</button><button class="btn-primary" style="flex:1.5; background:var(--success);" onclick="generateNow()">🎬 Create Now</button></div><div class="input-group"><label>Niches</label><input type="text" id="setting-niche"></div><div class="input-group"><label>Schedule</label><div id="schedule-list" style="display:flex; flex-wrap:wrap; gap:8px; margin-bottom:15px;"></div><div style="display:flex; gap:10px;"><input type="time" id="new-time" style="flex:1;"><button class="btn-primary" onclick="addTimeSlot()">+</button></div></div><button id="connect-btn" class="btn-primary btn-full" onclick="connectYouTube()" style="background:#ef4444;">Connect YouTube</button></div></div><div class="right-col"><div class="panel glass-panel"><h3 class="panel-title">Cloud Activity Logs</h3><div class="log-container" id="activity-log"></div></div></div>4 unmodified lineslet authToken = localStorage.getItem('saas_token');let preferredHours = [];let userPlan = 'free';if (authToken) { document.documentElement.classList.add('is-authed'); checkAuth(); }async function login() {const 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); authToken = d.token; checkAuth(); } else alert("Login Failed");}function logout() { localStorage.removeItem('saas_token'); location.reload(); }async function checkAuth() {if (!authToken) return;try {const res = await fetch('/api/auth/me', { headers: { 'Authorization': `Bearer ${authToken}` } });const d = await res.json();if (d.loggedIn) {userPlan = d.plan || 'free';document.getElementById('user-plan').innerText = userPlan === 'ultra' ? '☢️ GOD MODE' : '🛡️ FREE';document.getElementById('user-email').innerText = d.email;document.documentElement.classList.add('is-authed');initDashboard(); updateLogs(); loadVideos();} else { logout(); }} catch (e) { document.documentElement.classList.add('is-authed'); }}async function loadVideos() {const res = await fetch('/api/videos', { headers: { 'Authorization': `Bearer ${authToken}` } });const vids = await res.json();const list = document.getElementById('cloud-video-list');list.innerHTML = vids.length ? vids.map(v => `<div class="video-item"><div style="font-size:0.8rem; font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:200px;">${v.name}</div><a href="${v.url}" download class="btn-primary" style="padding:8px 12px; font-size:0.7rem; background:rgba(255,255,255,0.1);"><i data-lucide="download"></i> Download</a></div>`).join('') : '<div style="text-align:center; color:var(--text-dim); padding:20px;">No videos found in output folder</div>';lucide.createIcons();}async function initDashboard() {const res = await fetch('/api/stats', { headers: { 'Authorization': `Bearer ${authToken}` } });const d = await res.json();document.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 || '';preferredHours = d.preferred_hours || [];updateScheduleUI();}async function updateLogs() {const res = await fetch('/api/logs', { headers: { 'Authorization': `Bearer ${authToken}` } });const logs = await res.json();document.getElementById('activity-log').innerHTML = logs.map(l => `<div class="log-item"><span style="color:var(--accent); font-weight:800; font-size:0.7rem;">[${new Date(l.time).toLocaleTimeString()}]</span> ${l.msg}</div>`).join('');}function updateScheduleUI() { document.getElementById('schedule-list').innerHTML = preferredHours.map((t, i) => `<div class="tag" style="background:rgba(99,102,241,0.1); border:1px solid var(--accent);">${t} <span style="cursor:pointer;" onclick="removeTime(${i})">×</span></div>`).join(''); }function addTimeSlot() { const t = document.getElementById('new-time').value; if (t && !preferredHours.includes(t)) { preferredHours.push(t); updateScheduleUI(); } }function removeTime(i) { preferredHours.splice(i, 1); updateScheduleUI(); }async function saveSettings(btn) { const orig = btn.innerHTML; btn.innerHTML = '...'; await fetch('/api/settings', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${authToken}` }, body: JSON.stringify({ niche: document.getElementById('setting-niche').value, preferred_hours: preferredHours }) }); btn.innerHTML = 'Saved'; setTimeout(() => btn.innerHTML = orig, 2000); }async function generateNow() { if(!confirm("Start?")) return; await fetch('/api/generate', { method: 'POST', headers: { 'Authorization': `Bearer ${authToken}` } }); }async function connectYouTube() { const res = await fetch('/api/auth/url', { headers: { 'Authorization': `Bearer ${authToken}` } }); const d = await res.json(); if (d.url) window.open(d.url, '_blank'); }setInterval(() => { document.getElementById('server-time').innerText = new Date().toLocaleTimeString('en-IN', { timeZone: 'Asia/Kolkata', hour: '2-digit', minute: '2-digit', second: '2-digit' }); }, 1000);lucide.createIcons();</script>
27 unmodified lines28293031323327 unmodified linesapp.use(express.json());app.use(express.static(path.join(__dirname, 'dashboard')));// JWT Middleware// Admin Authentication Middleware27 unmodified lines282930313233343536373839404142434445464748495027 unmodified linesapp.use(express.json());app.use(express.static(path.join(__dirname, 'dashboard')));// Serve static video filesapp.use('/videos', express.static(path.join(__dirname, 'output')));app.get('/api/videos', authenticateToken, async (req, res) => {try {const videoDir = path.join(__dirname, 'output');const files = await fs.readdir(videoDir);const videos = files.filter(f => f.endsWith('.mp4')).map(f => ({name: f,url: `/videos/${f}`,time: new Date() // Ideally we'd get file birthtime})).reverse();res.json(videos);} catch (e) {res.json([]);}});// JWT Middleware// Admin Authentication Middleware
dashboard/index.html+87-162
server.js+17