diff --git a/src/UI/Episode/Activity/EpisodeActivityActionsCell.js b/src/UI/Episode/Activity/EpisodeActivityActionsCell.js index 759a2748c..d94bb490d 100644 --- a/src/UI/Episode/Activity/EpisodeActivityActionsCell.js +++ b/src/UI/Episode/Activity/EpisodeActivityActionsCell.js @@ -4,18 +4,28 @@ var Marionette = require('marionette'); var NzbDroneCell = require('../../Cells/NzbDroneCell'); module.exports = NzbDroneCell.extend({ - className : 'episode-actions-cell', - events : {"click .x-failed" : '_markAsFailed'}, - render : function(){ + className : 'episode-actions-cell', + + events : { + 'click .x-failed' : '_markAsFailed' + }, + + render : function() { this.$el.empty(); - if(this.model.get('eventType') === 'grabbed') { + + if (this.model.get('eventType') === 'grabbed') { this.$el.html(''); } + return this; }, - _markAsFailed : function(){ + + _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', diff --git a/src/UI/Episode/Activity/EpisodeActivityDetailsCell.js b/src/UI/Episode/Activity/EpisodeActivityDetailsCell.js index 7588c5092..b90b05ed1 100644 --- a/src/UI/Episode/Activity/EpisodeActivityDetailsCell.js +++ b/src/UI/Episode/Activity/EpisodeActivityDetailsCell.js @@ -7,10 +7,13 @@ require('bootstrap'); module.exports = NzbDroneCell.extend({ className : 'episode-activity-details-cell', - render : function(){ + + render : function() { this.$el.empty(); this.$el.html(''); - var html = new HistoryDetailsView({model : this.model}).render().$el; + + var html = new HistoryDetailsView({ model : this.model }).render().$el; + this.$el.popover({ content : html, html : true, @@ -19,6 +22,7 @@ module.exports = NzbDroneCell.extend({ placement : 'left', container : this.$el }); + return this; } }); \ No newline at end of file diff --git a/src/UI/Episode/Activity/EpisodeActivityLayout.js b/src/UI/Episode/Activity/EpisodeActivityLayout.js index e8d7332f6..98e4f3947 100644 --- a/src/UI/Episode/Activity/EpisodeActivityLayout.js +++ b/src/UI/Episode/Activity/EpisodeActivityLayout.js @@ -10,39 +10,52 @@ var NoActivityView = require('./NoActivityView'); var LoadingView = require('../../Shared/LoadingView'); module.exports = Marionette.Layout.extend({ - template : 'Episode/Activity/EpisodeActivityLayoutTemplate', - regions : {activityTable : '.activity-table'}, - columns : [{ - name : 'eventType', - label : '', - cell : EventTypeCell, - cellValue : 'this' - }, { - name : 'sourceTitle', - label : 'Source Title', - cell : 'string' - }, { - name : 'quality', - label : 'Quality', - cell : QualityCell - }, { - name : 'date', - label : 'Date', - cell : RelativeDateCell - }, { - name : 'this', - label : '', - cell : EpisodeActivityDetailsCell, - sortable : false - }, { - name : 'this', - label : '', - cell : EpisodeActivityActionsCell, - sortable : false - }], - initialize : function(options){ + template : 'Episode/Activity/EpisodeActivityLayoutTemplate', + + regions : { + activityTable : '.activity-table' + }, + + columns : [ + { + name : 'eventType', + label : '', + cell : EventTypeCell, + cellValue : 'this' + }, + { + name : 'sourceTitle', + label : 'Source Title', + cell : 'string' + }, + { + name : 'quality', + label : 'Quality', + cell : QualityCell + }, + { + name : 'date', + label : 'Date', + cell : RelativeDateCell + }, + { + name : 'this', + label : '', + cell : EpisodeActivityDetailsCell, + sortable : false + }, + { + name : 'this', + label : '', + cell : EpisodeActivityActionsCell, + sortable : false + } + ], + + initialize : function(options) { this.model = options.model; this.series = options.series; + this.collection = new HistoryCollection({ episodeId : this.model.id, tableName : 'episodeActivity' @@ -50,17 +63,20 @@ module.exports = Marionette.Layout.extend({ this.collection.fetch(); this.listenTo(this.collection, 'sync', this._showTable); }, - onRender : function(){ + + onRender : function() { this.activityTable.show(new LoadingView()); }, - _showTable : function(){ - if(this.collection.any()) { + + _showTable : function() { + if (this.collection.any()) { this.activityTable.show(new Backgrid.Grid({ collection : this.collection, columns : this.columns, className : 'table table-hover table-condensed' })); } + else { this.activityTable.show(new NoActivityView()); } diff --git a/src/UI/Episode/Activity/NoActivityView.js b/src/UI/Episode/Activity/NoActivityView.js index ec6326d21..7fc750a33 100644 --- a/src/UI/Episode/Activity/NoActivityView.js +++ b/src/UI/Episode/Activity/NoActivityView.js @@ -1,3 +1,5 @@ var Marionette = require('marionette'); -module.exports = Marionette.ItemView.extend({template : 'Episode/Activity/NoActivityViewTemplate'}); \ No newline at end of file +module.exports = Marionette.ItemView.extend({ + template : 'Episode/Activity/NoActivityViewTemplate' +}); \ No newline at end of file diff --git a/src/UI/Episode/EpisodeDetailsLayout.js b/src/UI/Episode/EpisodeDetailsLayout.js index eb6d2c351..8bc860704 100644 --- a/src/UI/Episode/EpisodeDetailsLayout.js +++ b/src/UI/Episode/EpisodeDetailsLayout.js @@ -6,97 +6,123 @@ var SeriesCollection = require('../Series/SeriesCollection'); var Messenger = require('../Shared/Messenger'); module.exports = Marionette.Layout.extend({ - className : 'modal-lg', - template : 'Episode/EpisodeDetailsLayoutTemplate', - regions : { + className : 'modal-lg', + template : 'Episode/EpisodeDetailsLayoutTemplate', + + regions : { summary : '#episode-summary', activity : '#episode-activity', search : '#episode-search' }, - ui : { + + ui : { summary : '.x-episode-summary', activity : '.x-episode-activity', search : '.x-episode-search', monitored : '.x-episode-monitored' }, - events : { - "click .x-episode-summary" : '_showSummary', - "click .x-episode-activity" : '_showActivity', - "click .x-episode-search" : '_showSearch', - "click .x-episode-monitored" : '_toggleMonitored' + + events : { + + 'click .x-episode-summary' : '_showSummary', + 'click .x-episode-activity' : '_showActivity', + 'click .x-episode-search' : '_showSearch', + 'click .x-episode-monitored' : '_toggleMonitored' }, - templateHelpers : {}, - initialize : function(options){ + + templateHelpers : {}, + + initialize : function(options) { this.templateHelpers.hideSeriesLink = options.hideSeriesLink; + this.series = SeriesCollection.get(this.model.get('seriesId')); this.templateHelpers.series = this.series.toJSON(); this.openingTab = options.openingTab || 'summary'; + this.listenTo(this.model, 'sync', this._setMonitoredState); }, - onShow : function(){ - this.searchLayout = new SearchLayout({model : this.model}); - if(this.openingTab === 'search') { + + onShow : function() { + this.searchLayout = new SearchLayout({ model : this.model }); + + if (this.openingTab === 'search') { this.searchLayout.startManualSearch = true; this._showSearch(); } + else { this._showSummary(); } + this._setMonitoredState(); - if(this.series.get('monitored')) { + + if (this.series.get('monitored')) { this.$el.removeClass('series-not-monitored'); } + else { this.$el.addClass('series-not-monitored'); } }, - _showSummary : function(e){ - if(e) { + + _showSummary : function(e) { + if (e) { e.preventDefault(); } + this.ui.summary.tab('show'); this.summary.show(new SummaryLayout({ model : this.model, series : this.series })); }, - _showActivity : function(e){ - if(e) { + + _showActivity : function(e) { + if (e) { e.preventDefault(); } + this.ui.activity.tab('show'); this.activity.show(new EpisodeActivityLayout({ model : this.model, series : this.series })); }, - _showSearch : function(e){ - if(e) { + + _showSearch : function(e) { + if (e) { e.preventDefault(); } + this.ui.search.tab('show'); this.search.show(this.searchLayout); }, - _toggleMonitored : function(){ - if(!this.series.get('monitored')) { + + _toggleMonitored : function() { + if (!this.series.get('monitored')) { + Messenger.show({ message : 'Unable to change monitored state when series is not monitored', type : 'error' }); + return; } + var name = 'monitored'; - this.model.set(name, !this.model.get(name), {silent : true}); + this.model.set(name, !this.model.get(name), { silent : true }); + this.ui.monitored.addClass('icon-spinner icon-spin'); this.model.save(); }, - _setMonitoredState : function(){ + + _setMonitoredState : function() { this.ui.monitored.removeClass('icon-spin icon-spinner'); - if(this.model.get('monitored')) { + + if (this.model.get('monitored')) { this.ui.monitored.addClass('icon-bookmark'); this.ui.monitored.removeClass('icon-bookmark-empty'); - } - else { + } else { this.ui.monitored.addClass('icon-bookmark-empty'); this.ui.monitored.removeClass('icon-bookmark'); } diff --git a/src/UI/Episode/Search/ButtonsView.js b/src/UI/Episode/Search/ButtonsView.js index fc4cb0437..6972f1201 100644 --- a/src/UI/Episode/Search/ButtonsView.js +++ b/src/UI/Episode/Search/ButtonsView.js @@ -1,3 +1,5 @@ var Marionette = require('marionette'); -module.exports = Marionette.ItemView.extend({template : 'Episode/Search/ButtonsViewTemplate'}); \ No newline at end of file +module.exports = Marionette.ItemView.extend({ + template : 'Episode/Search/ButtonsViewTemplate' +}); \ No newline at end of file diff --git a/src/UI/Episode/Search/EpisodeSearchLayout.js b/src/UI/Episode/Search/EpisodeSearchLayout.js index 97c82e5a2..7dd727ac2 100644 --- a/src/UI/Episode/Search/EpisodeSearchLayout.js +++ b/src/UI/Episode/Search/EpisodeSearchLayout.js @@ -9,55 +9,75 @@ var LoadingView = require('../../Shared/LoadingView'); var NoResultsView = require('./NoResultsView'); module.exports = Marionette.Layout.extend({ - template : 'Episode/Search/EpisodeSearchLayoutTemplate', - regions : {main : '#episode-search-region'}, - events : { - "click .x-search-auto" : '_searchAuto', - "click .x-search-manual" : '_searchManual', - "click .x-search-back" : '_showButtons' + template : 'Episode/Search/EpisodeSearchLayoutTemplate', + + regions : { + main : '#episode-search-region' }, - initialize : function(){ + + events : { + 'click .x-search-auto' : '_searchAuto', + 'click .x-search-manual' : '_searchManual', + 'click .x-search-back' : '_showButtons' + }, + + initialize : function() { this.mainView = new ButtonsView(); this.releaseCollection = new ReleaseCollection(); + this.listenTo(this.releaseCollection, 'sync', this._showSearchResults); }, - onShow : function(){ - if(this.startManualSearch) { + + onShow : function() { + if (this.startManualSearch) { this._searchManual(); } + else { this._showMainView(); } }, - _searchAuto : function(e){ - if(e) { + + _searchAuto : function(e) { + if (e) { e.preventDefault(); } - CommandController.Execute('episodeSearch', {episodeIds : [this.model.get('id')]}); + + CommandController.Execute('episodeSearch', { + episodeIds : [this.model.get('id')] + }); + vent.trigger(vent.Commands.CloseModalCommand); }, - _searchManual : function(e){ - if(e) { + + _searchManual : function(e) { + if (e) { e.preventDefault(); } + this.mainView = new LoadingView(); this._showMainView(); this.releaseCollection.fetchEpisodeReleases(this.model.id); }, - _showMainView : function(){ + + _showMainView : function() { this.main.show(this.mainView); }, - _showButtons : function(){ + + _showButtons : function() { this.mainView = new ButtonsView(); this._showMainView(); }, - _showSearchResults : function(){ - if(this.releaseCollection.length === 0) { + + _showSearchResults : function() { + if (this.releaseCollection.length === 0) { this.mainView = new NoResultsView(); } + else { - this.mainView = new ManualSearchLayout({collection : this.releaseCollection}); + this.mainView = new ManualSearchLayout({ collection : this.releaseCollection }); } + this._showMainView(); } }); \ No newline at end of file diff --git a/src/UI/Episode/Search/ManualLayout.js b/src/UI/Episode/Search/ManualLayout.js index 027585456..ff842d3c2 100644 --- a/src/UI/Episode/Search/ManualLayout.js +++ b/src/UI/Episode/Search/ManualLayout.js @@ -11,48 +11,63 @@ var PeersCell = require('../../Release/PeersCell'); module.exports = Marionette.Layout.extend({ template : 'Episode/Search/ManualLayoutTemplate', - regions : {grid : '#episode-release-grid'}, - columns : [{ - name : 'protocol', - label : 'Source', - cell : ProtocolCell - }, { - name : 'age', - label : 'Age', - cell : AgeCell - }, { - name : 'title', - label : 'Title', - cell : ReleaseTitleCell - }, { - name : 'indexer', - label : 'Indexer', - cell : Backgrid.StringCell - }, { - name : 'size', - label : 'Size', - cell : FileSizeCell - }, { - name : 'seeders', - label : 'Peers', - cell : PeersCell - }, { - name : 'quality', - label : 'Quality', - cell : QualityCell - }, { - name : 'rejections', - label : '', - cell : ApprovalStatusCell, - sortable : false - }, { - name : 'download', - label : '', - cell : DownloadReportCell, - sortable : true - }], - onShow : function(){ - if(!this.isClosed) { + + regions : { + grid : '#episode-release-grid' + }, + + columns : [ + { + name : 'protocol', + label : 'Source', + cell : ProtocolCell + }, + { + name : 'age', + label : 'Age', + cell : AgeCell + }, + { + name : 'title', + label : 'Title', + cell : ReleaseTitleCell + }, + { + name : 'indexer', + label : 'Indexer', + cell : Backgrid.StringCell + }, + { + name : 'size', + label : 'Size', + cell : FileSizeCell + }, + { + name : 'seeders', + label : 'Peers', + cell : PeersCell + }, + { + name : 'quality', + label : 'Quality', + cell : QualityCell + }, + { + name : 'rejections', + label : '', + cell : ApprovalStatusCell, + sortable : false + }, + { + name : 'download', + label : '', + cell : DownloadReportCell, + sortable : true + } + ], + + onShow : function() { + if (!this.isClosed) { this.grid.show(new Backgrid.Grid({ row : Backgrid.Row, columns : this.columns, diff --git a/src/UI/Episode/Search/NoResultsView.js b/src/UI/Episode/Search/NoResultsView.js index ea53ab92c..a1a68c4fa 100644 --- a/src/UI/Episode/Search/NoResultsView.js +++ b/src/UI/Episode/Search/NoResultsView.js @@ -1,3 +1,5 @@ var Marionette = require('marionette'); -module.exports = Marionette.ItemView.extend({template : 'Episode/Search/NoResultsViewTemplate'}); \ No newline at end of file +module.exports = Marionette.ItemView.extend({ + template : 'Episode/Search/NoResultsViewTemplate' +}); \ No newline at end of file diff --git a/src/UI/Episode/Summary/EpisodeSummaryLayout.js b/src/UI/Episode/Summary/EpisodeSummaryLayout.js index 1e83bd78c..29eaad626 100644 --- a/src/UI/Episode/Summary/EpisodeSummaryLayout.js +++ b/src/UI/Episode/Summary/EpisodeSummaryLayout.js @@ -10,66 +10,84 @@ var NoFileView = require('./NoFileView'); var LoadingView = require('../../Shared/LoadingView'); module.exports = Marionette.Layout.extend({ - template : 'Episode/Summary/EpisodeSummaryLayoutTemplate', - regions : { + template : 'Episode/Summary/EpisodeSummaryLayoutTemplate', + + regions : { overview : '.episode-overview', activity : '.episode-file-info' }, - columns : [{ - name : 'path', - label : 'Path', - cell : 'string', - sortable : false - }, { - name : 'size', - label : 'Size', - cell : FileSizeCell, - sortable : false - }, { - name : 'quality', - label : 'Quality', - cell : QualityCell, - sortable : false, - editable : true - }, { - name : 'this', - label : '', - cell : DeleteEpisodeFileCell, - sortable : false - }], - templateHelpers : {}, - initialize : function(options){ - if(!this.model.series) { + + columns : [ + { + name : 'path', + label : 'Path', + cell : 'string', + sortable : false + }, + { + name : 'size', + label : 'Size', + cell : FileSizeCell, + sortable : false + }, + { + name : 'quality', + label : 'Quality', + cell : QualityCell, + sortable : false, + editable : true + }, + { + name : 'this', + label : '', + cell : DeleteEpisodeFileCell, + sortable : false + } + ], + + templateHelpers : {}, + + initialize : function(options) { + if (!this.model.series) { this.templateHelpers.series = options.series.toJSON(); } }, - onShow : function(){ - if(this.model.get('hasFile')) { + + onShow : function() { + if (this.model.get('hasFile')) { var episodeFileId = this.model.get('episodeFileId'); - if(reqres.hasHandler(reqres.Requests.GetEpisodeFileById)) { + + if (reqres.hasHandler(reqres.Requests.GetEpisodeFileById)) { var episodeFile = reqres.request(reqres.Requests.GetEpisodeFileById, episodeFileId); - this.episodeFileCollection = new EpisodeFileCollection(episodeFile, {seriesId : this.model.get('seriesId')}); + this.episodeFileCollection = new EpisodeFileCollection(episodeFile, { seriesId : this.model.get('seriesId') }); this.listenTo(episodeFile, 'destroy', this._episodeFileDeleted); + this._showTable(); } + else { this.activity.show(new LoadingView()); + var self = this; - var newEpisodeFile = new EpisodeFileModel({id : episodeFileId}); - this.episodeFileCollection = new EpisodeFileCollection(newEpisodeFile, {seriesId : this.model.get('seriesId')}); + var newEpisodeFile = new EpisodeFileModel({ id : episodeFileId }); + this.episodeFileCollection = new EpisodeFileCollection(newEpisodeFile, { seriesId : this.model.get('seriesId') }); var promise = newEpisodeFile.fetch(); this.listenTo(newEpisodeFile, 'destroy', this._episodeFileDeleted); - promise.done(function(){ + + promise.done(function() { self._showTable(); }); } + this.listenTo(this.episodeFileCollection, 'add remove', this._collectionChanged); } + else { this._showNoFileView(); } }, - _showTable : function(){ + + _showTable : function() { this.activity.show(new Backgrid.Grid({ collection : this.episodeFileCollection, columns : this.columns, @@ -77,18 +95,22 @@ module.exports = Marionette.Layout.extend({ emptyText : 'Nothing to see here!' })); }, - _showNoFileView : function(){ + + _showNoFileView : function() { this.activity.show(new NoFileView()); }, - _collectionChanged : function(){ - if(!this.episodeFileCollection.any()) { + + _collectionChanged : function() { + if (!this.episodeFileCollection.any()) { this._showNoFileView(); } + else { this._showTable(); } }, - _episodeFileDeleted : function(){ + + _episodeFileDeleted : function() { this.model.set({ episodeFileId : 0, hasFile : false diff --git a/src/UI/Episode/Summary/NoFileView.js b/src/UI/Episode/Summary/NoFileView.js index d1361d77e..07aabc810 100644 --- a/src/UI/Episode/Summary/NoFileView.js +++ b/src/UI/Episode/Summary/NoFileView.js @@ -1,3 +1,5 @@ var Marionette = require('marionette'); -module.exports = Marionette.ItemView.extend({template : 'Episode/Summary/NoFileViewTemplate'}); \ No newline at end of file +module.exports = Marionette.ItemView.extend({ + template : 'Episode/Summary/NoFileViewTemplate' +}); \ No newline at end of file