1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01: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="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
<option name="OBJECT_LITERAL_WRAP" value="2" />
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
</JSCodeStyleSettings>
<XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
@ -34,15 +35,18 @@
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="true" />
<option name="KEEP_LINE_BREAKS" 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="FINALLY_ON_NEW_LINE" value="true" />
<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_IF_PARENTHESES" value="false" />
<option name="SPACE_BEFORE_METHOD_LBRACE" value="false" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<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="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" />

View File

@ -7,27 +7,32 @@ var QueueLayout = require('./Queue/QueueLayout');
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'
'click .x-queue-tab' : '_showQueue',
'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();
}
},
onShow : function(){
onShow : function() {
switch (this.action) {
case 'history':
this._showHistory();
@ -39,32 +44,39 @@ module.exports = Marionette.Layout.extend({
this._showQueue();
}
},
_navigate : function(route){
_navigate : function(route) {
Backbone.history.navigate(route, {
trigger : false,
replace : true
});
},
_showHistory : function(e){
if(e) {
_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) {
_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) {
_showQueue : function(e) {
if (e) {
e.preventDefault();
}
this.queueRegion.show(new QueueLayout());
this.ui.queueTab.tab('show');
this._navigate('/activity/queue');

View File

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

View File

@ -3,15 +3,16 @@ var PageableCollection = require('backbone.pageable');
var AsSortedCollection = require('../../Mixins/AsSortedCollection');
var AsPersistedStateCollection = require('../../Mixins/AsPersistedStateCollection');
module.exports = (function(){
var Collection = PageableCollection.extend({
var Collection = PageableCollection.extend({
url : window.NzbDrone.ApiRoot + '/blacklist',
model : BlacklistModel,
state : {
pageSize : 15,
sortKey : 'date',
order : 1
},
queryParams : {
totalPages : null,
totalRecords : null,
@ -23,17 +24,24 @@ module.exports = (function(){
'1' : 'desc'
}
},
sortMappings : {'series' : {sortKey : 'series.sortTitle'}},
parseState : function(resp){
return {totalRecords : resp.totalRecords};
sortMappings : {
'series' : { sortKey : 'series.sortTitle' }
},
parseRecords : function(resp){
if(resp) {
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);
});
Collection = AsSortedCollection.call(Collection);
Collection = AsPersistedStateCollection.call(Collection);
module.exports = Collection;

View File

@ -12,79 +12,102 @@ var ToolbarLayout = require('../../Shared/Toolbar/ToolbarLayout');
module.exports = Marionette.Layout.extend({
template : 'Activity/Blacklist/BlacklistLayoutTemplate',
regions : {
blacklist : '#x-blacklist',
toolbar : '#x-toolbar',
pager : '#x-pager'
},
columns : [{
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'});
}
],
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(){
onShow : function() {
this.blacklist.show(new LoadingView());
this._showToolbar();
this.collection.fetch();
},
_showTable : function(collection){
_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(){
_showToolbar : function() {
var leftSideButtons = {
type : 'default',
storeState : false,
items : [{
items : [
{
title : 'Clear Blacklist',
icon : 'icon-trash',
command : 'clearBlacklist'
}]
}
]
};
this.toolbar.show(new ToolbarLayout({
left : [leftSideButtons],
left : [
leftSideButtons
],
context : this
}));
},
_refreshTable : function(buttonContext){
_refreshTable : function(buttonContext) {
this.collection.state.currentPage = 1;
var promise = this.collection.fetch({reset : true});
if(buttonContext) {
var promise = this.collection.fetch({ reset : true });
if (buttonContext) {
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();
}
}

View File

@ -2,12 +2,15 @@ var Backbone = require('backbone');
var SeriesCollection = require('../../Series/SeriesCollection');
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');
};
},
parse : function(model){
parse : function(model) {
model.series = SeriesCollection.get(model.seriesId);
return model;
}

View File

@ -1,13 +1,14 @@
var Handlebars = require('handlebars');
module.exports = (function(){
Handlebars.registerHelper('historyAge', function(){
Handlebars.registerHelper('historyAge', function() {
var unit = 'days';
var age = this.age;
if(age < 2) {
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);
});

View File

@ -5,19 +5,31 @@ var HistoryDetailsView = require('./HistoryDetailsView');
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}));
regions : {
bodyRegion : '.modal-body'
},
_markAsFailed : function(){
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')};
var data = {
id : this.model.get('id')
};
$.ajax({
url : url,
type : 'POST',
data : data
});
vent.trigger(vent.Commands.CloseModalCommand);
}
});

View File

@ -1,4 +1,6 @@
var Marionette = require('marionette');
require('./HistoryDetailsAge');
module.exports = Marionette.ItemView.extend({template : 'Activity/History/Details/HistoryDetailsViewTemplate'});
module.exports = Marionette.ItemView.extend({
template : 'Activity/History/Details/HistoryDetailsViewTemplate'
});

View File

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

View File

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

View File

@ -14,112 +14,140 @@ var LoadingView = require('../../Shared/LoadingView');
module.exports = Marionette.Layout.extend({
template : 'Activity/History/HistoryLayoutTemplate',
regions : {
history : '#x-history',
toolbar : '#x-history-toolbar',
pager : '#x-history-pager'
},
columns : [{
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'});
}
],
initialize : function() {
this.collection = new HistoryCollection({ tableName : 'history' });
this.listenTo(this.collection, 'sync', this._showTable);
},
onShow : function(){
onShow : function() {
this.history.show(new LoadingView());
this._showToolbar();
},
_showTable : function(collection){
_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(){
_showToolbar : function() {
var filterOptions = {
type : 'radio',
storeState : true,
menuKey : 'history.filterMode',
defaultAction : 'all',
items : [{
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],
right : [
filterOptions
],
context : this
}));
},
_setFilter : function(buttonContext){
_setFilter : function(buttonContext) {
var mode = buttonContext.model.get('key');
this.collection.state.currentPage = 1;
var promise = this.collection.setFilterMode(mode);
if(buttonContext) {
if (buttonContext) {
buttonContext.ui.icon.spinForPromise(promise);
}
}

View File

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

View File

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

View File

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

View File

@ -1,68 +1,67 @@
'use strict';
define(
[
'jquery',
'marionette',
'Cells/TemplatedCell',
'Activity/Queue/RemoveFromQueueView',
'vent'
], function ($, Marionette, TemplatedCell, RemoveFromQueueView, vent) {
return TemplatedCell.extend({
var $ = require('jquery');
var vent = require('../../vent');
var Marionette = require('marionette');
var TemplatedCell = require('../../Cells/TemplatedCell');
var RemoveFromQueueView = require('./RemoveFromQueueView');
module.exports = TemplatedCell.extend({
template : 'Activity/Queue/QueueActionsCellTemplate',
className : 'queue-actions-cell',
events: {
events : {
'click .x-remove' : '_remove',
'click .x-import' : '_import',
'click .x-grab' : '_grab'
},
ui: {
ui : {
import : '.x-import',
grab : '.x-grab'
},
_remove : function () {
_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 promise = $.ajax({
url: window.NzbDrone.ApiRoot + '/queue/import',
type: 'POST',
data: JSON.stringify(this.model.toJSON())
url : window.NzbDrone.ApiRoot + '/queue/import',
type : 'POST',
data : JSON.stringify(this.model.toJSON())
});
$(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
self.model.trigger('destroy', self.model);
});
},
_grab : function () {
_grab : function() {
var self = this;
var promise = $.ajax({
url: window.NzbDrone.ApiRoot + '/queue/grab',
type: 'POST',
data: JSON.stringify(this.model.toJSON())
url : window.NzbDrone.ApiRoot + '/queue/grab',
type : 'POST',
data : JSON.stringify(this.model.toJSON())
});
$(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
self.model.trigger('destroy', self.model);
});
}
});
});
});

View File

@ -1,4 +1,4 @@
{{#if_eq status compare="Completed"}}
{{#if_eq status compare="Completed"}}
{{#if_eq trackedDownloadStatus compare="Warning"}}
<i class="icon-inbox x-import" title="Force import"></i>
{{/if_eq}}

View File

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

View File

@ -1,42 +1,26 @@
'use strict';
define(
[
'marionette',
'backgrid',
'Activity/Queue/QueueCollection',
'Cells/SeriesTitleCell',
'Cells/EpisodeNumberCell',
'Cells/EpisodeTitleCell',
'Cells/QualityCell',
'Activity/Queue/QueueStatusCell',
'Activity/Queue/QueueActionsCell',
'Activity/Queue/TimeleftCell',
'Activity/Queue/ProgressCell',
'Release/ProtocolCell',
'Shared/Grid/Pager'
], function (Marionette,
Backgrid,
QueueCollection,
SeriesTitleCell,
EpisodeNumberCell,
EpisodeTitleCell,
QualityCell,
QueueStatusCell,
QueueActionsCell,
TimeleftCell,
ProgressCell,
ProtocolCell,
GridPager) {
return Marionette.Layout.extend({
template: 'Activity/Queue/QueueLayoutTemplate',
var Marionette = require('marionette');
var Backgrid = require('backgrid');
var QueueCollection = require('./QueueCollection');
var SeriesTitleCell = require('../../Cells/SeriesTitleCell');
var EpisodeNumberCell = require('../../Cells/EpisodeNumberCell');
var EpisodeTitleCell = require('../../Cells/EpisodeTitleCell');
var QualityCell = require('../../Cells/QualityCell');
var QueueStatusCell = require('./QueueStatusCell');
var QueueActionsCell = require('./QueueActionsCell');
var TimeleftCell = require('./TimeleftCell');
var ProgressCell = require('./ProgressCell');
var ProtocolCell = require('../../Release/ProtocolCell');
var GridPager = require('../../Shared/Grid/Pager');
regions: {
table: '#x-queue',
pager: '#x-queue-pager'
module.exports = Marionette.Layout.extend({
template : 'Activity/Queue/QueueLayoutTemplate',
regions : {
table : '#x-queue',
pager : '#x-queue-pager'
},
columns:
[
columns : [
{
name : 'status',
label : '',
@ -92,25 +76,24 @@ define(
}
],
initialize: function () {
initialize : function() {
this.listenTo(QueueCollection, 'sync', this._showTable);
},
onShow: function () {
onShow : function() {
this._showTable();
},
_showTable: function () {
_showTable : function() {
this.table.show(new Backgrid.Grid({
columns : this.columns,
collection: QueueCollection,
collection : QueueCollection,
className : 'table table-hover'
}));
this.pager.show(new GridPager({
columns : this.columns,
collection: QueueCollection
collection : QueueCollection
}));
}
});
});
});

View File

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

View File

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

View File

@ -4,56 +4,68 @@ var NzbDroneCell = require('../../Cells/NzbDroneCell');
module.exports = NzbDroneCell.extend({
className : 'queue-status-cell',
template : 'Activity/Queue/QueueStatusCellTemplate',
render : function(){
render : function() {
this.$el.empty();
if(this.cellValue) {
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') {
if (status === 'paused') {
icon = 'icon-pause';
title = 'Paused';
}
if(status === 'queued') {
if (status === 'queued') {
icon = 'icon-cloud';
title = 'Queued';
}
if(status === 'completed') {
if (status === 'completed') {
icon = 'icon-inbox';
title = 'Downloaded';
}
if(status === 'pending') {
if (status === 'pending') {
icon = 'icon-time';
title = 'Pending';
}
if(status === 'failed') {
if (status === 'failed') {
icon = 'icon-nd-download-failed';
title = 'Download failed';
}
if(status === 'warning') {
if (status === 'warning') {
icon = 'icon-nd-download-warning';
title = 'Download warning: check download client for more details';
}
if(trackedDownloadStatus === 'warning') {
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') {
if (trackedDownloadStatus === 'error') {
if (status === 'completed') {
icon = 'icon-nd-import-failed';
title = 'Import failed: ' + itemTitle;
}
else {
} 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,

View File

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

View File

@ -1,39 +1,34 @@
'use strict';
define(
[
'vent',
'marionette'
], function (vent, Marionette) {
var vent = require('../../vent');
var Marionette = require('marionette');
return Marionette.ItemView.extend({
template: 'Activity/Queue/RemoveFromQueueViewTemplate',
module.exports = Marionette.ItemView.extend({
template : 'Activity/Queue/RemoveFromQueueViewTemplate',
events: {
events : {
'click .x-confirm-remove' : 'removeItem'
},
ui: {
ui : {
blacklist : '.x-blacklist',
indicator : '.x-indicator'
},
initialize: function (options) {
initialize : function(options) {
this.templateHelpers = {
showBlacklist: options.showBlacklist
showBlacklist : options.showBlacklist
};
},
removeItem: function () {
removeItem : function() {
var blacklist = this.ui.blacklist.prop('checked') || false;
this.ui.indicator.show();
this.model.destroy({
data: { 'blacklist': blacklist },
wait: true
}).done(function () {
data : { 'blacklist' : blacklist },
wait : true
}).done(function() {
vent.trigger(vent.Commands.CloseModalCommand);
});
}
});
});
});

View File

@ -6,26 +6,31 @@ var FormatHelpers = require('../../Shared/FormatHelpers');
module.exports = NzbDroneCell.extend({
className : 'timeleft-cell',
render : function(){
render : function() {
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 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));
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) {
if (timeleft === undefined) {
this.$el.html('-');
}
else {
} else {
this.$el.html('<span title="{1} / {2}">{0}</span>'.format(timeleft, remainingSize, totalSize));
}
}
return this;
}
});