Files
Readarr/src/UI/Cells/EpisodeStatusCell.js
Taloth Saldono d416dd4177 Repurposed the Missing page to include filter options and display episodes that haven't reached cutoff.
--HG--
rename : src/NzbDrone.Api/Missing/MissingModule.cs => src/NzbDrone.Api/Wanted/MissingModule.cs
rename : src/UI/Missing/ControlsColumnTemplate.html => src/UI/Wanted/ControlsColumnTemplate.html
rename : src/UI/Missing/MissingCollection.js => src/UI/Wanted/Missing/MissingCollection.js
rename : src/UI/Missing/MissingLayout.js => src/UI/Wanted/WantedLayout.js
rename : src/UI/Missing/MissingLayoutTemplate.html => src/UI/Wanted/WantedLayoutTemplate.html
extra : source : 2c76f3e423d39446f3bd7799b7344d7be63c70f5
2014-02-22 16:21:40 -08:00

110 lines
4.4 KiB
JavaScript

'use strict';
define(
[
'reqres',
'Cells/NzbDroneCell',
'History/Queue/QueueCollection',
'moment',
'Shared/FormatHelpers'
], function (reqres, NzbDroneCell, QueueCollection, Moment, FormatHelpers) {
return NzbDroneCell.extend({
className: 'episode-status-cell',
render: function () {
this.listenTo(QueueCollection, 'sync', this._renderCell);
this._renderCell();
return this;
},
_renderCell: function () {
this.$el.empty();
if (this.model) {
var icon;
var tooltip;
var hasAired = Moment(this.model.get('airDateUtc')).isBefore(Moment());
var hasFile = this.model.get('hasFile');
if (hasFile && reqres.hasHandler(reqres.Requests.GetEpisodeFileById)) {
var episodeFile = reqres.request(reqres.Requests.GetEpisodeFileById, this.model.get('episodeFileId'));
this.listenTo(episodeFile, 'change', this._refresh);
var quality = episodeFile.get('quality');
var size = FormatHelpers.bytes(episodeFile.get('size'));
var title = 'Episode downloaded';
if (quality.proper) {
title += ' [PROPER] - {0}'.format(size);
this.$el.html('<span class="badge badge-info" title="{0}">{1}</span>'.format(title, quality.quality.name));
}
else {
title += ' - {0}'.format(size);
this.$el.html('<span class="badge badge-inverse" title="{0}">{1}</span>'.format(title, quality.quality.name));
}
return;
}
else if (hasFile && this.model.get('episodeFile')) {
var episodeFile = this.model.get('episodeFile');
var quality = episodeFile.quality;
var size = FormatHelpers.bytes(episodeFile.size);
var title = 'Episode downloaded';
if (quality.proper) {
title += ' [PROPER] - {0}'.format(size);
this.$el.html('<span class="badge badge-info" title="{0}">{1}</span>'.format(title, quality.quality.name));
}
else {
title += ' - {0}'.format(size);
this.$el.html('<span class="badge badge-inverse" title="{0}">{1}</span>'.format(title, quality.quality.name));
}
return;
}
else {
var model = this.model;
var downloading = QueueCollection.findEpisode(model.get('id'));
if (downloading) {
var progress = 100 - (downloading.get('sizeleft') / downloading.get('size') * 100);
this.$el.html('<div class="progress progress-purple" title="Episode is downloading - {0}%" data-container="body">'.format(progress.toFixed(1)) +
'<div class="bar" style="width: {0}%;"></div></div>'.format(progress));
return;
}
else if (this.model.get('downloading')) {
icon = 'icon-nd-downloading';
tooltip = 'Episode is downloading';
}
else if (!this.model.get('airDateUtc')) {
icon = 'icon-nd-tba';
tooltip = 'TBA';
}
else if (hasAired) {
icon = 'icon-nd-missing';
tooltip = 'Episode missing from disk';
}
else {
icon = 'icon-nd-not-aired';
tooltip = 'Episode has not aired';
}
}
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, tooltip));
}
}
});
});