feat: loading overlay on dashboard, RDP pooled session routing fix
- dashboard.html: overlay div moved before <script> so getElementById works; double rAF ensures browser paints spinner before navigation - main.py: pooled_rdp route fix — session_status now returns /svc/<slug>/ route and redirect_url for POOL: RDP sessions (was always ready instantly) - docker-compose.yml: parametrise env vars via .env for easier tuning Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+8
-2
@@ -2419,7 +2419,13 @@ def session_status(session_id: str, user: User = Depends(require_user), db: Sess
|
||||
universal_pool_idx = int(sess.container_id.split(":", 1)[1])
|
||||
except Exception:
|
||||
universal_pool_idx = None
|
||||
route_path = f"/svc/{service.slug}/" if pooled_web and service else f"/s/{session_id}/"
|
||||
pooled_rdp = bool(sess.container_id and sess.container_id.startswith("POOL:") and service and service.type == ServiceType.RDP)
|
||||
if pooled_web and service:
|
||||
route_path = f"/svc/{service.slug}/"
|
||||
elif pooled_rdp and service:
|
||||
route_path = f"/svc/{service.slug}/"
|
||||
else:
|
||||
route_path = f"/s/{session_id}/"
|
||||
if web_pool_idx is not None:
|
||||
route_path = f"/w/{web_pool_idx}/"
|
||||
if universal_pool_idx is not None:
|
||||
@@ -2436,7 +2442,7 @@ def session_status(session_id: str, user: User = Depends(require_user), db: Sess
|
||||
"message": "Готово, открываем..." if ready else "Запуск сессии...",
|
||||
"steps": steps,
|
||||
}
|
||||
if pooled_web:
|
||||
if pooled_web or pooled_rdp:
|
||||
payload["redirect_url"] = f"/s/{session_id}/view"
|
||||
if web_pool_idx is not None:
|
||||
payload["redirect_url"] = f"/s/{session_id}/view"
|
||||
|
||||
@@ -103,6 +103,18 @@
|
||||
</section>
|
||||
<footer class="made-by-wrap"><a class="made-by" href="mailto:rgalyaviev@mont.com">Made by Galyaviev</a></footer>
|
||||
</main>
|
||||
<style>
|
||||
#loading-overlay{display:none;position:fixed;inset:0;z-index:8888;background:rgba(10,18,28,.88);
|
||||
backdrop-filter:blur(4px);flex-direction:column;align-items:center;justify-content:center;gap:1.2rem}
|
||||
#loading-overlay .lo-spinner{width:52px;height:52px;border:4px solid rgba(220,232,245,.15);
|
||||
border-top-color:#2a8cd6;border-radius:50%;animation:lo-spin .85s linear infinite}
|
||||
#loading-overlay .lo-text{color:#a0b8cc;font:600 1rem sans-serif}
|
||||
@keyframes lo-spin{to{transform:rotate(360deg)}}
|
||||
</style>
|
||||
<div id="loading-overlay">
|
||||
<div class="lo-spinner"></div>
|
||||
<div class="lo-text">Ожидайте...</div>
|
||||
</div>
|
||||
<script>
|
||||
(function () {
|
||||
const username = {{ user.username|tojson }};
|
||||
@@ -153,16 +165,30 @@
|
||||
return sp;
|
||||
}
|
||||
|
||||
const loadingOverlay = document.getElementById('loading-overlay');
|
||||
|
||||
document.querySelectorAll('a.tile[href^="/go/"]').forEach(function (link) {
|
||||
link.addEventListener('click', function () {
|
||||
link.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
let href = link.getAttribute('href');
|
||||
try {
|
||||
const url = new URL(link.getAttribute('href'), window.location.origin);
|
||||
const url = new URL(href, window.location.origin);
|
||||
const params = currentScreenParams();
|
||||
url.search = params.toString();
|
||||
link.setAttribute('href', url.pathname + '?' + url.searchParams.toString());
|
||||
href = url.pathname + '?' + url.searchParams.toString();
|
||||
} catch (e) {}
|
||||
if (loadingOverlay) loadingOverlay.style.display = 'flex';
|
||||
requestAnimationFrame(function () {
|
||||
requestAnimationFrame(function () {
|
||||
window.location.href = href;
|
||||
});
|
||||
});
|
||||
}, { capture: true });
|
||||
});
|
||||
|
||||
window.addEventListener('pageshow', function (e) {
|
||||
if (loadingOverlay) loadingOverlay.style.display = 'none';
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user