mirror of
https://github.com/lidarr/Lidarr
synced 2025-03-04 02:18:06 +00:00
Calendar uses start and end date
This commit is contained in:
parent
94daf08361
commit
0399b18357
4 changed files with 33 additions and 24 deletions
|
@ -22,19 +22,17 @@ namespace NzbDrone.Api.Calendar
|
||||||
|
|
||||||
private Response Calendar()
|
private Response Calendar()
|
||||||
{
|
{
|
||||||
var year = DateTime.Now.Year;
|
var start = DateTime.Today;
|
||||||
//Todo: This is just for testing
|
var end = DateTime.Today.AddDays(7);
|
||||||
//var month = DateTime.Now.Month;
|
|
||||||
var month = 1;
|
|
||||||
|
|
||||||
var yearQuery = Request.Query.Year;
|
var queryStart = Request.Query.Start;
|
||||||
var monthQuery = Request.Query.Month;
|
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();
|
return Mapper.Map<List<Episode>, List<CalendarResource>>(episodes).AsResponse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<div id="calendar">
|
<div id="calendar">
|
||||||
</div>
|
</div>
|
||||||
<div id="fakeContainer"></div>
|
<div id="upcomingContainer"></div>
|
|
@ -3,7 +3,7 @@
|
||||||
define(['app', 'Calendar/CalendarItemView'], function (app) {
|
define(['app', 'Calendar/CalendarItemView'], function (app) {
|
||||||
NzbDrone.Calendar.CalendarCollectionView = Backbone.Marionette.CompositeView.extend({
|
NzbDrone.Calendar.CalendarCollectionView = Backbone.Marionette.CompositeView.extend({
|
||||||
itemView: NzbDrone.Calendar.CalendarItemView,
|
itemView: NzbDrone.Calendar.CalendarItemView,
|
||||||
itemViewContainer: '#fakeContainer',
|
itemViewContainer: '#upcomingContainer',
|
||||||
template: 'Calendar/CalendarCollectionTemplate',
|
template: 'Calendar/CalendarCollectionTemplate',
|
||||||
|
|
||||||
ui: {
|
ui: {
|
||||||
|
@ -12,25 +12,39 @@ define(['app', 'Calendar/CalendarItemView'], function (app) {
|
||||||
|
|
||||||
initialize: function (context, collection) {
|
initialize: function (context, collection) {
|
||||||
this.collection = collection;
|
this.collection = collection;
|
||||||
|
this.calendar = new NzbDrone.Calendar.CalendarCollection();
|
||||||
},
|
},
|
||||||
onRender: function() {
|
onCompositeCollectionRendered: function() {
|
||||||
$(this.ui.calendar).fullCalendar({
|
$(this.ui.calendar).fullCalendar({
|
||||||
|
allDayDefault: false,
|
||||||
|
//ignoreTimezone: false,
|
||||||
|
weekMode: 'variable',
|
||||||
header: {
|
header: {
|
||||||
left: 'prev,next today',
|
left: 'prev,next today',
|
||||||
center: 'title',
|
center: 'title',
|
||||||
right: 'month,basicWeek',
|
right: 'month,basicWeek'
|
||||||
ignoreTimezone: false
|
|
||||||
},
|
},
|
||||||
buttonText: {
|
buttonText: {
|
||||||
prev: '<i class="icon-arrow-left"></i>',
|
prev: '<i class="icon-arrow-left"></i>',
|
||||||
next: '<i class="icon-arrow-right"></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(){
|
getEvents: function(start, end, callback){
|
||||||
$(this.ui.calendar).fullCalendar('addEventSource', this.collection.toJSON());
|
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());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -31,7 +31,7 @@ namespace NzbDrone.Core.Tv
|
||||||
void SetPostDownloadStatus(List<int> episodeIds, PostDownloadStatusType postDownloadStatus);
|
void SetPostDownloadStatus(List<int> episodeIds, PostDownloadStatusType postDownloadStatus);
|
||||||
void UpdateEpisodes(List<Episode> episodes);
|
void UpdateEpisodes(List<Episode> episodes);
|
||||||
Episode GetEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber);
|
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>
|
public class EpisodeService : IEpisodeService, IHandle<EpisodeGrabbedEvent>
|
||||||
|
@ -337,12 +337,9 @@ namespace NzbDrone.Core.Tv
|
||||||
return _episodeRepository.GetEpisodeBySceneNumbering(seriesId, seasonNumber, episodeNumber);
|
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);
|
return _episodeRepository.EpisodesBetweenDates(start.ToUniversalTime(), end.ToUniversalTime());
|
||||||
var lastDay = firstDay.AddMonths(1).AddDays(-1);
|
|
||||||
|
|
||||||
return _episodeRepository.EpisodesBetweenDates(firstDay, lastDay);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(EpisodeGrabbedEvent message)
|
public void Handle(EpisodeGrabbedEvent message)
|
||||||
|
|
Loading…
Add table
Reference in a new issue