Skip to content

Commit b066bd2

Browse files
feat: Enhance Protected Names functionality with pagination and additional game type display
1 parent bd792fe commit b066bd2

6 files changed

Lines changed: 45 additions & 12 deletions

File tree

src/XtremeIdiots.Portal.Web/Controllers/ProtectedNamesController.cs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,37 @@ public async Task<IActionResult> Index(CancellationToken cancellationToken = def
5454
if (authResult is not null)
5555
return authResult;
5656

57-
var protectedNamesResponse = await repositoryApiClient.Players.V1.GetProtectedNames(0, 1000).ConfigureAwait(false);
57+
const int protectedNamesPageSize = 500;
58+
var protectedNames = new List<ProtectedNameDto>();
59+
var skipEntries = 0;
5860

59-
if (!protectedNamesResponse.IsSuccess || protectedNamesResponse.Result?.Data?.Items is null)
61+
while (true)
6062
{
61-
Logger.LogWarning("Failed to retrieve protected names for user {UserId}", User.XtremeIdiotsId());
62-
return RedirectToAction(nameof(ErrorsController.Display), nameof(ErrorsController), new { id = 500 });
63+
var protectedNamesResponse = await repositoryApiClient.Players.V1
64+
.GetProtectedNames(skipEntries, protectedNamesPageSize)
65+
.ConfigureAwait(false);
66+
67+
if (!protectedNamesResponse.IsSuccess || protectedNamesResponse.Result?.Data?.Items is null)
68+
{
69+
Logger.LogWarning("Failed to retrieve protected names for user {UserId}", User.XtremeIdiotsId());
70+
return RedirectToAction(nameof(ErrorsController.Display), nameof(ErrorsController), new { id = 500 });
71+
}
72+
73+
var page = protectedNamesResponse.Result.Data.Items.ToList();
74+
if (page.Count == 0)
75+
break;
76+
77+
protectedNames.AddRange(page);
78+
79+
if (page.Count < protectedNamesPageSize)
80+
break;
81+
82+
skipEntries += protectedNamesPageSize;
6383
}
6484

6585
var model = new ProtectedNamesViewModel
6686
{
67-
ProtectedNames = [.. protectedNamesResponse.Result.Data.Items]
87+
ProtectedNames = protectedNames
6888
};
6989

7090
return View(model);

src/XtremeIdiots.Portal.Web/Views/ProtectedNames/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<h5>All Protected Names</h5>
2727
</div>
2828
<div class="ibox-content">
29-
<partial name="_ProtectedNamesTable" model="@(Model?.ProtectedNames ?? new List<ProtectedNameDto>())" />
29+
<partial name="_ProtectedNamesTable" model="@(Model?.ProtectedNames ?? Array.Empty<ProtectedNameDto>())" />
3030
</div>
3131
</div>
3232
</div>

src/XtremeIdiots.Portal.Web/Views/ProtectedNames/Report.cshtml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@
3939
</a>
4040
</dd>
4141
</div>
42+
<div class="detail-field">
43+
<dt class="detail-label">Owner Game</dt>
44+
<dd class="detail-value">
45+
<game-type-icon game="@Model.Report.OwningPlayer.GameType"></game-type-icon>
46+
<span>@Model.Report.OwningPlayer.GameType</span>
47+
</dd>
48+
</div>
4249
</dl>
4350
}
4451
</div>

src/XtremeIdiots.Portal.Web/Views/Shared/_ProtectedNamesTable.cshtml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<tr>
1717
<th>Name</th>
1818
<th>Owner</th>
19+
<th>Owner Game</th>
1920
<th>Created</th>
2021
<th>Created By</th>
2122
<th>Actions</th>
@@ -31,6 +32,10 @@
3132
View Player Profile
3233
</a>
3334
</td>
35+
<td>
36+
<game-type-icon game="@protectedName.OwnerGameType"></game-type-icon>
37+
<span>@protectedName.OwnerGameType</span>
38+
</td>
3439
<td><time user-time utc="@protectedName.CreatedOn"></time></td>
3540
<td>@protectedName.CreatedByUserProfile?.DisplayName</td>
3641
<td>

src/XtremeIdiots.Portal.Web/XtremeIdiots.Portal.Web.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
<PackageReference Include="MX.Api.Abstractions" Version="2.3.31" />
4949
<PackageReference Include="MX.Api.Client" Version="2.3.31" />
5050
<PackageReference Include="XtremeIdiots.Portal.Integrations.Servers.Api.Client.V1" Version="2.1.138" />
51-
<PackageReference Include="XtremeIdiots.Portal.Repository.Abstractions.V1" Version="2.1.220" />
52-
<PackageReference Include="XtremeIdiots.Portal.Repository.Api.Client.V1" Version="2.1.220" />
51+
<PackageReference Include="XtremeIdiots.Portal.Repository.Abstractions.V1" Version="2.1.230" />
52+
<PackageReference Include="XtremeIdiots.Portal.Repository.Api.Client.V1" Version="2.1.230" />
5353
<PackageReference Include="MX.GeoLocation.Api.Client.V1" Version="1.2.39" />
5454
</ItemGroup>
5555

src/XtremeIdiots.Portal.Web/wwwroot/js/protected-names-table.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ $(document).ready(function () {
1313
autoWidth: false,
1414
paging: true,
1515
pageLength: 25,
16-
order: [[2, 'desc']], // Created date desc (column index 2)
16+
order: [[3, 'desc']], // Created date desc (column index 3)
1717
columnDefs: [
1818
{ targets: 0, responsivePriority: 1 }, // Name - always visible
1919
{ targets: 1, responsivePriority: 3 }, // Owner/Player - medium priority
20-
{ targets: 2, responsivePriority: 4 }, // Created - lower priority
21-
{ targets: 3, responsivePriority: 5 }, // Created By - lowest priority
22-
{ targets: 4, responsivePriority: 2 } // Actions - high priority
20+
{ targets: 2, responsivePriority: 4 }, // Owner game - lower priority
21+
{ targets: 3, responsivePriority: 5 }, // Created - lower priority
22+
{ targets: 4, responsivePriority: 6 }, // Created By - lowest priority
23+
{ targets: 5, responsivePriority: 2 } // Actions - high priority
2324
],
2425
language: {
2526
search: '<i class="fa fa-search" aria-hidden="true"></i>',

0 commit comments

Comments
 (0)