diff --git a/NzbDrone.Api/AutomapperBootstraper.cs b/NzbDrone.Api/AutomapperBootstraper.cs index 3031bdcaf..393ecb18c 100644 --- a/NzbDrone.Api/AutomapperBootstraper.cs +++ b/NzbDrone.Api/AutomapperBootstraper.cs @@ -36,14 +36,6 @@ namespace NzbDrone.Api Mapper.CreateMap() .ForMember(dest => dest.QualityId, opt => opt.MapFrom(src => src.Id)); - - //Calendar - Mapper.CreateMap() - .ForMember(dest => dest.SeriesTitle, opt => opt.MapFrom(src => src.Series.Title)) - .ForMember(dest => dest.EpisodeTitle, opt => opt.MapFrom(src => src.Title)) - .ForMember(dest => dest.Start, opt => opt.MapFrom(src => src.AirDate)) - .ForMember(dest => dest.End, opt => opt.ResolveUsing()); - //Episode Mapper.CreateMap(); } diff --git a/NzbDrone.Api/Calendar/CalendarModule.cs b/NzbDrone.Api/Calendar/CalendarModule.cs index fc1b625ac..12bf573a1 100644 --- a/NzbDrone.Api/Calendar/CalendarModule.cs +++ b/NzbDrone.Api/Calendar/CalendarModule.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using AutoMapper; using Nancy; +using NzbDrone.Api.Episodes; using NzbDrone.Api.Extensions; using NzbDrone.Core.Tv; @@ -31,7 +32,7 @@ namespace NzbDrone.Api.Calendar if(queryEnd.HasValue) end = DateTime.Parse(queryEnd.Value); var episodes = _episodeService.EpisodesBetweenDates(start, end); - return Mapper.Map, List>(episodes).AsResponse(); + return Mapper.Map, List>(episodes).AsResponse(); } } } \ No newline at end of file diff --git a/NzbDrone.Api/Calendar/CalendarResource.cs b/NzbDrone.Api/Calendar/CalendarResource.cs deleted file mode 100644 index 787afeae4..000000000 --- a/NzbDrone.Api/Calendar/CalendarResource.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NzbDrone.Api.Calendar -{ - public class CalendarResource - { - public Int32 SeriesId { get; set; } - public String SeriesTitle { get; set; } - public Int32 EpisodeId { get; set; } - public String EpisodeTitle { get; set; } - public Int32 SeasonNumber { get; set; } - public Int32 EpisodeNumber { get; set; } - public DateTime Start { get; set; } - public DateTime End { get; set; } - public Int32 Status { get; set; } - public String Overview { get; set; } - } -} diff --git a/NzbDrone.Api/Episodes/EpisodeResource.cs b/NzbDrone.Api/Episodes/EpisodeResource.cs index d313ef1c3..409c0fe50 100644 --- a/NzbDrone.Api/Episodes/EpisodeResource.cs +++ b/NzbDrone.Api/Episodes/EpisodeResource.cs @@ -28,5 +28,6 @@ namespace NzbDrone.Api.Episodes public DateTime? EndTime { get; set; } public DateTime? GrabDate { get; set; } public PostDownloadStatusType PostDownloadStatus { get; set; } + public Core.Tv.Series Series { get; set; } } } diff --git a/NzbDrone.Api/NzbDrone.Api.csproj b/NzbDrone.Api/NzbDrone.Api.csproj index c410dc1a9..d718ddc63 100644 --- a/NzbDrone.Api/NzbDrone.Api.csproj +++ b/NzbDrone.Api/NzbDrone.Api.csproj @@ -84,7 +84,6 @@ - diff --git a/UI/Calendar/CalendarCollection.js b/UI/Calendar/CalendarCollection.js index f88459e09..047638819 100644 --- a/UI/Calendar/CalendarCollection.js +++ b/UI/Calendar/CalendarCollection.js @@ -1,8 +1,8 @@ "use strict"; -define(['app', 'Calendar/CalendarModel'], function () { +define(['app', 'Series/EpisodeModel'], function () { NzbDrone.Calendar.CalendarCollection = Backbone.Collection.extend({ url : NzbDrone.Constants.ApiRoot + '/calendar', - model : NzbDrone.Calendar.CalendarModel, + model : NzbDrone.Series.EpisodeModel, comparator: function (model) { return model.get('start'); } diff --git a/UI/Calendar/CalendarCollectionView.js b/UI/Calendar/CalendarCollectionView.js index 04c37b561..be82b09ec 100644 --- a/UI/Calendar/CalendarCollectionView.js +++ b/UI/Calendar/CalendarCollectionView.js @@ -36,7 +36,7 @@ define(['app', 'Calendar/CalendarItemView'], function () { element.popover({ title : '{seriesTitle} - {season}x{episode} - {episodeTitle}'.assign({ - seriesTitle : event.seriesTitle, + seriesTitle : event.title, season : event.seasonNumber, episode : event.episodeNumber.pad(2), episodeTitle: event.episodeTitle @@ -65,6 +65,14 @@ define(['app', 'Calendar/CalendarItemView'], function () { bbView.calendar.fetch({ data : { start: startDate, end: endDate }, success: function (calendarCollection) { + _.each(calendarCollection.models, function(element) { + var episodeTitle = element.get('title'); + var seriesTitle = element.get('series').title; + + element.set('title', seriesTitle); + element.set('episodeTitle', episodeTitle); + }); + callback(calendarCollection.toJSON()); } }); diff --git a/UI/Calendar/CalendarItemTemplate.html b/UI/Calendar/CalendarItemTemplate.html index 1f1278054..678dd9b0c 100644 --- a/UI/Calendar/CalendarItemTemplate.html +++ b/UI/Calendar/CalendarItemTemplate.html @@ -3,6 +3,6 @@

{{day}}

{{month}}

-

{{seriesTitle}}

+

{{series.title}}

{{startTime}} {{bestDateString}}{{seasonNumber}}x{{paddedEpisodeNumber}}
{{episodeTitle}}

\ No newline at end of file diff --git a/UI/Calendar/CalendarModel.js b/UI/Calendar/CalendarModel.js deleted file mode 100644 index e0bf71447..000000000 --- a/UI/Calendar/CalendarModel.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict"; -define(['app'], function () { - NzbDrone.Calendar.CalendarModel = Backbone.Model.extend({ - mutators: { - title : function () { - return this.get('seriesTitle'); - }, - allDay : function () { - return false; - }, - day : function () { - return Date.create(this.get('start')).format('{dd}'); - }, - month : function () { - return Date.create(this.get('start')).format('{MON}'); - }, - startTime : function () { - var start = Date.create(this.get('start')); - - if (start.format('{mm}') === '00') { - return start.format('{h}{tt}'); - } - - return start.format('{h}.{mm}{tt}'); - }, - paddedEpisodeNumber: function () { - return this.get('episodeNumber'); - }, - statusLevel : function () { - var status = this.get('status'); - var currentTime = Date.create(); - var start = Date.create(this.get('start')); - var end = Date.create(this.get('end')); - - if (currentTime.isBetween(start, end)) { - return 'warning'; - } - - if (start.isBefore(currentTime) || status === 'Missing') { - return 'danger'; - } - - if (status === 'Ready') { - return 'success'; - } - - return 'primary'; - }, - bestDateString : function () { - return bestDateString(this.get('start')); - } - }, - defaults: { - status: 0 - } - }); -}); diff --git a/UI/Series/EpisodeModel.js b/UI/Series/EpisodeModel.js index 46b6aab66..7c393c51b 100644 --- a/UI/Series/EpisodeModel.js +++ b/UI/Series/EpisodeModel.js @@ -8,11 +8,56 @@ define(['app'], function () { }, paddedEpisodeNumber: function () { return this.get('episodeNumber'); + }, + allDay : function () { + return false; + }, + day : function () { + return Date.create(this.get('airDate')).format('{dd}'); + }, + month : function () { + return Date.create(this.get('airDate')).format('{MON}'); + }, + startTime : function () { + var start = Date.create(this.get('airDate')); + + if (start.format('{mm}') === '00') { + return start.format('{h}{tt}'); + } + + return start.format('{h}.{mm}{tt}'); + }, + start : function () { + return this.get('airDate'); + }, + end : function () { + return this.get('endTime'); + }, + statusLevel : function () { + var status = this.get('status'); + var currentTime = Date.create(); + var start = Date.create(this.get('start')); + var end = Date.create(this.get('end')); + + if (currentTime.isBetween(start, end)) { + return 'warning'; + } + + if (start.isBefore(currentTime) || status === 'Missing') { + return 'danger'; + } + + if (status === 'Ready') { + return 'success'; + } + + return 'primary'; } }, defaults: { - seasonNumber: 0 + seasonNumber: 0, + status: 0 } }); });