mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 14:22:40 +01:00
parent
81bba8c829
commit
b71eb12e23
3 changed files with 79 additions and 23 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BTCPayServer.Data;
|
using BTCPayServer.Data;
|
||||||
using BTCPayServer.Models;
|
using BTCPayServer.Models;
|
||||||
|
@ -70,10 +71,40 @@ namespace BTCPayServer.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> ListStores()
|
public async Task<IActionResult> ListStores(
|
||||||
|
string sortOrder = null,
|
||||||
|
string sortOrderColumn = null
|
||||||
|
)
|
||||||
{
|
{
|
||||||
StoresViewModel result = new StoresViewModel();
|
StoresViewModel result = new StoresViewModel();
|
||||||
var stores = await _Repo.GetStoresByUserId(GetUserId());
|
var stores = await _Repo.GetStoresByUserId(GetUserId());
|
||||||
|
if (sortOrder != null && sortOrderColumn != null)
|
||||||
|
{
|
||||||
|
stores = stores.OrderByDescending(store =>
|
||||||
|
{
|
||||||
|
switch (sortOrderColumn)
|
||||||
|
{
|
||||||
|
case nameof(store.StoreName):
|
||||||
|
return store.StoreName;
|
||||||
|
case nameof(store.StoreWebsite):
|
||||||
|
return store.StoreWebsite;
|
||||||
|
default:
|
||||||
|
return store.Id;
|
||||||
|
}
|
||||||
|
}).ToArray();
|
||||||
|
|
||||||
|
switch (sortOrder)
|
||||||
|
{
|
||||||
|
case "desc":
|
||||||
|
ViewData[$"{sortOrderColumn}SortOrder"] = "asc";
|
||||||
|
break;
|
||||||
|
case "asc":
|
||||||
|
stores = stores.Reverse().ToArray();
|
||||||
|
ViewData[$"{sortOrderColumn}SortOrder"] = "desc";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < stores.Length; i++)
|
for (int i = 0; i < stores.Length; i++)
|
||||||
{
|
{
|
||||||
var store = stores[i];
|
var store = stores[i];
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
@using BTCPayServer.Services.Apps
|
@model ListAppsViewModel
|
||||||
@model ListAppsViewModel
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Apps";
|
ViewData["Title"] = "Apps";
|
||||||
|
var storeNameSortOrder = (string)ViewData["StoreNameSortOrder"];
|
||||||
|
var appNameSortOrder = (string)ViewData["AppNameSortOrder"];
|
||||||
|
var appTypeSortOrder = (string)ViewData["AppTypeSortOrder"];
|
||||||
|
var sortByDesc = "Sort by descending...";
|
||||||
|
var sortByAsc = "Sort by ascending...";
|
||||||
}
|
}
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@if (TempData.HasStatusMessage())
|
@if (TempData.HasStatusMessage())
|
||||||
|
@ -34,43 +39,37 @@
|
||||||
<th>
|
<th>
|
||||||
<a
|
<a
|
||||||
asp-action="ListApps"
|
asp-action="ListApps"
|
||||||
asp-route-sortOrder="@(ViewData["StoreNameSortOrder"] ?? "asc")"
|
asp-route-sortOrder="@(storeNameSortOrder ?? "asc")"
|
||||||
asp-route-sortOrderColumn="StoreName"
|
asp-route-sortOrderColumn="StoreName"
|
||||||
class="text-nowrap"
|
class="text-nowrap"
|
||||||
title="@((string)ViewData["StoreNameSortOrder"] == "desc" ? "Sort by descending..." : "Sort by ascending...")"
|
title="@(storeNameSortOrder == "desc" ? sortByDesc : sortByAsc)"
|
||||||
>
|
>
|
||||||
Store @if (ViewData["StoreNameSortOrder"] != null)
|
Store
|
||||||
{
|
<span class="fa @(storeNameSortOrder == "asc" ? "fa-sort-alpha-desc" : storeNameSortOrder == "desc" ? "fa-sort-alpha-asc" : "fa-sort")" />
|
||||||
<span class="fa @((string)ViewData["StoreNameSortOrder"] == "asc" ? "fa-arrow-down": "fa-arrow-up")" />
|
|
||||||
}
|
|
||||||
</a>
|
</a>
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
<a
|
<a
|
||||||
asp-action="ListApps"
|
asp-action="ListApps"
|
||||||
asp-route-sortOrder="@(ViewData["AppNameSortOrder"] ?? "asc")"
|
asp-route-sortOrder="@(appNameSortOrder ?? "asc")"
|
||||||
asp-route-sortOrderColumn="AppName"
|
asp-route-sortOrderColumn="AppName"
|
||||||
class="text-nowrap"
|
class="text-nowrap"
|
||||||
title="@((string)ViewData["AppNameSortOrder"] == "desc" ? "Sort by descending..." : "Sort by ascending...")"
|
title="@(appNameSortOrder == "desc" ? sortByDesc : sortByAsc)"
|
||||||
>
|
>
|
||||||
Name @if (ViewData["AppNameSortOrder"] != null)
|
Name
|
||||||
{
|
<span class="fa @(appNameSortOrder == "asc" ? "fa-sort-alpha-desc" : appNameSortOrder == "desc" ? "fa-sort-alpha-asc" : "fa-sort")" />
|
||||||
<span class="fa @((string)ViewData["AppNameSortOrder"] == "asc" ? "fa-arrow-down": "fa-arrow-up")" />
|
|
||||||
}
|
|
||||||
</a>
|
</a>
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
<a
|
<a
|
||||||
asp-action="ListApps"
|
asp-action="ListApps"
|
||||||
asp-route-sortOrder="@(ViewData["AppTypeSortOrder"] ?? "asc")"
|
asp-route-sortOrder="@(appTypeSortOrder ?? "asc")"
|
||||||
asp-route-sortOrderColumn="AppType"
|
asp-route-sortOrderColumn="AppType"
|
||||||
class="text-nowrap"
|
class="text-nowrap"
|
||||||
title="@((string)ViewData["AppTypeSortOrder"] == "desc" ? "Sort by descending..." : "Sort by ascending...")"
|
title="@(appTypeSortOrder == "desc" ? sortByDesc : sortByAsc)"
|
||||||
>
|
>
|
||||||
App Type @if (ViewData["AppTypeSortOrder"] != null)
|
App Type
|
||||||
{
|
<span class="fa @(appTypeSortOrder == "asc" ? "fa-sort-alpha-desc" : appTypeSortOrder == "desc" ? "fa-sort-alpha-asc" : "fa-sort")" />
|
||||||
<span class="fa @((string)ViewData["AppTypeSortOrder"] == "asc" ? "fa-arrow-down": "fa-arrow-up")" />
|
|
||||||
}
|
|
||||||
</a>
|
</a>
|
||||||
</th>
|
</th>
|
||||||
<th style="text-align:right">Actions</th>
|
<th style="text-align:right">Actions</th>
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
@model StoresViewModel
|
@model StoresViewModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Stores";
|
ViewData["Title"] = "Stores";
|
||||||
|
var storeNameSortOrder = (string)ViewData["StoreNameSortOrder"];
|
||||||
|
var storeWebsiteSortOrder = (string)ViewData["StoreWebsiteSortOrder"];
|
||||||
|
var sortByDesc = "Sort by descending...";
|
||||||
|
var sortByAsc = "Sort by ascending...";
|
||||||
}
|
}
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
@ -32,8 +36,30 @@
|
||||||
<table class="table table-sm table-responsive-md">
|
<table class="table table-sm table-responsive-md">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>
|
||||||
<th>Website</th>
|
<a
|
||||||
|
asp-action="ListStores"
|
||||||
|
asp-route-sortOrder="@(storeNameSortOrder ?? "asc")"
|
||||||
|
asp-route-sortOrderColumn="StoreName"
|
||||||
|
class="text-nowrap"
|
||||||
|
title="@(storeNameSortOrder == "desc" ? sortByDesc : sortByAsc)"
|
||||||
|
>
|
||||||
|
Name
|
||||||
|
<span class="fa @(storeNameSortOrder == "asc" ? "fa-sort-alpha-desc" : storeNameSortOrder == "desc" ? "fa-sort-alpha-asc" : "fa-sort")" />
|
||||||
|
</a>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<a
|
||||||
|
asp-action="ListStores"
|
||||||
|
asp-route-sortOrder="@(storeWebsiteSortOrder ?? "asc")"
|
||||||
|
asp-route-sortOrderColumn="StoreWebsite"
|
||||||
|
class="text-nowrap"
|
||||||
|
title="@(storeWebsiteSortOrder == "desc" ? sortByDesc : sortByAsc)"
|
||||||
|
>
|
||||||
|
Website
|
||||||
|
<span class="fa @(storeWebsiteSortOrder == "asc" ? "fa-sort-alpha-desc" : storeWebsiteSortOrder == "desc" ? "fa-sort-alpha-asc" : "fa-sort")" />
|
||||||
|
</a>
|
||||||
|
</th>
|
||||||
<th style="text-align:right">Actions</th>
|
<th style="text-align:right">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
Loading…
Add table
Reference in a new issue