From 780abad3f7747322903523e4f5cfc452ba7eb504 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 2 Sep 2011 23:41:50 -0700 Subject: [PATCH] Log view now uses proper paging so it doesn't take a year to load up each page. --- NzbDrone.Core/Instrumentation/LogProvider.cs | 5 +++++ NzbDrone.Web/Controllers/LogController.cs | 8 +++++--- NzbDrone.Web/Views/Log/Index.cshtml | 5 +++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/NzbDrone.Core/Instrumentation/LogProvider.cs b/NzbDrone.Core/Instrumentation/LogProvider.cs index e93bd1eae..7fbb54ab0 100644 --- a/NzbDrone.Core/Instrumentation/LogProvider.cs +++ b/NzbDrone.Core/Instrumentation/LogProvider.cs @@ -21,6 +21,11 @@ namespace NzbDrone.Core.Instrumentation return _database.Fetch(); } + public Page GetPagedLogs(int pageNumber, int pageSize) + { + return _database.Page(pageNumber, pageSize, "SELECT * FROM Logs ORDER BY Time DESC"); + } + public void DeleteAll() { _database.Delete(""); diff --git a/NzbDrone.Web/Controllers/LogController.cs b/NzbDrone.Web/Controllers/LogController.cs index 575916e25..aeef79dbd 100644 --- a/NzbDrone.Web/Controllers/LogController.cs +++ b/NzbDrone.Web/Controllers/LogController.cs @@ -26,10 +26,12 @@ namespace NzbDrone.Web.Controllers return Json(new NotificationResult() { Title = "Logs Cleared" }); } - [GridAction] - public ActionResult _AjaxBinding() + [GridAction(EnableCustomBinding = true)] + public ActionResult _AjaxBinding(GridCommand gridCommand) { - return View(new GridModel(_logProvider.GetAllLogs())); + var logs = _logProvider.GetPagedLogs(gridCommand.Page, gridCommand.PageSize); + + return View(new GridModel{ Data = logs.Items, Total = (int)logs.TotalItems }); } } } \ No newline at end of file diff --git a/NzbDrone.Web/Views/Log/Index.cshtml b/NzbDrone.Web/Views/Log/Index.cshtml index 2e413be22..4999bda4a 100644 --- a/NzbDrone.Web/Views/Log/Index.cshtml +++ b/NzbDrone.Web/Views/Log/Index.cshtml @@ -44,9 +44,10 @@ Logs "
<#= ExceptionType #>
" + "
<#= Exception #>
" )).DataBinding(data => data.Ajax().Select("_AjaxBinding", "Log")) - .Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.Time).Descending()).Enabled(true)) + //.Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.Time).Descending()).Enabled(true)) .Pageable(c => c.PageSize(50).Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPrevious)) - .Filterable() + .EnableCustomBinding(true) + //.Filterable() .ClientEvents(c => c.OnRowDataBound("onRowDataBound")) .Render();} }