diff --git a/NzbDrone.Web/Controllers/SeriesController.cs b/NzbDrone.Web/Controllers/SeriesController.cs index 0658ae19a..aedc5d80e 100644 --- a/NzbDrone.Web/Controllers/SeriesController.cs +++ b/NzbDrone.Web/Controllers/SeriesController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Web.Mvc; +using System.Web.Script.Serialization; using MvcMiniProfiler; using NzbDrone.Common.Model; using NzbDrone.Core; @@ -37,8 +38,10 @@ namespace NzbDrone.Web.Controllers public ActionResult Index() { - var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount()).OrderBy(o => SortHelper.SkipArticles(o.Title)).ToList(); - return View(series); + var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount()); + var serialized = new JavaScriptSerializer().Serialize(series); + + return View((object)serialized); } public ActionResult SeriesEditor(int seriesId) @@ -191,6 +194,7 @@ namespace NzbDrone.Web.Controllers { SeriesId = s.SeriesId, Title = s.Title, + TitleSorter = SortHelper.SkipArticles(s.Title), AirsDayOfWeek = s.AirsDayOfWeek.ToString(), Monitored = s.Monitored, Overview = s.Overview, @@ -203,7 +207,8 @@ namespace NzbDrone.Web.Controllers SeasonsCount = s.SeasonCount, EpisodeCount = s.EpisodeCount, EpisodeFileCount = s.EpisodeFileCount, - NextAiring = s.NextAiring == null ? String.Empty : s.NextAiring.Value.ToBestDateString() + NextAiring = s.NextAiring == null ? String.Empty : s.NextAiring.Value.ToBestDateString(), + NextAiringSorter = s.NextAiring == null ? "12/31/9999" : s.NextAiring.Value.ToString("MM/dd/yyyy") }).ToList(); return series; diff --git a/NzbDrone.Web/Models/SeriesModel.cs b/NzbDrone.Web/Models/SeriesModel.cs index babfca8eb..34002756a 100644 --- a/NzbDrone.Web/Models/SeriesModel.cs +++ b/NzbDrone.Web/Models/SeriesModel.cs @@ -7,12 +7,13 @@ using NzbDrone.Core.Repository; namespace NzbDrone.Web.Models { - public class SeriesModel + public class SeriesModel { public int SeriesId { get; set; } //View Only public string Title { get; set; } + public string TitleSorter { get; set; } public int SeasonsCount { get; set; } public int EpisodeCount { get; set; } public int EpisodeFileCount { get; set; } @@ -23,6 +24,8 @@ namespace NzbDrone.Web.Models public int Episodes { get; set; } public bool HasBanner { get; set; } public string NextAiring { get; set; } + public string NextAiringSorter { get; set; } + public string Details { get; set; } public IList Seasons { get; set; } diff --git a/NzbDrone.Web/Views/Series/Index.cshtml b/NzbDrone.Web/Views/Series/Index.cshtml index 6a7e4687a..978ead8fc 100644 --- a/NzbDrone.Web/Views/Series/Index.cshtml +++ b/NzbDrone.Web/Views/Series/Index.cshtml @@ -1,7 +1,7 @@ @using NzbDrone.Common @using NzbDrone.Web.Helpers @using NzbDrone.Web.Models; -@model List +@model string @{ViewBag.Title = "NzbDrone";} @section HeaderContent @@ -79,48 +79,24 @@ } - - - - - - - - - - - +
- - - - - - + + + + + + @*Commands Column*@ - - @for (int i = 0; i < Model.Count; i++) - { - var series = Model[i]; - - if (i % 2 == 0) - { - Html.RenderPartial("Series", series); - } - - else - { - Html.RenderPartial("Series", series, new ViewDataDictionary { new KeyValuePair("AltRow", true) }); - } - }
StatusTitleSeasonsQualityNext AiringEpisodesStatusTitleSeasonsQualityNext AiringEpisodes +
@@ -134,8 +110,97 @@ var seriesEditorUrl = './Series/SeriesEditor'; var saveSeriesEditorUrl = './Series/SaveSeriesEditor'; var seriesDeleteUrl = './Series/DeleteSeries'; + var pauseImage = 'Paused'; + var stopImage = 'Ended'; + var playImage = 'Active'; $(document).ready(function () { + $('#seriesGrid').removeClass('hidden-grid'); + + oTable = $('.dataTablesGrid').dataTable({ + "bShowAll": false, + "aaData": @Html.Raw(Model), + "bPaginate": false, + "bLengthChange": false, + "bFilter": false, + "bSort": true, + "bInfo": false, + "bAutoWidth": false, + "aoColumns": [ + { sWidth: '70px', + "sClass": "statusColumn", + "mDataProp": function (source, type, val) { + // 'display' and 'filter' use our fancy naming + if (type === 'display' || type === 'filter') { + var monitored = source["Monitored"]; + var status = source["Status"]; + + if (!monitored) { + return pauseImage; + } + + else { + if (status === "Ended"){ + return stopImage; + } + + else { + return playImage; + } + } + } + // 'sort' and 'type' both just use the raw data + return source["Status"]; + } + }, //Status + { sWidth: 'auto', "mDataProp": function (source, type, val) { + // 'display' and 'filter' use our fancy naming + if (type === 'display' || type === 'filter') { + return source["Title"]; + } + // 'sort' and 'type' both just use the raw data + return source["TitleSorter"]; + } + }, //Title + { sWidth: '100px', "mDataProp": "SeasonsCount", "bSortable": false }, //Seasons + { sWidth: '100px', "mDataProp": "QualityProfileName" }, //Quality + { sWidth: '120px', "mDataProp": function (source, type, val) { + // 'display' and 'filter' use our fancy naming + if (type === 'display' || type === 'filter') { + return source["NextAiring"]; + } + // 'sort' and 'type' both just use the raw data + return source["NextAiringSorter"]; + } + }, //Next Airing + { sWidth: '140px', "mDataProp": "Episodes", "bSortable": false, "fnRender": function (row) { + var progress = row.aData["EpisodeFileCount"] / row.aData["EpisodeCount"] * 100; + + var result = "
" + + "" + row.aData["EpisodeFileCount"] + " / " + row.aData["EpisodeCount"] +"" + + "
"; + + return result; + } + }, //Episodes + { sWidth: '50px', "mDataProp": "HasBanner", "bSortable": false, "fnRender": function (row) { + return "" + + ""; + } + }, //Commands + { sWidth: '60px', "mDataProp": "Details", "bSortable": false, "bVisible": false, "fnRender": function (row) { + var result = "Airs Day of Week: " + row.aData["AirsDayOfWeek"] + "
" + + "Overview: " + row.aData["Overview"] + "
"; + return result; + } + } //Details + ], + "aaSorting": [[1, 'asc']], + "fnCreatedRow": function( nRow, aData, iDataIndex ) { + $(nRow).addClass(aData["SeriesId"].toString()); + } + }); + $(".progressBar").each(function () { var element = this; @@ -197,11 +262,8 @@ width: 450, modal: true, buttons: { - "Delete": function () { - var seriesId = $('.seriesId').val(); - $.ajax({ type: "POST", url: seriesDeleteUrl, @@ -221,7 +283,6 @@ }); $(".editButton") - //.button() .live('click', function () { //Get the SeriesId and Title var seriesId = parseInt($(this).attr("value")); @@ -246,8 +307,7 @@ $("#seriesEditor").dialog("open"); }); - $(".deleteButton") - //.button() + $(".deleteButton") .live('click', function () { //Get the SeriesId and Title var seriesId = parseInt($(this).attr("value")); @@ -267,25 +327,20 @@ function updateStatus() { var monitored = $('#Monitored').attr('checked'); var seriesId = $('#SeriesId').val(); - var img = $('.' + seriesId).children('.statusColumn').children('img'); - var state = img.attr('alt'); - - if (state == "Ended") - return; - - if (state == "Active") { - if (!monitored) { - img.attr('title', 'Not monitored'); - img.attr('alt', 'Paused'); - img.attr('src', '../../Content/Images/pause.png'); - } + var status = $('#Status').val(); + var imgContainer = $('.' + seriesId).children('.statusColumn'); + + if (!monitored) { + imgContainer.html(pauseImage); } - - if (state == "Paused") { - if (monitored) { - img.attr('title', 'Continuing'); - img.attr('alt', 'Active'); - img.attr('src', '../../Content/Images/play.png'); + + else { + if (status === "Ended"){ + imgContainer.html(stopImage); + } + + else { + imgContainer.html(playImage); } } } diff --git a/NzbDrone.Web/Views/Series/SeriesEditor.cshtml b/NzbDrone.Web/Views/Series/SeriesEditor.cshtml index c9e9ccf39..52dd40e99 100644 --- a/NzbDrone.Web/Views/Series/SeriesEditor.cshtml +++ b/NzbDrone.Web/Views/Series/SeriesEditor.cshtml @@ -15,6 +15,7 @@ @using (Html.BeginForm("SaveSeriesEditor", "Series", FormMethod.Post, new { id = "SeriesEditorForm", name = "SeriesEditorForm", @class = "settingsForm" })) { @Html.HiddenFor(m => m.SeriesId) + @Html.HiddenFor(m => m.Status)