You've already forked Sonarr
							
							
				mirror of
				https://github.com/Sonarr/Sonarr.git
				synced 2025-10-31 00:07:55 +02:00 
			
		
		
		
	Upcoming shows view added.
This commit is contained in:
		| @@ -57,6 +57,7 @@ namespace NzbDrone.Core | ||||
|                 _kernel.Bind<ISeriesProvider>().To<SeriesProvider>().InSingletonScope(); | ||||
|                 _kernel.Bind<ISeasonProvider>().To<SeasonProvider>(); | ||||
|                 _kernel.Bind<IEpisodeProvider>().To<EpisodeProvider>(); | ||||
|                 _kernel.Bind<IUpcomingEpisodesProvider>().To<UpcomingEpisodesProvider>(); | ||||
|                 _kernel.Bind<IDiskProvider>().To<DiskProvider>(); | ||||
|                 _kernel.Bind<ITvDbProvider>().To<TvDbProvider>(); | ||||
|                 _kernel.Bind<IDownloadProvider>().To<SabProvider>(); | ||||
|   | ||||
							
								
								
									
										15
									
								
								NzbDrone.Core/Model/UpcomingEpisodesModel.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								NzbDrone.Core/Model/UpcomingEpisodesModel.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using NzbDrone.Core.Repository; | ||||
|  | ||||
| namespace NzbDrone.Core.Model | ||||
| { | ||||
|     public class UpcomingEpisodesModel | ||||
|     { | ||||
|         public List<Episode> Yesterday { get; set; } | ||||
|         public List<Episode> Today { get; set; } | ||||
|         public List<Episode> Week { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -177,6 +177,7 @@ | ||||
|     <Compile Include="Model\SabnzbdPriorityType.cs" /> | ||||
|     <Compile Include="Model\SceneNameModel.cs" /> | ||||
|     <Compile Include="Model\SeriesMappingModel.cs" /> | ||||
|     <Compile Include="Model\UpcomingEpisodesModel.cs" /> | ||||
|     <Compile Include="Providers\BacklogProvider.cs" /> | ||||
|     <Compile Include="Providers\ExternalNotificationProvider.cs" /> | ||||
|     <Compile Include="Providers\HistoryProvider.cs" /> | ||||
| @@ -193,6 +194,7 @@ | ||||
|     <Compile Include="Providers\IRssSyncProvider.cs" /> | ||||
|     <Compile Include="Providers\IRssProvider.cs" /> | ||||
|     <Compile Include="Providers\ITimerProvider.cs" /> | ||||
|     <Compile Include="Providers\IUpcomingEpisodesProvider.cs" /> | ||||
|     <Compile Include="Providers\IXbmcProvider.cs" /> | ||||
|     <Compile Include="Providers\PostProcessingProvider.cs" /> | ||||
|     <Compile Include="Providers\QualityProvider.cs" /> | ||||
| @@ -202,6 +204,7 @@ | ||||
|     <Compile Include="Providers\RssSyncProvider.cs" /> | ||||
|     <Compile Include="Providers\RssProvider.cs" /> | ||||
|     <Compile Include="Providers\TimerProvider.cs" /> | ||||
|     <Compile Include="Providers\UpcomingEpisodesProvider.cs" /> | ||||
|     <Compile Include="Providers\XbmcProvider.cs" /> | ||||
|     <Compile Include="Repository\EpisodeFile.cs" /> | ||||
|     <Compile Include="Model\Notification\BasicNotification.cs" /> | ||||
|   | ||||
							
								
								
									
										17
									
								
								NzbDrone.Core/Providers/IUpcomingEpisodesProvider.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								NzbDrone.Core/Providers/IUpcomingEpisodesProvider.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using NzbDrone.Core.Model; | ||||
| using NzbDrone.Core.Repository; | ||||
|  | ||||
| namespace NzbDrone.Core.Providers | ||||
| { | ||||
|     public interface IUpcomingEpisodesProvider | ||||
|     { | ||||
|         UpcomingEpisodesModel Upcoming(); | ||||
|         List<Episode> Yesterday(); | ||||
|         List<Episode> Today(); | ||||
|         List<Episode> Week(); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										50
									
								
								NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using NzbDrone.Core.Model; | ||||
| using NzbDrone.Core.Repository; | ||||
| using SubSonic.Repository; | ||||
|  | ||||
| namespace NzbDrone.Core.Providers | ||||
| { | ||||
|     public class UpcomingEpisodesProvider : IUpcomingEpisodesProvider | ||||
|     { | ||||
|         private IRepository _sonicRepo; | ||||
|  | ||||
|         public UpcomingEpisodesProvider(IRepository sonicRepo) | ||||
|         { | ||||
|             _sonicRepo = sonicRepo; | ||||
|         } | ||||
|  | ||||
|         #region IUpcomingEpisodesProvider | ||||
|  | ||||
|         public UpcomingEpisodesModel Upcoming() | ||||
|         { | ||||
|             var allEps = _sonicRepo.All<Episode>().Where(e => e.AirDate >= DateTime.Today.AddDays(-1) && e.AirDate < DateTime.Today.AddDays(8)); | ||||
|  | ||||
|             var yesterday = allEps.Where(e => e.AirDate == DateTime.Today.AddDays(-1)).ToList(); | ||||
|             var today = allEps.Where(e => e.AirDate == DateTime.Today).ToList(); | ||||
|             var week = allEps.Where(e => e.AirDate > DateTime.Today).ToList(); | ||||
|  | ||||
|             return new UpcomingEpisodesModel {Yesterday = yesterday, Today = today, Week = week}; | ||||
|         } | ||||
|  | ||||
|         public List<Episode> Yesterday() | ||||
|         { | ||||
|             return _sonicRepo.All<Episode>().Where(e => e.AirDate == DateTime.Today.AddDays(-1)).ToList(); | ||||
|         } | ||||
|  | ||||
|         public List<Episode> Today() | ||||
|         { | ||||
|             return _sonicRepo.All<Episode>().Where(e => e.AirDate == DateTime.Today).ToList(); | ||||
|         } | ||||
|  | ||||
|         public List<Episode> Week() | ||||
|         { | ||||
|             return _sonicRepo.All<Episode>().Where(e => e.AirDate > DateTime.Today && e.AirDate < DateTime.Today.AddDays(8)).ToList(); | ||||
|         } | ||||
|  | ||||
|         #endregion | ||||
|     } | ||||
| } | ||||
							
								
								
									
										77
									
								
								NzbDrone.Web/Controllers/UpcomingController.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								NzbDrone.Web/Controllers/UpcomingController.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,77 @@ | ||||
| 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 UpcomingController : Controller | ||||
|     { | ||||
|         private IUpcomingEpisodesProvider _upcomingEpisodesProvider; | ||||
|  | ||||
|         public UpcomingController(IUpcomingEpisodesProvider upcomingEpisodesProvider) | ||||
|         { | ||||
|             _upcomingEpisodesProvider = upcomingEpisodesProvider; | ||||
|         } | ||||
|  | ||||
|         // | ||||
|         // GET: /Upcoming/ | ||||
|  | ||||
|         public ActionResult Index() | ||||
|         { | ||||
|             return View(); | ||||
|         } | ||||
|  | ||||
|         [GridAction] | ||||
|         public ActionResult _AjaxBindingYesterday() | ||||
|         { | ||||
|             var upcoming = _upcomingEpisodesProvider.Yesterday().Select(e => new UpcomingEpisodeModel | ||||
|                                                                              { | ||||
|                                                                                  SeriesName = e.Series.Title, | ||||
|                                                                                  SeasonNumber = e.SeasonNumber, | ||||
|                                                                                  EpisodeNumber = e.EpisodeNumber, | ||||
|                                                                                  Title = e.Title, | ||||
|                                                                                  Overview = e.Overview, | ||||
|                                                                                  AirDate = e.AirDate | ||||
|                                                                              }); | ||||
|              | ||||
|             return View(new GridModel(upcoming)); | ||||
|         } | ||||
|  | ||||
|         [GridAction] | ||||
|         public ActionResult _AjaxBindingToday() | ||||
|         { | ||||
|             var upcoming = _upcomingEpisodesProvider.Today().Select(e => new UpcomingEpisodeModel | ||||
|             { | ||||
|                 SeriesName = e.Series.Title, | ||||
|                 SeasonNumber = e.SeasonNumber, | ||||
|                 EpisodeNumber = e.EpisodeNumber, | ||||
|                 Title = e.Title, | ||||
|                 Overview = e.Overview, | ||||
|                 AirDate = e.AirDate | ||||
|             }); | ||||
|  | ||||
|             return View(new GridModel(upcoming)); | ||||
|         } | ||||
|  | ||||
|         [GridAction] | ||||
|         public ActionResult _AjaxBindingWeek() | ||||
|         { | ||||
|             var upcoming = _upcomingEpisodesProvider.Week().Select(e => new UpcomingEpisodeModel | ||||
|             { | ||||
|                 SeriesName = e.Series.Title, | ||||
|                 SeasonNumber = e.SeasonNumber, | ||||
|                 EpisodeNumber = e.EpisodeNumber, | ||||
|                 Title = e.Title, | ||||
|                 Overview = e.Overview, | ||||
|                 AirDate = e.AirDate | ||||
|             }); | ||||
|  | ||||
|             return View(new GridModel(upcoming)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										17
									
								
								NzbDrone.Web/Models/UpcomingEpisodeModel.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								NzbDrone.Web/Models/UpcomingEpisodeModel.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Web; | ||||
|  | ||||
| namespace NzbDrone.Web.Models | ||||
| { | ||||
|     public class UpcomingEpisodeModel | ||||
|     { | ||||
|         public string SeriesName { get; set; } | ||||
|         public int SeasonNumber { get; set; } | ||||
|         public int EpisodeNumber { get; set; } | ||||
|         public string Title { get; set; } | ||||
|         public string Overview { get; set; } | ||||
|         public DateTime AirDate { get; set; } | ||||
|     } | ||||
| } | ||||
| @@ -85,6 +85,7 @@ | ||||
|     <Compile Include="Controllers\SeriesController.cs" /> | ||||
|     <Compile Include="Controllers\SettingsController.cs" /> | ||||
|     <Compile Include="Controllers\SharedController.cs" /> | ||||
|     <Compile Include="Controllers\UpcomingController.cs" /> | ||||
|     <Compile Include="Global.asax.cs"> | ||||
|       <DependentUpon>Global.asax</DependentUpon> | ||||
|     </Compile> | ||||
| @@ -105,6 +106,7 @@ | ||||
|     <Compile Include="Models\SeriesSearchResultModel.cs" /> | ||||
|     <Compile Include="Models\SettingsModels.cs" /> | ||||
|     <Compile Include="Models\TestModel.cs" /> | ||||
|     <Compile Include="Models\UpcomingEpisodeModel.cs" /> | ||||
|     <Compile Include="Ninject.Web.Mvc\ControllerMissingBindingResolver.cs" /> | ||||
|     <Compile Include="Ninject.Web.Mvc\FilterInjector.cs" /> | ||||
|     <Compile Include="Ninject.Web.Mvc\IFilterInjector.cs" /> | ||||
| @@ -303,6 +305,7 @@ | ||||
|     <Content Include="Views\Settings\SubMenu.ascx" /> | ||||
|     <Content Include="Views\Settings\UserProfileSection.ascx" /> | ||||
|     <Content Include="Views\Shared\Footer.ascx" /> | ||||
|     <Content Include="Views\Upcoming\Index.aspx" /> | ||||
|     <Content Include="Web.config"> | ||||
|       <SubType>Designer</SubType> | ||||
|     </Content> | ||||
|   | ||||
							
								
								
									
										99
									
								
								NzbDrone.Web/Views/Upcoming/Index.aspx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								NzbDrone.Web/Views/Upcoming/Index.aspx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,99 @@ | ||||
| <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<List<NzbDrone.Web.Models.UpcomingEpisodeModel>>" %> | ||||
|  | ||||
| <%@ Import Namespace="Telerik.Web.Mvc.UI" %> | ||||
| <%@ Import Namespace="NzbDrone.Web.Models" %> | ||||
| <%@ Import Namespace="NzbDrone.Core.Repository" %> | ||||
|  | ||||
| <asp:Content ID="Content1" ContentPlaceHolderID="Scripts" runat="server"> | ||||
|     <script type="text/javascript"> | ||||
|         function onRowDataBound(e) { | ||||
|  | ||||
|             e.row.style.boarder = ""; | ||||
|  | ||||
|             if (e.dataItem.Level == 3) { | ||||
|                 e.row.style.backgroundColor = "#FFD700"; | ||||
|             } | ||||
|             else if (e.dataItem.Level == 4) { | ||||
|                 e.row.style.backgroundColor = "#FF7500"; | ||||
|             } | ||||
|             else if (e.dataItem.Level == 5) { | ||||
|                 e.row.style.backgroundColor = "black"; | ||||
|                 e.row.style.color = "red"; | ||||
|             } | ||||
|             //e.row.style.color = 'blue'; | ||||
|         } | ||||
|     </script> | ||||
| </asp:Content> | ||||
| <asp:Content ID="Content2" ContentPlaceHolderID="TitleContent" runat="server"> | ||||
|     Upcoming | ||||
| </asp:Content> | ||||
| <asp:Content ID="Menu" ContentPlaceHolderID="ActionMenu" runat="server"> | ||||
|     <% | ||||
|         Html.Telerik().Menu().Name("historyMenu").Items(items => | ||||
|                                                             { | ||||
|                                                                 items.Add().Text("Trim History").Action("Trim", "History"); | ||||
|                                                                 items.Add().Text("Purge History").Action("Purge", "History"); | ||||
|                                                             }).Render(); | ||||
|     %> | ||||
| </asp:Content> | ||||
| <asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server"> | ||||
|     <%Html.Telerik().Grid<UpcomingEpisodeModel>().Name("Yesterday").NoRecordsTemplate("No watched shows aired yesterday") | ||||
|                           .Columns(columns => | ||||
|                                        { | ||||
|                                            columns.Bound(c => c.SeriesName).Title("Series Name").Width(110); | ||||
|                                            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").Width(120); | ||||
|                                            columns.Bound(c => c.AirDate).Title("Air Date").Width(0); | ||||
|                                        }) | ||||
|                           .DetailView(detailView => detailView.ClientTemplate( | ||||
|                               "<div><b>Overview: </b><#= Overview #></div>" | ||||
|                               )) | ||||
|                           .DataBinding(data => data.Ajax().Select("_AjaxBindingYesterday", "Upcoming")) | ||||
|                           .Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.AirDate).Ascending()).Enabled(true)) | ||||
|                           //.Pageable(c => c.PageSize(20).Position(GridPagerPosition.Both).Style(GridPagerStyles.PageInput | GridPagerStyles.NextPreviousAndNumeric)) | ||||
|                           //.Filterable() | ||||
|                           //.ClientEvents(c => c.OnRowDataBound("onRowDataBound")) | ||||
|                           .Render(); | ||||
|     %> | ||||
|  | ||||
|     <%Html.Telerik().Grid<UpcomingEpisodeModel>().Name("Today").NoRecordsTemplate("No watched shows airing today.") | ||||
|                           .Columns(columns => | ||||
|                                        { | ||||
|                                            columns.Bound(c => c.SeriesName).Title("Series Name").Width(110); | ||||
|                                            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").Width(120); | ||||
|                                            columns.Bound(c => c.AirDate).Title("Air Date").Width(0); | ||||
|                                        }) | ||||
|                           .DetailView(detailView => detailView.ClientTemplate( | ||||
|                               "<div><b>Overview: </b><#= Overview #></div>" | ||||
|                               )) | ||||
|                           .DataBinding(data => data.Ajax().Select("_AjaxBindingToday", "Upcoming")) | ||||
|                           .Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.AirDate).Ascending()).Enabled(true)) | ||||
|                           //.Pageable(c => c.PageSize(20).Position(GridPagerPosition.Both).Style(GridPagerStyles.PageInput | GridPagerStyles.NextPreviousAndNumeric)) | ||||
|                           //.Filterable() | ||||
|                           //.ClientEvents(c => c.OnRowDataBound("onRowDataBound")) | ||||
|                           .Render(); | ||||
|     %> | ||||
|  | ||||
|     <%Html.Telerik().Grid<UpcomingEpisodeModel>().Name("Week").NoRecordsTemplate("No watched shows airing in the next week...") | ||||
|                           .Columns(columns => | ||||
|                                        { | ||||
|                                            columns.Bound(c => c.SeriesName).Title("Series Name").Width(110); | ||||
|                                            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").Width(120); | ||||
|                                            columns.Bound(c => c.AirDate).Title("Air Date").Width(0); | ||||
|                                        }) | ||||
|                           .DetailView(detailView => detailView.ClientTemplate( | ||||
|                               "<div><b>Overview: </b><#= Overview #></div>" | ||||
|                               )) | ||||
|                           .DataBinding(data => data.Ajax().Select("_AjaxBindingWeek", "Upcoming")) | ||||
|                           .Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.AirDate).Ascending()).Enabled(true)) | ||||
|                           //.Pageable(c => c.PageSize(20).Position(GridPagerPosition.Both).Style(GridPagerStyles.PageInput | GridPagerStyles.NextPreviousAndNumeric)) | ||||
|                           //.Filterable() | ||||
|                           //.ClientEvents(c => c.OnRowDataBound("onRowDataBound")) | ||||
|                           .Render(); | ||||
|     %> | ||||
| </asp:Content> | ||||
		Reference in New Issue
	
	Block a user