mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Make invoice list search term persistent for session
This commit is contained in:
@@ -19,6 +19,7 @@ using BTCPayServer.Security;
|
|||||||
using BTCPayServer.Services.Invoices;
|
using BTCPayServer.Services.Invoices;
|
||||||
using BTCPayServer.Services.Invoices.Export;
|
using BTCPayServer.Services.Invoices.Export;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Microsoft.EntityFrameworkCore.Internal;
|
using Microsoft.EntityFrameworkCore.Internal;
|
||||||
@@ -466,6 +467,10 @@ namespace BTCPayServer.Controllers
|
|||||||
[BitpayAPIConstraint(false)]
|
[BitpayAPIConstraint(false)]
|
||||||
public async Task<IActionResult> ListInvoices(string searchTerm = null, int skip = 0, int count = 50)
|
public async Task<IActionResult> ListInvoices(string searchTerm = null, int skip = 0, int count = 50)
|
||||||
{
|
{
|
||||||
|
if (searchTerm == null)
|
||||||
|
{
|
||||||
|
searchTerm = HttpContext.Session.GetString("InvoicesSearchTerm");
|
||||||
|
}
|
||||||
var model = new InvoicesModel
|
var model = new InvoicesModel
|
||||||
{
|
{
|
||||||
SearchTerm = searchTerm,
|
SearchTerm = searchTerm,
|
||||||
@@ -627,6 +632,14 @@ namespace BTCPayServer.Controllers
|
|||||||
[BitpayAPIConstraint(false)]
|
[BitpayAPIConstraint(false)]
|
||||||
public IActionResult SearchInvoice(InvoicesModel invoices)
|
public IActionResult SearchInvoice(InvoicesModel invoices)
|
||||||
{
|
{
|
||||||
|
if (invoices.SearchTerm == null)
|
||||||
|
{
|
||||||
|
HttpContext.Session.Remove("InvoicesSearchTerm");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HttpContext.Session.SetString("InvoicesSearchTerm", invoices.SearchTerm);
|
||||||
|
}
|
||||||
return RedirectToAction(nameof(ListInvoices), new
|
return RedirectToAction(nameof(ListInvoices), new
|
||||||
{
|
{
|
||||||
searchTerm = invoices.SearchTerm,
|
searchTerm = invoices.SearchTerm,
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ namespace BTCPayServer.Hosting
|
|||||||
.AddDefaultTokenProviders();
|
.AddDefaultTokenProviders();
|
||||||
services.AddSignalR();
|
services.AddSignalR();
|
||||||
services.AddBTCPayServer();
|
services.AddBTCPayServer();
|
||||||
|
services.AddSession();
|
||||||
services.AddMvc(o =>
|
services.AddMvc(o =>
|
||||||
{
|
{
|
||||||
o.Filters.Add(new XFrameOptionsAttribute("DENY"));
|
o.Filters.Add(new XFrameOptionsAttribute("DENY"));
|
||||||
@@ -169,6 +170,7 @@ namespace BTCPayServer.Hosting
|
|||||||
app.UsePayServer();
|
app.UsePayServer();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
|
app.UseSession();
|
||||||
app.UseSignalR(route =>
|
app.UseSignalR(route =>
|
||||||
{
|
{
|
||||||
AppHub.Register(route);
|
AppHub.Register(route);
|
||||||
|
|||||||
Reference in New Issue
Block a user