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

61 lines
1.7 KiB
JavaScript
Raw Normal View History

'use strict';
2015-02-13 21:03:50 +00:00
var $ = require('jquery');
var _ = require('underscore');
2015-02-13 21:03:50 +00:00
var vent = require('../../vent');
var TemplatedCell = require('../../Cells/TemplatedCell');
var RemoveFromQueueView = require('./RemoveFromQueueView');
2015-02-13 21:03:50 +00:00
module.exports = TemplatedCell.extend({
2015-02-13 21:03:50 +00:00
template : 'Activity/Queue/QueueActionsCellTemplate',
className : 'queue-actions-cell',
2015-02-13 21:03:50 +00:00
events : {
2015-03-04 00:42:37 +00:00
'click .x-remove' : '_remove',
'click .x-manual-import' : '_manualImport',
'click .x-grab' : '_grab'
2015-02-13 21:03:50 +00:00
},
2015-01-31 08:24:09 +00:00
2015-02-13 21:03:50 +00:00
ui : {
import : '.x-import',
grab : '.x-grab'
},
2015-02-13 21:03:50 +00:00
_remove : function() {
var status = this.model.get('status');
var showBlacklist = status !== 'Delay' && status !== 'DownloadClientUnavailable';
2015-02-13 21:03:50 +00:00
vent.trigger(vent.Commands.OpenModalCommand, new RemoveFromQueueView({
model : this.model,
showBlacklist : showBlacklist
}));
},
2015-03-04 00:42:37 +00:00
_manualImport : function () {
vent.trigger(vent.Commands.ShowManualImport,
{
downloadId: this.model.get('downloadId'),
title: this.model.get('title')
});
2015-02-13 21:03:50 +00:00
},
2015-02-13 21:03:50 +00:00
_grab : function() {
var self = this;
var data = _.omit(this.model.toJSON(), 'series', 'episode');
2015-02-13 21:03:50 +00:00
var promise = $.ajax({
url : window.NzbDrone.ApiRoot + '/queue/grab',
type : 'POST',
data : JSON.stringify(data)
2015-02-13 21:03:50 +00:00
});
this.$(this.ui.grab).spinForPromise(promise);
2015-01-31 08:31:40 +00:00
2015-02-13 21:03:50 +00:00
promise.success(function() {
//find models that have the same series id and episode ids and remove them
self.model.trigger('destroy', self.model);
});
2015-02-13 21:03:50 +00:00
}
});