1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/UI/Cells/EpisodeStatusCell.js

70 lines
2.4 KiB
JavaScript
Raw Normal View History

2013-06-22 09:24:24 +03:00
'use strict';
define(
[
2013-08-22 00:47:39 +03:00
'Cells/NzbDroneCell',
'moment',
'Shared/FormatHelpers'
2013-08-22 00:47:39 +03:00
], function (NzbDroneCell, Moment, FormatHelpers) {
return NzbDroneCell.extend({
className: 'episode-status-cell',
2013-05-21 00:42:20 +03:00
render: function () {
this.$el.empty();
2013-05-21 00:05:48 +03:00
if (this.model) {
2013-05-21 00:05:48 +03:00
var icon;
2013-07-05 23:26:50 +03:00
var tooltip;
2013-05-21 00:05:48 +03:00
2013-07-26 08:19:50 +03:00
var hasAired = Moment(this.model.get('airDateUtc')).isBefore(Moment());
2013-07-17 06:25:42 +03:00
var hasFile = this.model.get('hasFile');
2013-07-17 02:54:45 +03:00
2013-07-17 06:25:42 +03:00
if (hasFile) {
var episodeFile = this.model.get('episodeFile');
2013-08-21 09:46:23 +03:00
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 this;
2013-05-21 00:06:01 +03:00
}
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';
2013-07-05 23:26:50 +03:00
tooltip = 'Episode missing from disk';
}
else {
icon = 'icon-nd-not-aired';
2013-07-05 23:26:50 +03:00
tooltip = 'Episode has not aired';
}
2013-05-21 00:06:01 +03:00
}
2013-07-05 23:26:50 +03:00
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, tooltip));
2013-05-21 00:06:01 +03:00
}
2013-05-21 00:05:48 +03:00
return this;
2013-05-21 00:05:48 +03:00
}
});
});