mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 09:54:30 +01:00
Merge pull request #1753 from bolatovumar/feat/1568
Allow sorting apps by store, name or app type
This commit is contained in:
commit
b7d66efb20
@ -47,9 +47,42 @@ namespace BTCPayServer.Controllers
|
||||
|
||||
public string CreatedAppId { get; set; }
|
||||
|
||||
public async Task<IActionResult> ListApps()
|
||||
public async Task<IActionResult> ListApps(
|
||||
string sortOrder = null,
|
||||
string sortOrderColumn = null
|
||||
)
|
||||
{
|
||||
var apps = await _AppService.GetAllApps(GetUserId());
|
||||
|
||||
if (sortOrder != null && sortOrderColumn != null)
|
||||
{
|
||||
apps = apps.OrderByDescending(app =>
|
||||
{
|
||||
switch (sortOrderColumn)
|
||||
{
|
||||
case nameof(app.AppName):
|
||||
return app.AppName;
|
||||
case nameof(app.StoreName):
|
||||
return app.StoreName;
|
||||
case nameof(app.AppType):
|
||||
return app.AppType;
|
||||
default:
|
||||
return app.Id;
|
||||
}
|
||||
}).ToArray();
|
||||
|
||||
switch (sortOrder)
|
||||
{
|
||||
case "desc":
|
||||
ViewData[$"{sortOrderColumn}SortOrder"] = "asc";
|
||||
break;
|
||||
case "asc":
|
||||
apps = apps.Reverse().ToArray();
|
||||
ViewData[$"{sortOrderColumn}SortOrder"] = "desc";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return View(new ListAppsViewModel()
|
||||
{
|
||||
Apps = apps
|
||||
|
@ -31,9 +31,48 @@
|
||||
<table class="table table-sm table-responsive-md">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Store</th>
|
||||
<th>Name</th>
|
||||
<th>App type</th>
|
||||
<th>
|
||||
<a
|
||||
asp-action="ListApps"
|
||||
asp-route-sortOrder="@(ViewData["StoreNameSortOrder"] ?? "asc")"
|
||||
asp-route-sortOrderColumn="StoreName"
|
||||
class="text-nowrap"
|
||||
title="@((string)ViewData["StoreNameSortOrder"] == "desc" ? "Sort by descending..." : "Sort by ascending...")"
|
||||
>
|
||||
Store @if (ViewData["StoreNameSortOrder"] != null)
|
||||
{
|
||||
<span class="fa @((string)ViewData["StoreNameSortOrder"] == "asc" ? "fa-arrow-down": "fa-arrow-up")" />
|
||||
}
|
||||
</a>
|
||||
</th>
|
||||
<th>
|
||||
<a
|
||||
asp-action="ListApps"
|
||||
asp-route-sortOrder="@(ViewData["AppNameSortOrder"] ?? "asc")"
|
||||
asp-route-sortOrderColumn="AppName"
|
||||
class="text-nowrap"
|
||||
title="@((string)ViewData["AppNameSortOrder"] == "desc" ? "Sort by descending..." : "Sort by ascending...")"
|
||||
>
|
||||
Name @if (ViewData["AppNameSortOrder"] != null)
|
||||
{
|
||||
<span class="fa @((string)ViewData["AppNameSortOrder"] == "asc" ? "fa-arrow-down": "fa-arrow-up")" />
|
||||
}
|
||||
</a>
|
||||
</th>
|
||||
<th>
|
||||
<a
|
||||
asp-action="ListApps"
|
||||
asp-route-sortOrder="@(ViewData["AppTypeSortOrder"] ?? "asc")"
|
||||
asp-route-sortOrderColumn="AppType"
|
||||
class="text-nowrap"
|
||||
title="@((string)ViewData["AppTypeSortOrder"] == "desc" ? "Sort by descending..." : "Sort by ascending...")"
|
||||
>
|
||||
App Type @if (ViewData["AppTypeSortOrder"] != null)
|
||||
{
|
||||
<span class="fa @((string)ViewData["AppTypeSortOrder"] == "asc" ? "fa-arrow-down": "fa-arrow-up")" />
|
||||
}
|
||||
</a>
|
||||
</th>
|
||||
<th style="text-align:right">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
Loading…
Reference in New Issue
Block a user