parent
b308f06af3
commit
b556eda4a0
@ -1,13 +1,14 @@
|
||||
var Handlebars = require('handlebars');
|
||||
|
||||
module.exports = (function(){
|
||||
Handlebars.registerHelper('historyAge', function(){
|
||||
var unit = 'days';
|
||||
var age = this.age;
|
||||
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);
|
||||
Handlebars.registerHelper('historyAge', function() {
|
||||
|
||||
var unit = 'days';
|
||||
var age = this.age;
|
||||
|
||||
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));
|
||||
});
|
||||
|
@ -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');
|
||||
|
||||
template : 'Activity/Queue/QueueActionsCellTemplate',
|
||||
className : 'queue-actions-cell',
|
||||
module.exports = TemplatedCell.extend({
|
||||
|
||||
events: {
|
||||
'click .x-remove' : '_remove',
|
||||
'click .x-import' : '_import',
|
||||
'click .x-grab' : '_grab'
|
||||
},
|
||||
template : 'Activity/Queue/QueueActionsCellTemplate',
|
||||
className : 'queue-actions-cell',
|
||||
|
||||
ui: {
|
||||
import : '.x-import',
|
||||
grab : '.x-grab'
|
||||
},
|
||||
events : {
|
||||
'click .x-remove' : '_remove',
|
||||
'click .x-import' : '_import',
|
||||
'click .x-grab' : '_grab'
|
||||
},
|
||||
|
||||
_remove : function () {
|
||||
ui : {
|
||||
import : '.x-import',
|
||||
grab : '.x-grab'
|
||||
},
|
||||
|
||||
var showBlacklist = this.model.get('status') !== 'Pending';
|
||||
_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 () {
|
||||
var self = this;
|
||||
_import : function() {
|
||||
var self = this;
|
||||
|
||||
var promise = $.ajax({
|
||||
url: window.NzbDrone.ApiRoot + '/queue/import',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(this.model.toJSON())
|
||||
});
|
||||
var promise = $.ajax({
|
||||
url : window.NzbDrone.ApiRoot + '/queue/import',
|
||||
type : 'POST',
|
||||
data : JSON.stringify(this.model.toJSON())
|
||||
});
|
||||
|
||||
$(this.ui.import).spinForPromise(promise);
|
||||
$(this.ui.import).spinForPromise(promise);
|
||||
|
||||
promise.success(function () {
|
||||
//find models that have the same series id and episode ids and remove them
|
||||
self.model.trigger('destroy', self.model);
|
||||
});
|
||||
},
|
||||
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 () {
|
||||
var self = this;
|
||||
_grab : function() {
|
||||
var self = this;
|
||||
|
||||
var promise = $.ajax({
|
||||
url: window.NzbDrone.ApiRoot + '/queue/grab',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(this.model.toJSON())
|
||||
});
|
||||
var promise = $.ajax({
|
||||
url : window.NzbDrone.ApiRoot + '/queue/grab',
|
||||
type : 'POST',
|
||||
data : JSON.stringify(this.model.toJSON())
|
||||
});
|
||||
|
||||
$(this.ui.grab).spinForPromise(promise);
|
||||
$(this.ui.grab).spinForPromise(promise);
|
||||
|
||||
promise.success(function () {
|
||||
//find models that have the same series id and episode ids and remove them
|
||||
self.model.trigger('destroy', self.model);
|
||||
});
|
||||
}
|
||||
promise.success(function() {
|
||||
//find models that have the same series id and episode ids and remove them
|
||||
self.model.trigger('destroy', self.model);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1,116 +1,99 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'Activity/Queue/QueueCollection',
|
||||
'Cells/SeriesTitleCell',
|
||||
'Cells/EpisodeNumberCell',
|
||||
'Cells/EpisodeTitleCell',
|
||||
'Cells/QualityCell',
|
||||
'Activity/Queue/QueueStatusCell',
|
||||
'Activity/Queue/QueueActionsCell',
|
||||
'Activity/Queue/TimeleftCell',
|
||||
'Activity/Queue/ProgressCell',
|
||||
'Release/ProtocolCell',
|
||||
'Shared/Grid/Pager'
|
||||
], function (Marionette,
|
||||
Backgrid,
|
||||
QueueCollection,
|
||||
SeriesTitleCell,
|
||||
EpisodeNumberCell,
|
||||
EpisodeTitleCell,
|
||||
QualityCell,
|
||||
QueueStatusCell,
|
||||
QueueActionsCell,
|
||||
TimeleftCell,
|
||||
ProgressCell,
|
||||
ProtocolCell,
|
||||
GridPager) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Activity/Queue/QueueLayoutTemplate',
|
||||
var Marionette = require('marionette');
|
||||
var Backgrid = require('backgrid');
|
||||
var QueueCollection = require('./QueueCollection');
|
||||
var SeriesTitleCell = require('../../Cells/SeriesTitleCell');
|
||||
var EpisodeNumberCell = require('../../Cells/EpisodeNumberCell');
|
||||
var EpisodeTitleCell = require('../../Cells/EpisodeTitleCell');
|
||||
var QualityCell = require('../../Cells/QualityCell');
|
||||
var QueueStatusCell = require('./QueueStatusCell');
|
||||
var QueueActionsCell = require('./QueueActionsCell');
|
||||
var TimeleftCell = require('./TimeleftCell');
|
||||
var ProgressCell = require('./ProgressCell');
|
||||
var ProtocolCell = require('../../Release/ProtocolCell');
|
||||
var GridPager = require('../../Shared/Grid/Pager');
|
||||
|
||||
regions: {
|
||||
table: '#x-queue',
|
||||
pager: '#x-queue-pager'
|
||||
},
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'Activity/Queue/QueueLayoutTemplate',
|
||||
|
||||
columns:
|
||||
[
|
||||
{
|
||||
name : 'status',
|
||||
label : '',
|
||||
cell : QueueStatusCell,
|
||||
cellValue : 'this'
|
||||
},
|
||||
{
|
||||
name : 'series',
|
||||
label : 'Series',
|
||||
cell : SeriesTitleCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'episode',
|
||||
label : 'Episode',
|
||||
cell : EpisodeNumberCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'episode',
|
||||
label : 'Episode Title',
|
||||
cell : EpisodeTitleCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'quality',
|
||||
label : 'Quality',
|
||||
cell : QualityCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'protocol',
|
||||
label : 'Protocol',
|
||||
cell : ProtocolCell
|
||||
},
|
||||
{
|
||||
name : 'timeleft',
|
||||
label : 'Timeleft',
|
||||
cell : TimeleftCell,
|
||||
cellValue : 'this'
|
||||
},
|
||||
{
|
||||
name : 'episode',
|
||||
label : 'Progress',
|
||||
cell : ProgressCell,
|
||||
cellValue : 'this'
|
||||
},
|
||||
{
|
||||
name : 'status',
|
||||
label : '',
|
||||
cell : QueueActionsCell,
|
||||
cellValue : 'this'
|
||||
}
|
||||
],
|
||||
regions : {
|
||||
table : '#x-queue',
|
||||
pager : '#x-queue-pager'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.listenTo(QueueCollection, 'sync', this._showTable);
|
||||
},
|
||||
columns : [
|
||||
{
|
||||
name : 'status',
|
||||
label : '',
|
||||
cell : QueueStatusCell,
|
||||
cellValue : 'this'
|
||||
},
|
||||
{
|
||||
name : 'series',
|
||||
label : 'Series',
|
||||
cell : SeriesTitleCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'episode',
|
||||
label : 'Episode',
|
||||
cell : EpisodeNumberCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'episode',
|
||||
label : 'Episode Title',
|
||||
cell : EpisodeTitleCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'quality',
|
||||
label : 'Quality',
|
||||
cell : QualityCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'protocol',
|
||||
label : 'Protocol',
|
||||
cell : ProtocolCell
|
||||
},
|
||||
{
|
||||
name : 'timeleft',
|
||||
label : 'Timeleft',
|
||||
cell : TimeleftCell,
|
||||
cellValue : 'this'
|
||||
},
|
||||
{
|
||||
name : 'episode',
|
||||
label : 'Progress',
|
||||
cell : ProgressCell,
|
||||
cellValue : 'this'
|
||||
},
|
||||
{
|
||||
name : 'status',
|
||||
label : '',
|
||||
cell : QueueActionsCell,
|
||||
cellValue : 'this'
|
||||
}
|
||||
],
|
||||
|
||||
onShow: function () {
|
||||
this._showTable();
|
||||
},
|
||||
initialize : function() {
|
||||
this.listenTo(QueueCollection, 'sync', this._showTable);
|
||||
},
|
||||
|
||||
_showTable: function () {
|
||||
this.table.show(new Backgrid.Grid({
|
||||
columns : this.columns,
|
||||
collection: QueueCollection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
onShow : function() {
|
||||
this._showTable();
|
||||
},
|
||||
|
||||
this.pager.show(new GridPager({
|
||||
columns : this.columns,
|
||||
collection: QueueCollection
|
||||
}));
|
||||
}
|
||||
});
|
||||
});
|
||||
_showTable : function() {
|
||||
this.table.show(new Backgrid.Grid({
|
||||
columns : this.columns,
|
||||
collection : QueueCollection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
|
||||
this.pager.show(new GridPager({
|
||||
columns : this.columns,
|
||||
collection : QueueCollection
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
@ -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: {
|
||||
'click .x-confirm-remove' : 'removeItem'
|
||||
},
|
||||
events : {
|
||||
'click .x-confirm-remove' : 'removeItem'
|
||||
},
|
||||
|
||||
ui: {
|
||||
blacklist : '.x-blacklist',
|
||||
indicator : '.x-indicator'
|
||||
},
|
||||
ui : {
|
||||
blacklist : '.x-blacklist',
|
||||
indicator : '.x-indicator'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.templateHelpers = {
|
||||
showBlacklist: options.showBlacklist
|
||||
};
|
||||
},
|
||||
initialize : function(options) {
|
||||
this.templateHelpers = {
|
||||
showBlacklist : options.showBlacklist
|
||||
};
|
||||
},
|
||||
|
||||
removeItem: function () {
|
||||
var blacklist = this.ui.blacklist.prop('checked') || false;
|
||||
removeItem : function() {
|
||||
var blacklist = this.ui.blacklist.prop('checked') || false;
|
||||
|
||||
this.ui.indicator.show();
|
||||
this.ui.indicator.show();
|
||||
|
||||
this.model.destroy({
|
||||
data: { 'blacklist': blacklist },
|
||||
wait: true
|
||||
}).done(function () {
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
});
|
||||
}
|
||||
this.model.destroy({
|
||||
data : { 'blacklist' : blacklist },
|
||||
wait : true
|
||||
}).done(function() {
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in new issue