session wait page: replace visible card with silent dark redirect

This commit is contained in:
2026-07-20 16:04:21 +00:00
parent f028f91ce4
commit 806c5d8e1f
+10 -40
View File
@@ -1568,61 +1568,31 @@ def session_wait_page(session_id: str, request: Request, user: User = Depends(re
service = db.get(Service, sess.service_id)
service_title = service.name if service else "Сервис"
is_rdp = service and service.type == ServiceType.RDP
label = "Ожидайте..." if is_rdp else "Сессия запускается..."
redirect_target = session_redirect_url(sess)
return HTMLResponse(
content=f"""
<!doctype html>
content=f"""<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title>{service_title}</title>
<style>
*{{box-sizing:border-box}}
body{{font-family:sans-serif;background:#0f1720;display:grid;place-items:center;height:100vh;margin:0;color:#dce8f5}}
.card{{background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.12);padding:1.6rem 2rem;border-radius:14px;
box-shadow:0 12px 32px rgba(0,0,0,.4);min-width:320px;max-width:440px;text-align:center}}
.spinner{{width:48px;height:48px;border:4px solid rgba(220,232,245,.15);border-top-color:#2a8cd6;
border-radius:50%;animation:spin .9s linear infinite;margin:0 auto 1.2rem}}
@keyframes spin{{to{{transform:rotate(360deg)}}}}
.title{{font-size:1.15rem;font-weight:700;margin-bottom:.5rem;color:#fff}}
.state{{font-size:.9rem;color:#a0b8cc;margin-bottom:.8rem;min-height:1.2em}}
ul{{margin:0;padding:0;list-style:none;font-size:.82rem;color:#7a99b0;text-align:left}}
li::before{{content:"· ";color:#2a8cd6}}
li+li{{margin-top:.2rem}}
.sid{{display:block;margin-top:1.2rem;font-size:.7rem;color:rgba(160,184,204,.4);word-break:break-all}}
</style>
<style>html,body{{margin:0;height:100%;background:#0f1720}}</style>
</head>
<body>
<div class="card">
<div class="spinner"></div>
<div class="title">{label}</div>
<div class="state" id="state">Проверка...</div>
<ul id="steps"></ul>
<span class="sid">{session_id}</span>
</div>
<script>
const sessionId = "{session_id}";
async function tick() {{
const r = await fetch(`/api/sessions/${{sessionId}}/status`, {{credentials:'include'}});
if (!r.ok) return;
const data = await r.json();
document.getElementById('state').textContent = data.message || 'Запуск...';
const ul = document.getElementById('steps');
ul.innerHTML = '';
(data.steps || []).forEach((x) => {{
const li = document.createElement('li');
li.textContent = x;
ul.appendChild(li);
}});
if (data.ready) window.location.replace(data.redirect_url || "{redirect_target}");
try {{
const r = await fetch(`/api/sessions/${{sessionId}}/status`, {{credentials:'include'}});
if (!r.ok) return;
const data = await r.json();
if (data.ready) {{ window.location.replace(data.redirect_url || "{redirect_target}"); return; }}
}} catch(e) {{}}
setTimeout(tick, 300);
}}
setInterval(tick, 1000);
tick();
</script>
</body>
</html>
""".strip(),
</html>""",
status_code=200,
)