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