mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-11 01:35:22 +01:00
parent
561caf966a
commit
36e3eeecaa
2 changed files with 76 additions and 4 deletions
|
@ -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 "Name":
|
||||
return app.AppName;
|
||||
case "Store":
|
||||
return app.StoreName;
|
||||
case "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["StoreSortOrder"] ?? "asc")"
|
||||
asp-route-sortOrderColumn="Store"
|
||||
class="text-nowrap"
|
||||
title="@((string)ViewData["StoreSortOrder"] == "desc" ? "Sort by descending..." : "Sort by ascending...")"
|
||||
>
|
||||
Store @if (ViewData["StoreSortOrder"] != null)
|
||||
{
|
||||
<span class="fa @((string)ViewData["StoreSortOrder"] == "asc" ? "fa-arrow-down": "fa-arrow-up")" />
|
||||
}
|
||||
</a>
|
||||
</th>
|
||||
<th>
|
||||
<a
|
||||
asp-action="ListApps"
|
||||
asp-route-sortOrder="@(ViewData["NameSortOrder"] ?? "asc")"
|
||||
asp-route-sortOrderColumn="Name"
|
||||
class="text-nowrap"
|
||||
title="@((string)ViewData["NameSortOrder"] == "desc" ? "Sort by descending..." : "Sort by ascending...")"
|
||||
>
|
||||
Name @if (ViewData["NameSortOrder"] != null)
|
||||
{
|
||||
<span class="fa @((string)ViewData["NameSortOrder"] == "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…
Add table
Reference in a new issue