Sonarr/src/UI/Activity/Queue/QueueStatusCell.js

81 lines
2.7 KiB
JavaScript
Raw Normal View History

2015-02-03 01:18:45 +00:00
var Marionette = require('marionette');
var NzbDroneCell = require('../../Cells/NzbDroneCell');
2013-10-03 21:06:52 +00:00
2015-02-03 01:18:45 +00:00
module.exports = NzbDroneCell.extend({
className : 'queue-status-cell',
template : 'Activity/Queue/QueueStatusCellTemplate',
2015-02-13 21:03:50 +00:00
render : function() {
2015-02-03 01:18:45 +00:00
this.$el.empty();
2015-02-13 21:03:50 +00:00
if (this.cellValue) {
2015-02-03 01:18:45 +00:00
var status = this.cellValue.get('status').toLowerCase();
var trackedDownloadStatus = this.cellValue.has('trackedDownloadStatus') ? this.cellValue.get('trackedDownloadStatus').toLowerCase() : 'ok';
var icon = 'icon-nd-downloading';
var title = 'Downloading';
var itemTitle = this.cellValue.get('title');
var content = itemTitle;
2015-02-13 21:03:50 +00:00
if (status === 'paused') {
2015-02-03 01:18:45 +00:00
icon = 'icon-pause';
title = 'Paused';
}
2015-02-13 21:03:50 +00:00
if (status === 'queued') {
2015-02-03 01:18:45 +00:00
icon = 'icon-cloud';
title = 'Queued';
}
2015-02-13 21:03:50 +00:00
if (status === 'completed') {
2015-02-03 01:18:45 +00:00
icon = 'icon-inbox';
title = 'Downloaded';
}
2015-02-13 21:03:50 +00:00
if (status === 'pending') {
2015-02-03 01:18:45 +00:00
icon = 'icon-time';
title = 'Pending';
}
2015-02-13 21:03:50 +00:00
if (status === 'failed') {
2015-02-03 01:18:45 +00:00
icon = 'icon-nd-download-failed';
title = 'Download failed';
}
2015-02-13 21:03:50 +00:00
if (status === 'warning') {
2015-02-03 01:18:45 +00:00
icon = 'icon-nd-download-warning';
title = 'Download warning: check download client for more details';
}
2015-02-13 21:03:50 +00:00
if (trackedDownloadStatus === 'warning') {
2015-02-03 01:18:45 +00:00
icon += ' icon-nd-warning';
2015-02-13 21:03:50 +00:00
2015-02-03 01:18:45 +00:00
this.templateFunction = Marionette.TemplateCache.get(this.template);
content = this.templateFunction(this.cellValue.toJSON());
}
2015-02-13 21:03:50 +00:00
if (trackedDownloadStatus === 'error') {
if (status === 'completed') {
2015-02-03 01:18:45 +00:00
icon = 'icon-nd-import-failed';
title = 'Import failed: ' + itemTitle;
2015-02-13 21:03:50 +00:00
} else {
2015-02-03 01:18:45 +00:00
icon = 'icon-nd-download-failed';
title = 'Download failed';
}
2015-02-13 21:03:50 +00:00
2015-02-03 01:18:45 +00:00
this.templateFunction = Marionette.TemplateCache.get(this.template);
content = this.templateFunction(this.cellValue.toJSON());
2013-10-03 21:06:52 +00:00
}
2015-02-13 21:03:50 +00:00
2015-02-03 01:18:45 +00:00
this.$el.html('<i class="{0}"></i>'.format(icon));
this.$el.popover({
content : content,
html : true,
trigger : 'hover',
title : title,
placement : 'right',
container : this.$el
});
}
return this;
}
});