2013-06-22 08:24:24 +02:00
|
|
|
'use strict';
|
2013-05-15 03:17:24 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
define(
|
|
|
|
[
|
2013-08-22 02:56:25 +02:00
|
|
|
'app',
|
2013-08-21 23:47:39 +02:00
|
|
|
'Cells/NzbDroneCell',
|
2013-08-07 09:04:34 +02:00
|
|
|
'moment',
|
|
|
|
'Shared/FormatHelpers'
|
2013-08-22 02:56:25 +02:00
|
|
|
], function (App, NzbDroneCell, Moment, FormatHelpers) {
|
2013-08-21 23:47:39 +02:00
|
|
|
return NzbDroneCell.extend({
|
2013-05-15 03:17:24 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
className: 'episode-status-cell',
|
2013-05-20 23:42:20 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
render: function () {
|
|
|
|
this.$el.empty();
|
2013-05-20 23:05:48 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
if (this.model) {
|
2013-05-20 23:05:48 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
var icon;
|
2013-07-05 22:26:50 +02:00
|
|
|
var tooltip;
|
2013-05-20 23:05:48 +02:00
|
|
|
|
2013-07-26 07:19:50 +02:00
|
|
|
var hasAired = Moment(this.model.get('airDateUtc')).isBefore(Moment());
|
2013-07-17 05:25:42 +02:00
|
|
|
var hasFile = this.model.get('hasFile');
|
2013-07-17 01:54:45 +02:00
|
|
|
|
2013-07-17 05:25:42 +02:00
|
|
|
if (hasFile) {
|
2013-08-22 02:56:25 +02:00
|
|
|
var episodeFile = App.request(App.Reqres.GetEpisodeFileById, this.model.get('episodeFileId'));
|
|
|
|
|
|
|
|
this.listenTo(episodeFile, 'change', this._refresh);
|
|
|
|
|
2013-08-21 08:46:23 +02:00
|
|
|
var quality = episodeFile.get('quality');
|
|
|
|
var size = FormatHelpers.bytes(episodeFile.get('size'));
|
2013-08-07 09:04:34 +02:00
|
|
|
var title = 'Episode downloaded';
|
2013-07-19 17:41:08 +02:00
|
|
|
|
|
|
|
if (quality.proper) {
|
2013-08-07 09:04:34 +02:00
|
|
|
title += ' [PROPER] - {0}'.format(size);
|
|
|
|
this.$el.html('<span class="badge badge-info" title="{0}">{1}</span>'.format(title, quality.quality.name));
|
2013-07-19 17:41:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
2013-08-07 09:04:34 +02:00
|
|
|
title += ' - {0}'.format(size);
|
|
|
|
this.$el.html('<span class="badge badge-inverse" title="{0}">{1}</span>'.format(title, quality.quality.name));
|
2013-07-19 17:41:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
2013-05-20 23:06:01 +02:00
|
|
|
}
|
|
|
|
else {
|
2013-08-10 20:38:01 +02:00
|
|
|
if (this.model.get('downloading')) {
|
2013-08-10 21:11:58 +02:00
|
|
|
icon = 'icon-nd-downloading';
|
2013-08-10 20:38:01 +02:00
|
|
|
tooltip = 'Episode is downloading';
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!this.model.get('airDateUtc')) {
|
2013-08-10 21:11:58 +02:00
|
|
|
icon = 'icon-nd-tba';
|
2013-07-18 07:02:19 +02:00
|
|
|
tooltip = 'TBA';
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (hasAired) {
|
2013-08-10 21:11:58 +02:00
|
|
|
icon = 'icon-nd-missing';
|
2013-07-05 22:26:50 +02:00
|
|
|
tooltip = 'Episode missing from disk';
|
2013-06-25 01:41:59 +02:00
|
|
|
}
|
|
|
|
else {
|
2013-08-10 21:11:58 +02:00
|
|
|
icon = 'icon-nd-not-aired';
|
2013-07-05 22:26:50 +02:00
|
|
|
tooltip = 'Episode has not aired';
|
2013-06-25 01:41:59 +02:00
|
|
|
}
|
2013-05-20 23:06:01 +02:00
|
|
|
}
|
2013-07-18 07:52:13 +02:00
|
|
|
|
2013-07-05 22:26:50 +02:00
|
|
|
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, tooltip));
|
2013-05-20 23:06:01 +02:00
|
|
|
}
|
2013-05-20 23:05:48 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
return this;
|
2013-05-20 23:05:48 +02:00
|
|
|
}
|
2013-06-25 01:41:59 +02:00
|
|
|
});
|
2013-05-15 03:17:24 +02:00
|
|
|
});
|