System/PendingProcessing grid converted to Datatables.
Misnamed Controller and Views removed.
This commit is contained in:
parent
f21f3517cf
commit
d6e4c5fc53
|
@ -1,36 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Web.Models;
|
||||
using Telerik.Web.Mvc;
|
||||
|
||||
namespace NzbDrone.Web.Controllers
|
||||
{
|
||||
public class MisnamedController : Controller
|
||||
{
|
||||
private readonly MisnamedProvider _misnamedProvider;
|
||||
|
||||
public MisnamedController(MisnamedProvider misnamedProvider)
|
||||
{
|
||||
_misnamedProvider = misnamedProvider;
|
||||
}
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[GridAction(EnableCustomBinding = true)]
|
||||
public ActionResult _AjaxBinding(GridCommand gridCommand)
|
||||
{
|
||||
var totalItems = 0;
|
||||
|
||||
var misnamed = _misnamedProvider.MisnamedFiles(gridCommand.Page, gridCommand.PageSize, out totalItems);
|
||||
|
||||
return View(new GridModel{ Data = misnamed, Total = totalItems });
|
||||
}
|
||||
}
|
||||
}
|
|
@ -40,25 +40,5 @@ namespace NzbDrone.Web.Controllers
|
|||
|
||||
return View((object)serialized);
|
||||
}
|
||||
|
||||
[GridAction]
|
||||
public ActionResult _AjaxBinding()
|
||||
{
|
||||
var missingEpisodes = _episodeProvider.EpisodesWithoutFiles(false);
|
||||
|
||||
var missing = missingEpisodes.Select(e => new MissingEpisodeModel
|
||||
{
|
||||
EpisodeId = e.EpisodeId,
|
||||
SeriesId = e.SeriesId,
|
||||
EpisodeNumbering = string.Format("{0}x{1:00}", e.SeasonNumber, e.EpisodeNumber),
|
||||
EpisodeTitle = e.Title,
|
||||
Overview = e.Overview,
|
||||
SeriesTitle = e.Series.Title,
|
||||
AirDate = e.AirDate.Value.ToString(),
|
||||
AirDateString = e.AirDate.Value.ToBestDateString()
|
||||
});
|
||||
|
||||
return View(new GridModel(missing));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,12 +109,7 @@ namespace NzbDrone.Web.Controllers
|
|||
public ActionResult PendingProcessing()
|
||||
{
|
||||
ViewData["DropDir"] = _configProvider.SabDropDirectory;
|
||||
return View();
|
||||
}
|
||||
|
||||
[GridAction]
|
||||
public ActionResult _PendingProcessingAjaxBinding()
|
||||
{
|
||||
var dropDir = _configProvider.SabDropDirectory;
|
||||
var subFolders = _diskProvider.GetDirectories(dropDir);
|
||||
|
||||
|
@ -125,7 +120,7 @@ namespace NzbDrone.Web.Controllers
|
|||
{
|
||||
var model = new PendingProcessingModel();
|
||||
model.Name = new DirectoryInfo(folder).Name;
|
||||
model.Created = _diskProvider.DirectoryDateCreated(folder);
|
||||
model.Created = _diskProvider.DirectoryDateCreated(folder).ToString();
|
||||
model.Path = folder.Replace(Path.DirectorySeparatorChar, '|').Replace(Path.VolumeSeparatorChar, '^').Replace('\'', '`');
|
||||
|
||||
var files = _diskProvider.GetFileInfos(folder, "*.*", SearchOption.AllDirectories);
|
||||
|
@ -143,7 +138,9 @@ namespace NzbDrone.Web.Controllers
|
|||
models.Add(model);
|
||||
}
|
||||
|
||||
return View(new GridModel(models));
|
||||
var serialized = new JavaScriptSerializer().Serialize(models);
|
||||
|
||||
return View((object)serialized);
|
||||
}
|
||||
|
||||
public JsonResult RenamePendingProcessing(string path)
|
||||
|
|
|
@ -8,7 +8,9 @@ namespace NzbDrone.Web.Models
|
|||
{
|
||||
public string Name { get; set; }
|
||||
public string Files { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public string Created { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string Actions { get; set; }
|
||||
public string Details { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
@using NzbDrone.Common
|
||||
@using NzbDrone.Core.Model
|
||||
@{ViewBag.Title = "Misnamed";}
|
||||
@section ActionMenu{
|
||||
<ul class="sub-menu">
|
||||
<li>@Ajax.ActionLink("Trim History", "Trim", "History", new AjaxOptions { OnSuccess = "reloadHistoryGrid" })</li>
|
||||
<li>@Ajax.ActionLink("Purge History", "Purge", "History", new AjaxOptions { OnSuccess = "reloadHistoryGrid" })</li>
|
||||
</ul>
|
||||
}
|
||||
<style>
|
||||
.searchImage
|
||||
{
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
padding: 1px;
|
||||
margin: 2px;
|
||||
@*border-width: 1px;
|
||||
border-style: dashed;
|
||||
border-color: lightgray;*@
|
||||
}
|
||||
|
||||
.searchImage:hover
|
||||
{
|
||||
background-color: #065EFE;
|
||||
}
|
||||
</style>
|
||||
<div class="grid-container">
|
||||
@{Html.Telerik().Grid<MisnamedEpisodeModel>().Name("misnamed")
|
||||
.TableHtmlAttributes(new { @class = "Grid" })
|
||||
.Columns(columns =>
|
||||
{
|
||||
columns.Bound(c => c.SeriesTitle)
|
||||
.ClientTemplate("<a href=" +
|
||||
Url.Action("Details", "Series", new { seriesId = "<#= SeriesId #>" }) +
|
||||
"><#= SeriesTitle #></a>")
|
||||
.Title("Series Title");
|
||||
columns.Bound(c => c.CurrentName).Title("Current Name");
|
||||
columns.Bound(c => c.ProperName).Title("Proper Name");
|
||||
columns.Bound(c => c.EpisodeFileId)
|
||||
.Title("Actions")
|
||||
.Width("40");
|
||||
})
|
||||
.DataBinding(data => data.Ajax().Select("_AjaxBinding", "Misnamed"))
|
||||
.Pageable(
|
||||
c =>
|
||||
c.PageSize(20).Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPrevious))
|
||||
.EnableCustomBinding(true)
|
||||
.ClientEvents(clientEvents =>
|
||||
{
|
||||
clientEvents.OnDataBound("grid_dataBound");
|
||||
if (EnviromentProvider.IsProduction)
|
||||
clientEvents.OnError("grid_onError");
|
||||
})
|
||||
.Render();}
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
deleteHistoryRowUrl = '../History/Delete';
|
||||
redownloadUrl = '../History/Redownload';
|
||||
|
||||
function reloadHistoryGrid() {
|
||||
var grid = $('#history').data('tGrid');
|
||||
grid.rebind();
|
||||
grid.sort("Date-desc");
|
||||
}
|
||||
|
||||
function deleteHistoryRow(historyId) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: deleteHistoryRowUrl,
|
||||
data: jQuery.param({ historyId: historyId }),
|
||||
success: function () {
|
||||
reloadHistoryGrid();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function redownload(historyId, episodeId) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: redownloadUrl,
|
||||
data: jQuery.param({ historyId: historyId, episodeId: episodeId }),
|
||||
success: function () {
|
||||
reloadHistoryGrid();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function grid_dataBound(e) {
|
||||
var id = $(this).attr('id');
|
||||
var lastButton = $('#' + id + ' .t-arrow-last');
|
||||
lastButton.hide();
|
||||
}
|
||||
</script>
|
|
@ -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>
|
||||
}
|
Loading…
Reference in New Issue