mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 14:04:12 +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 BTCPayServer.Data;
|
||||
using BTCPayServer.Models;
|
||||
|
@ -70,10 +71,40 @@ namespace BTCPayServer.Controllers
|
|||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> ListStores()
|
||||
public async Task<IActionResult> ListStores(
|
||||
string sortOrder = null,
|
||||
string sortOrderColumn = null
|
||||
)
|
||||
{
|
||||
StoresViewModel result = new StoresViewModel();
|
||||
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++)
|
||||
{
|
||||
var store = stores[i];
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
@using BTCPayServer.Services.Apps
|
||||
@model ListAppsViewModel
|
||||
@model ListAppsViewModel
|
||||
@{
|
||||
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>
|
||||
<div class="container">
|
||||
@if (TempData.HasStatusMessage())
|
||||
|
@ -34,43 +39,37 @@
|
|||
<th>
|
||||
<a
|
||||
asp-action="ListApps"
|
||||
asp-route-sortOrder="@(ViewData["StoreNameSortOrder"] ?? "asc")"
|
||||
asp-route-sortOrder="@(storeNameSortOrder ?? "asc")"
|
||||
asp-route-sortOrderColumn="StoreName"
|
||||
class="text-nowrap"
|
||||
title="@((string)ViewData["StoreNameSortOrder"] == "desc" ? "Sort by descending..." : "Sort by ascending...")"
|
||||
title="@(storeNameSortOrder == "desc" ? sortByDesc : sortByAsc)"
|
||||
>
|
||||
Store @if (ViewData["StoreNameSortOrder"] != null)
|
||||
{
|
||||
<span class="fa @((string)ViewData["StoreNameSortOrder"] == "asc" ? "fa-arrow-down": "fa-arrow-up")" />
|
||||
}
|
||||
Store
|
||||
<span class="fa @(storeNameSortOrder == "asc" ? "fa-sort-alpha-desc" : storeNameSortOrder == "desc" ? "fa-sort-alpha-asc" : "fa-sort")" />
|
||||
</a>
|
||||
</th>
|
||||
<th>
|
||||
<a
|
||||
asp-action="ListApps"
|
||||
asp-route-sortOrder="@(ViewData["AppNameSortOrder"] ?? "asc")"
|
||||
asp-route-sortOrder="@(appNameSortOrder ?? "asc")"
|
||||
asp-route-sortOrderColumn="AppName"
|
||||
class="text-nowrap"
|
||||
title="@((string)ViewData["AppNameSortOrder"] == "desc" ? "Sort by descending..." : "Sort by ascending...")"
|
||||
title="@(appNameSortOrder == "desc" ? sortByDesc : sortByAsc)"
|
||||
>
|
||||
Name @if (ViewData["AppNameSortOrder"] != null)
|
||||
{
|
||||
<span class="fa @((string)ViewData["AppNameSortOrder"] == "asc" ? "fa-arrow-down": "fa-arrow-up")" />
|
||||
}
|
||||
Name
|
||||
<span class="fa @(appNameSortOrder == "asc" ? "fa-sort-alpha-desc" : appNameSortOrder == "desc" ? "fa-sort-alpha-asc" : "fa-sort")" />
|
||||
</a>
|
||||
</th>
|
||||
<th>
|
||||
<a
|
||||
asp-action="ListApps"
|
||||
asp-route-sortOrder="@(ViewData["AppTypeSortOrder"] ?? "asc")"
|
||||
asp-route-sortOrder="@(appTypeSortOrder ?? "asc")"
|
||||
asp-route-sortOrderColumn="AppType"
|
||||
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)
|
||||
{
|
||||
<span class="fa @((string)ViewData["AppTypeSortOrder"] == "asc" ? "fa-arrow-down": "fa-arrow-up")" />
|
||||
}
|
||||
App Type
|
||||
<span class="fa @(appTypeSortOrder == "asc" ? "fa-sort-alpha-desc" : appTypeSortOrder == "desc" ? "fa-sort-alpha-asc" : "fa-sort")" />
|
||||
</a>
|
||||
</th>
|
||||
<th style="text-align:right">Actions</th>
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
@model StoresViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Stores";
|
||||
var storeNameSortOrder = (string)ViewData["StoreNameSortOrder"];
|
||||
var storeWebsiteSortOrder = (string)ViewData["StoreWebsiteSortOrder"];
|
||||
var sortByDesc = "Sort by descending...";
|
||||
var sortByAsc = "Sort by ascending...";
|
||||
}
|
||||
|
||||
<section>
|
||||
|
@ -32,8 +36,30 @@
|
|||
<table class="table table-sm table-responsive-md">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Website</th>
|
||||
<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>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
Loading…
Add table
Reference in a new issue