diff --git a/BTCPayServer/Controllers/AppsController.cs b/BTCPayServer/Controllers/AppsController.cs index 45496f7ee..ef756f1b1 100644 --- a/BTCPayServer/Controllers/AppsController.cs +++ b/BTCPayServer/Controllers/AppsController.cs @@ -47,9 +47,42 @@ namespace BTCPayServer.Controllers public string CreatedAppId { get; set; } - public async Task ListApps() + public async Task 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 diff --git a/BTCPayServer/Views/Apps/ListApps.cshtml b/BTCPayServer/Views/Apps/ListApps.cshtml index a218a312b..51babba39 100644 --- a/BTCPayServer/Views/Apps/ListApps.cshtml +++ b/BTCPayServer/Views/Apps/ListApps.cshtml @@ -31,9 +31,48 @@ - - - + + +
StoreNameApp type + + Store @if (ViewData["StoreSortOrder"] != null) + { + + } + + + + Name @if (ViewData["NameSortOrder"] != null) + { + + } + + + + App Type @if (ViewData["AppTypeSortOrder"] != null) + { + + } + + Actions