|
|
|
@ -7,13 +7,13 @@ define(
|
|
|
|
|
'marionette',
|
|
|
|
|
'moment',
|
|
|
|
|
'Calendar/Collection',
|
|
|
|
|
'System/StatusModel',
|
|
|
|
|
'Shared/UiSettingsModel',
|
|
|
|
|
'History/Queue/QueueCollection',
|
|
|
|
|
'Config',
|
|
|
|
|
'Mixins/backbone.signalr.mixin',
|
|
|
|
|
'fullcalendar',
|
|
|
|
|
'jquery.easypiechart'
|
|
|
|
|
], function ($, vent, Marionette, moment, CalendarCollection, StatusModel, QueueCollection, Config) {
|
|
|
|
|
], function ($, vent, Marionette, moment, CalendarCollection, UiSettings, QueueCollection, Config) {
|
|
|
|
|
|
|
|
|
|
return Marionette.ItemView.extend({
|
|
|
|
|
storageKey: 'calendar.view',
|
|
|
|
@ -44,39 +44,45 @@ define(
|
|
|
|
|
this.$(element).addClass(event.statusLevel);
|
|
|
|
|
this.$(element).children('.fc-event-inner').addClass(event.statusLevel);
|
|
|
|
|
|
|
|
|
|
if (event.progress > 0) {
|
|
|
|
|
this.$(element).find('.fc-event-time')
|
|
|
|
|
.after('<span class="chart pull-right" data-percent="{0}"></span>'.format(event.progress));
|
|
|
|
|
|
|
|
|
|
this.$(element).find('.chart').easyPieChart({
|
|
|
|
|
barColor : '#ffffff',
|
|
|
|
|
trackColor: false,
|
|
|
|
|
scaleColor: false,
|
|
|
|
|
lineWidth : 2,
|
|
|
|
|
size : 14,
|
|
|
|
|
animate : false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.$(element).find('.chart').tooltip({
|
|
|
|
|
title: 'Episode is downloading - {0}% {1}'.format(event.progress.toFixed(1), event.releaseTitle),
|
|
|
|
|
container: 'body'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (event.downloading) {
|
|
|
|
|
var progress = 100 - (event.downloading.get('sizeleft') / event.downloading.get('size') * 100);
|
|
|
|
|
var releaseTitle = event.downloading.get('title');
|
|
|
|
|
var estimatedCompletionTime = moment(event.downloading.get('estimatedCompletionTime')).fromNow();
|
|
|
|
|
|
|
|
|
|
if (event.downloading.get('status').toLocaleLowerCase() === 'pending') {
|
|
|
|
|
this.$(element).find('.fc-event-time')
|
|
|
|
|
.after('<span class="pending pull-right"><i class="icon-time"></i></span>');
|
|
|
|
|
|
|
|
|
|
if (event.pending) {
|
|
|
|
|
this.$(element).find('.fc-event-time')
|
|
|
|
|
.after('<span class="pending pull-right"><i class="icon-time"></i></span>');
|
|
|
|
|
this.$(element).find('.pending').tooltip({
|
|
|
|
|
title: 'Release will be processed {0}'.format(estimatedCompletionTime),
|
|
|
|
|
container: 'body'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.$(element).find('.pending').tooltip({
|
|
|
|
|
title: 'Release will be processed {0}'.format(event.pending),
|
|
|
|
|
container: 'body'
|
|
|
|
|
});
|
|
|
|
|
else {
|
|
|
|
|
this.$(element).find('.fc-event-time')
|
|
|
|
|
.after('<span class="chart pull-right" data-percent="{0}"></span>'.format(progress));
|
|
|
|
|
|
|
|
|
|
this.$(element).find('.chart').easyPieChart({
|
|
|
|
|
barColor : '#ffffff',
|
|
|
|
|
trackColor: false,
|
|
|
|
|
scaleColor: false,
|
|
|
|
|
lineWidth : 2,
|
|
|
|
|
size : 14,
|
|
|
|
|
animate : false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.$(element).find('.chart').tooltip({
|
|
|
|
|
title: 'Episode is downloading - {0}% {1}'.format(progress.toFixed(1), releaseTitle),
|
|
|
|
|
container: 'body'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_getEvents: function (view) {
|
|
|
|
|
var start = moment(view.visStart).toISOString();
|
|
|
|
|
var end = moment(view.visEnd).toISOString();
|
|
|
|
|
var start = view.start.toISOString();
|
|
|
|
|
var end = view.end.toISOString();
|
|
|
|
|
|
|
|
|
|
this.$el.fullCalendar('removeEvents');
|
|
|
|
|
|
|
|
|
@ -99,13 +105,10 @@ define(
|
|
|
|
|
|
|
|
|
|
var event = {
|
|
|
|
|
title : seriesTitle,
|
|
|
|
|
start : start,
|
|
|
|
|
end : end,
|
|
|
|
|
start : moment(start),
|
|
|
|
|
end : moment(end),
|
|
|
|
|
allDay : false,
|
|
|
|
|
statusLevel : self._getStatusLevel(model, end),
|
|
|
|
|
progress : self._getDownloadProgress(model),
|
|
|
|
|
pending : self._getPendingInfo(model),
|
|
|
|
|
releaseTitle: self._getReleaseTitle(model),
|
|
|
|
|
downloading : QueueCollection.findEpisode(model.get('id')),
|
|
|
|
|
model : model
|
|
|
|
|
};
|
|
|
|
@ -153,47 +156,12 @@ define(
|
|
|
|
|
this._setEventData(this.collection);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_getDownloadProgress: function (element) {
|
|
|
|
|
var downloading = QueueCollection.findEpisode(element.get('id'));
|
|
|
|
|
|
|
|
|
|
if (!downloading) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 100 - (downloading.get('sizeleft') / downloading.get('size') * 100);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_getPendingInfo: function (element) {
|
|
|
|
|
var pending = QueueCollection.findEpisode(element.get('id'));
|
|
|
|
|
|
|
|
|
|
if (!pending || pending.get('status').toLocaleLowerCase() !== 'pending') {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return moment(pending.get('estimatedCompletionTime')).fromNow();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_getReleaseTitle: function (element) {
|
|
|
|
|
var downloading = QueueCollection.findEpisode(element.get('id'));
|
|
|
|
|
|
|
|
|
|
if (!downloading) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return downloading.get('title');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_getOptions: function () {
|
|
|
|
|
var options = {
|
|
|
|
|
allDayDefault : false,
|
|
|
|
|
ignoreTimezone: false,
|
|
|
|
|
weekMode : 'variable',
|
|
|
|
|
firstDay : StatusModel.get('startOfWeek'),
|
|
|
|
|
timeFormat : 'h(:mm)tt',
|
|
|
|
|
buttonText : {
|
|
|
|
|
prev: '<i class="icon-arrow-left"></i>',
|
|
|
|
|
next: '<i class="icon-arrow-right"></i>'
|
|
|
|
|
},
|
|
|
|
|
firstDay : UiSettings.get('firstDayOfWeek'),
|
|
|
|
|
timeFormat : 'h(:mm)a',
|
|
|
|
|
viewRender : this._viewRender.bind(this),
|
|
|
|
|
eventRender : this._eventRender.bind(this),
|
|
|
|
|
eventClick : function (event) {
|
|
|
|
@ -204,12 +172,6 @@ define(
|
|
|
|
|
if ($(window).width() < 768) {
|
|
|
|
|
options.defaultView = Config.getValue(this.storageKey, 'basicDay');
|
|
|
|
|
|
|
|
|
|
options.titleFormat = {
|
|
|
|
|
month: 'MMM yyyy', // September 2009
|
|
|
|
|
week: 'MMM d[ yyyy]{ \'—\'[ MMM] d yyyy}', // Sep 7 - 13 2009
|
|
|
|
|
day: 'ddd, MMM d, yyyy' // Tuesday, Sep 8, 2009
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
options.header = {
|
|
|
|
|
left : 'prev,next today',
|
|
|
|
|
center: 'title',
|
|
|
|
@ -220,12 +182,6 @@ define(
|
|
|
|
|
else {
|
|
|
|
|
options.defaultView = Config.getValue(this.storageKey, 'basicWeek');
|
|
|
|
|
|
|
|
|
|
options.titleFormat = {
|
|
|
|
|
month: 'MMM yyyy', // September 2009
|
|
|
|
|
week: 'MMM d[ yyyy]{ \'—\'[ MMM] d yyyy}', // Sep 7 - 13 2009
|
|
|
|
|
day: 'dddd, MMM d, yyyy' // Tues, Sep 8, 2009
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
options.header = {
|
|
|
|
|
left : 'prev,next today',
|
|
|
|
|
center: 'title',
|
|
|
|
@ -233,6 +189,22 @@ define(
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
options.titleFormat = {
|
|
|
|
|
month : 'MMMM YYYY',
|
|
|
|
|
week : UiSettings.get('shortDateFormat'),
|
|
|
|
|
day : UiSettings.get('longDateFormat')
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
options.columnFormat = {
|
|
|
|
|
month : 'ddd', // Mon
|
|
|
|
|
week : UiSettings.get('calendarWeekColumnHeader'),
|
|
|
|
|
day : 'dddd' // Monday
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
options.timeFormat = {
|
|
|
|
|
'default': UiSettings.get('timeFormat')
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return options;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|