2013-10-03 21:06:52 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
define(
|
|
|
|
[
|
2014-09-13 23:13:00 +00:00
|
|
|
'marionette',
|
2013-10-03 21:06:52 +00:00
|
|
|
'Cells/NzbDroneCell'
|
2014-09-13 23:13:00 +00:00
|
|
|
], function (Marionette, NzbDroneCell) {
|
2013-10-03 21:06:52 +00:00
|
|
|
return NzbDroneCell.extend({
|
|
|
|
|
2014-09-13 23:13:00 +00:00
|
|
|
className : 'queue-status-cell',
|
2014-10-12 07:29:09 +00:00
|
|
|
template : 'Activity/Queue/QueueStatusCellTemplate',
|
2013-10-03 21:06:52 +00:00
|
|
|
|
|
|
|
render: function () {
|
|
|
|
this.$el.empty();
|
|
|
|
|
|
|
|
if (this.cellValue) {
|
|
|
|
var status = this.cellValue.get('status').toLowerCase();
|
2014-10-16 16:57:59 +00:00
|
|
|
var trackedDownloadStatus = this.cellValue.has('trackedDownloadStatus') ? this.cellValue.get('trackedDownloadStatus').toLowerCase() : 'ok';
|
2013-10-03 21:06:52 +00:00
|
|
|
var icon = 'icon-nd-downloading';
|
|
|
|
var title = 'Downloading';
|
2014-09-13 23:13:00 +00:00
|
|
|
var itemTitle = this.cellValue.get('title');
|
|
|
|
var content = itemTitle;
|
2013-10-03 21:06:52 +00:00
|
|
|
|
|
|
|
if (status === 'paused') {
|
|
|
|
icon = 'icon-pause';
|
|
|
|
title = 'Paused';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status === 'queued') {
|
|
|
|
icon = 'icon-cloud';
|
|
|
|
title = 'Queued';
|
|
|
|
}
|
|
|
|
|
2014-04-19 15:09:22 +00:00
|
|
|
if (status === 'completed') {
|
|
|
|
icon = 'icon-inbox';
|
|
|
|
title = 'Downloaded';
|
|
|
|
}
|
2014-06-08 08:22:55 +00:00
|
|
|
|
|
|
|
if (status === 'pending') {
|
|
|
|
icon = 'icon-time';
|
|
|
|
title = 'Pending';
|
|
|
|
}
|
2014-04-19 15:09:22 +00:00
|
|
|
|
2014-08-07 06:23:13 +00:00
|
|
|
if (status === 'failed') {
|
|
|
|
icon = 'icon-nd-download-failed';
|
2014-09-13 23:13:00 +00:00
|
|
|
title = 'Download failed';
|
2014-08-07 06:23:13 +00:00
|
|
|
}
|
|
|
|
|
2014-09-18 21:00:52 +00:00
|
|
|
if (status === 'warning') {
|
|
|
|
icon = 'icon-nd-download-warning';
|
|
|
|
title = 'Download warning: check download client for more details';
|
|
|
|
}
|
|
|
|
|
2014-09-13 23:13:00 +00:00
|
|
|
if (trackedDownloadStatus === 'warning') {
|
|
|
|
icon += ' icon-nd-warning';
|
|
|
|
|
|
|
|
this.templateFunction = Marionette.TemplateCache.get(this.template);
|
|
|
|
content = this.templateFunction(this.cellValue.toJSON());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trackedDownloadStatus === 'error') {
|
2014-07-17 19:02:27 +00:00
|
|
|
if (status === 'completed') {
|
|
|
|
icon = 'icon-nd-import-failed';
|
2014-09-13 23:13:00 +00:00
|
|
|
title = 'Import failed: ' + itemTitle;
|
2014-07-17 19:02:27 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
icon = 'icon-nd-download-failed';
|
2014-08-07 06:23:13 +00:00
|
|
|
title = 'Download failed';
|
2014-07-17 19:02:27 +00:00
|
|
|
}
|
2014-09-13 23:13:00 +00:00
|
|
|
|
|
|
|
this.templateFunction = Marionette.TemplateCache.get(this.template);
|
|
|
|
content = this.templateFunction(this.cellValue.toJSON());
|
2014-07-17 19:02:27 +00:00
|
|
|
}
|
2014-09-13 23:13:00 +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
|
|
|
|
});
|
2013-10-03 21:06:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|