mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
Adds View Style to Apps list
This commit is contained in:
committed by
Andrew Camilleri
parent
193b209c92
commit
e914c84ad3
@@ -73,6 +73,8 @@ namespace BTCPayServer.Controllers
|
|||||||
return app.StoreName;
|
return app.StoreName;
|
||||||
case nameof(app.AppType):
|
case nameof(app.AppType):
|
||||||
return app.AppType;
|
return app.AppType;
|
||||||
|
case nameof(app.ViewStyle):
|
||||||
|
return app.ViewStyle;
|
||||||
default:
|
default:
|
||||||
return app.Id;
|
return app.Id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace BTCPayServer.Models.AppViewModels
|
|||||||
public string StoreId { get; set; }
|
public string StoreId { get; set; }
|
||||||
public string AppName { get; set; }
|
public string AppName { get; set; }
|
||||||
public string AppType { get; set; }
|
public string AppType { get; set; }
|
||||||
|
public string ViewStyle { get; set; }
|
||||||
public bool IsOwner { get; set; }
|
public bool IsOwner { get; set; }
|
||||||
|
|
||||||
public string UpdateAction { get { return "Update" + AppType; } }
|
public string UpdateAction { get { return "Update" + AppType; } }
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BTCPayServer.Client.Models;
|
using BTCPayServer.Client.Models;
|
||||||
|
using BTCPayServer.Controllers;
|
||||||
using BTCPayServer.Data;
|
using BTCPayServer.Data;
|
||||||
using BTCPayServer.Models.AppViewModels;
|
using BTCPayServer.Models.AppViewModels;
|
||||||
using BTCPayServer.Payments;
|
using BTCPayServer.Payments;
|
||||||
@@ -232,7 +233,7 @@ namespace BTCPayServer.Services.Apps
|
|||||||
{
|
{
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using (var ctx = _ContextFactory.CreateContext())
|
||||||
{
|
{
|
||||||
return await ctx.UserStore
|
var listApps = await ctx.UserStore
|
||||||
.Where(us =>
|
.Where(us =>
|
||||||
(allowNoUser && string.IsNullOrEmpty(userId) || us.ApplicationUserId == userId) &&
|
(allowNoUser && string.IsNullOrEmpty(userId) || us.ApplicationUserId == userId) &&
|
||||||
(storeId == null || us.StoreDataId == storeId))
|
(storeId == null || us.StoreDataId == storeId))
|
||||||
@@ -248,9 +249,40 @@ namespace BTCPayServer.Services.Apps
|
|||||||
Id = app.Id
|
Id = app.Id
|
||||||
})
|
})
|
||||||
.ToArrayAsync();
|
.ToArrayAsync();
|
||||||
|
|
||||||
|
foreach (ListAppsViewModel.ListAppViewModel app in listApps)
|
||||||
|
{
|
||||||
|
app.ViewStyle = await GetAppViewStyleAsync(app.Id, app.AppType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return listApps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<string> GetAppViewStyleAsync(string appId, string appType)
|
||||||
|
{
|
||||||
|
AppType appTypeEnum = Enum.Parse<AppType>(appType);
|
||||||
|
AppData appData = await GetApp(appId, appTypeEnum, false);
|
||||||
|
var settings = appData.GetSettings<AppsController.PointOfSaleSettings>();
|
||||||
|
|
||||||
|
string style;
|
||||||
|
switch (appTypeEnum)
|
||||||
|
{
|
||||||
|
case AppType.PointOfSale:
|
||||||
|
string posViewStyle = (settings.EnableShoppingCart ? PosViewType.Cart : settings.DefaultView).ToString();
|
||||||
|
style = typeof(PosViewType).DisplayName(posViewStyle);
|
||||||
|
break;
|
||||||
|
case AppType.Crowdfund:
|
||||||
|
style = string.Empty;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
style = string.Empty;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<List<AppData>> GetApps(string[] appIds, bool includeStore = false)
|
public async Task<List<AppData>> GetApps(string[] appIds, bool includeStore = false)
|
||||||
{
|
{
|
||||||
using (var ctx = _ContextFactory.CreateContext())
|
using (var ctx = _ContextFactory.CreateContext())
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
var storeNameSortOrder = (string)ViewData["StoreNameSortOrder"];
|
var storeNameSortOrder = (string)ViewData["StoreNameSortOrder"];
|
||||||
var appNameSortOrder = (string)ViewData["AppNameSortOrder"];
|
var appNameSortOrder = (string)ViewData["AppNameSortOrder"];
|
||||||
var appTypeSortOrder = (string)ViewData["AppTypeSortOrder"];
|
var appTypeSortOrder = (string)ViewData["AppTypeSortOrder"];
|
||||||
|
var viewStyleSortOrder = (string)ViewData["ViewStyleSortOrder"];
|
||||||
var sortByDesc = "Sort by descending...";
|
var sortByDesc = "Sort by descending...";
|
||||||
var sortByAsc = "Sort by ascending...";
|
var sortByAsc = "Sort by ascending...";
|
||||||
}
|
}
|
||||||
@@ -68,6 +69,18 @@
|
|||||||
<span class="fa @(appTypeSortOrder == "asc" ? "fa-sort-alpha-desc" : appTypeSortOrder == "desc" ? "fa-sort-alpha-asc" : "fa-sort")" />
|
<span class="fa @(appTypeSortOrder == "asc" ? "fa-sort-alpha-desc" : appTypeSortOrder == "desc" ? "fa-sort-alpha-asc" : "fa-sort")" />
|
||||||
</a>
|
</a>
|
||||||
</th>
|
</th>
|
||||||
|
<th>
|
||||||
|
<a
|
||||||
|
asp-action="ListApps"
|
||||||
|
asp-route-sortOrder="@(viewStyleSortOrder ?? "asc")"
|
||||||
|
asp-route-sortOrderColumn="ViewStyle"
|
||||||
|
class="text-nowrap"
|
||||||
|
title="@(viewStyleSortOrder == "desc" ? sortByDesc : sortByAsc)"
|
||||||
|
>
|
||||||
|
View Style
|
||||||
|
<span class="fa @(viewStyleSortOrder == "asc" ? "fa-sort-alpha-desc" : viewStyleSortOrder == "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>
|
||||||
@@ -87,6 +100,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>@app.AppName</td>
|
<td>@app.AppName</td>
|
||||||
<td>@typeof(AppType).DisplayName(app.AppType)</td>
|
<td>@typeof(AppType).DisplayName(app.AppType)</td>
|
||||||
|
<td>@app.ViewStyle</td>
|
||||||
<td style="text-align:right">
|
<td style="text-align:right">
|
||||||
@if (app.IsOwner)
|
@if (app.IsOwner)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user