84 lines
3.8 KiB
HTML
84 lines
3.8 KiB
HTML
<!doctype html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
<title>Crear sesión — Broadcast Panel</title>
|
|
<style>
|
|
body { font-family: Inter, system-ui, Arial; background:#0b0b0d; color:#eee; display:flex; align-items:center; justify-content:center; height:100vh; }
|
|
.card { background:#0f1724; padding:20px;border-radius:8px; width:520px; box-shadow:0 6px 18px rgba(2,6,23,0.6); }
|
|
label{display:block;margin-top:12px;font-size:13px;color:#cbd5e1}
|
|
input{width:100%;padding:8px;border-radius:6px;border:1px solid #334155;background:#020617;color:#fff}
|
|
button{margin-top:14px;padding:10px 14px;border-radius:6px;border:none;background:#2563eb;color:#fff;cursor:pointer}
|
|
pre{background:#020617;padding:10px;border-radius:6px;overflow:auto;color:#9aa8ff}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="card">
|
|
<h2>Crear sesión (Broadcast Panel)</h2>
|
|
<p>Genera una sessionId en el token-server y abre la ruta del broadcast panel: <code>https://avanzacast-broadcastpanel.bfzqqk.easypanel.host/<sessionId></code></p>
|
|
|
|
<label>Room (opcional)</label>
|
|
<input id="room" placeholder="broadcast-room-name (default: random)" />
|
|
|
|
<label>Username</label>
|
|
<input id="username" placeholder="Xesar" value="Guest" />
|
|
|
|
<label>Token server (opcional)</label>
|
|
<input id="backend" placeholder="https://avanzacast-servertokens.bfzqqk.easypanel.host" value="https://avanzacast-servertokens.bfzqqk.easypanel.host" />
|
|
|
|
<div style="display:flex;gap:8px">
|
|
<button id="createBtn">Crear sesión y abrir Studio</button>
|
|
<button id="createOnly">Crear sin abrir</button>
|
|
</div>
|
|
|
|
<div id="log" style="margin-top:12px;display:none">
|
|
<div style="font-size:13px;color:#9ca3af;margin-bottom:6px">Resultado (JSON):</div>
|
|
<pre id="out"></pre>
|
|
</div>
|
|
|
|
<div style="margin-top:12px;color:#94a3b8;font-size:13px">Nota: este script intenta POST `/api/session` al token-server y abrir la URL del broadcast panel producida.</div>
|
|
</div>
|
|
|
|
<script>
|
|
async function createSession(openAfter = false) {
|
|
const room = document.getElementById('room').value || undefined;
|
|
const username = document.getElementById('username').value || 'Guest';
|
|
let backend = document.getElementById('backend').value || '';
|
|
if (!backend) backend = 'https://avanzacast-servertokens.bfzqqk.easypanel.host';
|
|
const url = backend.replace(/\/$/, '') + '/api/session';
|
|
|
|
const out = document.getElementById('out');
|
|
const log = document.getElementById('log');
|
|
log.style.display = 'block';
|
|
out.textContent = 'Enviando petición...';
|
|
|
|
try {
|
|
const body = { username };
|
|
if (room) body.room = room;
|
|
const resp = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
|
|
const txt = await resp.text();
|
|
let json;
|
|
try { json = JSON.parse(txt); } catch (e) { json = { raw: txt } }
|
|
out.textContent = JSON.stringify({ status: resp.status, body: json }, null, 2);
|
|
if (!resp.ok) return;
|
|
|
|
const id = json && (json.id || json.sessionId) ? (json.id || json.sessionId) : null;
|
|
const studioHost = (new URL(window.location.href)).origin || 'https://avanzacast-broadcastpanel.bfzqqk.easypanel.host';
|
|
const sessionUrl = json && json.studioUrl ? json.studioUrl : (studioHost.replace(/\/$/, '') + '/' + encodeURIComponent(id || ''));
|
|
out.textContent += '\n\nOpen URL:\n' + sessionUrl;
|
|
if (openAfter && sessionUrl) {
|
|
window.location.href = sessionUrl;
|
|
}
|
|
} catch (err) {
|
|
out.textContent = 'Error: ' + String(err);
|
|
}
|
|
}
|
|
|
|
document.getElementById('createBtn').addEventListener('click', () => createSession(true));
|
|
document.getElementById('createOnly').addEventListener('click', () => createSession(false));
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|