diff --git a/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Administer.cshtml.cs b/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Administer.cshtml.cs index 9cacff90..29750e8e 100644 --- a/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Administer.cshtml.cs +++ b/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Administer.cshtml.cs @@ -49,7 +49,8 @@ public IActionResult OnPostDeleteAllIgnoredSuggestions() Message = $"All {count} ignored suggestions permanently removed"; CardType = CardType.Success; - return RedirectToPage(new { + return RedirectToPage(new + { Message, CardType }); @@ -168,7 +169,7 @@ public IActionResult OnPostImportDeletedRedirects() public IActionResult OnPostExportRedirects() { - var redirects = _redirectsService.GetSaved().ToList(); + var redirects = _redirectsService.GetRedirects(new Data.QueryParams() { QueryState = RedirectState.Saved }).Redirects.ToList(); var document = _redirectsXmlParser.Export(redirects); var memoryStream = new MemoryStream(); @@ -208,5 +209,6 @@ private CustomRedirectCollection ReadDeletedRedirectsFromImportFile() public class DeleteSuggestionsModel { public int MaxErrors { get; set; } = 5; + public int MinimumDays { get; set; } = 30; } diff --git a/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Components/Pager/Default.cshtml b/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Components/Pager/Default.cshtml index d6f6348c..75e6d0fa 100644 --- a/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Components/Pager/Default.cshtml +++ b/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Components/Pager/Default.cshtml @@ -3,19 +3,23 @@ \ No newline at end of file diff --git a/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Components/Pager/PagerViewComponent.cs b/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Components/Pager/PagerViewComponent.cs index eb3dd9c0..cea32358 100644 --- a/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Components/Pager/PagerViewComponent.cs +++ b/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Components/Pager/PagerViewComponent.cs @@ -1,6 +1,6 @@ +using System; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using X.PagedList; namespace Geta.NotFoundHandler.Admin.Pages.Geta.NotFoundHandler.Admin.Components.Pager { @@ -13,15 +13,16 @@ public PagerViewComponent(IHttpContextAccessor contextAccessor) _contextAccessor = contextAccessor; } - public IViewComponentResult Invoke(IPagedList items) + public IViewComponentResult Invoke(int page, int pageSize, int totalCount) { var context = _contextAccessor.HttpContext; + var pageCount = pageSize is int ps && ps > 0 ? (int)Math.Ceiling((decimal)totalCount / ps) : 1; return View(new PagerViewModel { - HasPreviousPage = items.HasPreviousPage, - HasNextPage = items.HasNextPage, - PageNumber = items.PageNumber, - PageCount = items.PageCount, + HasPreviousPage = page > 1, + HasNextPage = pageCount > page, + PageNumber = page, + PageCount = pageCount, QueryString = context.Request.QueryString.ToString() }); } diff --git a/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Components/Pager/PagerViewModel.cs b/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Components/Pager/PagerViewModel.cs index 1ec85ce7..cff0d84d 100644 --- a/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Components/Pager/PagerViewModel.cs +++ b/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Components/Pager/PagerViewModel.cs @@ -1,20 +1,15 @@ -using System.Web; - namespace Geta.NotFoundHandler.Admin.Pages.Geta.NotFoundHandler.Admin.Components.Pager { public class PagerViewModel { public bool HasPreviousPage { get; set; } + public bool HasNextPage { get; set; } + public int PageNumber { get; set; } + public int PageCount { get; set; } - public string QueryString { get; set; } - public string PageUrl(int page) - { - var qs = HttpUtility.ParseQueryString(QueryString); - qs["page"] = page.ToString(); - return $"?{qs}"; - } + public string QueryString { get; set; } } } diff --git a/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Components/SortableHeader/Default.cshtml b/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Components/SortableHeader/Default.cshtml new file mode 100644 index 00000000..4e4138bc --- /dev/null +++ b/src/Geta.NotFoundHandler.Admin/Areas/GetaNotFoundHandlerAdmin/Pages/Components/SortableHeader/Default.cshtml @@ -0,0 +1,24 @@ +@using System.Data.SqlClient; +@model Geta.NotFoundHandler.Admin.Areas.GetaNotFoundHandlerAdmin.Pages.Components.SortableHeader.SortableHeaderViewModel + +@{ + var sortBy = Model.InternalName; + var isCurrent = Model.Params.SortBy == Model.InternalName; + var nextSortDirection = isCurrent && Model.Params.SortDirection == SortOrder.Ascending ? SortOrder.Descending : SortOrder.Ascending; +} + +