diff --git a/BTCPayServer/Views/Shared/Components/NotificationsDropdown/Default.cshtml b/BTCPayServer/Components/NotificationsDropdown/Default.cshtml similarity index 56% rename from BTCPayServer/Views/Shared/Components/NotificationsDropdown/Default.cshtml rename to BTCPayServer/Components/NotificationsDropdown/Default.cshtml index 3e8a80093..2671854bb 100644 --- a/BTCPayServer/Views/Shared/Components/NotificationsDropdown/Default.cshtml +++ b/BTCPayServer/Components/NotificationsDropdown/Default.cshtml @@ -1,4 +1,5 @@ -@model BTCPayServer.Services.Notifications.NotificationSummaryViewModel +@inject LinkGenerator linkGenerator +@model BTCPayServer.Components.NotificationsDropdown.NotificationSummaryViewModel @if (Model.UnseenCount > 0) { @@ -31,3 +32,36 @@ else } + diff --git a/BTCPayServer/Components/NotificationsDropdown/NoticationsDropdown.cs b/BTCPayServer/Components/NotificationsDropdown/NoticationsDropdown.cs new file mode 100644 index 000000000..3cff8e623 --- /dev/null +++ b/BTCPayServer/Components/NotificationsDropdown/NoticationsDropdown.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using BTCPayServer.Services.Notifications; +using Microsoft.AspNetCore.Mvc; + +namespace BTCPayServer.Components.NotificationsDropdown +{ + public class NotificationsDropdown : ViewComponent + { + private readonly NotificationManager _notificationManager; + + public NotificationsDropdown(NotificationManager notificationManager) + { + _notificationManager = notificationManager; + } + + public async Task InvokeAsync() + { + return View(await _notificationManager.GetSummaryNotifications(UserClaimsPrincipal)); + } + } +} diff --git a/BTCPayServer/Components/NotificationsDropdown/NotificationSummaryViewModel.cs b/BTCPayServer/Components/NotificationsDropdown/NotificationSummaryViewModel.cs new file mode 100644 index 000000000..41eaf556c --- /dev/null +++ b/BTCPayServer/Components/NotificationsDropdown/NotificationSummaryViewModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using BTCPayServer.Models.NotificationViewModels; + +namespace BTCPayServer.Components.NotificationsDropdown +{ + public class NotificationSummaryViewModel + { + public int UnseenCount { get; set; } + public List Last5 { get; set; } + } +} diff --git a/BTCPayServer/Views/Shared/_TableFooterPager.cshtml b/BTCPayServer/Components/Pager/Default.cshtml similarity index 100% rename from BTCPayServer/Views/Shared/_TableFooterPager.cshtml rename to BTCPayServer/Components/Pager/Default.cshtml diff --git a/BTCPayServer/Components/Pager/Pager.cs b/BTCPayServer/Components/Pager/Pager.cs new file mode 100644 index 000000000..9cb40cda5 --- /dev/null +++ b/BTCPayServer/Components/Pager/Pager.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using BTCPayServer.Models; +using Microsoft.AspNetCore.Mvc; + +namespace BTCPayServer.Components +{ + public class Pager : ViewComponent + { + public Pager() + { + } + public IViewComponentResult Invoke(BasePagingViewModel viewModel) + { + return View(viewModel); + } + } +} diff --git a/BTCPayServer/Controllers/NotificationsController.cs b/BTCPayServer/Controllers/NotificationsController.cs index 4a664d9e9..b8c01f687 100644 --- a/BTCPayServer/Controllers/NotificationsController.cs +++ b/BTCPayServer/Controllers/NotificationsController.cs @@ -15,22 +15,6 @@ using Microsoft.AspNetCore.Mvc; namespace BTCPayServer.Controllers { - - public class NotificationsDropdown : ViewComponent - { - private readonly NotificationManager _notificationManager; - - public NotificationsDropdown(NotificationManager notificationManager) - { - _notificationManager = notificationManager; - } - - public async Task InvokeAsync(int noOfEmployee) - { - return View(await _notificationManager.GetSummaryNotifications(UserClaimsPrincipal)); - } - } - [BitpayAPIConstraint(false)] [Authorize(AuthenticationSchemes = AuthenticationSchemes.Cookie)] [Route("[controller]/[action]")] diff --git a/BTCPayServer/Hosting/Startup.cs b/BTCPayServer/Hosting/Startup.cs index ec7765212..dfe61389c 100644 --- a/BTCPayServer/Hosting/Startup.cs +++ b/BTCPayServer/Hosting/Startup.cs @@ -81,6 +81,12 @@ namespace BTCPayServer.Hosting return builtInFactory(context); }; }) + .AddRazorOptions(o => + { + // /Components/{View Component Name}/{View Name}.cshtml + o.ViewLocationFormats.Add("/{0}.cshtml"); + o.PageViewLocationFormats.Add("/{0}.cshtml"); + }) .AddNewtonsoftJson() #if RAZOR_RUNTIME_COMPILE .AddRazorRuntimeCompilation() diff --git a/BTCPayServer/Services/Notifications/NotificationManager.cs b/BTCPayServer/Services/Notifications/NotificationManager.cs index b3965d524..36379732a 100644 --- a/BTCPayServer/Services/Notifications/NotificationManager.cs +++ b/BTCPayServer/Services/Notifications/NotificationManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; +using BTCPayServer.Components.NotificationsDropdown; using BTCPayServer.Data; using BTCPayServer.Models.NotificationViewModels; using Microsoft.AspNetCore.Identity; @@ -124,10 +125,4 @@ namespace BTCPayServer.Services.Notifications throw new InvalidOperationException($"No INotificationHandler found for {blobType.Name}"); } } - - public class NotificationSummaryViewModel - { - public int UnseenCount { get; set; } - public List Last5 { get; set; } - } } diff --git a/BTCPayServer/Views/Invoice/ListInvoices.cshtml b/BTCPayServer/Views/Invoice/ListInvoices.cshtml index 3fd231d38..81bb2b967 100644 --- a/BTCPayServer/Views/Invoice/ListInvoices.cshtml +++ b/BTCPayServer/Views/Invoice/ListInvoices.cshtml @@ -5,16 +5,17 @@ @section HeadScripts { } + @Html.HiddenFor(a => a.Count) @if (TempData.HasStatusMessage()) { - - - - + + + + } @@ -49,7 +50,7 @@ - + Search @@ -91,7 +92,7 @@ Create a new invoice - + Actions @@ -99,7 +100,7 @@ Archive - + Export @@ -114,7 +115,7 @@ - + @* Custom Range Modal *@ @@ -131,8 +132,8 @@ + data-fdtp='{ "enableTime": true, "enableSeconds": true, "dateFormat": "Y-m-d H:i:S", "time_24hr": true, "defaultHour": 0 }' + placeholder="Start Date" /> @@ -146,8 +147,8 @@ + data-fdtp='{ "enableTime": true, "enableSeconds": true, "dateFormat": "Y-m-d H:i:S", "time_24hr": true, "defaultHour": 0 }' + placeholder="End Date" /> @@ -194,8 +195,7 @@ @* Custom Range Modal *@ diff --git a/BTCPayServer/Views/Shared/_Layout.cshtml b/BTCPayServer/Views/Shared/_Layout.cshtml index 58cf15de1..297ab4b87 100644 --- a/BTCPayServer/Views/Shared/_Layout.cshtml +++ b/BTCPayServer/Views/Shared/_Layout.cshtml @@ -1,4 +1,4 @@ -@inject SignInManager SignInManager +@inject SignInManager SignInManager @inject UserManager UserManager @inject RoleManager RoleManager @inject BTCPayServer.Services.BTCPayServerEnvironment env @@ -77,8 +77,7 @@ - - + diff --git a/BTCPayServer/Views/_ViewImports.cshtml b/BTCPayServer/_ViewImports.cshtml similarity index 93% rename from BTCPayServer/Views/_ViewImports.cshtml rename to BTCPayServer/_ViewImports.cshtml index 3af9178f9..e8c8d515e 100644 --- a/BTCPayServer/Views/_ViewImports.cshtml +++ b/BTCPayServer/_ViewImports.cshtml @@ -10,3 +10,4 @@ @using Microsoft.AspNetCore.Routing; @inject BTCPayServer.Services.Safe Safe @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, BTCPayServer