From 7f095511d6908954060fbc54cfcc2d693d83674e Mon Sep 17 00:00:00 2001 From: djbadders <34887832+djbadders@users.noreply.github.com> Date: Sun, 14 Apr 2019 07:45:09 +0100 Subject: [PATCH] Stops dashboard refreshes stacking and causing issues with browsers --- Monitor/Pages/Index.cshtml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Monitor/Pages/Index.cshtml b/Monitor/Pages/Index.cshtml index d61c407..fe49026 100644 --- a/Monitor/Pages/Index.cshtml +++ b/Monitor/Pages/Index.cshtml @@ -28,10 +28,17 @@ var errCountIndex = []; var intervalDashboardTop; var intervalDashboardBottom; + var loadDashboardTop = function () { $("#baglist-refresh-icon").html(''); $("#buylist-refresh-icon").html(''); + // Clear exisitng interval to stop multiple attempts to load at the same time. + if (intervalDashboardTop != null) + { + clearInterval(intervalDashboardTop); + } + $("#dashboardTop").load('@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)_get/DashboardTop', '', function (responseText, textStatus, XMLHttpRequest) { $("#baglist-refresh-icon").html(''); $("#buylist-refresh-icon").html(''); @@ -49,6 +56,9 @@ } else { errCountIndex["DashboardTop"] = 0; } + + // Reinstate interval + intervalDashboardTop = setInterval(function () { loadDashboardTop(); }, 5 * 1000); }); }; @@ -62,6 +72,13 @@ nv.logs = {}; nv.tooltip = {}; + // Clear exisitng interval to stop multiple attempts to load at the same time. + if (intervalDashboardBottom != null) + { + clearInterval(intervalDashboardBottom); + } + + // Load dashboard $("#dashboardBottom").load('@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)_get/DashboardBottom', '', function (responseText, textStatus, XMLHttpRequest) { if (textStatus == 'error') { errCountIndex["DashboardBottom"]++; @@ -73,17 +90,18 @@ } else { errCountIndex["DashboardBottom"] = 0; } + + // Reinstate the interval. + intervalDashboardBottom = setInterval(function () { loadDashboardBottom(); }, @Model.PTMagicConfiguration.GeneralSettings.Monitor.RefreshSeconds * 1000); }); }; $(document).ready(function () { errCountIndex["DashboardTop"] = 0; - loadDashboardTop(); - intervalDashboardTop = setInterval(function () { loadDashboardTop(); }, 5 * 1000); + loadDashboardTop(); errCountIndex["DashboardBottom"] = 0; loadDashboardBottom(); - intervalDashboardBottom = setInterval(function () { loadDashboardBottom(); }, @Model.PTMagicConfiguration.GeneralSettings.Monitor.RefreshSeconds * 1000); }); } \ No newline at end of file