1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-26 09:37:12 +00:00

System/Jobs now uses DataTables

This commit is contained in:
Mark McDowall 2012-02-09 22:17:53 -08:00
parent 463ab0812e
commit 185edfb7f7
5 changed files with 147 additions and 7 deletions

View file

@ -36,15 +36,31 @@ public SystemController(JobProvider jobProvider, IndexerProvider indexerProvider
public ActionResult Jobs()
{
ViewData["Queue"] = _jobProvider.Queue.Select(c => new JobQueueItemModel
var queue = _jobProvider.Queue.Select(c => new JobQueueItemModel
{
Name = c.JobType.Name,
TargetId = c.TargetId,
SecondaryTargetId = c.SecondaryTargetId
});
var jobs = _jobProvider.All();
return View(jobs);
var serializedQueue = new JavaScriptSerializer().Serialize(queue);
ViewData["Queue"] = serializedQueue;
var jobs = _jobProvider.All().Select(j => new JobModel
{
Id = j.Id,
Enable = j.Enable,
TypeName = j.TypeName,
Name = j.Name,
Interval = j.Interval,
LastExecution = j.LastExecution.ToString(),
Success = j.Success
}).OrderBy(j => j.Interval);
var serializedJobs = new JavaScriptSerializer().Serialize(jobs);
return View((object)serializedJobs);
}
public ActionResult Indexers()

View file

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NzbDrone.Web.Models
{
public class JobModel
{
public Int32 Id { get; set; }
public Boolean Enable { get; set; }
public String TypeName { get; set; }
public String Name { get; set; }
public Int32 Interval { get; set; }
public String LastExecution { get; set; }
public Boolean Success { get; set; }
public string Actions { get; set; }
}
}

View file

@ -245,6 +245,7 @@
<Compile Include="Helpers\HtmlPrefixScopeExtensions.cs" />
<Compile Include="Helpers\IsCurrentActionHelper.cs" />
<Compile Include="Models\DataTablesParams.cs" />
<Compile Include="Models\JobModel.cs" />
<Compile Include="Models\LogModel.cs" />
<Compile Include="Models\UpcomingEpisodesModel.cs" />
<Compile Include="Models\SeasonModel.cs" />

View file

@ -71,7 +71,7 @@
{ sWidth: 'auto', "mDataProp": "SeriesTitle" }, //Series Title
{ sWidth: '80px', "mDataProp": "EpisodeNumbering", "bSortable": false }, //EpisodeNumbering
{ sWidth: 'auto', "mDataProp": "EpisodeTitle", "bSortable": false }, //Episode Title
{ sWidth: '70px', "mDataProp": "Quality", "bSoratble": false }, //Quality
{ sWidth: '70px', "mDataProp": "Quality", "bSortable": false }, //Quality
{ sWidth: '150px', "mDataProp": "Date" }, //Grabbed On
{ sWidth: '40px', "mDataProp": "HistoryId", "bSortable": false, "fnRender": function (row) {
var deleteImage = "<img src=\"../../Content/Images/X.png\" alt=\"Delete\" title=\"Delete from History\" class=\"searchImage\" onclick=\"deleteHistory(this.parentNode.parentNode, " + row.aData["HistoryId"] + ")\">";

View file

@ -1,9 +1,113 @@
@using NzbDrone.Web.Models
@using NzbDrone.Web.Helpers
@model IEnumerable<NzbDrone.Core.Repository.JobDefinition>
@model string
@{ViewBag.Title = "Jobs";}
@{Html.Telerik().Grid(Model).Name("Grid")
@section HeaderContent
{
@Html.IncludeCss("Grid.css")
}
<div class="grid-container">
<table id="jobGrid" class="dataTablesGrid hidden-grid no-details">
<thead>
<tr>
<th>ID</th>
<th>Enable</th>
<th>Type Name</th>
<th>Name</th>
<th>Interval</th>
<th>Last Execution</th>
<th>Success</th>
@*Commands Column*@
<th>Actions</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<h1>Items currently in queue</h1>
<div class="grid-container">
<table id="queueGrid" class="dataTablesGrid hidden-grid no-details">
<thead>
<tr>
<th>Type</th>
<th>Target</th>
<th>Secondary</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
@section Scripts{
<script type="text/javascript">
$(document).ready(function() {
$('#jobGrid').removeClass('hidden-grid');
oTable = $('#jobGrid').dataTable({
"bShowAll": false,
"aaData": @Html.Raw(Model),
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": false,
"iDisplayLength": 20,
"sPaginationType": "four_button",
"aoColumns": [
{ sWidth: '30px', "mDataProp": "Id"}, //Id
{ sWidth: '70px', "mDataProp": "Enable" }, //Enable
{ sWidth: '80px', "mDataProp": "TypeName" }, //TypeName
{ sWidth: 'auto', "mDataProp": "Name" }, //Name
{ sWidth: '70px', "mDataProp": "Interval" }, //Interval
{ sWidth: '150px', "mDataProp": "LastExecution" }, //LastExecution
{ sWidth: '80px', "mDataProp": "Success" }, //Success
{ sWidth: '40px', "mDataProp": "Actions", "bSortable": false, "fnRender": function (row) {
if (!row.aData["Enable"])
return "";
return createImageAjaxLink('/System/RunJob?typeName=' + row.aData["TypeName"], '../../Content/Images/Gear.png', 'Run', 'Run Job', 'searchImage');
//return createImageAjaxLink('/History/Delete?historyId=' + row.aData["HistoryId"], '../../Content/Images/X.png', 'Delete', 'Delete from History', 'searchImage');
}
} //Actions
],
"aaSorting": [[4, 'asc']]
});
$('#queueGrid').removeClass('hidden-grid');
oTable = $('#queueGrid').dataTable({
"bShowAll": false,
"aaData": @ViewData["Queue"],
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": false,
"iDisplayLength": 20,
"sPaginationType": "four_button",
"aoColumns": [
{ sWidth: 'auto', "mDataProp": "Type"}, //Type
{ sWidth: '100px', "mDataProp": "Target" }, //Target
{ sWidth: '100px', "mDataProp": "SecondaryTarget" }, //SecondaryTarget
]
});
});
</script>
}
@*@{Html.Telerik().Grid(Model).Name("Grid")
.Columns(c => c.Bound(g => g.Id))
.Columns(c => c.Bound(g => g.Enable))
.Columns(c => c.Bound(g => g.TypeName))
@ -28,4 +132,4 @@
.Columns(c => c.Bound(g => g.Name).Title("Type").Width(100))
.Columns(c => c.Bound(g => g.TargetId).Title("Target"))
.Columns(c => c.Bound(g => g.SecondaryTargetId).Title("Secondary Target"))
.Render();}
.Render();}*@