UI Cleanup - Updated Activity subtree.

pull/4/head
Taloth Saldono 9 years ago
parent b308f06af3
commit b556eda4a0

@ -21,6 +21,7 @@
<option name="ALIGN_OBJECT_PROPERTIES" value="2" /> <option name="ALIGN_OBJECT_PROPERTIES" value="2" />
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" /> <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
<option name="OBJECT_LITERAL_WRAP" value="2" /> <option name="OBJECT_LITERAL_WRAP" value="2" />
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
</JSCodeStyleSettings> </JSCodeStyleSettings>
<XML> <XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" /> <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
@ -34,15 +35,18 @@
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="true" /> <option name="LINE_COMMENT_AT_FIRST_COLUMN" value="true" />
<option name="KEEP_LINE_BREAKS" value="false" /> <option name="KEEP_LINE_BREAKS" value="false" />
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" /> <option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
<option name="ELSE_ON_NEW_LINE" value="true" /> <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="CATCH_ON_NEW_LINE" value="true" /> <option name="CATCH_ON_NEW_LINE" value="true" />
<option name="FINALLY_ON_NEW_LINE" value="true" /> <option name="FINALLY_ON_NEW_LINE" value="true" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" /> <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" />
<option name="SPACE_BEFORE_METHOD_PARENTHESES" value="true" /> <option name="SPACE_BEFORE_METHOD_PARENTHESES" value="true" />
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false" /> <option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="SPACE_BEFORE_METHOD_LBRACE" value="false" /> <option name="BINARY_OPERATION_WRAP" value="1" />
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" /> <option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" /> <option name="ARRAY_INITIALIZER_WRAP" value="2" />
<option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
<option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
<option name="IF_BRACE_FORCE" value="3" /> <option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" /> <option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" /> <option name="WHILE_BRACE_FORCE" value="3" />

@ -6,28 +6,33 @@ var BlacklistLayout = require('./Blacklist/BlacklistLayout');
var QueueLayout = require('./Queue/QueueLayout'); var QueueLayout = require('./Queue/QueueLayout');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Activity/ActivityLayoutTemplate', template : 'Activity/ActivityLayoutTemplate',
regions : {
regions : {
queueRegion : '#queue', queueRegion : '#queue',
history : '#history', history : '#history',
blacklist : '#blacklist' blacklist : '#blacklist'
}, },
ui : {
ui : {
queueTab : '.x-queue-tab', queueTab : '.x-queue-tab',
historyTab : '.x-history-tab', historyTab : '.x-history-tab',
blacklistTab : '.x-blacklist-tab' blacklistTab : '.x-blacklist-tab'
}, },
events : {
"click .x-queue-tab" : '_showQueue', events : {
"click .x-history-tab" : '_showHistory', 'click .x-queue-tab' : '_showQueue',
"click .x-blacklist-tab" : '_showBlacklist' 'click .x-history-tab' : '_showHistory',
'click .x-blacklist-tab' : '_showBlacklist'
}, },
initialize : function(options){
if(options.action) { initialize : function(options) {
if (options.action) {
this.action = options.action.toLowerCase(); this.action = options.action.toLowerCase();
} }
}, },
onShow : function(){
onShow : function() {
switch (this.action) { switch (this.action) {
case 'history': case 'history':
this._showHistory(); this._showHistory();
@ -39,32 +44,39 @@ module.exports = Marionette.Layout.extend({
this._showQueue(); this._showQueue();
} }
}, },
_navigate : function(route){
_navigate : function(route) {
Backbone.history.navigate(route, { Backbone.history.navigate(route, {
trigger : false, trigger : false,
replace : true replace : true
}); });
}, },
_showHistory : function(e){
if(e) { _showHistory : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.history.show(new HistoryLayout()); this.history.show(new HistoryLayout());
this.ui.historyTab.tab('show'); this.ui.historyTab.tab('show');
this._navigate('/activity/history'); this._navigate('/activity/history');
}, },
_showBlacklist : function(e){
if(e) { _showBlacklist : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.blacklist.show(new BlacklistLayout()); this.blacklist.show(new BlacklistLayout());
this.ui.blacklistTab.tab('show'); this.ui.blacklistTab.tab('show');
this._navigate('/activity/blacklist'); this._navigate('/activity/blacklist');
}, },
_showQueue : function(e){
if(e) { _showQueue : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.queueRegion.show(new QueueLayout()); this.queueRegion.show(new QueueLayout());
this.ui.queueTab.tab('show'); this.ui.queueTab.tab('show');
this._navigate('/activity/queue'); this._navigate('/activity/queue');

@ -2,15 +2,19 @@ var NzbDroneCell = require('../../Cells/NzbDroneCell');
module.exports = NzbDroneCell.extend({ module.exports = NzbDroneCell.extend({
className : 'blacklist-controls-cell', className : 'blacklist-controls-cell',
events : {
events : {
'click' : '_delete' 'click' : '_delete'
}, },
render : function(){
render : function() {
this.$el.empty(); this.$el.empty();
this.$el.html('<i class="icon-nd-delete"></i>'); this.$el.html('<i class="icon-nd-delete"></i>');
return this; return this;
}, },
_delete : function(){
_delete : function() {
this.model.destroy(); this.model.destroy();
} }
}); });

@ -3,37 +3,45 @@ var PageableCollection = require('backbone.pageable');
var AsSortedCollection = require('../../Mixins/AsSortedCollection'); var AsSortedCollection = require('../../Mixins/AsSortedCollection');
var AsPersistedStateCollection = require('../../Mixins/AsPersistedStateCollection'); var AsPersistedStateCollection = require('../../Mixins/AsPersistedStateCollection');
module.exports = (function(){ var Collection = PageableCollection.extend({
var Collection = PageableCollection.extend({ url : window.NzbDrone.ApiRoot + '/blacklist',
url : window.NzbDrone.ApiRoot + '/blacklist', model : BlacklistModel,
model : BlacklistModel,
state : { state : {
pageSize : 15, pageSize : 15,
sortKey : 'date', sortKey : 'date',
order : 1 order : 1
}, },
queryParams : {
totalPages : null, queryParams : {
totalRecords : null, totalPages : null,
pageSize : 'pageSize', totalRecords : null,
sortKey : 'sortKey', pageSize : 'pageSize',
order : 'sortDir', sortKey : 'sortKey',
directions : { order : 'sortDir',
'-1' : 'asc', directions : {
'1' : 'desc' '-1' : 'asc',
} '1' : 'desc'
}, }
sortMappings : {'series' : {sortKey : 'series.sortTitle'}}, },
parseState : function(resp){
return {totalRecords : resp.totalRecords}; sortMappings : {
}, 'series' : { sortKey : 'series.sortTitle' }
parseRecords : function(resp){ },
if(resp) {
return resp.records; parseState : function(resp) {
} return { totalRecords : resp.totalRecords };
return resp; },
parseRecords : function(resp) {
if (resp) {
return resp.records;
} }
});
Collection = AsSortedCollection.call(Collection); return resp;
return AsPersistedStateCollection.call(Collection); }
}).call(this); });
Collection = AsSortedCollection.call(Collection);
Collection = AsPersistedStateCollection.call(Collection);
module.exports = Collection;

@ -11,81 +11,104 @@ var LoadingView = require('../../Shared/LoadingView');
var ToolbarLayout = require('../../Shared/Toolbar/ToolbarLayout'); var ToolbarLayout = require('../../Shared/Toolbar/ToolbarLayout');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Activity/Blacklist/BlacklistLayoutTemplate', template : 'Activity/Blacklist/BlacklistLayoutTemplate',
regions : {
regions : {
blacklist : '#x-blacklist', blacklist : '#x-blacklist',
toolbar : '#x-toolbar', toolbar : '#x-toolbar',
pager : '#x-pager' pager : '#x-pager'
}, },
columns : [{
name : 'series', columns : [
label : 'Series', {
cell : SeriesTitleCell name : 'series',
}, { label : 'Series',
name : 'sourceTitle', cell : SeriesTitleCell
label : 'Source Title', },
cell : 'string' {
}, { name : 'sourceTitle',
name : 'quality', label : 'Source Title',
label : 'Quality', cell : 'string'
cell : QualityCell, },
sortable : false {
}, { name : 'quality',
name : 'date', label : 'Quality',
label : 'Date', cell : QualityCell,
cell : RelativeDateCell sortable : false
}, { },
name : 'this', {
label : '', name : 'date',
cell : BlacklistActionsCell, label : 'Date',
sortable : false cell : RelativeDateCell
}], },
initialize : function(){ {
this.collection = new BlacklistCollection({tableName : 'blacklist'}); name : 'this',
label : '',
cell : BlacklistActionsCell,
sortable : false
}
],
initialize : function() {
this.collection = new BlacklistCollection({ tableName : 'blacklist' });
this.listenTo(this.collection, 'sync', this._showTable); this.listenTo(this.collection, 'sync', this._showTable);
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete); this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
}, },
onShow : function(){
onShow : function() {
this.blacklist.show(new LoadingView()); this.blacklist.show(new LoadingView());
this._showToolbar(); this._showToolbar();
this.collection.fetch(); this.collection.fetch();
}, },
_showTable : function(collection){
_showTable : function(collection) {
this.blacklist.show(new Backgrid.Grid({ this.blacklist.show(new Backgrid.Grid({
columns : this.columns, columns : this.columns,
collection : collection, collection : collection,
className : 'table table-hover' className : 'table table-hover'
})); }));
this.pager.show(new GridPager({ this.pager.show(new GridPager({
columns : this.columns, columns : this.columns,
collection : collection collection : collection
})); }));
}, },
_showToolbar : function(){
_showToolbar : function() {
var leftSideButtons = { var leftSideButtons = {
type : 'default', type : 'default',
storeState : false, storeState : false,
items : [{ items : [
title : 'Clear Blacklist', {
icon : 'icon-trash', title : 'Clear Blacklist',
command : 'clearBlacklist' icon : 'icon-trash',
}] command : 'clearBlacklist'
}
]
}; };
this.toolbar.show(new ToolbarLayout({ this.toolbar.show(new ToolbarLayout({
left : [leftSideButtons], left : [
leftSideButtons
],
context : this context : this
})); }));
}, },
_refreshTable : function(buttonContext){
_refreshTable : function(buttonContext) {
this.collection.state.currentPage = 1; this.collection.state.currentPage = 1;
var promise = this.collection.fetch({reset : true}); var promise = this.collection.fetch({ reset : true });
if(buttonContext) {
if (buttonContext) {
buttonContext.ui.icon.spinForPromise(promise); buttonContext.ui.icon.spinForPromise(promise);
} }
}, },
_commandComplete : function(options){
if(options.command.get('name') === 'clearblacklist') { _commandComplete : function(options) {
if (options.command.get('name') === 'clearblacklist') {
this._refreshTable(); this._refreshTable();
} }
} }
}); });

@ -2,12 +2,15 @@ var Backbone = require('backbone');
var SeriesCollection = require('../../Series/SeriesCollection'); var SeriesCollection = require('../../Series/SeriesCollection');
module.exports = Backbone.Model.extend({ module.exports = Backbone.Model.extend({
initialize : function(){
this.url = function(){ //Hack to deal with Backbone 1.0's bug
initialize : function() {
this.url = function() {
return this.collection.url + '/' + this.get('id'); return this.collection.url + '/' + this.get('id');
}; };
}, },
parse : function(model){
parse : function(model) {
model.series = SeriesCollection.get(model.seriesId); model.series = SeriesCollection.get(model.seriesId);
return model; return model;
} }

@ -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) {
unit = 'hours'; if (age < 2) {
age = parseFloat(this.ageHours).toFixed(1); 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); return new Handlebars.SafeString('<dt>Age (when grabbed):</dt><dd>{0} {1}</dd>'.format(age, unit));
});

@ -4,20 +4,32 @@ var Marionette = require('marionette');
var HistoryDetailsView = require('./HistoryDetailsView'); var HistoryDetailsView = require('./HistoryDetailsView');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Activity/History/Details/HistoryDetailsLayoutTemplate', template : 'Activity/History/Details/HistoryDetailsLayoutTemplate',
regions : {bodyRegion : '.modal-body'},
events : {"click .x-mark-as-failed" : '_markAsFailed'}, regions : {
onShow : function(){ bodyRegion : '.modal-body'
this.bodyRegion.show(new HistoryDetailsView({model : this.model})); },
events : {
'click .x-mark-as-failed' : '_markAsFailed'
},
onShow : function() {
this.bodyRegion.show(new HistoryDetailsView({ model : this.model }));
}, },
_markAsFailed : function(){
_markAsFailed : function() {
var url = window.NzbDrone.ApiRoot + '/history/failed'; var url = window.NzbDrone.ApiRoot + '/history/failed';
var data = {id : this.model.get('id')}; var data = {
id : this.model.get('id')
};
$.ajax({ $.ajax({
url : url, url : url,
type : 'POST', type : 'POST',
data : data data : data
}); });
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
} }
}); });

@ -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'
});

@ -4,53 +4,80 @@ var AsFilteredCollection = require('../../Mixins/AsFilteredCollection');
var AsSortedCollection = require('../../Mixins/AsSortedCollection'); var AsSortedCollection = require('../../Mixins/AsSortedCollection');
var AsPersistedStateCollection = require('../../Mixins/AsPersistedStateCollection'); var AsPersistedStateCollection = require('../../Mixins/AsPersistedStateCollection');
module.exports = (function(){ var Collection = PageableCollection.extend({
var Collection = PageableCollection.extend({ url : window.NzbDrone.ApiRoot + '/history',
url : window.NzbDrone.ApiRoot + '/history', model : HistoryModel,
model : HistoryModel,
state : { state : {
pageSize : 15, pageSize : 15,
sortKey : 'date', sortKey : 'date',
order : 1 order : 1
}, },
queryParams : {
totalPages : null, queryParams : {
totalRecords : null, totalPages : null,
pageSize : 'pageSize', totalRecords : null,
sortKey : 'sortKey', pageSize : 'pageSize',
order : 'sortDir', sortKey : 'sortKey',
directions : { order : 'sortDir',
"-1" : 'asc', directions : {
"1" : 'desc' '-1' : 'asc',
} '1' : 'desc'
}, }
filterModes : { },
"all" : [null, null],
"grabbed" : ['eventType', '1'], filterModes : {
"imported" : ['eventType', '3'], 'all' : [
"failed" : ['eventType', '4'], null,
"deleted" : ['eventType', '5'] null
}, ],
sortMappings : {"series" : {sortKey : 'series.sortTitle'}}, 'grabbed' : [
initialize : function(options){ 'eventType',
delete this.queryParams.episodeId; '1'
if(options) { ],
if(options.episodeId) { 'imported' : [
this.queryParams.episodeId = options.episodeId; 'eventType',
} '3'
} ],
}, 'failed' : [
parseState : function(resp){ 'eventType',
return {totalRecords : resp.totalRecords}; '4'
}, ],
parseRecords : function(resp){ 'deleted' : [
if(resp) { 'eventType',
return resp.records; '5'
]
},
sortMappings : {
'series' : { sortKey : 'series.sortTitle' }
},
initialize : function(options) {
delete this.queryParams.episodeId;
if (options) {
if (options.episodeId) {
this.queryParams.episodeId = options.episodeId;
} }
return resp;
} }
}); },
Collection = AsFilteredCollection.call(Collection);
Collection = AsSortedCollection.call(Collection); parseState : function(resp) {
return AsPersistedStateCollection.call(Collection); return { totalRecords : resp.totalRecords };
}).call(this); },
parseRecords : function(resp) {
if (resp) {
return resp.records;
}
return resp;
}
});
Collection = AsFilteredCollection.call(Collection);
Collection = AsSortedCollection.call(Collection);
Collection = AsPersistedStateCollection.call(Collection);
module.exports = Collection;

@ -2,14 +2,20 @@ var vent = require('vent');
var NzbDroneCell = require('../../Cells/NzbDroneCell'); var NzbDroneCell = require('../../Cells/NzbDroneCell');
module.exports = NzbDroneCell.extend({ module.exports = NzbDroneCell.extend({
className : 'history-details-cell', className : 'history-details-cell',
events : {"click" : '_showDetails'},
render : function(){ events : {
'click' : '_showDetails'
},
render : function() {
this.$el.empty(); this.$el.empty();
this.$el.html('<i class="icon-info-sign"></i>'); this.$el.html('<i class="icon-info-sign"></i>');
return this; return this;
}, },
_showDetails : function(){
vent.trigger(vent.Commands.ShowHistoryDetails, {model : this.model}); _showDetails : function() {
vent.trigger(vent.Commands.ShowHistoryDetails, { model : this.model });
} }
}); });

@ -13,114 +13,142 @@ var ToolbarLayout = require('../../Shared/Toolbar/ToolbarLayout');
var LoadingView = require('../../Shared/LoadingView'); var LoadingView = require('../../Shared/LoadingView');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Activity/History/HistoryLayoutTemplate', template : 'Activity/History/HistoryLayoutTemplate',
regions : {
regions : {
history : '#x-history', history : '#x-history',
toolbar : '#x-history-toolbar', toolbar : '#x-history-toolbar',
pager : '#x-history-pager' pager : '#x-history-pager'
}, },
columns : [{
name : 'eventType', columns : [
label : '', {
cell : EventTypeCell, name : 'eventType',
cellValue : 'this' label : '',
}, { cell : EventTypeCell,
name : 'series', cellValue : 'this'
label : 'Series', },
cell : SeriesTitleCell {
}, { name : 'series',
name : 'episode', label : 'Series',
label : 'Episode', cell : SeriesTitleCell
cell : EpisodeNumberCell, },
sortable : false {
}, { name : 'episode',
name : 'episode', label : 'Episode',
label : 'Episode Title', cell : EpisodeNumberCell,
cell : EpisodeTitleCell, sortable : false
sortable : false },
}, { {
name : 'this', name : 'episode',
label : 'Quality', label : 'Episode Title',
cell : HistoryQualityCell, cell : EpisodeTitleCell,
sortable : false sortable : false
}, { },
name : 'date', {
label : 'Date', name : 'this',
cell : RelativeDateCell label : 'Quality',
}, { cell : HistoryQualityCell,
name : 'this', sortable : false
label : '', },
cell : HistoryDetailsCell, {
sortable : false name : 'date',
}], label : 'Date',
initialize : function(){ cell : RelativeDateCell
this.collection = new HistoryCollection({tableName : 'history'}); },
{
name : 'this',
label : '',
cell : HistoryDetailsCell,
sortable : false
}
],
initialize : function() {
this.collection = new HistoryCollection({ tableName : 'history' });
this.listenTo(this.collection, 'sync', this._showTable); this.listenTo(this.collection, 'sync', this._showTable);
}, },
onShow : function(){
onShow : function() {
this.history.show(new LoadingView()); this.history.show(new LoadingView());
this._showToolbar(); this._showToolbar();
}, },
_showTable : function(collection){
_showTable : function(collection) {
this.history.show(new Backgrid.Grid({ this.history.show(new Backgrid.Grid({
columns : this.columns, columns : this.columns,
collection : collection, collection : collection,
className : 'table table-hover' className : 'table table-hover'
})); }));
this.pager.show(new GridPager({ this.pager.show(new GridPager({
columns : this.columns, columns : this.columns,
collection : collection collection : collection
})); }));
}, },
_showToolbar : function(){
_showToolbar : function() {
var filterOptions = { var filterOptions = {
type : 'radio', type : 'radio',
storeState : true, storeState : true,
menuKey : 'history.filterMode', menuKey : 'history.filterMode',
defaultAction : 'all', defaultAction : 'all',
items : [{ items : [
key : 'all', {
title : '', key : 'all',
tooltip : 'All', title : '',
icon : 'icon-circle-blank', tooltip : 'All',
callback : this._setFilter icon : 'icon-circle-blank',
}, { callback : this._setFilter
key : 'grabbed', },
title : '', {
tooltip : 'Grabbed', key : 'grabbed',
icon : 'icon-nd-downloading', title : '',
callback : this._setFilter tooltip : 'Grabbed',
}, { icon : 'icon-nd-downloading',
key : 'imported', callback : this._setFilter
title : '', },
tooltip : 'Imported', {
icon : 'icon-nd-imported', key : 'imported',
callback : this._setFilter title : '',
}, { tooltip : 'Imported',
key : 'failed', icon : 'icon-nd-imported',
title : '', callback : this._setFilter
tooltip : 'Failed', },
icon : 'icon-nd-download-failed', {
callback : this._setFilter key : 'failed',
}, { title : '',
key : 'deleted', tooltip : 'Failed',
title : '', icon : 'icon-nd-download-failed',
tooltip : 'Deleted', callback : this._setFilter
icon : 'icon-nd-deleted', },
callback : this._setFilter {
}] key : 'deleted',
title : '',
tooltip : 'Deleted',
icon : 'icon-nd-deleted',
callback : this._setFilter
}
]
}; };
this.toolbar.show(new ToolbarLayout({ this.toolbar.show(new ToolbarLayout({
right : [filterOptions], right : [
filterOptions
],
context : this context : this
})); }));
}, },
_setFilter : function(buttonContext){
_setFilter : function(buttonContext) {
var mode = buttonContext.model.get('key'); var mode = buttonContext.model.get('key');
this.collection.state.currentPage = 1; this.collection.state.currentPage = 1;
var promise = this.collection.setFilterMode(mode); var promise = this.collection.setFilterMode(mode);
if(buttonContext) {
if (buttonContext) {
buttonContext.ui.icon.spinForPromise(promise); buttonContext.ui.icon.spinForPromise(promise);
} }
} }
}); });

@ -3,7 +3,7 @@ var SeriesModel = require('../../Series/SeriesModel');
var EpisodeModel = require('../../Series/EpisodeModel'); var EpisodeModel = require('../../Series/EpisodeModel');
module.exports = Backbone.Model.extend({ module.exports = Backbone.Model.extend({
parse : function(model){ parse : function(model) {
model.series = new SeriesModel(model.series); model.series = new SeriesModel(model.series);
model.episode = new EpisodeModel(model.episode); model.episode = new EpisodeModel(model.episode);
model.episode.set('series', model.series); model.episode.set('series', model.series);

@ -2,23 +2,29 @@ var NzbDroneCell = require('../../Cells/NzbDroneCell');
module.exports = NzbDroneCell.extend({ module.exports = NzbDroneCell.extend({
className : 'history-quality-cell', className : 'history-quality-cell',
render : function(){
render : function() {
var title = ''; var title = '';
var quality = this.model.get('quality'); var quality = this.model.get('quality');
var revision = quality.revision; var revision = quality.revision;
if(revision.real && revision.real > 0) {
if (revision.real && revision.real > 0) {
title += ' REAL'; title += ' REAL';
} }
if(revision.version && revision.version > 1) {
if (revision.version && revision.version > 1) {
title += ' PROPER'; title += ' PROPER';
} }
title = title.trim(); title = title.trim();
if(this.model.get('qualityCutoffNotMet')) {
if (this.model.get('qualityCutoffNotMet')) {
this.$el.html('<span class="badge badge-inverse" title="{0}">{1}</span>'.format(title, quality.quality.name)); this.$el.html('<span class="badge badge-inverse" title="{0}">{1}</span>'.format(title, quality.quality.name));
} } else {
else {
this.$el.html('<span class="badge" title="{0}">{1}</span>'.format(title, quality.quality.name)); this.$el.html('<span class="badge" title="{0}">{1}</span>'.format(title, quality.quality.name));
} }
return this; return this;
} }
}); });

@ -2,15 +2,22 @@ var NzbDroneCell = require('../../Cells/NzbDroneCell');
module.exports = NzbDroneCell.extend({ module.exports = NzbDroneCell.extend({
className : 'progress-cell', className : 'progress-cell',
render : function(){
render : function() {
this.$el.empty(); this.$el.empty();
if(this.cellValue) {
if (this.cellValue) {
var status = this.model.get('status').toLowerCase(); var status = this.model.get('status').toLowerCase();
if(status === 'downloading') {
var progress = 100 - this.model.get('sizeleft') / this.model.get('size') * 100; if (status === 'downloading') {
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)); 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; return this;
} }
}); });

@ -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'
], function ($, Marionette, TemplatedCell, RemoveFromQueueView, vent) {
return TemplatedCell.extend({
template : 'Activity/Queue/QueueActionsCellTemplate', module.exports = TemplatedCell.extend({
className : 'queue-actions-cell',
events: { template : 'Activity/Queue/QueueActionsCellTemplate',
'click .x-remove' : '_remove', className : 'queue-actions-cell',
'click .x-import' : '_import',
'click .x-grab' : '_grab'
},
ui: { events : {
import : '.x-import', 'click .x-remove' : '_remove',
grab : '.x-grab' '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 () { _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,4 +1,4 @@
{{#if_eq status compare="Completed"}} {{#if_eq status compare="Completed"}}
{{#if_eq trackedDownloadStatus compare="Warning"}} {{#if_eq trackedDownloadStatus compare="Warning"}}
<i class="icon-inbox x-import" title="Force import"></i> <i class="icon-inbox x-import" title="Force import"></i>
{{/if_eq}} {{/if_eq}}

@ -4,19 +4,24 @@ var PageableCollection = require('backbone.pageable');
var QueueModel = require('./QueueModel'); var QueueModel = require('./QueueModel');
require('../../Mixins/backbone.signalr.mixin'); require('../../Mixins/backbone.signalr.mixin');
module.exports = (function(){ var QueueCollection = PageableCollection.extend({
var QueueCollection = PageableCollection.extend({ url : window.NzbDrone.ApiRoot + '/queue',
url : window.NzbDrone.ApiRoot + '/queue', model : QueueModel,
model : QueueModel,
state : {pageSize : 15}, state : {
mode : 'client', pageSize : 15
findEpisode : function(episodeId){ },
return _.find(this.fullCollection.models, function(queueModel){
return queueModel.get('episode').id === episodeId; mode : 'client',
});
} findEpisode : function(episodeId) {
}); return _.find(this.fullCollection.models, function(queueModel) {
var collection = new QueueCollection().bindSignalR(); return queueModel.get('episode').id === episodeId;
collection.fetch(); });
return collection; }
}).call(this); });
var collection = new QueueCollection().bindSignalR();
collection.fetch();
module.exports = collection;

@ -1,116 +1,99 @@
'use strict'; var Marionette = require('marionette');
define( var Backgrid = require('backgrid');
[ var QueueCollection = require('./QueueCollection');
'marionette', var SeriesTitleCell = require('../../Cells/SeriesTitleCell');
'backgrid', var EpisodeNumberCell = require('../../Cells/EpisodeNumberCell');
'Activity/Queue/QueueCollection', var EpisodeTitleCell = require('../../Cells/EpisodeTitleCell');
'Cells/SeriesTitleCell', var QualityCell = require('../../Cells/QualityCell');
'Cells/EpisodeNumberCell', var QueueStatusCell = require('./QueueStatusCell');
'Cells/EpisodeTitleCell', var QueueActionsCell = require('./QueueActionsCell');
'Cells/QualityCell', var TimeleftCell = require('./TimeleftCell');
'Activity/Queue/QueueStatusCell', var ProgressCell = require('./ProgressCell');
'Activity/Queue/QueueActionsCell', var ProtocolCell = require('../../Release/ProtocolCell');
'Activity/Queue/TimeleftCell', var GridPager = require('../../Shared/Grid/Pager');
'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',
regions: { module.exports = Marionette.Layout.extend({
table: '#x-queue', template : 'Activity/Queue/QueueLayoutTemplate',
pager: '#x-queue-pager'
},
columns: regions : {
[ table : '#x-queue',
{ pager : '#x-queue-pager'
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'
}
],
initialize: function () { columns : [
this.listenTo(QueueCollection, 'sync', this._showTable); {
}, 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 () { initialize : function() {
this._showTable(); this.listenTo(QueueCollection, 'sync', this._showTable);
}, },
_showTable: function () { onShow : function() {
this.table.show(new Backgrid.Grid({ this._showTable();
columns : this.columns, },
collection: QueueCollection,
className : 'table table-hover'
}));
this.pager.show(new GridPager({ _showTable : function() {
columns : this.columns, this.table.show(new Backgrid.Grid({
collection: QueueCollection columns : this.columns,
})); collection : QueueCollection,
} className : 'table table-hover'
}); }));
});
this.pager.show(new GridPager({
columns : this.columns,
collection : QueueCollection
}));
}
});

@ -1,4 +1,4 @@
<div class="row"> <div class="row">
<div class="col-md-12 table-responsive"> <div class="col-md-12 table-responsive">
<div id="x-queue" class="queue"/> <div id="x-queue" class="queue"/>
</div> </div>

@ -3,7 +3,7 @@ var SeriesModel = require('../../Series/SeriesModel');
var EpisodeModel = require('../../Series/EpisodeModel'); var EpisodeModel = require('../../Series/EpisodeModel');
module.exports = Backbone.Model.extend({ module.exports = Backbone.Model.extend({
parse : function(model){ parse : function(model) {
model.series = new SeriesModel(model.series); model.series = new SeriesModel(model.series);
model.episode = new EpisodeModel(model.episode); model.episode = new EpisodeModel(model.episode);
model.episode.set('series', model.series); model.episode.set('series', model.series);

@ -4,56 +4,68 @@ var NzbDroneCell = require('../../Cells/NzbDroneCell');
module.exports = NzbDroneCell.extend({ module.exports = NzbDroneCell.extend({
className : 'queue-status-cell', className : 'queue-status-cell',
template : 'Activity/Queue/QueueStatusCellTemplate', template : 'Activity/Queue/QueueStatusCellTemplate',
render : function(){
render : function() {
this.$el.empty(); this.$el.empty();
if(this.cellValue) {
if (this.cellValue) {
var status = this.cellValue.get('status').toLowerCase(); var status = this.cellValue.get('status').toLowerCase();
var trackedDownloadStatus = this.cellValue.has('trackedDownloadStatus') ? this.cellValue.get('trackedDownloadStatus').toLowerCase() : 'ok'; var trackedDownloadStatus = this.cellValue.has('trackedDownloadStatus') ? this.cellValue.get('trackedDownloadStatus').toLowerCase() : 'ok';
var icon = 'icon-nd-downloading'; var icon = 'icon-nd-downloading';
var title = 'Downloading'; var title = 'Downloading';
var itemTitle = this.cellValue.get('title'); var itemTitle = this.cellValue.get('title');
var content = itemTitle; var content = itemTitle;
if(status === 'paused') {
if (status === 'paused') {
icon = 'icon-pause'; icon = 'icon-pause';
title = 'Paused'; title = 'Paused';
} }
if(status === 'queued') {
if (status === 'queued') {
icon = 'icon-cloud'; icon = 'icon-cloud';
title = 'Queued'; title = 'Queued';
} }
if(status === 'completed') {
if (status === 'completed') {
icon = 'icon-inbox'; icon = 'icon-inbox';
title = 'Downloaded'; title = 'Downloaded';
} }
if(status === 'pending') {
if (status === 'pending') {
icon = 'icon-time'; icon = 'icon-time';
title = 'Pending'; title = 'Pending';
} }
if(status === 'failed') {
if (status === 'failed') {
icon = 'icon-nd-download-failed'; icon = 'icon-nd-download-failed';
title = 'Download failed'; title = 'Download failed';
} }
if(status === 'warning') {
if (status === 'warning') {
icon = 'icon-nd-download-warning'; icon = 'icon-nd-download-warning';
title = 'Download warning: check download client for more details'; title = 'Download warning: check download client for more details';
} }
if(trackedDownloadStatus === 'warning') {
if (trackedDownloadStatus === 'warning') {
icon += ' icon-nd-warning'; icon += ' icon-nd-warning';
this.templateFunction = Marionette.TemplateCache.get(this.template); this.templateFunction = Marionette.TemplateCache.get(this.template);
content = this.templateFunction(this.cellValue.toJSON()); content = this.templateFunction(this.cellValue.toJSON());
} }
if(trackedDownloadStatus === 'error') {
if(status === 'completed') { if (trackedDownloadStatus === 'error') {
if (status === 'completed') {
icon = 'icon-nd-import-failed'; icon = 'icon-nd-import-failed';
title = 'Import failed: ' + itemTitle; title = 'Import failed: ' + itemTitle;
} } else {
else {
icon = 'icon-nd-download-failed'; icon = 'icon-nd-download-failed';
title = 'Download failed'; title = 'Download failed';
} }
this.templateFunction = Marionette.TemplateCache.get(this.template); this.templateFunction = Marionette.TemplateCache.get(this.template);
content = this.templateFunction(this.cellValue.toJSON()); content = this.templateFunction(this.cellValue.toJSON());
} }
this.$el.html('<i class="{0}"></i>'.format(icon)); this.$el.html('<i class="{0}"></i>'.format(icon));
this.$el.popover({ this.$el.popover({
content : content, content : content,

@ -3,30 +3,37 @@ var Marionette = require('marionette');
var QueueCollection = require('./QueueCollection'); var QueueCollection = require('./QueueCollection');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
tagName : 'span', tagName : 'span',
initialize : function(){
initialize : function() {
this.listenTo(QueueCollection, 'sync', this.render); this.listenTo(QueueCollection, 'sync', this.render);
QueueCollection.fetch(); QueueCollection.fetch();
}, },
render : function(){
render : function() {
this.$el.empty(); this.$el.empty();
if(QueueCollection.length === 0) {
if (QueueCollection.length === 0) {
return this; return this;
} }
var count = QueueCollection.fullCollection.length; var count = QueueCollection.fullCollection.length;
var label = 'label-info'; var label = 'label-info';
var errors = QueueCollection.fullCollection.some(function(model){
var errors = QueueCollection.fullCollection.some(function(model) {
return model.has('trackedDownloadStatus') && model.get('trackedDownloadStatus').toLowerCase() === 'error'; return model.has('trackedDownloadStatus') && model.get('trackedDownloadStatus').toLowerCase() === 'error';
}); });
var warnings = QueueCollection.fullCollection.some(function(model){
var warnings = QueueCollection.fullCollection.some(function(model) {
return model.has('trackedDownloadStatus') && model.get('trackedDownloadStatus').toLowerCase() === 'warning'; return model.has('trackedDownloadStatus') && model.get('trackedDownloadStatus').toLowerCase() === 'warning';
}); });
if(errors) {
if (errors) {
label = 'label-danger'; label = 'label-danger';
} } else if (warnings) {
else if(warnings) {
label = 'label-warning'; label = 'label-warning';
} }
this.$el.html('<span class="label {0}">{1}</span>'.format(label, count)); this.$el.html('<span class="label {0}">{1}</span>'.format(label, count));
return this; return this;
} }

@ -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);
});
}
}); });
}); }
});

@ -6,26 +6,31 @@ var FormatHelpers = require('../../Shared/FormatHelpers');
module.exports = NzbDroneCell.extend({ module.exports = NzbDroneCell.extend({
className : 'timeleft-cell', className : 'timeleft-cell',
render : function(){
render : function() {
this.$el.empty(); this.$el.empty();
if(this.cellValue) {
if(this.cellValue.get('status').toLowerCase() === 'pending') { if (this.cellValue) {
if (this.cellValue.get('status').toLowerCase() === 'pending') {
var ect = this.cellValue.get('estimatedCompletionTime'); var ect = this.cellValue.get('estimatedCompletionTime');
var time = '{0} at {1}'.format(FormatHelpers.relativeDate(ect), moment(ect).format(UiSettingsModel.time(true, false))); var time = '{0} at {1}'.format(FormatHelpers.relativeDate(ect), moment(ect).format(UiSettingsModel.time(true, false)));
this.$el.html('-'); this.$el.html('-');
this.$el.attr('title', 'Will be processed during the first RSS Sync after {0}'.format(time)); this.$el.attr('title', 'Will be processed during the first RSS Sync after {0}'.format(time));
return this; return this;
} }
var timeleft = this.cellValue.get('timeleft'); var timeleft = this.cellValue.get('timeleft');
var totalSize = fileSize(this.cellValue.get('size'), 1, false); var totalSize = fileSize(this.cellValue.get('size'), 1, false);
var remainingSize = fileSize(this.cellValue.get('sizeleft'), 1, false); var remainingSize = fileSize(this.cellValue.get('sizeleft'), 1, false);
if(timeleft === undefined) {
if (timeleft === undefined) {
this.$el.html('-'); this.$el.html('-');
} } else {
else {
this.$el.html('<span title="{1} / {2}">{0}</span>'.format(timeleft, remainingSize, totalSize)); this.$el.html('<span title="{1} / {2}">{0}</span>'.format(timeleft, remainingSize, totalSize));
} }
} }
return this; return this;
} }
}); });
Loading…
Cancel
Save