2012-02-08 16:26:34 -08:00
@model String
2011-12-09 21:05:17 -08:00
@{ViewBag.Title = "History";}
2011-04-20 21:20:39 -07:00
@section ActionMenu{
2011-08-21 19:56:04 -07:00
<ul class="sub-menu">
2012-08-06 11:49:44 -07:00
<li>@Ajax.ActionLink("Trim History", "Trim", "History", null, new AjaxOptions{ OnSuccess = "redrawGrid", Confirm = "Delete history items older than 30 days?"}, new { Title = "Delete history items older than 30 days" })</li>
<li>@Ajax.ActionLink("Purge History", "Purge", "History", null, new AjaxOptions{ OnSuccess = "redrawGrid", Confirm = "Purge all history items?" }, new { Title = "Delete all history items" })</li>
2012-04-23 12:56:59 -07:00
<li>@Html.ActionLink("Search History", "Index", "SearchHistory", null, new { Title = "Review recent searches" })</li>
2011-08-05 19:04:35 -07:00
</ul>
2011-04-20 21:20:39 -07:00
}
2012-02-08 00:17:40 -08:00
2011-11-30 21:25:01 -08:00
<div class="grid-container">
2012-02-09 09:41:51 -08:00
<table id="historyGrid" class="dataTablesGrid hidden-grid">
2012-02-08 17:05:16 -08:00
<thead>
<tr>
<th></th>
<th>Series Title</th>
<th>Episode</th>
<th>Episode Title</th>
<th>Quality</th>
<th>Grabbed On</th>
2012-02-08 00:17:40 -08:00
2012-02-08 17:05:16 -08:00
@*Commands Column*@
<th>Actions</th>
2012-02-08 00:17:40 -08:00
2012-02-08 17:05:16 -08:00
@*Details Column*@
<th style="display: none;">Details</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
2011-11-30 21:25:01 -08:00
</div>
2012-02-08 00:17:40 -08:00
2012-02-09 21:26:30 -08:00
@section Scripts{
<script type="text/javascript">
deleteHistoryRowUrl = '../History/Delete';
redownloadUrl = '../History/Redownload';
2011-08-05 19:04:35 -07:00
2012-02-09 21:26:30 -08:00
function reloadHistoryGrid() {
var grid = $('#history').data('tGrid');
grid.ajaxRequest();
}
2012-02-08 00:17:40 -08:00
2012-02-09 21:26:30 -08:00
$(document).ready(function() {
$('#historyGrid').removeClass('hidden-grid');
2012-02-08 00:17:40 -08:00
2012-02-10 21:00:22 -08:00
oTable = $('#historyGrid').dataTable({
2012-10-24 08:09:42 -07:00
"sAjaxSource": "/history/ajaxbinding",
2012-07-27 23:37:47 -07:00
"bServerSide": true,
2012-02-10 21:00:22 -08:00
"bProcessing": true,
2012-02-09 21:26:30 -08:00
"bShowAll": false,
2012-02-10 21:00:22 -08:00
"bPaginate": true,
"bLengthChange": false,
"bFilter": true,
"bSort": true,
"bInfo": true,
"bAutoWidth": false,
"iDisplayLength": 20,
"sPaginationType": "four_button",
"aoColumns": [
2012-04-14 14:44:02 -07:00
{
2012-07-27 23:37:47 -07:00
sName: 'Icon', sWidth: '20px', "bSortable": false, "bSearchable": false, "mDataProp": function (source, type, val) {
2012-04-14 14:44:02 -07:00
// 'display' and 'filter' use the image
if (type === 'display' || type === 'filter') {
2012-05-08 14:29:24 -07:00
if (source['Indexer'].indexOf("Newznab") === 0)
2013-01-08 00:11:33 -08:00
return '<img src="/Image/Newznab?name=' + source['Indexer'] + '" alt="' + source['Indexer'].replace('_', ' - ') + '" title="' + source['Indexer'].replace('_', ' - ') + '">';
2012-05-08 14:29:24 -07:00
2012-04-14 14:44:02 -07:00
return "<img src='/Content/Images/Indexers/" + source['Indexer'] + ".png' alt='" + source["Indexer"] + "' title='" + source["Indexer"] + "'>";
}
// 'sort' and 'type' both just use the raw data
return source["Indexer"];
2012-02-10 21:00:22 -08:00
}
}, //Image
2012-07-27 23:37:47 -07:00
{
sName: 'Series.Title', sWidth: 'auto', "mDataProp": function (source, type, val) {
2012-02-26 20:47:49 -08:00
// 'display' and 'filter' use our fancy naming
if (type === 'display' || type === 'filter') {
return "<a href='/Series/Details?seriesId=" + source["SeriesId"] + "'>" + source["SeriesTitle"] + "</a>";
}
// 'sort' and 'type' both just use the raw data
return source["SeriesTitleSorter"];
}
}, //Series Title
2012-07-27 23:37:47 -07:00
{ sName: 'EpisodeNumbering', sWidth: '80px', "mDataProp": "EpisodeNumbering", "bSortable": false, "bSearchable": false }, //EpisodeNumbering
{ sName: 'Episodes.Title', sWidth: 'auto', "mDataProp": "EpisodeTitle", "bSortable": false }, //Episode Title
{ sName: 'Quality', sWidth: '70px', "mDataProp": "Quality", "bSortable": false, "bSearchable": false }, //Quality
{ sName: 'Date', sWidth: '150px', "bSearchable": false, "mDataProp": function (source, type, val) {
2012-02-14 10:48:13 -08:00
// 'display' and 'filter' use our fancy naming
if (type === 'display' || type === 'filter') {
return source["Date"];
}
// 'sort' and 'type' both just use the raw data
return source["DateSorter"];
}
}, //Date
2012-07-27 23:37:47 -07:00
{ sName: 'Actions', sWidth: '40px', "mDataProp": "HistoryId", "bSortable": false, "bSearchable": false, "fnRender": function (row) {
2012-10-10 19:59:35 -07:00
var deleteImage = '<i class="icon-remove gridAction" title="Delete from History" onclick="deleteHistory(this.parentNode.parentNode, ' + row.aData["HistoryId"] + ')"></i>';
2012-10-11 10:25:31 -07:00
var redownloadImage = '<i class="icon-repeat gridAction" title="Redownload Episode" onclick="redownloadHistory(this.parentNode.parentNode, ' + row.aData["HistoryId"] + ', ' + row.aData["EpisodeId"] + ')"></i>';
2012-02-08 16:26:34 -08:00
2012-02-10 21:00:22 -08:00
return deleteImage + redownloadImage;
}
}, //Actions
{
2012-07-27 23:37:47 -07:00
sName: 'Details', sWidth: 'auto',
2012-02-10 21:00:22 -08:00
"mDataProp": "Details",
"bSortable": false,
2012-07-27 23:37:47 -07:00
"bSearchable": false,
2012-02-10 21:00:22 -08:00
"bVisible": false,
"fnRender": function(row) {
var result = "<b>Overview: </b>" + row.aData["EpisodeOverview"] + "<br/>" +
"<b>NZB Title: </b>" + row.aData["NzbTitle"] + "<br/>" +
2012-04-14 14:44:02 -07:00
"<b>Proper: </b>" + row.aData["IsProper"] + "<br/>" +
2012-05-08 14:29:24 -07:00
"<b>Indexer: </b>" + row.aData["Indexer"].replace('_', ' - ');
2012-05-02 15:42:21 -07:00
2012-08-07 16:46:23 -07:00
if (row.aData["ReleaseGroup"] != null && row.aData["ReleaseGroup"] != "")
result += "<br/><b>Release Group: </b> " + row.aData["ReleaseGroup"];
2012-05-02 15:42:21 -07:00
if (row.aData["NzbInfoUrl"] != null && row.aData["NzbInfoUrl"] != "")
result += "<br/><b>Nzb Details: </b> <a href=\"" + row.aData["NzbInfoUrl"] + "\" target=\"_blank\">Details</a>";
2012-02-10 21:00:22 -08:00
return result;
}
} //Details
],
2012-09-26 08:51:02 -07:00
"aaSorting": [[5, 'desc']],
"oLanguage": {
"sEmptyTable": "Nothing has been downloaded, or results have been purged",
"sZeroRecords": "No items match the filter"
}
2012-07-27 23:37:47 -07:00
}).fnSetFilteringDelay(500);
2012-02-09 21:26:30 -08:00
});
function deleteHistory(row, historyId) {
//Delete from DB
$.ajax({
type: "POST",
url: deleteHistoryRowUrl,
data: { historyId: historyId },
success: function() {
oTable.fnDeleteRow(oTable.fnGetPosition(row));
}
});
}
function redownloadHistory(row, historyId, episodeId) {
$.ajax({
type: "POST",
url: redownloadUrl,
data: { historyId: historyId, episodeId: episodeId },
success: function() {
oTable.fnDeleteRow(oTable.fnGetPosition(row));
}
});
}
</script>
}