mirror of https://github.com/lidarr/Lidarr
Default Log view uses client operations, added all logs view that uses paging (No support for sorting or filtering).
This commit is contained in:
parent
179de93a6e
commit
c13c9d15c4
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Helpers
|
||||
{
|
||||
public class SortHelper
|
||||
{
|
||||
public static string SkipArticles(string input)
|
||||
{
|
||||
var articles = new List<string> { "The ", "An ", "A " };
|
||||
|
||||
foreach (string article in articles)
|
||||
{
|
||||
if (input.ToLower().StartsWith(article, StringComparison.InvariantCultureIgnoreCase))
|
||||
return input.Substring(article.Length).Trim();
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NLog;
|
||||
using PetaPoco;
|
||||
|
||||
|
@ -21,6 +22,20 @@ namespace NzbDrone.Core.Instrumentation
|
|||
return _database.Fetch<Log>();
|
||||
}
|
||||
|
||||
public IList<Log> TopLogs()
|
||||
{
|
||||
var logs = _database.Fetch<Log>("SELECT TOP 7500 * FROM Logs ORDER BY Time Desc");
|
||||
logs.Add(new Log
|
||||
{
|
||||
Time = DateTime.Now.AddYears(-100),
|
||||
Level = "Info",
|
||||
Logger = "NzbDrone.Core.Instrumentation.LogProvider",
|
||||
Message = String.Format("Number of logs currently shown: 7500. More may exist, check 'All' to see everything")
|
||||
});
|
||||
|
||||
return logs;
|
||||
}
|
||||
|
||||
public Page<Log> GetPagedLogs(int pageNumber, int pageSize)
|
||||
{
|
||||
return _database.Page<Log>(pageNumber, pageSize, "SELECT * FROM Logs ORDER BY Time DESC");
|
||||
|
|
|
@ -182,6 +182,7 @@
|
|||
<Compile Include="Fluent.cs" />
|
||||
<Compile Include="Helpers\EpisodeSortingHelper.cs" />
|
||||
<Compile Include="Helpers\FileSizeFormatHelpercs.cs" />
|
||||
<Compile Include="Helpers\SortHelper.cs" />
|
||||
<Compile Include="Instrumentation\LogProvider.cs" />
|
||||
<Compile Include="Instrumentation\DatabaseTarget.cs" />
|
||||
<Compile Include="Instrumentation\ExceptioneerTarget.cs" />
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using NzbDrone.Core.Instrumentation;
|
||||
using NzbDrone.Web.Models;
|
||||
using Telerik.Web.Mvc;
|
||||
using System.Linq;
|
||||
|
||||
namespace NzbDrone.Web.Controllers
|
||||
{
|
||||
|
@ -19,15 +20,28 @@ namespace NzbDrone.Web.Controllers
|
|||
return View();
|
||||
}
|
||||
|
||||
public ActionResult All()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public JsonResult Clear()
|
||||
{
|
||||
_logProvider.DeleteAll();
|
||||
|
||||
return Json(new NotificationResult() { Title = "Logs Cleared" });
|
||||
return Json(new NotificationResult { Title = "Logs Cleared" });
|
||||
}
|
||||
|
||||
[GridAction]
|
||||
public ActionResult _TopAjaxBinding()
|
||||
{
|
||||
var logs = _logProvider.TopLogs();
|
||||
|
||||
return View(new GridModel(logs));
|
||||
}
|
||||
|
||||
[GridAction(EnableCustomBinding = true)]
|
||||
public ActionResult _AjaxBinding(GridCommand gridCommand)
|
||||
public ActionResult _AllAjaxBinding(GridCommand gridCommand)
|
||||
{
|
||||
var logs = _logProvider.GetPagedLogs(gridCommand.Page, gridCommand.PageSize);
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using MvcMiniProfiler;
|
||||
using NzbDrone.Core.Helpers;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Jobs;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
@ -50,7 +51,7 @@ namespace NzbDrone.Web.Controllers
|
|||
[GridAction]
|
||||
public ActionResult _AjaxSeriesGrid()
|
||||
{
|
||||
var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount());
|
||||
var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount()).OrderBy(o => SortHelper.SkipArticles(o.Title));
|
||||
return View(new GridModel(series));
|
||||
}
|
||||
|
||||
|
|
|
@ -355,6 +355,12 @@
|
|||
<ItemGroup>
|
||||
<Content Include="Views\Misnamed\Index.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Log\SubMenu.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Log\All.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
@using NzbDrone.Core.Instrumentation
|
||||
@model IEnumerable<NzbDrone.Core.Instrumentation.Log>
|
||||
@section Scripts{
|
||||
<script type="text/javascript">
|
||||
function onRowDataBound(e) {
|
||||
|
||||
e.row.style.boarder = "";
|
||||
|
||||
if (e.dataItem.Level == "Warn") {
|
||||
e.row.style.backgroundColor = "#FFD700";
|
||||
}
|
||||
else if (e.dataItem.Level == "Error") {
|
||||
e.row.style.backgroundColor = "#FF7500";
|
||||
}
|
||||
else if (e.dataItem.Level == "Fatal") {
|
||||
e.row.style.backgroundColor = "black";
|
||||
e.row.style.color = "red";
|
||||
}
|
||||
//e.row.style.color = 'blue';
|
||||
}
|
||||
</script>
|
||||
}
|
||||
@section TitleContent{
|
||||
Logs
|
||||
}
|
||||
|
||||
@section ActionMenu{
|
||||
@{Html.RenderPartial("SubMenu");}
|
||||
}
|
||||
|
||||
@section MainContent{
|
||||
@{Html.Telerik().Grid<Log>().Name("logsGrid")
|
||||
.TableHtmlAttributes(new { @class = "Grid" })
|
||||
.Columns(columns =>
|
||||
{
|
||||
columns.Bound(c => c.Time).Title("Time").Width(0);
|
||||
columns.Bound(c => c.Level).Title("Level").Width(0);
|
||||
columns.Bound(c => c.Logger).Title("Source").Width(0);
|
||||
columns.Bound(c => c.Message);
|
||||
})
|
||||
.DetailView(detailView => detailView.ClientTemplate(
|
||||
"<div>Method: <#= Method #></div>" +
|
||||
"<div><#= ExceptionType #></div>" +
|
||||
"<div class='stackframe'><#= Exception #></div>"
|
||||
))
|
||||
.DataBinding(data => data
|
||||
.Ajax()
|
||||
.Select("_AllAjaxBinding", "Log"))
|
||||
//.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)
|
||||
.ClientEvents(c => c.OnRowDataBound("onRowDataBound"))
|
||||
.Render();}
|
||||
}
|
||||
|
||||
<script type="text/javascript">
|
||||
function reloadGrid() {
|
||||
var grid = $('#logsGrid').data('tGrid');
|
||||
grid.rebind();
|
||||
}
|
||||
</script>
|
|
@ -1,3 +1,4 @@
|
|||
@using NzbDrone.Core.Instrumentation
|
||||
@model IEnumerable<NzbDrone.Core.Instrumentation.Log>
|
||||
@section Scripts{
|
||||
<script type="text/javascript">
|
||||
|
@ -24,13 +25,11 @@ Logs
|
|||
}
|
||||
|
||||
@section ActionMenu{
|
||||
<ul class="sub-menu">
|
||||
<li>@Ajax.ActionLink("Clear Logs", "Clear", "Log", new AjaxOptions{ OnSuccess = "reloadGrid" })</li>
|
||||
</ul>
|
||||
@{Html.RenderPartial("SubMenu");}
|
||||
}
|
||||
|
||||
@section MainContent{
|
||||
@{Html.Telerik().Grid(Model).Name("logsGrid")
|
||||
@{Html.Telerik().Grid<Log>().Name("logsGrid")
|
||||
.TableHtmlAttributes(new { @class = "Grid" })
|
||||
.Columns(columns =>
|
||||
{
|
||||
|
@ -43,11 +42,14 @@ Logs
|
|||
"<div>Method: <#= Method #></div>" +
|
||||
"<div><#= ExceptionType #></div>" +
|
||||
"<div class='stackframe'><#= Exception #></div>"
|
||||
)).DataBinding(data => data.Ajax().Select("_AjaxBinding", "Log"))
|
||||
//.Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.Time).Descending()).Enabled(true))
|
||||
))
|
||||
.DataBinding(data => data
|
||||
.Ajax()
|
||||
.OperationMode(GridOperationMode.Client)
|
||||
.Select("_TopAjaxBinding", "Log"))
|
||||
.Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.Time).Descending()).Enabled(true))
|
||||
.Pageable(c => c.PageSize(50).Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPrevious))
|
||||
.EnableCustomBinding(true)
|
||||
//.Filterable()
|
||||
.Filterable()
|
||||
.ClientEvents(c => c.OnRowDataBound("onRowDataBound"))
|
||||
.Render();}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<ul class="sub-menu">
|
||||
<li>@Html.ActionLink("Top", "Index", "Log")</li>
|
||||
<li>@Html.ActionLink("All", "All", "Log")</li>
|
||||
<li>@Ajax.ActionLink("Clear Logs", "Clear", "Log", new AjaxOptions{ OnSuccess = "reloadGrid" })</li>
|
||||
</ul>
|
||||
|
||||
<div style="margin-bottom: 10px"></div>
|
|
@ -1,5 +1,4 @@
|
|||
@using NzbDrone.Core.Repository;
|
||||
@using NzbDrone.Web.Controllers
|
||||
@using NzbDrone.Core.Helpers;
|
||||
@using NzbDrone.Web.Models;
|
||||
@model IEnumerable<NzbDrone.Core.Repository.Series>
|
||||
@section TitleContent{
|
||||
|
@ -89,7 +88,7 @@ NZBDrone
|
|||
|
||||
})
|
||||
.Editable(editor => editor.Mode(GridEditMode.PopUp))
|
||||
.Sortable(sort => sort.OrderBy(order => order.Add(o => o.Title).Ascending()).Enabled(true))
|
||||
//.Sortable(sort => sort.OrderBy(order => order.Add(o => o.Title).Ascending()).Enabled(true))
|
||||
.DetailView(detailView => detailView.ClientTemplate("<#= Overview #>"))
|
||||
.ClientEvents(clientEvents =>
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<link type="text/css" rel="stylesheet" href="/Content/ActionButton.css" />
|
||||
<link type="text/css" rel="stylesheet" href="/Content/overrides.css" />
|
||||
<link type="text/css" rel="stylesheet" href="/Content/Menu.css" />
|
||||
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/yui/3.3.0/build/yui/yui-min.js"></script>
|
||||
|
|
Loading…
Reference in New Issue