mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-28 23:27:08 -04:00
rjs -> webpack
This commit is contained in:
@@ -1,85 +1,72 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'backbone',
|
||||
'backgrid',
|
||||
'Activity/History/HistoryLayout',
|
||||
'Activity/Blacklist/BlacklistLayout',
|
||||
'Activity/Queue/QueueLayout'
|
||||
], function (Marionette, Backbone, Backgrid, HistoryLayout, BlacklistLayout, QueueLayout) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Activity/ActivityLayoutTemplate',
|
||||
var Marionette = require('marionette');
|
||||
var Backbone = require('backbone');
|
||||
var Backgrid = require('backgrid');
|
||||
var HistoryLayout = require('./History/HistoryLayout');
|
||||
var BlacklistLayout = require('./Blacklist/BlacklistLayout');
|
||||
var QueueLayout = require('./Queue/QueueLayout');
|
||||
|
||||
regions: {
|
||||
queueRegion : '#queue',
|
||||
history : '#history',
|
||||
blacklist : '#blacklist'
|
||||
},
|
||||
|
||||
ui: {
|
||||
queueTab : '.x-queue-tab',
|
||||
historyTab : '.x-history-tab',
|
||||
blacklistTab : '.x-blacklist-tab'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click .x-queue-tab' : '_showQueue',
|
||||
'click .x-history-tab' : '_showHistory',
|
||||
'click .x-blacklist-tab' : '_showBlacklist'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
if (options.action) {
|
||||
this.action = options.action.toLowerCase();
|
||||
}
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
switch (this.action) {
|
||||
case 'history':
|
||||
this._showHistory();
|
||||
break;
|
||||
case 'blacklist':
|
||||
this._showBlacklist();
|
||||
break;
|
||||
default:
|
||||
this._showQueue();
|
||||
}
|
||||
},
|
||||
|
||||
_navigate: function (route) {
|
||||
Backbone.history.navigate(route, { trigger: false, replace: true });
|
||||
},
|
||||
|
||||
_showHistory: function (e) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.history.show(new HistoryLayout());
|
||||
this.ui.historyTab.tab('show');
|
||||
this._navigate('/activity/history');
|
||||
},
|
||||
|
||||
_showBlacklist: function (e) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.blacklist.show(new BlacklistLayout());
|
||||
this.ui.blacklistTab.tab('show');
|
||||
this._navigate('/activity/blacklist');
|
||||
},
|
||||
|
||||
_showQueue: function (e) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.queueRegion.show(new QueueLayout());
|
||||
this.ui.queueTab.tab('show');
|
||||
this._navigate('/activity/queue');
|
||||
}
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'Activity/ActivityLayoutTemplate',
|
||||
regions : {
|
||||
queueRegion : '#queue',
|
||||
history : '#history',
|
||||
blacklist : '#blacklist'
|
||||
},
|
||||
ui : {
|
||||
queueTab : '.x-queue-tab',
|
||||
historyTab : '.x-history-tab',
|
||||
blacklistTab : '.x-blacklist-tab'
|
||||
},
|
||||
events : {
|
||||
"click .x-queue-tab" : '_showQueue',
|
||||
"click .x-history-tab" : '_showHistory',
|
||||
"click .x-blacklist-tab" : '_showBlacklist'
|
||||
},
|
||||
initialize : function(options){
|
||||
if(options.action) {
|
||||
this.action = options.action.toLowerCase();
|
||||
}
|
||||
},
|
||||
onShow : function(){
|
||||
switch (this.action) {
|
||||
case 'history':
|
||||
this._showHistory();
|
||||
break;
|
||||
case 'blacklist':
|
||||
this._showBlacklist();
|
||||
break;
|
||||
default:
|
||||
this._showQueue();
|
||||
}
|
||||
},
|
||||
_navigate : function(route){
|
||||
Backbone.history.navigate(route, {
|
||||
trigger : false,
|
||||
replace : true
|
||||
});
|
||||
});
|
||||
},
|
||||
_showHistory : function(e){
|
||||
if(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
this.history.show(new HistoryLayout());
|
||||
this.ui.historyTab.tab('show');
|
||||
this._navigate('/activity/history');
|
||||
},
|
||||
_showBlacklist : function(e){
|
||||
if(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
this.blacklist.show(new BlacklistLayout());
|
||||
this.ui.blacklistTab.tab('show');
|
||||
this._navigate('/activity/blacklist');
|
||||
},
|
||||
_showQueue : function(e){
|
||||
if(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
this.queueRegion.show(new QueueLayout());
|
||||
this.ui.queueTab.tab('show');
|
||||
this._navigate('/activity/queue');
|
||||
}
|
||||
});
|
||||
@@ -1,26 +1,16 @@
|
||||
'use strict';
|
||||
var NzbDroneCell = require('../../Cells/NzbDroneCell');
|
||||
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'blacklist-controls-cell',
|
||||
|
||||
events: {
|
||||
'click': '_delete'
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
this.$el.html('<i class="icon-nd-delete"></i>');
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
_delete: function () {
|
||||
this.model.destroy();
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'blacklist-controls-cell',
|
||||
events : {
|
||||
'click' : '_delete'
|
||||
},
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
this.$el.html('<i class="icon-nd-delete"></i>');
|
||||
return this;
|
||||
},
|
||||
_delete : function(){
|
||||
this.model.destroy();
|
||||
}
|
||||
});
|
||||
@@ -1,50 +1,39 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Activity/Blacklist/BlacklistModel',
|
||||
'backbone.pageable',
|
||||
'Mixins/AsSortedCollection',
|
||||
'Mixins/AsPersistedStateCollection'
|
||||
], function (BlacklistModel, PageableCollection, AsSortedCollection, AsPersistedStateCollection) {
|
||||
var Collection = PageableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/blacklist',
|
||||
model: BlacklistModel,
|
||||
var BlacklistModel = require('./BlacklistModel');
|
||||
var PageableCollection = require('backbone.pageable');
|
||||
var AsSortedCollection = require('../../Mixins/AsSortedCollection');
|
||||
var AsPersistedStateCollection = require('../../Mixins/AsPersistedStateCollection');
|
||||
|
||||
state: {
|
||||
pageSize: 15,
|
||||
sortKey : 'date',
|
||||
order : 1
|
||||
},
|
||||
|
||||
queryParams: {
|
||||
totalPages : null,
|
||||
totalRecords: null,
|
||||
pageSize : 'pageSize',
|
||||
sortKey : 'sortKey',
|
||||
order : 'sortDir',
|
||||
directions : {
|
||||
'-1': 'asc',
|
||||
'1' : 'desc'
|
||||
}
|
||||
},
|
||||
|
||||
sortMappings: {
|
||||
'series' : { sortKey: 'series.sortTitle' }
|
||||
},
|
||||
|
||||
parseState: function (resp) {
|
||||
return { totalRecords: resp.totalRecords };
|
||||
},
|
||||
|
||||
parseRecords: function (resp) {
|
||||
if (resp) {
|
||||
return resp.records;
|
||||
}
|
||||
|
||||
return resp;
|
||||
module.exports = (function(){
|
||||
var Collection = PageableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/blacklist',
|
||||
model : BlacklistModel,
|
||||
state : {
|
||||
pageSize : 15,
|
||||
sortKey : 'date',
|
||||
order : 1
|
||||
},
|
||||
queryParams : {
|
||||
totalPages : null,
|
||||
totalRecords : null,
|
||||
pageSize : 'pageSize',
|
||||
sortKey : 'sortKey',
|
||||
order : 'sortDir',
|
||||
directions : {
|
||||
'-1' : 'asc',
|
||||
'1' : 'desc'
|
||||
}
|
||||
});
|
||||
|
||||
Collection = AsSortedCollection.call(Collection);
|
||||
return AsPersistedStateCollection.call(Collection);
|
||||
},
|
||||
sortMappings : {'series' : {sortKey : 'series.sortTitle'}},
|
||||
parseState : function(resp){
|
||||
return {totalRecords : resp.totalRecords};
|
||||
},
|
||||
parseRecords : function(resp){
|
||||
if(resp) {
|
||||
return resp.records;
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
});
|
||||
Collection = AsSortedCollection.call(Collection);
|
||||
return AsPersistedStateCollection.call(Collection);
|
||||
}).call(this);
|
||||
@@ -1,131 +1,91 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'Activity/Blacklist/BlacklistCollection',
|
||||
'Cells/SeriesTitleCell',
|
||||
'Cells/QualityCell',
|
||||
'Cells/RelativeDateCell',
|
||||
'Activity/Blacklist/BlacklistActionsCell',
|
||||
'Shared/Grid/Pager',
|
||||
'Shared/LoadingView',
|
||||
'Shared/Toolbar/ToolbarLayout'
|
||||
], function (vent,
|
||||
Marionette,
|
||||
Backgrid,
|
||||
BlacklistCollection,
|
||||
SeriesTitleCell,
|
||||
QualityCell,
|
||||
RelativeDateCell,
|
||||
BlacklistActionsCell,
|
||||
GridPager,
|
||||
LoadingView,
|
||||
ToolbarLayout) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Activity/Blacklist/BlacklistLayoutTemplate',
|
||||
var vent = require('../../vent');
|
||||
var Marionette = require('marionette');
|
||||
var Backgrid = require('backgrid');
|
||||
var BlacklistCollection = require('./BlacklistCollection');
|
||||
var SeriesTitleCell = require('../../Cells/SeriesTitleCell');
|
||||
var QualityCell = require('../../Cells/QualityCell');
|
||||
var RelativeDateCell = require('../../Cells/RelativeDateCell');
|
||||
var BlacklistActionsCell = require('./BlacklistActionsCell');
|
||||
var GridPager = require('../../Shared/Grid/Pager');
|
||||
var LoadingView = require('../../Shared/LoadingView');
|
||||
var ToolbarLayout = require('../../Shared/Toolbar/ToolbarLayout');
|
||||
|
||||
regions: {
|
||||
blacklist : '#x-blacklist',
|
||||
toolbar : '#x-toolbar',
|
||||
pager : '#x-pager'
|
||||
},
|
||||
|
||||
columns:
|
||||
[
|
||||
{
|
||||
name : 'series',
|
||||
label : 'Series',
|
||||
cell : SeriesTitleCell
|
||||
},
|
||||
{
|
||||
name : 'sourceTitle',
|
||||
label : 'Source Title',
|
||||
cell : 'string'
|
||||
},
|
||||
{
|
||||
name : 'quality',
|
||||
label : 'Quality',
|
||||
cell : QualityCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'date',
|
||||
label : 'Date',
|
||||
cell : RelativeDateCell
|
||||
},
|
||||
{
|
||||
name : 'this',
|
||||
label : '',
|
||||
cell : BlacklistActionsCell,
|
||||
sortable : false
|
||||
}
|
||||
],
|
||||
|
||||
initialize: function () {
|
||||
this.collection = new BlacklistCollection({ tableName: 'blacklist' });
|
||||
|
||||
this.listenTo(this.collection, 'sync', this._showTable);
|
||||
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
this.blacklist.show(new LoadingView());
|
||||
this._showToolbar();
|
||||
this.collection.fetch();
|
||||
},
|
||||
|
||||
_showTable: function (collection) {
|
||||
|
||||
this.blacklist.show(new Backgrid.Grid({
|
||||
columns : this.columns,
|
||||
collection: collection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
|
||||
this.pager.show(new GridPager({
|
||||
columns : this.columns,
|
||||
collection: collection
|
||||
}));
|
||||
},
|
||||
|
||||
_showToolbar: function () {
|
||||
var leftSideButtons = {
|
||||
type : 'default',
|
||||
storeState: false,
|
||||
items :
|
||||
[
|
||||
{
|
||||
title : 'Clear Blacklist',
|
||||
icon : 'icon-trash',
|
||||
command : 'clearBlacklist'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.toolbar.show(new ToolbarLayout({
|
||||
left :
|
||||
[
|
||||
leftSideButtons
|
||||
],
|
||||
context: this
|
||||
}));
|
||||
},
|
||||
|
||||
_refreshTable: function (buttonContext) {
|
||||
this.collection.state.currentPage = 1;
|
||||
var promise = this.collection.fetch({ reset: true });
|
||||
|
||||
if (buttonContext) {
|
||||
buttonContext.ui.icon.spinForPromise(promise);
|
||||
}
|
||||
},
|
||||
|
||||
_commandComplete: function (options) {
|
||||
if (options.command.get('name') === 'clearblacklist') {
|
||||
this._refreshTable();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'Activity/Blacklist/BlacklistLayoutTemplate',
|
||||
regions : {
|
||||
blacklist : '#x-blacklist',
|
||||
toolbar : '#x-toolbar',
|
||||
pager : '#x-pager'
|
||||
},
|
||||
columns : [{
|
||||
name : 'series',
|
||||
label : 'Series',
|
||||
cell : SeriesTitleCell
|
||||
}, {
|
||||
name : 'sourceTitle',
|
||||
label : 'Source Title',
|
||||
cell : 'string'
|
||||
}, {
|
||||
name : 'quality',
|
||||
label : 'Quality',
|
||||
cell : QualityCell,
|
||||
sortable : false
|
||||
}, {
|
||||
name : 'date',
|
||||
label : 'Date',
|
||||
cell : RelativeDateCell
|
||||
}, {
|
||||
name : 'this',
|
||||
label : '',
|
||||
cell : BlacklistActionsCell,
|
||||
sortable : false
|
||||
}],
|
||||
initialize : function(){
|
||||
this.collection = new BlacklistCollection({tableName : 'blacklist'});
|
||||
this.listenTo(this.collection, 'sync', this._showTable);
|
||||
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
|
||||
},
|
||||
onShow : function(){
|
||||
this.blacklist.show(new LoadingView());
|
||||
this._showToolbar();
|
||||
this.collection.fetch();
|
||||
},
|
||||
_showTable : function(collection){
|
||||
this.blacklist.show(new Backgrid.Grid({
|
||||
columns : this.columns,
|
||||
collection : collection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
this.pager.show(new GridPager({
|
||||
columns : this.columns,
|
||||
collection : collection
|
||||
}));
|
||||
},
|
||||
_showToolbar : function(){
|
||||
var leftSideButtons = {
|
||||
type : 'default',
|
||||
storeState : false,
|
||||
items : [{
|
||||
title : 'Clear Blacklist',
|
||||
icon : 'icon-trash',
|
||||
command : 'clearBlacklist'
|
||||
}]
|
||||
};
|
||||
this.toolbar.show(new ToolbarLayout({
|
||||
left : [leftSideButtons],
|
||||
context : this
|
||||
}));
|
||||
},
|
||||
_refreshTable : function(buttonContext){
|
||||
this.collection.state.currentPage = 1;
|
||||
var promise = this.collection.fetch({reset : true});
|
||||
if(buttonContext) {
|
||||
buttonContext.ui.icon.spinForPromise(promise);
|
||||
}
|
||||
},
|
||||
_commandComplete : function(options){
|
||||
if(options.command.get('name') === 'clearblacklist') {
|
||||
this._refreshTable();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,21 +1,14 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'Series/SeriesCollection'
|
||||
], function (Backbone, SeriesCollection) {
|
||||
return Backbone.Model.extend({
|
||||
var Backbone = require('backbone');
|
||||
var SeriesCollection = require('../../Series/SeriesCollection');
|
||||
|
||||
//Hack to deal with Backbone 1.0's bug
|
||||
initialize: function () {
|
||||
this.url = function () {
|
||||
return this.collection.url + '/' + this.get('id');
|
||||
};
|
||||
},
|
||||
|
||||
parse: function (model) {
|
||||
model.series = SeriesCollection.get(model.seriesId);
|
||||
return model;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Backbone.Model.extend({
|
||||
initialize : function(){
|
||||
this.url = function(){
|
||||
return this.collection.url + '/' + this.get('id');
|
||||
};
|
||||
},
|
||||
parse : function(model){
|
||||
model.series = SeriesCollection.get(model.seriesId);
|
||||
return model;
|
||||
}
|
||||
});
|
||||
@@ -1,19 +1,13 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'handlebars'
|
||||
], function (Handlebars) {
|
||||
var Handlebars = require('handlebars');
|
||||
|
||||
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));
|
||||
});
|
||||
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);
|
||||
@@ -1,40 +1,23 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'jquery',
|
||||
'vent',
|
||||
'marionette',
|
||||
'Activity/History/Details/HistoryDetailsView'
|
||||
], function ($, vent, Marionette, HistoryDetailsView) {
|
||||
var $ = require('jquery');
|
||||
var vent = require('../../../vent');
|
||||
var Marionette = require('marionette');
|
||||
var HistoryDetailsView = require('./HistoryDetailsView');
|
||||
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Activity/History/Details/HistoryDetailsLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
bodyRegion: '.modal-body'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click .x-mark-as-failed': '_markAsFailed'
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
this.bodyRegion.show(new HistoryDetailsView({ model: this.model }));
|
||||
},
|
||||
|
||||
_markAsFailed: function () {
|
||||
var url = window.NzbDrone.ApiRoot + '/history/failed';
|
||||
var data = {
|
||||
id: this.model.get('id')
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: data
|
||||
});
|
||||
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
}
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'Activity/History/Details/HistoryDetailsLayoutTemplate',
|
||||
regions : {bodyRegion : '.modal-body'},
|
||||
events : {"click .x-mark-as-failed" : '_markAsFailed'},
|
||||
onShow : function(){
|
||||
this.bodyRegion.show(new HistoryDetailsView({model : this.model}));
|
||||
},
|
||||
_markAsFailed : function(){
|
||||
var url = window.NzbDrone.ApiRoot + '/history/failed';
|
||||
var data = {id : this.model.get('id')};
|
||||
$.ajax({
|
||||
url : url,
|
||||
type : 'POST',
|
||||
data : data
|
||||
});
|
||||
});
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
}
|
||||
});
|
||||
@@ -1,11 +1,4 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Activity/History/Details/HistoryDetailsAge'
|
||||
], function (Marionette) {
|
||||
var Marionette = require('marionette');
|
||||
require('./HistoryDetailsAge');
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Activity/History/Details/HistoryDetailsViewTemplate'
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.ItemView.extend({template : 'Activity/History/Details/HistoryDetailsViewTemplate'});
|
||||
@@ -1,70 +1,56 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Activity/History/HistoryModel',
|
||||
'backbone.pageable',
|
||||
'Mixins/AsFilteredCollection',
|
||||
'Mixins/AsSortedCollection',
|
||||
'Mixins/AsPersistedStateCollection'
|
||||
], function (HistoryModel, PageableCollection, AsFilteredCollection, AsSortedCollection, AsPersistedStateCollection) {
|
||||
var Collection = PageableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/history',
|
||||
model: HistoryModel,
|
||||
var HistoryModel = require('./HistoryModel');
|
||||
var PageableCollection = require('backbone.pageable');
|
||||
var AsFilteredCollection = require('../../Mixins/AsFilteredCollection');
|
||||
var AsSortedCollection = require('../../Mixins/AsSortedCollection');
|
||||
var AsPersistedStateCollection = require('../../Mixins/AsPersistedStateCollection');
|
||||
|
||||
state: {
|
||||
pageSize: 15,
|
||||
sortKey : 'date',
|
||||
order : 1
|
||||
},
|
||||
|
||||
queryParams: {
|
||||
totalPages : null,
|
||||
totalRecords: null,
|
||||
pageSize : 'pageSize',
|
||||
sortKey : 'sortKey',
|
||||
order : 'sortDir',
|
||||
directions : {
|
||||
'-1': 'asc',
|
||||
'1' : 'desc'
|
||||
}
|
||||
},
|
||||
|
||||
filterModes: {
|
||||
'all' : [null, null],
|
||||
'grabbed' : ['eventType', '1'],
|
||||
'imported' : ['eventType', '3'],
|
||||
'failed' : ['eventType', '4'],
|
||||
'deleted' : ['eventType', '5']
|
||||
},
|
||||
|
||||
sortMappings: {
|
||||
'series' : { sortKey: 'series.sortTitle' }
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
delete this.queryParams.episodeId;
|
||||
|
||||
if (options) {
|
||||
if (options.episodeId) {
|
||||
this.queryParams.episodeId = options.episodeId;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
parseState: function (resp) {
|
||||
return { totalRecords: resp.totalRecords };
|
||||
},
|
||||
|
||||
parseRecords: function (resp) {
|
||||
if (resp) {
|
||||
return resp.records;
|
||||
}
|
||||
|
||||
return resp;
|
||||
module.exports = (function(){
|
||||
var Collection = PageableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/history',
|
||||
model : HistoryModel,
|
||||
state : {
|
||||
pageSize : 15,
|
||||
sortKey : 'date',
|
||||
order : 1
|
||||
},
|
||||
queryParams : {
|
||||
totalPages : null,
|
||||
totalRecords : null,
|
||||
pageSize : 'pageSize',
|
||||
sortKey : 'sortKey',
|
||||
order : 'sortDir',
|
||||
directions : {
|
||||
"-1" : 'asc',
|
||||
"1" : 'desc'
|
||||
}
|
||||
});
|
||||
|
||||
Collection = AsFilteredCollection.call(Collection);
|
||||
Collection = AsSortedCollection.call(Collection);
|
||||
return AsPersistedStateCollection.call(Collection);
|
||||
},
|
||||
filterModes : {
|
||||
"all" : [null, null],
|
||||
"grabbed" : ['eventType', '1'],
|
||||
"imported" : ['eventType', '3'],
|
||||
"failed" : ['eventType', '4'],
|
||||
"deleted" : ['eventType', '5']
|
||||
},
|
||||
sortMappings : {"series" : {sortKey : 'series.sortTitle'}},
|
||||
initialize : function(options){
|
||||
delete this.queryParams.episodeId;
|
||||
if(options) {
|
||||
if(options.episodeId) {
|
||||
this.queryParams.episodeId = options.episodeId;
|
||||
}
|
||||
}
|
||||
},
|
||||
parseState : function(resp){
|
||||
return {totalRecords : resp.totalRecords};
|
||||
},
|
||||
parseRecords : function(resp){
|
||||
if(resp) {
|
||||
return resp.records;
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
});
|
||||
Collection = AsFilteredCollection.call(Collection);
|
||||
Collection = AsSortedCollection.call(Collection);
|
||||
return AsPersistedStateCollection.call(Collection);
|
||||
}).call(this);
|
||||
@@ -1,27 +1,15 @@
|
||||
'use strict';
|
||||
var vent = require('../../vent');
|
||||
var NzbDroneCell = require('../../Cells/NzbDroneCell');
|
||||
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'Cells/NzbDroneCell'
|
||||
], function (vent, NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'history-details-cell',
|
||||
|
||||
events: {
|
||||
'click': '_showDetails'
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
this.$el.html('<i class="icon-info-sign"></i>');
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
_showDetails: function () {
|
||||
vent.trigger(vent.Commands.ShowHistoryDetails, { model: this.model });
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'history-details-cell',
|
||||
events : {"click" : '_showDetails'},
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
this.$el.html('<i class="icon-info-sign"></i>');
|
||||
return this;
|
||||
},
|
||||
_showDetails : function(){
|
||||
vent.trigger(vent.Commands.ShowHistoryDetails, {model : this.model});
|
||||
}
|
||||
});
|
||||
@@ -1,173 +1,126 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'Activity/History/HistoryCollection',
|
||||
'Cells/EventTypeCell',
|
||||
'Cells/SeriesTitleCell',
|
||||
'Cells/EpisodeNumberCell',
|
||||
'Cells/EpisodeTitleCell',
|
||||
'Activity/History/HistoryQualityCell',
|
||||
'Cells/RelativeDateCell',
|
||||
'Activity/History/HistoryDetailsCell',
|
||||
'Shared/Grid/Pager',
|
||||
'Shared/Toolbar/ToolbarLayout',
|
||||
'Shared/LoadingView'
|
||||
], function (Marionette,
|
||||
Backgrid,
|
||||
HistoryCollection,
|
||||
EventTypeCell,
|
||||
SeriesTitleCell,
|
||||
EpisodeNumberCell,
|
||||
EpisodeTitleCell,
|
||||
HistoryQualityCell,
|
||||
RelativeDateCell,
|
||||
HistoryDetailsCell,
|
||||
GridPager,
|
||||
ToolbarLayout,
|
||||
LoadingView) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Activity/History/HistoryLayoutTemplate',
|
||||
var Marionette = require('marionette');
|
||||
var Backgrid = require('backgrid');
|
||||
var HistoryCollection = require('./HistoryCollection');
|
||||
var EventTypeCell = require('../../Cells/EventTypeCell');
|
||||
var SeriesTitleCell = require('../../Cells/SeriesTitleCell');
|
||||
var EpisodeNumberCell = require('../../Cells/EpisodeNumberCell');
|
||||
var EpisodeTitleCell = require('../../Cells/EpisodeTitleCell');
|
||||
var HistoryQualityCell = require('./HistoryQualityCell');
|
||||
var RelativeDateCell = require('../../Cells/RelativeDateCell');
|
||||
var HistoryDetailsCell = require('./HistoryDetailsCell');
|
||||
var GridPager = require('../../Shared/Grid/Pager');
|
||||
var ToolbarLayout = require('../../Shared/Toolbar/ToolbarLayout');
|
||||
var LoadingView = require('../../Shared/LoadingView');
|
||||
|
||||
regions: {
|
||||
history: '#x-history',
|
||||
toolbar: '#x-history-toolbar',
|
||||
pager : '#x-history-pager'
|
||||
},
|
||||
|
||||
columns:
|
||||
[
|
||||
{
|
||||
name : 'eventType',
|
||||
label : '',
|
||||
cell : EventTypeCell,
|
||||
cellValue : 'this'
|
||||
},
|
||||
{
|
||||
name : 'series',
|
||||
label : 'Series',
|
||||
cell : SeriesTitleCell
|
||||
},
|
||||
{
|
||||
name : 'episode',
|
||||
label : 'Episode',
|
||||
cell : EpisodeNumberCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'episode',
|
||||
label : 'Episode Title',
|
||||
cell : EpisodeTitleCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'this',
|
||||
label : 'Quality',
|
||||
cell : HistoryQualityCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'date',
|
||||
label : 'Date',
|
||||
cell : RelativeDateCell
|
||||
},
|
||||
{
|
||||
name : 'this',
|
||||
label : '',
|
||||
cell : HistoryDetailsCell,
|
||||
sortable : false
|
||||
}
|
||||
],
|
||||
|
||||
initialize: function () {
|
||||
this.collection = new HistoryCollection({ tableName: 'history' });
|
||||
this.listenTo(this.collection, 'sync', this._showTable);
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
this.history.show(new LoadingView());
|
||||
this._showToolbar();
|
||||
},
|
||||
|
||||
_showTable: function (collection) {
|
||||
|
||||
this.history.show(new Backgrid.Grid({
|
||||
columns : this.columns,
|
||||
collection: collection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
|
||||
this.pager.show(new GridPager({
|
||||
columns : this.columns,
|
||||
collection: collection
|
||||
}));
|
||||
},
|
||||
|
||||
_showToolbar: function () {
|
||||
var filterOptions = {
|
||||
type : 'radio',
|
||||
storeState : true,
|
||||
menuKey : 'history.filterMode',
|
||||
defaultAction : 'all',
|
||||
items :
|
||||
[
|
||||
{
|
||||
key : 'all',
|
||||
title : '',
|
||||
tooltip : 'All',
|
||||
icon : 'icon-circle-blank',
|
||||
callback : this._setFilter
|
||||
},
|
||||
{
|
||||
key : 'grabbed',
|
||||
title : '',
|
||||
tooltip : 'Grabbed',
|
||||
icon : 'icon-nd-downloading',
|
||||
callback : this._setFilter
|
||||
},
|
||||
{
|
||||
key : 'imported',
|
||||
title : '',
|
||||
tooltip : 'Imported',
|
||||
icon : 'icon-nd-imported',
|
||||
callback : this._setFilter
|
||||
},
|
||||
{
|
||||
key : 'failed',
|
||||
title : '',
|
||||
tooltip : 'Failed',
|
||||
icon : 'icon-nd-download-failed',
|
||||
callback : this._setFilter
|
||||
},
|
||||
{
|
||||
key : 'deleted',
|
||||
title : '',
|
||||
tooltip : 'Deleted',
|
||||
icon : 'icon-nd-deleted',
|
||||
callback : this._setFilter
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.toolbar.show(new ToolbarLayout({
|
||||
right :
|
||||
[
|
||||
filterOptions
|
||||
],
|
||||
context: this
|
||||
}));
|
||||
},
|
||||
|
||||
_setFilter: function(buttonContext) {
|
||||
var mode = buttonContext.model.get('key');
|
||||
|
||||
this.collection.state.currentPage = 1;
|
||||
var promise = this.collection.setFilterMode(mode);
|
||||
|
||||
if (buttonContext) {
|
||||
buttonContext.ui.icon.spinForPromise(promise);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'Activity/History/HistoryLayoutTemplate',
|
||||
regions : {
|
||||
history : '#x-history',
|
||||
toolbar : '#x-history-toolbar',
|
||||
pager : '#x-history-pager'
|
||||
},
|
||||
columns : [{
|
||||
name : 'eventType',
|
||||
label : '',
|
||||
cell : EventTypeCell,
|
||||
cellValue : 'this'
|
||||
}, {
|
||||
name : 'series',
|
||||
label : 'Series',
|
||||
cell : SeriesTitleCell
|
||||
}, {
|
||||
name : 'episode',
|
||||
label : 'Episode',
|
||||
cell : EpisodeNumberCell,
|
||||
sortable : false
|
||||
}, {
|
||||
name : 'episode',
|
||||
label : 'Episode Title',
|
||||
cell : EpisodeTitleCell,
|
||||
sortable : false
|
||||
}, {
|
||||
name : 'this',
|
||||
label : 'Quality',
|
||||
cell : HistoryQualityCell,
|
||||
sortable : false
|
||||
}, {
|
||||
name : 'date',
|
||||
label : 'Date',
|
||||
cell : RelativeDateCell
|
||||
}, {
|
||||
name : 'this',
|
||||
label : '',
|
||||
cell : HistoryDetailsCell,
|
||||
sortable : false
|
||||
}],
|
||||
initialize : function(){
|
||||
this.collection = new HistoryCollection({tableName : 'history'});
|
||||
this.listenTo(this.collection, 'sync', this._showTable);
|
||||
},
|
||||
onShow : function(){
|
||||
this.history.show(new LoadingView());
|
||||
this._showToolbar();
|
||||
},
|
||||
_showTable : function(collection){
|
||||
this.history.show(new Backgrid.Grid({
|
||||
columns : this.columns,
|
||||
collection : collection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
this.pager.show(new GridPager({
|
||||
columns : this.columns,
|
||||
collection : collection
|
||||
}));
|
||||
},
|
||||
_showToolbar : function(){
|
||||
var filterOptions = {
|
||||
type : 'radio',
|
||||
storeState : true,
|
||||
menuKey : 'history.filterMode',
|
||||
defaultAction : 'all',
|
||||
items : [{
|
||||
key : 'all',
|
||||
title : '',
|
||||
tooltip : 'All',
|
||||
icon : 'icon-circle-blank',
|
||||
callback : this._setFilter
|
||||
}, {
|
||||
key : 'grabbed',
|
||||
title : '',
|
||||
tooltip : 'Grabbed',
|
||||
icon : 'icon-nd-downloading',
|
||||
callback : this._setFilter
|
||||
}, {
|
||||
key : 'imported',
|
||||
title : '',
|
||||
tooltip : 'Imported',
|
||||
icon : 'icon-nd-imported',
|
||||
callback : this._setFilter
|
||||
}, {
|
||||
key : 'failed',
|
||||
title : '',
|
||||
tooltip : 'Failed',
|
||||
icon : 'icon-nd-download-failed',
|
||||
callback : this._setFilter
|
||||
}, {
|
||||
key : 'deleted',
|
||||
title : '',
|
||||
tooltip : 'Deleted',
|
||||
icon : 'icon-nd-deleted',
|
||||
callback : this._setFilter
|
||||
}]
|
||||
};
|
||||
this.toolbar.show(new ToolbarLayout({
|
||||
right : [filterOptions],
|
||||
context : this
|
||||
}));
|
||||
},
|
||||
_setFilter : function(buttonContext){
|
||||
var mode = buttonContext.model.get('key');
|
||||
this.collection.state.currentPage = 1;
|
||||
var promise = this.collection.setFilterMode(mode);
|
||||
if(buttonContext) {
|
||||
buttonContext.ui.icon.spinForPromise(promise);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,16 +1,12 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'Series/SeriesModel',
|
||||
'Series/EpisodeModel'
|
||||
], function (Backbone, SeriesModel, EpisodeModel) {
|
||||
return Backbone.Model.extend({
|
||||
parse: function (model) {
|
||||
model.series = new SeriesModel(model.series);
|
||||
model.episode = new EpisodeModel(model.episode);
|
||||
model.episode.set('series', model.series);
|
||||
return model;
|
||||
}
|
||||
});
|
||||
});
|
||||
var Backbone = require('backbone');
|
||||
var SeriesModel = require('../../Series/SeriesModel');
|
||||
var EpisodeModel = require('../../Series/EpisodeModel');
|
||||
|
||||
module.exports = Backbone.Model.extend({
|
||||
parse : function(model){
|
||||
model.series = new SeriesModel(model.series);
|
||||
model.episode = new EpisodeModel(model.episode);
|
||||
model.episode.set('series', model.series);
|
||||
return model;
|
||||
}
|
||||
});
|
||||
@@ -1,36 +1,24 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
var NzbDroneCell = require('../../Cells/NzbDroneCell');
|
||||
|
||||
className: 'history-quality-cell',
|
||||
|
||||
render: function () {
|
||||
|
||||
var title = '';
|
||||
var quality = this.model.get('quality');
|
||||
var revision = quality.revision;
|
||||
|
||||
if (revision.real && revision.real > 0) {
|
||||
title += ' REAL';
|
||||
}
|
||||
|
||||
if (revision.version && revision.version > 1) {
|
||||
title += ' PROPER';
|
||||
}
|
||||
|
||||
title = title.trim();
|
||||
|
||||
if (this.model.get('qualityCutoffNotMet')) {
|
||||
this.$el.html('<span class="badge badge-inverse" title="{0}">{1}</span>'.format(title, quality.quality.name));
|
||||
}
|
||||
else {
|
||||
this.$el.html('<span class="badge" title="{0}">{1}</span>'.format(title, quality.quality.name));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'history-quality-cell',
|
||||
render : function(){
|
||||
var title = '';
|
||||
var quality = this.model.get('quality');
|
||||
var revision = quality.revision;
|
||||
if(revision.real && revision.real > 0) {
|
||||
title += ' REAL';
|
||||
}
|
||||
if(revision.version && revision.version > 1) {
|
||||
title += ' PROPER';
|
||||
}
|
||||
title = title.trim();
|
||||
if(this.model.get('qualityCutoffNotMet')) {
|
||||
this.$el.html('<span class="badge badge-inverse" title="{0}">{1}</span>'.format(title, quality.quality.name));
|
||||
}
|
||||
else {
|
||||
this.$el.html('<span class="badge" title="{0}">{1}</span>'.format(title, quality.quality.name));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,29 +1,16 @@
|
||||
'use strict';
|
||||
var NzbDroneCell = require('../../Cells/NzbDroneCell');
|
||||
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'progress-cell',
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
if (this.cellValue) {
|
||||
|
||||
var status = this.model.get('status').toLowerCase();
|
||||
|
||||
if (status === 'downloading') {
|
||||
var progress = 100 - (this.model.get('sizeleft') / this.model.get('size') * 100);
|
||||
|
||||
this.$el.html('<div class="progress" title="{0}%">'.format(progress.toFixed(1)) +
|
||||
'<div class="progress-bar progress-bar-purple" style="width: {0}%;"></div></div>'.format(progress));
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'progress-cell',
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
if(this.cellValue) {
|
||||
var status = this.model.get('status').toLowerCase();
|
||||
if(status === 'downloading') {
|
||||
var progress = 100 - this.model.get('sizeleft') / this.model.get('size') * 100;
|
||||
this.$el.html('<div class="progress" title="{0}%">'.format(progress.toFixed(1)) + '<div class="progress-bar progress-bar-purple" style="width: {0}%;"></div></div>'.format(progress));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,31 +1,22 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'underscore',
|
||||
'backbone',
|
||||
'backbone.pageable',
|
||||
'Activity/Queue/QueueModel',
|
||||
'Mixins/backbone.signalr.mixin'
|
||||
], function (_, Backbone, PageableCollection, QueueModel) {
|
||||
var QueueCollection = PageableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/queue',
|
||||
model: QueueModel,
|
||||
var _ = require('underscore');
|
||||
var Backbone = require('backbone');
|
||||
var PageableCollection = require('backbone.pageable');
|
||||
var QueueModel = require('./QueueModel');
|
||||
require('../../Mixins/backbone.signalr.mixin');
|
||||
|
||||
state: {
|
||||
pageSize: 15
|
||||
},
|
||||
|
||||
mode: 'client',
|
||||
|
||||
findEpisode: function (episodeId) {
|
||||
return _.find(this.fullCollection.models, function (queueModel) {
|
||||
return queueModel.get('episode').id === episodeId;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var collection = new QueueCollection().bindSignalR();
|
||||
collection.fetch();
|
||||
|
||||
return collection;
|
||||
module.exports = (function(){
|
||||
var QueueCollection = PageableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/queue',
|
||||
model : QueueModel,
|
||||
state : {pageSize : 15},
|
||||
mode : 'client',
|
||||
findEpisode : function(episodeId){
|
||||
return _.find(this.fullCollection.models, function(queueModel){
|
||||
return queueModel.get('episode').id === episodeId;
|
||||
});
|
||||
}
|
||||
});
|
||||
var collection = new QueueCollection().bindSignalR();
|
||||
collection.fetch();
|
||||
return collection;
|
||||
}).call(this);
|
||||
@@ -1,16 +1,12 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'Series/SeriesModel',
|
||||
'Series/EpisodeModel'
|
||||
], function (Backbone, SeriesModel, EpisodeModel) {
|
||||
return Backbone.Model.extend({
|
||||
parse: function (model) {
|
||||
model.series = new SeriesModel(model.series);
|
||||
model.episode = new EpisodeModel(model.episode);
|
||||
model.episode.set('series', model.series);
|
||||
return model;
|
||||
}
|
||||
});
|
||||
});
|
||||
var Backbone = require('backbone');
|
||||
var SeriesModel = require('../../Series/SeriesModel');
|
||||
var EpisodeModel = require('../../Series/EpisodeModel');
|
||||
|
||||
module.exports = Backbone.Model.extend({
|
||||
parse : function(model){
|
||||
model.series = new SeriesModel(model.series);
|
||||
model.episode = new EpisodeModel(model.episode);
|
||||
model.episode.set('series', model.series);
|
||||
return model;
|
||||
}
|
||||
});
|
||||
@@ -1,89 +1,69 @@
|
||||
'use strict';
|
||||
var Marionette = require('marionette');
|
||||
var NzbDroneCell = require('../../Cells/NzbDroneCell');
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Cells/NzbDroneCell'
|
||||
], function (Marionette, NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className : 'queue-status-cell',
|
||||
template : 'Activity/Queue/QueueStatusCellTemplate',
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
if (this.cellValue) {
|
||||
var status = this.cellValue.get('status').toLowerCase();
|
||||
var trackedDownloadStatus = this.cellValue.has('trackedDownloadStatus') ? this.cellValue.get('trackedDownloadStatus').toLowerCase() : 'ok';
|
||||
var icon = 'icon-nd-downloading';
|
||||
var title = 'Downloading';
|
||||
var itemTitle = this.cellValue.get('title');
|
||||
var content = itemTitle;
|
||||
|
||||
if (status === 'paused') {
|
||||
icon = 'icon-pause';
|
||||
title = 'Paused';
|
||||
}
|
||||
|
||||
if (status === 'queued') {
|
||||
icon = 'icon-cloud';
|
||||
title = 'Queued';
|
||||
}
|
||||
|
||||
if (status === 'completed') {
|
||||
icon = 'icon-inbox';
|
||||
title = 'Downloaded';
|
||||
}
|
||||
|
||||
if (status === 'pending') {
|
||||
icon = 'icon-time';
|
||||
title = 'Pending';
|
||||
}
|
||||
|
||||
if (status === 'failed') {
|
||||
icon = 'icon-nd-download-failed';
|
||||
title = 'Download failed';
|
||||
}
|
||||
|
||||
if (status === 'warning') {
|
||||
icon = 'icon-nd-download-warning';
|
||||
title = 'Download warning: check download client for more details';
|
||||
}
|
||||
|
||||
if (trackedDownloadStatus === 'warning') {
|
||||
icon += ' icon-nd-warning';
|
||||
|
||||
this.templateFunction = Marionette.TemplateCache.get(this.template);
|
||||
content = this.templateFunction(this.cellValue.toJSON());
|
||||
}
|
||||
|
||||
if (trackedDownloadStatus === 'error') {
|
||||
if (status === 'completed') {
|
||||
icon = 'icon-nd-import-failed';
|
||||
title = 'Import failed: ' + itemTitle;
|
||||
}
|
||||
else {
|
||||
icon = 'icon-nd-download-failed';
|
||||
title = 'Download failed';
|
||||
}
|
||||
|
||||
this.templateFunction = Marionette.TemplateCache.get(this.template);
|
||||
content = this.templateFunction(this.cellValue.toJSON());
|
||||
}
|
||||
|
||||
this.$el.html('<i class="{0}"></i>'.format(icon));
|
||||
this.$el.popover({
|
||||
content : content,
|
||||
html : true,
|
||||
trigger : 'hover',
|
||||
title : title,
|
||||
placement: 'right',
|
||||
container: this.$el
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'queue-status-cell',
|
||||
template : 'Activity/Queue/QueueStatusCellTemplate',
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
if(this.cellValue) {
|
||||
var status = this.cellValue.get('status').toLowerCase();
|
||||
var trackedDownloadStatus = this.cellValue.has('trackedDownloadStatus') ? this.cellValue.get('trackedDownloadStatus').toLowerCase() : 'ok';
|
||||
var icon = 'icon-nd-downloading';
|
||||
var title = 'Downloading';
|
||||
var itemTitle = this.cellValue.get('title');
|
||||
var content = itemTitle;
|
||||
if(status === 'paused') {
|
||||
icon = 'icon-pause';
|
||||
title = 'Paused';
|
||||
}
|
||||
});
|
||||
});
|
||||
if(status === 'queued') {
|
||||
icon = 'icon-cloud';
|
||||
title = 'Queued';
|
||||
}
|
||||
if(status === 'completed') {
|
||||
icon = 'icon-inbox';
|
||||
title = 'Downloaded';
|
||||
}
|
||||
if(status === 'pending') {
|
||||
icon = 'icon-time';
|
||||
title = 'Pending';
|
||||
}
|
||||
if(status === 'failed') {
|
||||
icon = 'icon-nd-download-failed';
|
||||
title = 'Download failed';
|
||||
}
|
||||
if(status === 'warning') {
|
||||
icon = 'icon-nd-download-warning';
|
||||
title = 'Download warning: check download client for more details';
|
||||
}
|
||||
if(trackedDownloadStatus === 'warning') {
|
||||
icon += ' icon-nd-warning';
|
||||
this.templateFunction = Marionette.TemplateCache.get(this.template);
|
||||
content = this.templateFunction(this.cellValue.toJSON());
|
||||
}
|
||||
if(trackedDownloadStatus === 'error') {
|
||||
if(status === 'completed') {
|
||||
icon = 'icon-nd-import-failed';
|
||||
title = 'Import failed: ' + itemTitle;
|
||||
}
|
||||
else {
|
||||
icon = 'icon-nd-download-failed';
|
||||
title = 'Download failed';
|
||||
}
|
||||
this.templateFunction = Marionette.TemplateCache.get(this.template);
|
||||
content = this.templateFunction(this.cellValue.toJSON());
|
||||
}
|
||||
this.$el.html('<i class="{0}"></i>'.format(icon));
|
||||
this.$el.popover({
|
||||
content : content,
|
||||
html : true,
|
||||
trigger : 'hover',
|
||||
title : title,
|
||||
placement : 'right',
|
||||
container : this.$el
|
||||
});
|
||||
}
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,46 +1,33 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'underscore',
|
||||
'marionette',
|
||||
'Activity/Queue/QueueCollection'
|
||||
], function (_, Marionette, QueueCollection) {
|
||||
return Marionette.ItemView.extend({
|
||||
tagName: 'span',
|
||||
var _ = require('underscore');
|
||||
var Marionette = require('marionette');
|
||||
var QueueCollection = require('./QueueCollection');
|
||||
|
||||
initialize: function () {
|
||||
this.listenTo(QueueCollection, 'sync', this.render);
|
||||
QueueCollection.fetch();
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
if (QueueCollection.length === 0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
var count = QueueCollection.fullCollection.length;
|
||||
var label = 'label-info';
|
||||
|
||||
var errors = QueueCollection.fullCollection.some(function (model) {
|
||||
return model.has('trackedDownloadStatus') && model.get('trackedDownloadStatus').toLowerCase() === 'error';
|
||||
});
|
||||
|
||||
var warnings = QueueCollection.fullCollection.some(function (model) {
|
||||
return model.has('trackedDownloadStatus') && model.get('trackedDownloadStatus').toLowerCase() === 'warning';
|
||||
});
|
||||
|
||||
if (errors) {
|
||||
label = 'label-danger';
|
||||
}
|
||||
|
||||
else if (warnings) {
|
||||
label = 'label-warning';
|
||||
}
|
||||
|
||||
this.$el.html('<span class="label {0}">{1}</span>'.format(label, count));
|
||||
return this;
|
||||
}
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
tagName : 'span',
|
||||
initialize : function(){
|
||||
this.listenTo(QueueCollection, 'sync', this.render);
|
||||
QueueCollection.fetch();
|
||||
},
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
if(QueueCollection.length === 0) {
|
||||
return this;
|
||||
}
|
||||
var count = QueueCollection.fullCollection.length;
|
||||
var label = 'label-info';
|
||||
var errors = QueueCollection.fullCollection.some(function(model){
|
||||
return model.has('trackedDownloadStatus') && model.get('trackedDownloadStatus').toLowerCase() === 'error';
|
||||
});
|
||||
});
|
||||
var warnings = QueueCollection.fullCollection.some(function(model){
|
||||
return model.has('trackedDownloadStatus') && model.get('trackedDownloadStatus').toLowerCase() === 'warning';
|
||||
});
|
||||
if(errors) {
|
||||
label = 'label-danger';
|
||||
}
|
||||
else if(warnings) {
|
||||
label = 'label-warning';
|
||||
}
|
||||
this.$el.html('<span class="label {0}">{1}</span>'.format(label, count));
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,47 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell',
|
||||
'filesize',
|
||||
'moment',
|
||||
'Shared/UiSettingsModel',
|
||||
'Shared/FormatHelpers'
|
||||
], function (NzbDroneCell, fileSize, moment, UiSettingsModel, FormatHelpers) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'timeleft-cell',
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
if (this.cellValue) {
|
||||
|
||||
//If the release is pending we want to use the timeleft as the time it will be processed at
|
||||
if (this.cellValue.get('status').toLowerCase() === 'pending') {
|
||||
var ect = this.cellValue.get('estimatedCompletionTime');
|
||||
var time = '{0} at {1}'.format(FormatHelpers.relativeDate(ect), moment(ect).format(UiSettingsModel.time(true, false)));
|
||||
|
||||
this.$el.html('-');
|
||||
this.$el.attr('title', 'Will be processed during the first RSS Sync after {0}'.format(time));
|
||||
this.$el.attr('data-container', 'body');
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
var timeleft = this.cellValue.get('timeleft');
|
||||
var totalSize = fileSize(this.cellValue.get('size'), 1, false);
|
||||
var remainingSize = fileSize(this.cellValue.get('sizeleft'), 1, false);
|
||||
|
||||
if (timeleft === undefined) {
|
||||
this.$el.html('-');
|
||||
}
|
||||
else {
|
||||
this.$el.html('<span title="{1} / {2}">{0}</span>'.format(timeleft, remainingSize, totalSize));
|
||||
}
|
||||
}
|
||||
var NzbDroneCell = require('../../Cells/NzbDroneCell');
|
||||
var fileSize = require('filesize');
|
||||
var moment = require('moment');
|
||||
var UiSettingsModel = require('../../Shared/UiSettingsModel');
|
||||
var FormatHelpers = require('../../Shared/FormatHelpers');
|
||||
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'timeleft-cell',
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
if(this.cellValue) {
|
||||
if(this.cellValue.get('status').toLowerCase() === 'pending') {
|
||||
var ect = this.cellValue.get('estimatedCompletionTime');
|
||||
var time = '{0} at {1}'.format(FormatHelpers.relativeDate(ect), moment(ect).format(UiSettingsModel.time(true, false)));
|
||||
this.$el.html('-');
|
||||
this.$el.attr('title', 'Will be processed during the first RSS Sync after {0}'.format(time));
|
||||
this.$el.attr('data-container', 'body');
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
var timeleft = this.cellValue.get('timeleft');
|
||||
var totalSize = fileSize(this.cellValue.get('size'), 1, false);
|
||||
var remainingSize = fileSize(this.cellValue.get('sizeleft'), 1, false);
|
||||
if(timeleft === undefined) {
|
||||
this.$el.html('-');
|
||||
}
|
||||
else {
|
||||
this.$el.html('<span title="{1} / {2}">{0}</span>'.format(timeleft, remainingSize, totalSize));
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user