1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-26 01:38:24 +00:00

Calendar uses start and end date

This commit is contained in:
Mark McDowall 2013-02-25 19:30:24 -08:00
parent 94daf08361
commit 0399b18357
4 changed files with 33 additions and 24 deletions

View file

@ -22,19 +22,17 @@ public CalendarModule(EpisodeService episodeService)
private Response Calendar()
{
var year = DateTime.Now.Year;
//Todo: This is just for testing
//var month = DateTime.Now.Month;
var month = 1;
var start = DateTime.Today;
var end = DateTime.Today.AddDays(7);
var yearQuery = Request.Query.Year;
var monthQuery = Request.Query.Month;
var queryStart = Request.Query.Start;
var queryEnd = Request.Query.End;
if (yearQuery.HasValue) year = Convert.ToInt32(yearQuery.Value);
if (queryStart.HasValue) start = DateTime.Parse(queryStart.Value);
if(monthQuery.HasValue) month = Convert.ToInt32(monthQuery.Value);
if(queryEnd.HasValue) end = DateTime.Parse(queryEnd.Value);
var episodes = _episodeService.GetEpisodesAiredInMonth(year, month);
var episodes = _episodeService.EpisodesBetweenDates(start, end);
return Mapper.Map<List<Episode>, List<CalendarResource>>(episodes).AsResponse();
}
}

View file

@ -1,3 +1,3 @@
<div id="calendar">
</div>
<div id="fakeContainer"></div>
<div id="upcomingContainer"></div>

View file

@ -3,7 +3,7 @@
define(['app', 'Calendar/CalendarItemView'], function (app) {
NzbDrone.Calendar.CalendarCollectionView = Backbone.Marionette.CompositeView.extend({
itemView: NzbDrone.Calendar.CalendarItemView,
itemViewContainer: '#fakeContainer',
itemViewContainer: '#upcomingContainer',
template: 'Calendar/CalendarCollectionTemplate',
ui: {
@ -12,25 +12,39 @@ define(['app', 'Calendar/CalendarItemView'], function (app) {
initialize: function (context, collection) {
this.collection = collection;
this.calendar = new NzbDrone.Calendar.CalendarCollection();
},
onRender: function() {
onCompositeCollectionRendered: function() {
$(this.ui.calendar).fullCalendar({
allDayDefault: false,
//ignoreTimezone: false,
weekMode: 'variable',
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek',
ignoreTimezone: false
right: 'month,basicWeek'
},
buttonText: {
prev: '<i class="icon-arrow-left"></i>',
next: '<i class="icon-arrow-right"></i>'
}
},
events: this.getEvents
});
$(this.ui.calendar).fullCalendar('addEventSource', this.collection.toJSON());
NzbDrone.Calendar.CalendarCollectionView.Instance = this;
$(this.ui.calendar).fullCalendar('addEventSource', this.calendar.toJSON());
},
addAll: function(){
$(this.ui.calendar).fullCalendar('addEventSource', this.collection.toJSON());
getEvents: function(start, end, callback){
var bbView = NzbDrone.Calendar.CalendarCollectionView.Instance;
bbView.calendar.fetch({
data:{ start: Date.create(start).format(Date.ISO8601_DATETIME), end: Date.create(end).format(Date.ISO8601_DATETIME) },
success:function (calendarCollection) {
callback(calendarCollection.toJSON());
}
});
}
});
});

View file

@ -31,7 +31,7 @@ public interface IEpisodeService
void SetPostDownloadStatus(List<int> episodeIds, PostDownloadStatusType postDownloadStatus);
void UpdateEpisodes(List<Episode> episodes);
Episode GetEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber);
List<Episode> GetEpisodesAiredInMonth(int year, int month);
List<Episode> EpisodesBetweenDates(DateTime start, DateTime end);
}
public class EpisodeService : IEpisodeService, IHandle<EpisodeGrabbedEvent>
@ -337,12 +337,9 @@ public virtual Episode GetEpisodeBySceneNumbering(int seriesId, int seasonNumber
return _episodeRepository.GetEpisodeBySceneNumbering(seriesId, seasonNumber, episodeNumber);
}
public List<Episode> GetEpisodesAiredInMonth(int year, int month)
public List<Episode> EpisodesBetweenDates(DateTime start, DateTime end)
{
var firstDay = new DateTime(year, month, 1);
var lastDay = firstDay.AddMonths(1).AddDays(-1);
return _episodeRepository.EpisodesBetweenDates(firstDay, lastDay);
return _episodeRepository.EpisodesBetweenDates(start.ToUniversalTime(), end.ToUniversalTime());
}
public void Handle(EpisodeGrabbedEvent message)