Skip to content

Commit

Permalink
Version 256:
Browse files Browse the repository at this point in the history
* In the event of a failure during the initial startup sequence, UI3 will now reload itself automatically after 3 seconds.  This behavior can be manipulated by a ui3-local-overrides.js script.
  • Loading branch information
bp2008 committed Nov 15, 2023
1 parent 2eeed58 commit 1bd430d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ui3.htm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
};
</script>
<script type="text/javascript">
var ui_version = "255";
var ui_version = "256";
var bi_version = "%%VERSION%%";
var appPath_raw = "%%VIRTDIR%%";
var local_bi_session = "%%SESSION%%";
Expand Down
41 changes: 29 additions & 12 deletions ui3/ui3.js
Original file line number Diff line number Diff line change
Expand Up @@ -3212,7 +3212,7 @@ $.ajax({
},
error: function (jqXHR, textStatus, errorThrown)
{
loadingHelper.SetErrorStatus("svg", 'Error trying to load icons.svg<br/>Response: ' + jqXHR.status + ' ' + jqXHR.statusText + '<br>Status: ' + textStatus + '<br>Error: ' + errorThrown);
loadingHelper.SetErrorStatus("svg", 'Error trying to load icons.svg<br/>Response: ' + jqXHR.status + ' ' + jqXHR.statusText + '<br>Status: ' + textStatus + '<br>Error: ' + errorThrown, true);
}
});
$(function ()
Expand Down Expand Up @@ -13688,7 +13688,7 @@ function SessionManager()
LogInWithCredentials(currentServer.remoteServerUser, currentServer.remoteServerPass, function (failResponse, errorMessage)
{
// The login failed
loadingHelper.SetErrorStatus("login", 'UI3 was unable to log in to the remote server. ' + errorMessage);
loadingHelper.SetErrorStatus("login", 'UI3 was unable to log in to the remote server. ' + errorMessage, false);
}, true);
}
else
Expand All @@ -13697,7 +13697,7 @@ function SessionManager()
var oldSession = self.GetAPISession();
if (!oldSession)
{
loadingHelper.SetErrorStatus("login", "Blue Iris did not provide the expected session data. This version of UI3 requires Blue Iris 4.8.2.3 or newer.");
loadingHelper.SetErrorStatus("login", "Blue Iris did not provide the expected session data. This version of UI3 requires Blue Iris 4.8.2.3 or newer.", false);
return;
}
ExecJSON({ cmd: "login", session: oldSession }, function (response)
Expand Down Expand Up @@ -13736,28 +13736,27 @@ function SessionManager()
if (response.data.reason == "missing response")
{
// The { cmd: "login", session: oldSession } method of learning session status always seemed a little hacky. If this error ever arises, it means Blue Iris has broken this method and we need a replacement.
loadingHelper.SetErrorStatus("login", 'Blue Iris sent an authentication challenge instead of session data (probably indicates a Blue Iris bug).');
loadingHelper.SetErrorStatus("login", 'Blue Iris sent an authentication challenge instead of session data (probably indicates a Blue Iris bug).', false);
return;
}
else
errorInfo = JSON.stringify(response);
}
else
{
loadingHelper.SetErrorStatus("login", 'The current session is invalid or expired. Reloading this page momentarily.');
setTimeout(ReloadInterface, 3000);
loadingHelper.SetErrorStatus("login", 'The current session is invalid or expired.', 3000);
return;
}
}
else
{
errorInfo = JSON.stringify(response);
loadingHelper.SetErrorStatus("login", 'Unrecognized response when getting session status. ' + errorInfo);
loadingHelper.SetErrorStatus("login", 'Unrecognized response when getting session status. ' + errorInfo, true);
}
}
}, function (jqXHR, textStatus, errorThrown)
{
loadingHelper.SetErrorStatus("login", 'Error contacting Blue Iris server to check session status.<br/>' + jqXHR.ErrorMessageHtml);
loadingHelper.SetErrorStatus("login", 'Error contacting Blue Iris server to check session status.<br/>' + jqXHR.ErrorMessageHtml, true);
});
}
}
Expand Down Expand Up @@ -14316,7 +14315,7 @@ function CameraListLoader()
else
{
lastResponse = response;
loadingHelper.SetErrorStatus("cameraList", "Camera list is empty! Try reloading the page.");
loadingHelper.SetErrorStatus("cameraList", "Camera list is empty! Try reloading the page.", true);
}
return;
}
Expand Down Expand Up @@ -18347,7 +18346,7 @@ function Pnacl_Player(frameRendered, PlaybackReachedNaturalEndCB)
var $err = $('<div>Native H.264 player ' + (isCrash ? "crashed" : "error") + '!<br><br>' + player.lastError + '</div>');
if (!isLoaded)
{
loadingHelper.SetErrorStatus("h264");
loadingHelper.SetErrorStatus("h264", "The NACL video player failed to load.", true);
$err.append($disablePnaclButton);
var $explanation = mse_mp4_h264_supported || h264_js_player_supported || webcodecs_h264_player_supported ? $('<div>You can load UI3 by changing to a different player:</div>') : $('<div>You can load UI3 by changing to a JPEG streaming method:</div>');
$explanation.css('margin-top', '12px');
Expand Down Expand Up @@ -29466,7 +29465,7 @@ function LoadingHelper()
}
FinishLoadingIfConditionsMet();
}
this.SetErrorStatus = function (name, errorMessage)
this.SetErrorStatus = function (name, errorMessage, reloadTimeoutMs)
{
var thing = GetThing(name);
var loadingStatusObj = $(thing[1]);
Expand All @@ -29475,7 +29474,25 @@ function LoadingHelper()
loadingStatusObj.html("FAIL");
loadingStatusObj.css("color", "#CC0000");
}
if (typeof errorMessage != "undefined" && errorMessage != null && errorMessage != "")

if (reloadTimeoutMs === true)
reloadTimeoutMs = 3000;
else if (typeof reloadTimeoutMs === undefined || reloadTimeoutMs === false || reloadTimeoutMs < 0)
reloadTimeoutMs = -1;

var eventArg = { reloadTimeoutMs: reloadTimeoutMs, showErrorToast: true };
BI_CustomEvent.Invoke("UI_Loading_Failed", eventArg);

if (typeof errorMessage === "undefined" || !errorMessage)
errorMessage = "UI3 failed to load.";
if (!errorMessage.endsWith("."))
errorMessage += ".";
if (eventArg.reloadTimeoutMs >= 0)
{
errorMessage += " Reloading momentarily...";
setTimeout(ReloadInterface, eventArg.reloadTimeoutMs);
}
if (eventArg.showErrorToast)
toaster.Error(errorMessage, 600000);
}
var GetThing = function (name)
Expand Down

0 comments on commit 1bd430d

Please sign in to comment.