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';
2015-02-21 02:20:31 +00:00
var icon = 'icon-sonarr-downloading';
2015-02-03 01:18:45 +00:00
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-21 02:20:31 +00:00
icon = 'icon-sonarr-paused';
2015-02-03 01:18:45 +00:00
title = 'Paused';
}
2015-02-13 21:03:50 +00:00
if (status === 'queued') {
2015-02-21 02:20:31 +00:00
icon = 'icon-sonarr-queued';
2015-02-03 01:18:45 +00:00
title = 'Queued';
}
2015-02-13 21:03:50 +00:00
if (status === 'completed') {
2015-02-21 02:20:31 +00:00
icon = 'icon-sonarr-downloaded';
2015-02-03 01:18:45 +00:00
title = 'Downloaded';
}
2015-02-13 21:03:50 +00:00
if (status === 'pending') {
2015-02-21 02:20:31 +00:00
icon = 'icon-sonarr-pending';
2015-02-03 01:18:45 +00:00
title = 'Pending';
}
2015-02-13 21:03:50 +00:00
if (status === 'failed') {
2015-02-21 02:20:31 +00:00
icon = 'icon-sonarr-download-failed';
2015-02-03 01:18:45 +00:00
title = 'Download failed';
}
2015-02-13 21:03:50 +00:00
if (status === 'warning') {
2015-02-21 02:20:31 +00:00
icon = 'icon-sonarr-download-warning';
2015-02-03 01:18:45 +00:00
title = 'Download warning: check download client for more details';
}
2015-02-13 21:03:50 +00:00
if (trackedDownloadStatus === 'warning') {
2015-02-21 02:20:31 +00:00
icon += ' icon-sonarr-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-21 02:20:31 +00:00
icon = 'icon-sonarr-import-failed';
2015-02-03 01:18:45 +00:00
title = 'Import failed: ' + itemTitle;
2015-02-13 21:03:50 +00:00
} else {
2015-02-21 02:20:31 +00:00
icon = 'icon-sonarr-download-failed';
2015-02-03 01:18:45 +00:00
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;
}
});