From de003b97742c3932ac2d93975914d1613c093ae5 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 27 Apr 2011 16:51:38 -0700 Subject: [PATCH] Added "Tomorrow" view for the upcoming episodes page so it was separate from the weekly forecast. --- .../Providers/UpcomingEpisodesProvider.cs | 7 ++++- .../Controllers/UpcomingController.cs | 17 +++++++++++ NzbDrone.Web/Views/Upcoming/Index.cshtml | 30 ++++++++++++++++++- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs b/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs index 50611fa45..be62fd20e 100644 --- a/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs +++ b/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs @@ -39,10 +39,15 @@ namespace NzbDrone.Core.Providers return _repository.All().Where(e => e.AirDate == DateTime.Today).ToList(); } + public virtual List Tomorrow() + { + return _repository.All().Where(e => e.AirDate == DateTime.Today.AddDays(1)).ToList(); + } + public virtual List Week() { return - _repository.All().Where(e => e.AirDate > DateTime.Today && e.AirDate < DateTime.Today.AddDays(8)) + _repository.All().Where(e => e.AirDate > DateTime.Today.AddDays(1) && e.AirDate < DateTime.Today.AddDays(8)) .ToList(); } } diff --git a/NzbDrone.Web/Controllers/UpcomingController.cs b/NzbDrone.Web/Controllers/UpcomingController.cs index af264a4a4..3c9b4e826 100644 --- a/NzbDrone.Web/Controllers/UpcomingController.cs +++ b/NzbDrone.Web/Controllers/UpcomingController.cs @@ -58,6 +58,23 @@ namespace NzbDrone.Web.Controllers return View(new GridModel(upcoming)); } + [GridAction] + public ActionResult _AjaxBindingTomorrow() + { + var upcoming = _upcomingEpisodesProvider.Tomorrow().Select(e => new UpcomingEpisodeModel + { + SeriesId = e.Series.SeriesId, + SeriesName = e.Series.Title, + SeasonNumber = e.SeasonNumber, + EpisodeNumber = e.EpisodeNumber, + Title = e.Title, + Overview = e.Overview, + AirDate = e.AirDate.Add(Convert.ToDateTime(e.Series.AirTimes).TimeOfDay) + }); + + return View(new GridModel(upcoming)); + } + [GridAction] public ActionResult _AjaxBindingWeek() { diff --git a/NzbDrone.Web/Views/Upcoming/Index.cshtml b/NzbDrone.Web/Views/Upcoming/Index.cshtml index b835206e1..609f0dd5b 100644 --- a/NzbDrone.Web/Views/Upcoming/Index.cshtml +++ b/NzbDrone.Web/Views/Upcoming/Index.cshtml @@ -66,9 +66,37 @@ Upcoming .Render();}
+
+

+ Tomorrow

+ @{Html.Telerik().Grid().Name("Tomorrow").NoRecordsTemplate( + "No watched shows airing tomorrow") + .TableHtmlAttributes(new { @class = "Grid" }) + .Columns(columns => + { + columns.Bound(c => c.SeriesName) + .ClientTemplate("<#= SeriesName #>") + .Title("Series Name"); + columns.Bound(c => c.SeasonNumber).Title("Season #").Width(40); + columns.Bound(c => c.EpisodeNumber).Title("Episode #").Width(40); + columns.Bound(c => c.Title).Title("Episode Title"); + columns.Bound(c => c.AirDate).Title("Air Date").Width(160); + }) + .DetailView(detailView => detailView.ClientTemplate( + "
" + + "
Overview: <#= Overview #>
" + + "
" + )) + .DataBinding(data => data.Ajax().Select("_AjaxBindingTomorrow", "Upcoming")) + .Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.AirDate).Ascending()).Enabled(true)) + .Render();} +
+

- 7-Day Forecast

+ Future Forecast @{Html.Telerik().Grid().Name("Week").NoRecordsTemplate( "No watched shows airing in the next week...") .TableHtmlAttributes(new { @class = "Grid" })