From 72cc44641b5914164f727cef54298d8e2b1f3719 Mon Sep 17 00:00:00 2001 From: Shaun Walker Date: Sat, 24 Sep 2022 08:37:18 -0400 Subject: [PATCH] Add Blazor Server reconnect script, fix event log direct link from notification email, add more validation to Pager, improve browser refresh script to wait for server availability --- Oqtane.Client/Modules/Admin/Logs/Index.razor | 2 +- Oqtane.Client/Modules/Controls/Pager.razor | 1 + Oqtane.Server/Pages/_Host.cshtml | 1 + Oqtane.Server/Pages/_Host.cshtml.cs | 91 +++++++++++++------- Oqtane.Server/wwwroot/js/interop.js | 13 ++- 5 files changed, 70 insertions(+), 38 deletions(-) diff --git a/Oqtane.Client/Modules/Admin/Logs/Index.razor b/Oqtane.Client/Modules/Admin/Logs/Index.razor index afd95fdb..d763a5de 100644 --- a/Oqtane.Client/Modules/Admin/Logs/Index.razor +++ b/Oqtane.Client/Modules/Admin/Logs/Index.razor @@ -109,7 +109,7 @@ else // external link to log item will display Details component if (PageState.QueryString.ContainsKey("id") && int.TryParse(PageState.QueryString["id"], out int id)) { - NavigationManager.NavigateTo(EditUrl(PageState.Page.Path, ModuleState.ModuleId, "Detail", $"id={id}")); + NavigationManager.NavigateTo(EditUrl(PageState.Page.Path, ModuleState.ModuleId, "Detail", $"/{id}")); } if (UrlParameters.ContainsKey("level")) diff --git a/Oqtane.Client/Modules/Controls/Pager.razor b/Oqtane.Client/Modules/Controls/Pager.razor index e317f38b..068e0d55 100644 --- a/Oqtane.Client/Modules/Controls/Pager.razor +++ b/Oqtane.Client/Modules/Controls/Pager.razor @@ -293,6 +293,7 @@ { _page = 1; } + if (_page < 1) _page = 1; _startPage = 0; _endPage = 0; diff --git a/Oqtane.Server/Pages/_Host.cshtml b/Oqtane.Server/Pages/_Host.cshtml index e8de6ad5..21518a22 100644 --- a/Oqtane.Server/Pages/_Host.cshtml +++ b/Oqtane.Server/Pages/_Host.cshtml @@ -49,6 +49,7 @@ @if (Model.Runtime == "Server") { + @Html.Raw(Model.ReconnectScript) } @if (!string.IsNullOrEmpty(Model.PWAScript)) { diff --git a/Oqtane.Server/Pages/_Host.cshtml.cs b/Oqtane.Server/Pages/_Host.cshtml.cs index c0b64609..8ae0696f 100644 --- a/Oqtane.Server/Pages/_Host.cshtml.cs +++ b/Oqtane.Server/Pages/_Host.cshtml.cs @@ -69,6 +69,7 @@ namespace Oqtane.Pages public string Meta = ""; public string FavIcon = "favicon.ico"; public string PWAScript = ""; + public string ReconnectScript = ""; public string Message = ""; public IActionResult OnGet() @@ -128,6 +129,10 @@ namespace Oqtane.Pages { FavIcon = Utilities.FileUrl(alias, site.FaviconFileId.Value); } + if (Runtime == "Server") + { + ReconnectScript = CreateReconnectScript(); + } if (site.PwaIsEnabled && site.PwaAppIconFileId != null && site.PwaSplashIconFileId != null) { PWAScript = CreatePWAScript(alias, site, route); @@ -374,40 +379,60 @@ namespace Oqtane.Pages private string CreatePWAScript(Alias alias, Site site, Route route) { return - "" + Environment.NewLine + - ""; + } + + private string CreateReconnectScript() + { + return + ""; } diff --git a/Oqtane.Server/wwwroot/js/interop.js b/Oqtane.Server/wwwroot/js/interop.js index 8a677952..90c2bda4 100644 --- a/Oqtane.Server/wwwroot/js/interop.js +++ b/Oqtane.Server/wwwroot/js/interop.js @@ -356,10 +356,15 @@ Oqtane.Interop = { } } }, - refreshBrowser: function (reload, wait) { - setInterval(function () { - window.location.reload(reload); - }, wait * 1000); + refreshBrowser: function (verify, wait) { + async function attemptReload (verify) { + if (verify) { + await fetch(''); + } + window.location.reload(); + } + attemptReload(verify); + setInterval(attemptReload, wait * 1000); }, redirectBrowser: function (url, wait) { setInterval(function () {