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

67 lines
1.8 KiB
JavaScript
Raw Normal View History

'use strict';
2015-02-13 21:03:50 +00:00
var $ = require('jquery');
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 : {
'click .x-remove' : '_remove',
'click .x-import' : '_import',
'click .x-grab' : '_grab'
},
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 showBlacklist = this.model.get('status') !== 'Pending';
2015-02-13 21:03:50 +00:00
vent.trigger(vent.Commands.OpenModalCommand, new RemoveFromQueueView({
model : this.model,
showBlacklist : showBlacklist
}));
},
2015-02-13 21:03:50 +00:00
_import : function() {
var self = this;
2015-02-13 21:03:50 +00:00
var promise = $.ajax({
url : window.NzbDrone.ApiRoot + '/queue/import',
type : 'POST',
data : JSON.stringify(this.model.toJSON())
});
this.$(this.ui.import).spinForPromise(promise);
2015-01-31 08:24:09 +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
_grab : function() {
var self = this;
2015-02-13 21:03:50 +00:00
var promise = $.ajax({
url : window.NzbDrone.ApiRoot + '/queue/grab',
type : 'POST',
data : JSON.stringify(this.model.toJSON())
});
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
}
});