Skip to content

Commit

Permalink
Add app filter
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisreimann committed May 11, 2023
1 parent da30e22 commit 1eea23f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
10 changes: 10 additions & 0 deletions BTCPayServer/Controllers/UIInvoiceController.UI.cs
Expand Up @@ -1097,6 +1097,16 @@ public async Task<IActionResult> ListInvoices(InvoicesModel? model = null)
invoiceQuery.IncludeRefunds = true;
var list = await _InvoiceRepository.GetInvoices(invoiceQuery);

// Apps
var apps = await _appService.GetAllApps(GetUserId(), false, storeId);
model.Apps = apps.Select(a => new InvoiceAppModel
{
Id = a.Id,
AppName = a.AppName,
AppType = a.AppType,
AppOrderId = AppService.GetAppOrderId(a.AppType, a.Id)
}).ToList();

foreach (var invoice in list)
{
var state = invoice.GetInvoiceState();
Expand Down
3 changes: 3 additions & 0 deletions BTCPayServer/Controllers/UIInvoiceController.cs
Expand Up @@ -58,6 +58,7 @@ public partial class UIInvoiceController : Controller
private readonly InvoiceActivator _invoiceActivator;
private readonly LinkGenerator _linkGenerator;
private readonly IAuthorizationService _authorizationService;
private readonly AppService _appService;

public WebhookSender WebhookNotificationManager { get; }

Expand All @@ -81,6 +82,7 @@ public partial class UIInvoiceController : Controller
UIWalletsController walletsController,
InvoiceActivator invoiceActivator,
LinkGenerator linkGenerator,
AppService appService,
IAuthorizationService authorizationService)
{
_displayFormatter = displayFormatter;
Expand All @@ -102,6 +104,7 @@ public partial class UIInvoiceController : Controller
_invoiceActivator = invoiceActivator;
_linkGenerator = linkGenerator;
_authorizationService = authorizationService;
_appService = appService;
}


Expand Down
9 changes: 9 additions & 0 deletions BTCPayServer/Models/InvoicingModels/InvoicesModel.cs
Expand Up @@ -12,6 +12,7 @@ public class InvoicesModel : BasePagingViewModel

public string SearchText { get; set; }
public SearchString Search { get; set; }
public List<InvoiceAppModel> Apps { get; set; }
}

public class InvoiceModel
Expand All @@ -34,4 +35,12 @@ public class InvoiceModel
public InvoiceDetailsModel Details { get; set; }
public bool HasRefund { get; set; }
}

public class InvoiceAppModel
{
public string Id { get; set; }
public string AppName { get; set; }
public string AppType { get; set; }
public string AppOrderId { get; set; }
}
}
14 changes: 14 additions & 0 deletions BTCPayServer/Views/UIInvoice/ListInvoices.cshtml
Expand Up @@ -249,6 +249,20 @@
<a asp-action="ListInvoices" asp-route-storeId="@Model.StoreId" asp-route-count="@Model.Count" asp-route-searchTerm="@Model.Search.Toggle("includearchived", "true")" class="dropdown-item @(HasBooleanFilter("includearchived") ? "dropdown-item-custom-active" : "")" id="StatusOptionsIncludeArchived">Archived</a>
</div>
</div>
@if (Model.Apps.Any())
{
<div class="dropdown">
<button id="AppOptionsToggle" class="btn btn-secondary dropdown-toggle dropdown-toggle-custom-caret" type="button" data-bs-toggle="dropdown" aria-expanded="false">
App
</button>
<div class="dropdown-menu" aria-labelledby="AppOptionsToggle">
@foreach (var app in Model.Apps)
{
<a asp-action="ListInvoices" asp-route-storeId="@Model.StoreId" asp-route-count="@Model.Count" asp-route-searchTerm="@Model.Search.Toggle("orderid", app.AppOrderId)" class="dropdown-item @(HasArrayFilter("orderid", app.AppOrderId) ? "dropdown-item-custom-active" : "")">@app.AppName</a>
}
</div>
</div>
}
<div class="dropdown">
<button id="DateOptionsToggle" class="btn btn-secondary dropdown-toggle dropdown-toggle-custom-caret" type="button" data-bs-toggle="dropdown" aria-expanded="false">
Time
Expand Down

0 comments on commit 1eea23f

Please sign in to comment.