System/PendingProcessing grid converted to Datatables.

Misnamed Controller and Views removed.
This commit is contained in:
Mark McDowall 2012-02-09 23:11:56 -08:00
commit d6e4c5fc53
6 changed files with 79 additions and 203 deletions

View file

@ -1,50 +1,76 @@
@model List<NzbDrone.Web.Models.PendingProcessingModel>
@model string
@using NzbDrone.Web.Models
@{ViewBag.Title = "Pending Processing";}
@section ActionMenu{
@{Html.Telerik().Menu().Name("historyMenu").Items(items =>
{
items.Add().Text("Trim History").Action("Trim", "History");
items.Add().Text("Purge History").Action("Purge", "History");
}).Render();}
}
<div class="grid-container">
@{Html.Telerik().Grid<PendingProcessingModel>().Name("PendingProcessingGrid")
.TableHtmlAttributes(new { @class = "Grid" })
.Columns(columns =>
{
columns.Bound(c => c.Name);
columns.Bound(c => c.Created).Title("Creation Date");
columns.Bound(c => c.Path).Title("")
.ClientTemplate("<a href='#Rename' onClick=\"renamePending('<#= Path #>'); return false;\">Rename</a>");
})
.DetailView(detailView => detailView.ClientTemplate(
"<div><#= Files #></div>"
))
.DataBinding(data => data.Ajax().Select("_PendingProcessingAjaxBinding", "System"))
.Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.Name).Ascending()).Enabled(true))
.Pageable(
c =>
c.PageSize(20).Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPrevious))
.Render();}
</div>
<script type="text/javascript">
var renamePendingUrl = '@Url.Action("RenamePendingProcessing", "System")';
function renamePending(path) {
$.ajax({
type: "POST",
url: renamePendingUrl,
data: jQuery.param({ path: path }),
error: function (req, status, error) {
alert("Sorry! We could rename " + name + " at this time. " + error);
},
success: function (data, textStatus, jqXHR) {
if (data == "ok") {
var grid = $('#PendingProcessingGrid').data('tGrid');
grid.ajaxRequest();
}
}
<div class="grid-container">
<table id="pendingProcessingGrid" class="dataTablesGrid hidden-grid">
<thead>
<tr>
<th>Name</th>
<th>Creation Date</th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
@section Scripts
{
<script type="text/javascript">
var renamePendingUrl = '@Url.Action("RenamePendingProcessing", "System")';
$(document).ready(function() {
$('#pendingProcessingGrid').removeClass('hidden-grid');
oTable = $('.dataTablesGrid').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: 'auto', "mDataProp": "Name"}, //Name
{ sWidth: '250px', "mDataProp": "Created"}, //CreationDate
{ sWidth: '40px', "mDataProp": "Actions", "bSortable": false, "fnRender": function (row) {
return "<a href='#Rename' onClick=\"renamePending('" + row.aData["Path"] + "'); return false;\">Rename</a>";
}
}, //Actions
{
sWidth: 'auto',
"mDataProp": "Details",
"bSortable": false,
"bVisible": false,
"fnRender": function(row) {
var result = "<div>" + row.aData["Files"] + "</div>";
return result;
}
} //Details
]
});
});
}
</script>
function renamePending(path) {
$.ajax({
type: "POST",
url: renamePendingUrl,
data: jQuery.param({ path: path }),
error: function (req, status, error) {
alert("Sorry! We could rename " + name + " at this time. " + error);
},
success: function (data, textStatus, jqXHR) {
if (data == "ok") {
var grid = $('#PendingProcessingGrid').data('tGrid');
grid.ajaxRequest();
}
}
});
}
</script>
}