1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-01-04 06:38:28 +02:00

UI Cleanup - Updated Activity subtree.

This commit is contained in:
Taloth Saldono 2015-02-13 22:03:50 +01:00
parent b308f06af3
commit b556eda4a0
25 changed files with 659 additions and 510 deletions

View File

@ -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" />

View File

@ -7,26 +7,31 @@ 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 : { events : {
"click .x-queue-tab" : '_showQueue', 'click .x-queue-tab' : '_showQueue',
"click .x-history-tab" : '_showHistory', 'click .x-history-tab' : '_showHistory',
"click .x-blacklist-tab" : '_showBlacklist' 'click .x-blacklist-tab' : '_showBlacklist'
}, },
initialize : function(options) { initialize : function(options) {
if (options.action) { 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':
@ -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) { _showHistory : function(e) {
if (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) { _showBlacklist : function(e) {
if (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) { _showQueue : function(e) {
if (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');

View File

@ -2,14 +2,18 @@ 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();
} }

View File

@ -3,15 +3,16 @@ 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 : { queryParams : {
totalPages : null, totalPages : null,
totalRecords : null, totalRecords : null,
@ -23,17 +24,24 @@ module.exports = (function(){
'1' : 'desc' '1' : 'desc'
} }
}, },
sortMappings : {'series' : {sortKey : 'series.sortTitle'}},
sortMappings : {
'series' : { sortKey : 'series.sortTitle' }
},
parseState : function(resp) { parseState : function(resp) {
return { totalRecords : resp.totalRecords }; return { totalRecords : resp.totalRecords };
}, },
parseRecords : function(resp) { parseRecords : function(resp) {
if (resp) { if (resp) {
return resp.records; return resp.records;
} }
return resp; return resp;
} }
}); });
Collection = AsSortedCollection.call(Collection); Collection = AsSortedCollection.call(Collection);
return AsPersistedStateCollection.call(Collection); Collection = AsPersistedStateCollection.call(Collection);
}).call(this);
module.exports = Collection;

View File

@ -12,77 +12,100 @@ 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 : [{
columns : [
{
name : 'series', name : 'series',
label : 'Series', label : 'Series',
cell : SeriesTitleCell cell : SeriesTitleCell
}, { },
{
name : 'sourceTitle', name : 'sourceTitle',
label : 'Source Title', label : 'Source Title',
cell : 'string' cell : 'string'
}, { },
{
name : 'quality', name : 'quality',
label : 'Quality', label : 'Quality',
cell : QualityCell, cell : QualityCell,
sortable : false sortable : false
}, { },
{
name : 'date', name : 'date',
label : 'Date', label : 'Date',
cell : RelativeDateCell cell : RelativeDateCell
}, { },
{
name : 'this', name : 'this',
label : '', label : '',
cell : BlacklistActionsCell, cell : BlacklistActionsCell,
sortable : false sortable : false
}], }
],
initialize : function() { initialize : function() {
this.collection = new BlacklistCollection({ tableName : 'blacklist' }); 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', title : 'Clear Blacklist',
icon : 'icon-trash', icon : 'icon-trash',
command : 'clearBlacklist' 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) { _commandComplete : function(options) {
if (options.command.get('name') === 'clearblacklist') { if (options.command.get('name') === 'clearblacklist') {
this._refreshTable(); this._refreshTable();

View File

@ -2,11 +2,14 @@ var Backbone = require('backbone');
var SeriesCollection = require('../../Series/SeriesCollection'); var SeriesCollection = require('../../Series/SeriesCollection');
module.exports = Backbone.Model.extend({ module.exports = Backbone.Model.extend({
//Hack to deal with Backbone 1.0's bug
initialize : function() { initialize : function() {
this.url = 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;

View File

@ -1,13 +1,14 @@
var Handlebars = require('handlebars'); var Handlebars = require('handlebars');
module.exports = (function(){
Handlebars.registerHelper('historyAge', function() { Handlebars.registerHelper('historyAge', function() {
var unit = 'days'; var unit = 'days';
var age = this.age; var age = this.age;
if (age < 2) { if (age < 2) {
unit = 'hours'; unit = 'hours';
age = parseFloat(this.ageHours).toFixed(1); age = parseFloat(this.ageHours).toFixed(1);
} }
return new Handlebars.SafeString('<dt>Age (when grabbed):</dt><dd>{0} {1}</dd>'.format(age, unit)); return new Handlebars.SafeString('<dt>Age (when grabbed):</dt><dd>{0} {1}</dd>'.format(age, unit));
}); });
}).call(this);

View File

@ -5,19 +5,31 @@ 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 : {
bodyRegion : '.modal-body'
},
events : {
'click .x-mark-as-failed' : '_markAsFailed'
},
onShow : function() { onShow : function() {
this.bodyRegion.show(new HistoryDetailsView({ model : this.model })); 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);
} }
}); });

View File

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

View File

@ -4,15 +4,16 @@ 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 : { queryParams : {
totalPages : null, totalPages : null,
totalRecords : null, totalRecords : null,
@ -20,37 +21,63 @@ module.exports = (function(){
sortKey : 'sortKey', sortKey : 'sortKey',
order : 'sortDir', order : 'sortDir',
directions : { directions : {
"-1" : 'asc', '-1' : 'asc',
"1" : 'desc' '1' : 'desc'
} }
}, },
filterModes : { filterModes : {
"all" : [null, null], 'all' : [
"grabbed" : ['eventType', '1'], null,
"imported" : ['eventType', '3'], null
"failed" : ['eventType', '4'], ],
"deleted" : ['eventType', '5'] 'grabbed' : [
'eventType',
'1'
],
'imported' : [
'eventType',
'3'
],
'failed' : [
'eventType',
'4'
],
'deleted' : [
'eventType',
'5'
]
}, },
sortMappings : {"series" : {sortKey : 'series.sortTitle'}},
sortMappings : {
'series' : { sortKey : 'series.sortTitle' }
},
initialize : function(options) { initialize : function(options) {
delete this.queryParams.episodeId; delete this.queryParams.episodeId;
if (options) { if (options) {
if (options.episodeId) { if (options.episodeId) {
this.queryParams.episodeId = options.episodeId; this.queryParams.episodeId = options.episodeId;
} }
} }
}, },
parseState : function(resp) { parseState : function(resp) {
return { totalRecords : resp.totalRecords }; return { totalRecords : resp.totalRecords };
}, },
parseRecords : function(resp) { parseRecords : function(resp) {
if (resp) { if (resp) {
return resp.records; return resp.records;
} }
return resp; return resp;
} }
}); });
Collection = AsFilteredCollection.call(Collection); Collection = AsFilteredCollection.call(Collection);
Collection = AsSortedCollection.call(Collection); Collection = AsSortedCollection.call(Collection);
return AsPersistedStateCollection.call(Collection); Collection = AsPersistedStateCollection.call(Collection);
}).call(this);
module.exports = Collection;

View File

@ -3,12 +3,18 @@ var NzbDroneCell = require('../../Cells/NzbDroneCell');
module.exports = NzbDroneCell.extend({ module.exports = NzbDroneCell.extend({
className : 'history-details-cell', className : 'history-details-cell',
events : {"click" : '_showDetails'},
events : {
'click' : '_showDetails'
},
render : function() { 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() { _showDetails : function() {
vent.trigger(vent.Commands.ShowHistoryDetails, { model : this.model }); vent.trigger(vent.Commands.ShowHistoryDetails, { model : this.model });
} }

View File

@ -14,111 +14,139 @@ 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 : [{
columns : [
{
name : 'eventType', name : 'eventType',
label : '', label : '',
cell : EventTypeCell, cell : EventTypeCell,
cellValue : 'this' cellValue : 'this'
}, { },
{
name : 'series', name : 'series',
label : 'Series', label : 'Series',
cell : SeriesTitleCell cell : SeriesTitleCell
}, { },
{
name : 'episode', name : 'episode',
label : 'Episode', label : 'Episode',
cell : EpisodeNumberCell, cell : EpisodeNumberCell,
sortable : false sortable : false
}, { },
{
name : 'episode', name : 'episode',
label : 'Episode Title', label : 'Episode Title',
cell : EpisodeTitleCell, cell : EpisodeTitleCell,
sortable : false sortable : false
}, { },
{
name : 'this', name : 'this',
label : 'Quality', label : 'Quality',
cell : HistoryQualityCell, cell : HistoryQualityCell,
sortable : false sortable : false
}, { },
{
name : 'date', name : 'date',
label : 'Date', label : 'Date',
cell : RelativeDateCell cell : RelativeDateCell
}, { },
{
name : 'this', name : 'this',
label : '', label : '',
cell : HistoryDetailsCell, cell : HistoryDetailsCell,
sortable : false sortable : false
}], }
],
initialize : function() { initialize : function() {
this.collection = new HistoryCollection({ tableName : 'history' }); 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', key : 'all',
title : '', title : '',
tooltip : 'All', tooltip : 'All',
icon : 'icon-circle-blank', icon : 'icon-circle-blank',
callback : this._setFilter callback : this._setFilter
}, { },
{
key : 'grabbed', key : 'grabbed',
title : '', title : '',
tooltip : 'Grabbed', tooltip : 'Grabbed',
icon : 'icon-nd-downloading', icon : 'icon-nd-downloading',
callback : this._setFilter callback : this._setFilter
}, { },
{
key : 'imported', key : 'imported',
title : '', title : '',
tooltip : 'Imported', tooltip : 'Imported',
icon : 'icon-nd-imported', icon : 'icon-nd-imported',
callback : this._setFilter callback : this._setFilter
}, { },
{
key : 'failed', key : 'failed',
title : '', title : '',
tooltip : 'Failed', tooltip : 'Failed',
icon : 'icon-nd-download-failed', icon : 'icon-nd-download-failed',
callback : this._setFilter callback : this._setFilter
}, { },
{
key : 'deleted', key : 'deleted',
title : '', title : '',
tooltip : 'Deleted', tooltip : 'Deleted',
icon : 'icon-nd-deleted', icon : 'icon-nd-deleted',
callback : this._setFilter 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);
} }

View File

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

View File

@ -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') { if (status === 'downloading') {
var progress = 100 - this.model.get('sizeleft') / this.model.get('size') * 100; 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));
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;
} }
}); });

View File

@ -1,14 +1,12 @@
'use strict'; 'use strict';
define( var $ = require('jquery');
[ var vent = require('../../vent');
'jquery', var Marionette = require('marionette');
'marionette', var TemplatedCell = require('../../Cells/TemplatedCell');
'Cells/TemplatedCell', var RemoveFromQueueView = require('./RemoveFromQueueView');
'Activity/Queue/RemoveFromQueueView',
'vent' module.exports = TemplatedCell.extend({
], function ($, Marionette, TemplatedCell, RemoveFromQueueView, vent) {
return TemplatedCell.extend({
template : 'Activity/Queue/QueueActionsCellTemplate', template : 'Activity/Queue/QueueActionsCellTemplate',
className : 'queue-actions-cell', className : 'queue-actions-cell',
@ -25,10 +23,12 @@ define(
}, },
_remove : function() { _remove : function() {
var showBlacklist = this.model.get('status') !== 'Pending'; var showBlacklist = this.model.get('status') !== 'Pending';
vent.trigger(vent.Commands.OpenModalCommand, new RemoveFromQueueView({ model: this.model, showBlacklist: showBlacklist })); vent.trigger(vent.Commands.OpenModalCommand, new RemoveFromQueueView({
model : this.model,
showBlacklist : showBlacklist
}));
}, },
_import : function() { _import : function() {
@ -65,4 +65,3 @@ define(
}); });
} }
}); });
});

View File

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

View File

@ -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 : {
pageSize : 15
},
mode : 'client', mode : 'client',
findEpisode : function(episodeId) { findEpisode : function(episodeId) {
return _.find(this.fullCollection.models, function(queueModel) { return _.find(this.fullCollection.models, function(queueModel) {
return queueModel.get('episode').id === episodeId; return queueModel.get('episode').id === episodeId;
}); });
} }
}); });
var collection = new QueueCollection().bindSignalR(); var collection = new QueueCollection().bindSignalR();
collection.fetch(); collection.fetch();
return collection;
}).call(this); module.exports = collection;

View File

@ -1,33 +1,18 @@
'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', module.exports = Marionette.Layout.extend({
'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', template : 'Activity/Queue/QueueLayoutTemplate',
regions : { regions : {
@ -35,8 +20,7 @@ define(
pager : '#x-queue-pager' pager : '#x-queue-pager'
}, },
columns: columns : [
[
{ {
name : 'status', name : 'status',
label : '', label : '',
@ -113,4 +97,3 @@ define(
})); }));
} }
}); });
});

View File

@ -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>

View File

@ -4,8 +4,10 @@ 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';
@ -13,47 +15,57 @@ module.exports = NzbDroneCell.extend({
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 (trackedDownloadStatus === 'error') {
if (status === 'completed') { 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,

View File

@ -4,29 +4,36 @@ 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;
} }

View File

@ -1,11 +1,7 @@
'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 : {
@ -36,4 +32,3 @@ define(
}); });
} }
}); });
});

View File

@ -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) {
if (this.cellValue.get('status').toLowerCase() === 'pending') { 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;
} }
}); });