parent
b308f06af3
commit
b556eda4a0
@ -1,13 +1,14 @@
|
||||
var Handlebars = require('handlebars');
|
||||
|
||||
module.exports = (function(){
|
||||
Handlebars.registerHelper('historyAge', function(){
|
||||
Handlebars.registerHelper('historyAge', function() {
|
||||
|
||||
var unit = 'days';
|
||||
var age = this.age;
|
||||
if(age < 2) {
|
||||
|
||||
if (age < 2) {
|
||||
unit = 'hours';
|
||||
age = parseFloat(this.ageHours).toFixed(1);
|
||||
}
|
||||
|
||||
return new Handlebars.SafeString('<dt>Age (when grabbed):</dt><dd>{0} {1}</dd>'.format(age, unit));
|
||||
});
|
||||
}).call(this);
|
||||
});
|
||||
|
@ -1,4 +1,6 @@
|
||||
var Marionette = require('marionette');
|
||||
require('./HistoryDetailsAge');
|
||||
|
||||
module.exports = Marionette.ItemView.extend({template : 'Activity/History/Details/HistoryDetailsViewTemplate'});
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
template : 'Activity/History/Details/HistoryDetailsViewTemplate'
|
||||
});
|
@ -1,68 +1,67 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
[
|
||||
'jquery',
|
||||
'marionette',
|
||||
'Cells/TemplatedCell',
|
||||
'Activity/Queue/RemoveFromQueueView',
|
||||
'vent'
|
||||
], function ($, Marionette, TemplatedCell, RemoveFromQueueView, vent) {
|
||||
return TemplatedCell.extend({
|
||||
var $ = require('jquery');
|
||||
var vent = require('../../vent');
|
||||
var Marionette = require('marionette');
|
||||
var TemplatedCell = require('../../Cells/TemplatedCell');
|
||||
var RemoveFromQueueView = require('./RemoveFromQueueView');
|
||||
|
||||
module.exports = TemplatedCell.extend({
|
||||
|
||||
template : 'Activity/Queue/QueueActionsCellTemplate',
|
||||
className : 'queue-actions-cell',
|
||||
|
||||
events: {
|
||||
events : {
|
||||
'click .x-remove' : '_remove',
|
||||
'click .x-import' : '_import',
|
||||
'click .x-grab' : '_grab'
|
||||
},
|
||||
|
||||
ui: {
|
||||
ui : {
|
||||
import : '.x-import',
|
||||
grab : '.x-grab'
|
||||
},
|
||||
|
||||
_remove : function () {
|
||||
|
||||
_remove : function() {
|
||||
var showBlacklist = this.model.get('status') !== 'Pending';
|
||||
|
||||
vent.trigger(vent.Commands.OpenModalCommand, new RemoveFromQueueView({ model: this.model, showBlacklist: showBlacklist }));
|
||||
vent.trigger(vent.Commands.OpenModalCommand, new RemoveFromQueueView({
|
||||
model : this.model,
|
||||
showBlacklist : showBlacklist
|
||||
}));
|
||||
},
|
||||
|
||||
_import : function () {
|
||||
_import : function() {
|
||||
var self = this;
|
||||
|
||||
var promise = $.ajax({
|
||||
url: window.NzbDrone.ApiRoot + '/queue/import',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(this.model.toJSON())
|
||||
url : window.NzbDrone.ApiRoot + '/queue/import',
|
||||
type : 'POST',
|
||||
data : JSON.stringify(this.model.toJSON())
|
||||
});
|
||||
|
||||
$(this.ui.import).spinForPromise(promise);
|
||||
|
||||
promise.success(function () {
|
||||
promise.success(function() {
|
||||
//find models that have the same series id and episode ids and remove them
|
||||
self.model.trigger('destroy', self.model);
|
||||
});
|
||||
},
|
||||
|
||||
_grab : function () {
|
||||
_grab : function() {
|
||||
var self = this;
|
||||
|
||||
var promise = $.ajax({
|
||||
url: window.NzbDrone.ApiRoot + '/queue/grab',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(this.model.toJSON())
|
||||
url : window.NzbDrone.ApiRoot + '/queue/grab',
|
||||
type : 'POST',
|
||||
data : JSON.stringify(this.model.toJSON())
|
||||
});
|
||||
|
||||
$(this.ui.grab).spinForPromise(promise);
|
||||
|
||||
promise.success(function () {
|
||||
promise.success(function() {
|
||||
//find models that have the same series id and episode ids and remove them
|
||||
self.model.trigger('destroy', self.model);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,39 +1,34 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'marionette'
|
||||
], function (vent, Marionette) {
|
||||
var vent = require('../../vent');
|
||||
var Marionette = require('marionette');
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Activity/Queue/RemoveFromQueueViewTemplate',
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
template : 'Activity/Queue/RemoveFromQueueViewTemplate',
|
||||
|
||||
events: {
|
||||
events : {
|
||||
'click .x-confirm-remove' : 'removeItem'
|
||||
},
|
||||
|
||||
ui: {
|
||||
ui : {
|
||||
blacklist : '.x-blacklist',
|
||||
indicator : '.x-indicator'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
initialize : function(options) {
|
||||
this.templateHelpers = {
|
||||
showBlacklist: options.showBlacklist
|
||||
showBlacklist : options.showBlacklist
|
||||
};
|
||||
},
|
||||
|
||||
removeItem: function () {
|
||||
removeItem : function() {
|
||||
var blacklist = this.ui.blacklist.prop('checked') || false;
|
||||
|
||||
this.ui.indicator.show();
|
||||
|
||||
this.model.destroy({
|
||||
data: { 'blacklist': blacklist },
|
||||
wait: true
|
||||
}).done(function () {
|
||||
data : { 'blacklist' : blacklist },
|
||||
wait : true
|
||||
}).done(function() {
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in new issue