mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-13 08:33:58 -07:00
Log Grid added, using server side filtering, sorting and paging. Using DynamicQueryable.
This commit is contained in:
parent
ca5888160d
commit
9c24b5989b
16 changed files with 4886 additions and 64 deletions
|
@ -1,4 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using System.Web.Mvc;
|
||||
using NzbDrone.Common;
|
||||
|
@ -26,6 +29,11 @@ namespace NzbDrone.Web.Controllers
|
|||
return View();
|
||||
}
|
||||
|
||||
public ActionResult IndexOld()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public FileContentResult File()
|
||||
{
|
||||
string log = string.Empty;
|
||||
|
@ -47,8 +55,56 @@ namespace NzbDrone.Web.Controllers
|
|||
return JsonNotificationResult.Info("Logs Cleared");
|
||||
}
|
||||
|
||||
public ActionResult AjaxBinding(DataTablesParams dataTablesParams)
|
||||
{
|
||||
var logs = _logProvider.GetAllLogs();
|
||||
var totalCount = logs.Count();
|
||||
|
||||
IQueryable<Log> q = logs;
|
||||
if (!string.IsNullOrEmpty(dataTablesParams.sSearch))
|
||||
{
|
||||
q = q.Where(b => b.Logger.Contains(dataTablesParams.sSearch)
|
||||
|| b.Exception.Contains(dataTablesParams.sSearch)
|
||||
|| b.Message.Contains(dataTablesParams.sSearch));
|
||||
}
|
||||
|
||||
int filteredCount = q.Count();
|
||||
|
||||
int sortCol = dataTablesParams.iSortCol.First();
|
||||
var sortColName = sortCol == 0 ? "Time" : sortCol == 1 ? "Level" : "Logger";
|
||||
var sortExpression = String.Format("{0} {1}", sortColName, dataTablesParams.sSortDir.First());
|
||||
|
||||
var sorted = q.OrderBy(sortExpression);
|
||||
|
||||
IQueryable<Log> filteredAndSorted = sorted;
|
||||
if (filteredCount > dataTablesParams.iDisplayLength)
|
||||
{
|
||||
filteredAndSorted = sorted.Skip(dataTablesParams.iDisplayStart).Take(dataTablesParams.iDisplayLength);
|
||||
}
|
||||
|
||||
var logModels = filteredAndSorted.ToList().Select(s => new LogModel
|
||||
{
|
||||
Time = s.Time.ToString(),
|
||||
Level = s.Level,
|
||||
Source = s.Logger,
|
||||
Message = s.Message,
|
||||
Method = s.Method,
|
||||
ExceptionType = s.ExceptionType,
|
||||
Exception = s.Exception
|
||||
});
|
||||
|
||||
return Json(new
|
||||
{
|
||||
sEcho = dataTablesParams.sEcho,
|
||||
iTotalRecords = totalCount,
|
||||
iTotalDisplayRecords = filteredCount,
|
||||
aaData = logModels
|
||||
},
|
||||
JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
[GridAction]
|
||||
public ActionResult AjaxBinding()
|
||||
public ActionResult AjaxBindingOld()
|
||||
{
|
||||
return View(new GridModel(_logProvider.GetAllLogs()));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue