Skip to content

Commit 945c232

Browse files
committed
Add paging to applications to show all applications
1 parent 6feb558 commit 945c232

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/Minigun/Areas/Shared/_ApplicationsPartial.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<div class="dropdown-item px-4 py-2 text-sm text-gray-700 cursor-pointer hover:bg-gray-100 @(application.Identifier == Model.SelectedApplicationId ? "bg-gray-100" : "")"
3333
data-application-id="@application.Identifier"
3434
data-application-name="@application.Name"
35-
hx-on:click="selectApplication(this)">
35+
onclick="selectApplication(this)">
3636
@application.Name
3737
</div>
3838
}

src/Minigun/ViewComponents/ApplicationsViewComponent.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Microsoft.AspNetCore.Mvc;
22
using Minigun.Models;
33
using Minigun.Services;
4+
using System.Text.Json;
45

56
namespace Minigun.ViewComponents;
67

@@ -18,7 +19,10 @@ public async Task<IViewComponentResult> InvokeAsync()
1819
var pathParts = Request.Path.ToString().Split("/", StringSplitOptions.RemoveEmptyEntries);
1920
var selectedId = pathParts.Length > 1 ? pathParts[1] : null;
2021

21-
var applications = await _raygunApiService.ListApplicationsAsync(100);
22+
var applications = await GetAllApplicationsAsync();
23+
24+
// Sort applications alphabetically
25+
applications = applications.OrderBy(a => a.Name).ToList();
2226

2327
// Find selected application and move it to first position if found
2428
var selectedApp = applications.FirstOrDefault(a => a.Identifier == selectedId);
@@ -38,4 +42,24 @@ public async Task<IViewComponentResult> InvokeAsync()
3842

3943
return View("/Areas/Shared/_ApplicationsPartial.cshtml", model);
4044
}
45+
46+
private async Task<List<Application>> GetAllApplicationsAsync()
47+
{
48+
var allApplications = new List<Application>();
49+
var offset = 0;
50+
const int pageSize = 100;
51+
bool hasMoreData;
52+
53+
do
54+
{
55+
var batch = await _raygunApiService.ListApplicationsAsync(pageSize, offset);
56+
allApplications.AddRange(batch);
57+
58+
hasMoreData = batch.Count == pageSize;
59+
offset += pageSize;
60+
}
61+
while (hasMoreData);
62+
63+
return allApplications;
64+
}
4165
}

0 commit comments

Comments
 (0)