From dc07e72fb39a2cc768b8b3553f28f33f53bfd8a5 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Thu, 28 Apr 2022 11:42:23 -0500 Subject: [PATCH] improve loading of recent clients --- WebfrontCore/Controllers/ActionController.cs | 5 ++- WebfrontCore/Views/Admin/AuditLog.cshtml | 3 -- WebfrontCore/Views/Client/Message/Find.cshtml | 3 -- .../Views/Client/Profile/Index.cshtml | 1 - .../Views/Client/Statistics/Index.cshtml | 1 - WebfrontCore/Views/Penalty/List.cshtml | 1 - .../Components/Client/_RecentClient.cshtml | 24 ----------- .../Components/Client/_RecentClients.cshtml | 42 +++++++++---------- .../Client/_RecentClientsContainer.cshtml | 13 ++++++ WebfrontCore/Views/Shared/_Layout.cshtml | 1 + WebfrontCore/wwwroot/js/loader.js | 11 ++++- 11 files changed, 49 insertions(+), 56 deletions(-) delete mode 100644 WebfrontCore/Views/Shared/Components/Client/_RecentClient.cshtml create mode 100644 WebfrontCore/Views/Shared/Components/Client/_RecentClientsContainer.cshtml diff --git a/WebfrontCore/Controllers/ActionController.cs b/WebfrontCore/Controllers/ActionController.cs index 820e923a..6fb7711f 100644 --- a/WebfrontCore/Controllers/ActionController.cs +++ b/WebfrontCore/Controllers/ActionController.cs @@ -325,7 +325,10 @@ namespace WebfrontCore.Controllers } var clients = await Manager.GetClientService().GetRecentClients(request); - return View("~/Views/Shared/Components/Client/_RecentClients.cshtml", clients); + + return request.Offset == 0 + ? View("~/Views/Shared/Components/Client/_RecentClientsContainer.cshtml", clients) + : View("~/Views/Shared/Components/Client/_RecentClients.cshtml", clients); } public IActionResult RecentReportsForm() diff --git a/WebfrontCore/Views/Admin/AuditLog.cshtml b/WebfrontCore/Views/Admin/AuditLog.cshtml index 2e44516c..1acfa035 100644 --- a/WebfrontCore/Views/Admin/AuditLog.cshtml +++ b/WebfrontCore/Views/Admin/AuditLog.cshtml @@ -23,9 +23,6 @@ @section scripts { - - - - diff --git a/WebfrontCore/Views/Client/Statistics/Index.cshtml b/WebfrontCore/Views/Client/Statistics/Index.cshtml index 473b6196..654611f6 100644 --- a/WebfrontCore/Views/Client/Statistics/Index.cshtml +++ b/WebfrontCore/Views/Client/Statistics/Index.cshtml @@ -41,7 +41,6 @@ @section scripts { - diff --git a/WebfrontCore/Views/Penalty/List.cshtml b/WebfrontCore/Views/Penalty/List.cshtml index 7b878712..79270c55 100644 --- a/WebfrontCore/Views/Penalty/List.cshtml +++ b/WebfrontCore/Views/Penalty/List.cshtml @@ -86,7 +86,6 @@ @section scripts { - +
+ +
@client.IPAddress
+
+
@client.LastConnection.HumanizeForCurrentCulture()
+
+ } diff --git a/WebfrontCore/Views/Shared/Components/Client/_RecentClientsContainer.cshtml b/WebfrontCore/Views/Shared/Components/Client/_RecentClientsContainer.cshtml new file mode 100644 index 00000000..9ac51a8f --- /dev/null +++ b/WebfrontCore/Views/Shared/Components/Client/_RecentClientsContainer.cshtml @@ -0,0 +1,13 @@ +@model IEnumerable +@{ + Layout = null; +} + +
New clients connected in the last 24 hours
+ +
+ +
+ + + diff --git a/WebfrontCore/Views/Shared/_Layout.cshtml b/WebfrontCore/Views/Shared/_Layout.cshtml index c39617d6..6f05ae81 100644 --- a/WebfrontCore/Views/Shared/_Layout.cshtml +++ b/WebfrontCore/Views/Shared/_Layout.cshtml @@ -163,6 +163,7 @@ + diff --git a/WebfrontCore/wwwroot/js/loader.js b/WebfrontCore/wwwroot/js/loader.js index 8f0f85e1..95655aa6 100644 --- a/WebfrontCore/wwwroot/js/loader.js +++ b/WebfrontCore/wwwroot/js/loader.js @@ -14,11 +14,20 @@ function initLoader(location, loaderId, count = 10, start = count, additional = loaderOffset = start; additionalParams = additional; - setupMonitor(); + try { + setupMonitor(); + } + catch { + // ignored (can happen when the action modal loader exists but no page level loader does) + } $('#loaderLoad').click(function () { loadMoreItems(); }); + + $('.loader-load-more').click(function() { + loadMoreItems(); + }) } function setupMonitor() {