improve loading of recent clients

This commit is contained in:
RaidMax 2022-04-28 11:42:23 -05:00
parent a3b94b50e3
commit 1995dbd080
11 changed files with 49 additions and 56 deletions

View File

@ -325,7 +325,10 @@ namespace WebfrontCore.Controllers
} }
var clients = await Manager.GetClientService().GetRecentClients(request); 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() public IActionResult RecentReportsForm()

View File

@ -23,9 +23,6 @@
</div> </div>
@section scripts { @section scripts {
<environment include="Development">
<script type="text/javascript" src="~/js/loader.js"></script>
</environment>
<script> <script>
$(document).ready(function () { $(document).ready(function () {
initLoader('/Admin/ListAuditLog', '#audit_log_table_body', @ViewBag.IntialOffset); initLoader('/Admin/ListAuditLog', '#audit_log_table_body', @ViewBag.IntialOffset);

View File

@ -31,9 +31,6 @@ else
</div> </div>
@section scripts { @section scripts {
<environment include="Development">
<script type="text/javascript" src="~/js/loader.js"></script>
</environment>
<script> <script>
$(document).ready(function () { $(document).ready(function () {
initLoader('/Message/FindNext?query=@ViewBag.Query', '#message_table_body', @Model.RetrievedResultCount, @ViewBag.QueryLimit); initLoader('/Message/FindNext?query=@ViewBag.Query', '#message_table_body', @Model.RetrievedResultCount, @ViewBag.QueryLimit);

View File

@ -346,7 +346,6 @@
@section scripts { @section scripts {
<environment include="Development"> <environment include="Development">
<script type="text/javascript" src="~/js/loader.js"></script>
<script type="text/javascript" src="~/js/profile.js"></script> <script type="text/javascript" src="~/js/profile.js"></script>
</environment> </environment>
<script>initLoader('/Client/Meta/@Model.ClientId', '#profile_events', 30, 30, [{ 'name': 'metaFilterType', 'value': '@Model.MetaFilterType' }]);</script> <script>initLoader('/Client/Meta/@Model.ClientId', '#profile_events', 30, 30, [{ 'name': 'metaFilterType', 'value': '@Model.MetaFilterType' }]);</script>

View File

@ -41,7 +41,6 @@
@section scripts @section scripts
{ {
<environment include="Development"> <environment include="Development">
<script type="text/javascript" src="~/js/loader.js"></script>
<script type="text/javascript" src="~/js/stats.js"></script> <script type="text/javascript" src="~/js/stats.js"></script>
</environment> </environment>
<script>initLoader('/Stats/GetTopPlayersAsync', '#topPlayersContainer', 25);</script> <script>initLoader('/Stats/GetTopPlayersAsync', '#topPlayersContainer', 25);</script>

View File

@ -86,7 +86,6 @@
@section scripts { @section scripts {
<environment include="Development"> <environment include="Development">
<script type="text/javascript" src="~/js/loader.js"></script>
<script type="text/javascript" src="~/js/penalty.js"></script> <script type="text/javascript" src="~/js/penalty.js"></script>
</environment> </environment>
<script> <script>

View File

@ -1,24 +0,0 @@
@model SharedLibraryCore.Dtos.PlayerInfo
<div class="bg-very-dark-dm bg-light-ex-lm p-15 rounded mb-10">
<div class="d-flex flex-row">
<a asp-controller="Client" asp-action="Profile" asp-route-id="@Model.ClientId" class="h4 mr-auto">
<color-code value="@Model.Name"></color-code>
</a>
@if (Model.GeoLocationInfo is not null)
{
@if (!string.IsNullOrEmpty(Model.GeoLocationInfo.CountryCode))
{
<div data-toggle="tooltip" data-title="@Model.GeoLocationInfo.Country">
<div class="rounded" style="width: 40px; height: 25.66px; background-repeat: no-repeat; background-position: center center; background-image: url('https://flagcdn.com/w40/@(Model.GeoLocationInfo.CountryCode.ToLower()).png')"></div>
</div>
}
}
</div>
<div class="d-flex flex-row">
<has-permission entity="ClientIPAddress" required-permission="Read">
<div class="align-self-center mr-auto">@Model.IPAddress</div>
</has-permission>
<div class="align-self-center text-muted font-size-12">@Model.LastConnection.HumanizeForCurrentCulture()</div>
</div>
</div>

View File

@ -3,28 +3,28 @@
Layout = null; Layout = null;
} }
@if (ViewBag.First)
{
<div class="mb-15 text-center font-weight-lighter">New clients connected in the last <span class="text-primary">24</span> hours</div>
}
@foreach (var client in Model) @foreach (var client in Model)
{ {
@if (ViewBag.First) <div class="bg-very-dark-dm bg-light-ex-lm p-15 rounded mb-10">
<div class="d-flex flex-row">
<a asp-controller="Client" asp-action="Profile" asp-route-id="@client.ClientId" class="h4 mr-auto">
<color-code value="@client.Name"></color-code>
</a>
@if (client.GeoLocationInfo is not null)
{ {
<div id="recentClientsContainer"> @if (!string.IsNullOrEmpty(client.GeoLocationInfo.CountryCode))
<partial name="~/Views/Shared/Components/Client/_RecentClient.cshtml" for="@client"/> {
<div data-toggle="tooltip" data-title="@client.GeoLocationInfo.Country">
<div class="rounded" style="width: 40px; height: 25.66px; background-repeat: no-repeat; background-position: center center; background-image: url('https://flagcdn.com/w40/@(client.GeoLocationInfo.CountryCode.ToLower()).png')"></div>
</div> </div>
} }
else
{
<partial name="~/Views/Shared/Components/Client/_RecentClient.cshtml" for="@client"/>
} }
} </div>
<div class="d-flex flex-row">
@if (ViewBag.First) <has-permission entity="ClientIPAddress" required-permission="Read">
{ <div class="align-self-center mr-auto">@client.IPAddress</div>
<i id="loaderLoad" class="loader-load-more oi oi-chevron-bottom text-center text-primary d-none d-lg-block mt-10"></i> </has-permission>
<div class="align-self-center text-muted font-size-12">@client.LastConnection.HumanizeForCurrentCulture()</div>
<script>initLoader('/Action/RecentClientsForm', '#recentClientsContainer', 20);</script> </div>
</div>
} }

View File

@ -0,0 +1,13 @@
@model IEnumerable<SharedLibraryCore.Dtos.PlayerInfo>
@{
Layout = null;
}
<div class="mb-15 text-center font-weight-lighter">New clients connected in the last <span class="text-primary">24</span> hours</div>
<div id="recentClientContainer">
<partial name="~/Views/Shared/Components/Client/_RecentClients.cshtml" for="@Model"/>
</div>
<i class="loader-load-more oi oi-chevron-bottom text-center text-primary w-full"></i>
<script>initLoader('/Action/RecentClientsForm', '#recentClientContainer', 20);</script>

View File

@ -163,6 +163,7 @@
<script type="text/javascript" src="~/lib/chart.js/dist/Chart.bundle.min.js"></script> <script type="text/javascript" src="~/lib/chart.js/dist/Chart.bundle.min.js"></script>
<script type="text/javascript" src="~/lib/halfmoon/js/halfmoon.js"></script> <script type="text/javascript" src="~/lib/halfmoon/js/halfmoon.js"></script>
<script type="text/javascript" src="~/js/action.js"></script> <script type="text/javascript" src="~/js/action.js"></script>
<script type="text/javascript" src="~/js/loader.js"></script>
<script type="text/javascript" src="~/js/search.js"></script> <script type="text/javascript" src="~/js/search.js"></script>
</environment> </environment>
<environment include="Production"> <environment include="Production">

View File

@ -14,11 +14,20 @@ function initLoader(location, loaderId, count = 10, start = count, additional =
loaderOffset = start; loaderOffset = start;
additionalParams = additional; additionalParams = additional;
try {
setupMonitor(); setupMonitor();
}
catch {
// ignored (can happen when the action modal loader exists but no page level loader does)
}
$('#loaderLoad').click(function () { $('#loaderLoad').click(function () {
loadMoreItems(); loadMoreItems();
}); });
$('.loader-load-more').click(function() {
loadMoreItems();
})
} }
function setupMonitor() { function setupMonitor() {