Enhance WebSocket handling and log polling logic
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-11 16:25:48 +11:00
parent ffd43d5217
commit e48a061ca0
6 changed files with 126 additions and 39 deletions

View File

@@ -987,6 +987,27 @@ function initShellLayout() {
SHELL_LAYOUT_READY = true
}
function shouldPollLogs():boolean {
if (document.hidden == true) {
return false
}
if (document.getElementById("content_log") == null) {
return false
}
if (ACTIVE_MENU_ID.length < 1) {
return false
}
var activeItem = document.getElementById(ACTIVE_MENU_ID)
if (activeItem == null) {
return false
}
return activeItem.getAttribute("data-menu") == "log"
}
function PageReady() {
initShellLayout()
@@ -994,6 +1015,29 @@ function PageReady() {
var server:Server = new Server("getServerConfig")
server.request(new Object())
var bootstrapAttempts:number = 0
var maxBootstrapAttempts:number = 5
var bootstrapTimer:number = window.setInterval(function() {
if (SERVER.hasOwnProperty("clientInfo") == true) {
window.clearInterval(bootstrapTimer)
return
}
if (SERVER_CONNECTION == true) {
return
}
bootstrapAttempts++
var retryServer:Server = new Server("getServerConfig")
retryServer.request(new Object())
if (bootstrapAttempts >= maxBootstrapAttempts) {
window.clearInterval(bootstrapTimer)
}
}, 3000)
window.addEventListener("resize", function(){
if (window.innerWidth > 900) {
setLayoutMenuState(false)
@@ -1002,7 +1046,7 @@ function PageReady() {
}, true);
setInterval(function(){
if (document.hidden == true) {
if (shouldPollLogs() == false) {
return
}
updateLog()