UI Cleanup - Updated Episode subtree.

pull/197/head
Taloth Saldono 10 years ago
parent 7b7f199587
commit fb7988edb8

@ -4,18 +4,28 @@ var Marionette = require('marionette');
var NzbDroneCell = require('../../Cells/NzbDroneCell'); var NzbDroneCell = require('../../Cells/NzbDroneCell');
module.exports = NzbDroneCell.extend({ module.exports = NzbDroneCell.extend({
className : 'episode-actions-cell', className : 'episode-actions-cell',
events : {"click .x-failed" : '_markAsFailed'},
render : function(){ events : {
'click .x-failed' : '_markAsFailed'
},
render : function() {
this.$el.empty(); this.$el.empty();
if(this.model.get('eventType') === 'grabbed') {
if (this.model.get('eventType') === 'grabbed') {
this.$el.html('<i class="icon-nd-delete x-failed" title="Mark download as failed"></i>'); this.$el.html('<i class="icon-nd-delete x-failed" title="Mark download as failed"></i>');
} }
return this; return this;
}, },
_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',

@ -7,10 +7,13 @@ require('bootstrap');
module.exports = NzbDroneCell.extend({ module.exports = NzbDroneCell.extend({
className : 'episode-activity-details-cell', className : 'episode-activity-details-cell',
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>');
var html = new HistoryDetailsView({model : this.model}).render().$el;
var html = new HistoryDetailsView({ model : this.model }).render().$el;
this.$el.popover({ this.$el.popover({
content : html, content : html,
html : true, html : true,
@ -19,6 +22,7 @@ module.exports = NzbDroneCell.extend({
placement : 'left', placement : 'left',
container : this.$el container : this.$el
}); });
return this; return this;
} }
}); });

@ -10,39 +10,52 @@ var NoActivityView = require('./NoActivityView');
var LoadingView = require('../../Shared/LoadingView'); var LoadingView = require('../../Shared/LoadingView');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Episode/Activity/EpisodeActivityLayoutTemplate', template : 'Episode/Activity/EpisodeActivityLayoutTemplate',
regions : {activityTable : '.activity-table'},
columns : [{ regions : {
name : 'eventType', activityTable : '.activity-table'
label : '', },
cell : EventTypeCell,
cellValue : 'this' columns : [
}, { {
name : 'sourceTitle', name : 'eventType',
label : 'Source Title', label : '',
cell : 'string' cell : EventTypeCell,
}, { cellValue : 'this'
name : 'quality', },
label : 'Quality', {
cell : QualityCell name : 'sourceTitle',
}, { label : 'Source Title',
name : 'date', cell : 'string'
label : 'Date', },
cell : RelativeDateCell {
}, { name : 'quality',
name : 'this', label : 'Quality',
label : '', cell : QualityCell
cell : EpisodeActivityDetailsCell, },
sortable : false {
}, { name : 'date',
name : 'this', label : 'Date',
label : '', cell : RelativeDateCell
cell : EpisodeActivityActionsCell, },
sortable : false {
}], name : 'this',
initialize : function(options){ label : '',
cell : EpisodeActivityDetailsCell,
sortable : false
},
{
name : 'this',
label : '',
cell : EpisodeActivityActionsCell,
sortable : false
}
],
initialize : function(options) {
this.model = options.model; this.model = options.model;
this.series = options.series; this.series = options.series;
this.collection = new HistoryCollection({ this.collection = new HistoryCollection({
episodeId : this.model.id, episodeId : this.model.id,
tableName : 'episodeActivity' tableName : 'episodeActivity'
@ -50,17 +63,20 @@ module.exports = Marionette.Layout.extend({
this.collection.fetch(); this.collection.fetch();
this.listenTo(this.collection, 'sync', this._showTable); this.listenTo(this.collection, 'sync', this._showTable);
}, },
onRender : function(){
onRender : function() {
this.activityTable.show(new LoadingView()); this.activityTable.show(new LoadingView());
}, },
_showTable : function(){
if(this.collection.any()) { _showTable : function() {
if (this.collection.any()) {
this.activityTable.show(new Backgrid.Grid({ this.activityTable.show(new Backgrid.Grid({
collection : this.collection, collection : this.collection,
columns : this.columns, columns : this.columns,
className : 'table table-hover table-condensed' className : 'table table-hover table-condensed'
})); }));
} }
else { else {
this.activityTable.show(new NoActivityView()); this.activityTable.show(new NoActivityView());
} }

@ -1,3 +1,5 @@
var Marionette = require('marionette'); var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({template : 'Episode/Activity/NoActivityViewTemplate'}); module.exports = Marionette.ItemView.extend({
template : 'Episode/Activity/NoActivityViewTemplate'
});

@ -6,97 +6,123 @@ var SeriesCollection = require('../Series/SeriesCollection');
var Messenger = require('../Shared/Messenger'); var Messenger = require('../Shared/Messenger');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
className : 'modal-lg', className : 'modal-lg',
template : 'Episode/EpisodeDetailsLayoutTemplate', template : 'Episode/EpisodeDetailsLayoutTemplate',
regions : {
regions : {
summary : '#episode-summary', summary : '#episode-summary',
activity : '#episode-activity', activity : '#episode-activity',
search : '#episode-search' search : '#episode-search'
}, },
ui : {
ui : {
summary : '.x-episode-summary', summary : '.x-episode-summary',
activity : '.x-episode-activity', activity : '.x-episode-activity',
search : '.x-episode-search', search : '.x-episode-search',
monitored : '.x-episode-monitored' monitored : '.x-episode-monitored'
}, },
events : {
"click .x-episode-summary" : '_showSummary', events : {
"click .x-episode-activity" : '_showActivity',
"click .x-episode-search" : '_showSearch', 'click .x-episode-summary' : '_showSummary',
"click .x-episode-monitored" : '_toggleMonitored' '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.templateHelpers.hideSeriesLink = options.hideSeriesLink;
this.series = SeriesCollection.get(this.model.get('seriesId')); this.series = SeriesCollection.get(this.model.get('seriesId'));
this.templateHelpers.series = this.series.toJSON(); this.templateHelpers.series = this.series.toJSON();
this.openingTab = options.openingTab || 'summary'; this.openingTab = options.openingTab || 'summary';
this.listenTo(this.model, 'sync', this._setMonitoredState); this.listenTo(this.model, 'sync', this._setMonitoredState);
}, },
onShow : function(){
this.searchLayout = new SearchLayout({model : this.model}); onShow : function() {
if(this.openingTab === 'search') { this.searchLayout = new SearchLayout({ model : this.model });
if (this.openingTab === 'search') {
this.searchLayout.startManualSearch = true; this.searchLayout.startManualSearch = true;
this._showSearch(); this._showSearch();
} }
else { else {
this._showSummary(); this._showSummary();
} }
this._setMonitoredState(); this._setMonitoredState();
if(this.series.get('monitored')) {
if (this.series.get('monitored')) {
this.$el.removeClass('series-not-monitored'); this.$el.removeClass('series-not-monitored');
} }
else { else {
this.$el.addClass('series-not-monitored'); this.$el.addClass('series-not-monitored');
} }
}, },
_showSummary : function(e){
if(e) { _showSummary : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.summary.tab('show'); this.ui.summary.tab('show');
this.summary.show(new SummaryLayout({ this.summary.show(new SummaryLayout({
model : this.model, model : this.model,
series : this.series series : this.series
})); }));
}, },
_showActivity : function(e){
if(e) { _showActivity : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.activity.tab('show'); this.ui.activity.tab('show');
this.activity.show(new EpisodeActivityLayout({ this.activity.show(new EpisodeActivityLayout({
model : this.model, model : this.model,
series : this.series series : this.series
})); }));
}, },
_showSearch : function(e){
if(e) { _showSearch : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.search.tab('show'); this.ui.search.tab('show');
this.search.show(this.searchLayout); this.search.show(this.searchLayout);
}, },
_toggleMonitored : function(){
if(!this.series.get('monitored')) { _toggleMonitored : function() {
if (!this.series.get('monitored')) {
Messenger.show({ Messenger.show({
message : 'Unable to change monitored state when series is not monitored', message : 'Unable to change monitored state when series is not monitored',
type : 'error' type : 'error'
}); });
return; return;
} }
var name = 'monitored'; 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.ui.monitored.addClass('icon-spinner icon-spin');
this.model.save(); this.model.save();
}, },
_setMonitoredState : function(){
_setMonitoredState : function() {
this.ui.monitored.removeClass('icon-spin icon-spinner'); 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.addClass('icon-bookmark');
this.ui.monitored.removeClass('icon-bookmark-empty'); this.ui.monitored.removeClass('icon-bookmark-empty');
} } else {
else {
this.ui.monitored.addClass('icon-bookmark-empty'); this.ui.monitored.addClass('icon-bookmark-empty');
this.ui.monitored.removeClass('icon-bookmark'); this.ui.monitored.removeClass('icon-bookmark');
} }

@ -1,3 +1,5 @@
var Marionette = require('marionette'); var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({template : 'Episode/Search/ButtonsViewTemplate'}); module.exports = Marionette.ItemView.extend({
template : 'Episode/Search/ButtonsViewTemplate'
});

@ -9,55 +9,75 @@ var LoadingView = require('../../Shared/LoadingView');
var NoResultsView = require('./NoResultsView'); var NoResultsView = require('./NoResultsView');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Episode/Search/EpisodeSearchLayoutTemplate', template : 'Episode/Search/EpisodeSearchLayoutTemplate',
regions : {main : '#episode-search-region'},
events : { regions : {
"click .x-search-auto" : '_searchAuto', main : '#episode-search-region'
"click .x-search-manual" : '_searchManual', },
"click .x-search-back" : '_showButtons'
}, events : {
initialize : function(){ 'click .x-search-auto' : '_searchAuto',
'click .x-search-manual' : '_searchManual',
'click .x-search-back' : '_showButtons'
},
initialize : function() {
this.mainView = new ButtonsView(); this.mainView = new ButtonsView();
this.releaseCollection = new ReleaseCollection(); this.releaseCollection = new ReleaseCollection();
this.listenTo(this.releaseCollection, 'sync', this._showSearchResults); this.listenTo(this.releaseCollection, 'sync', this._showSearchResults);
}, },
onShow : function(){
if(this.startManualSearch) { onShow : function() {
if (this.startManualSearch) {
this._searchManual(); this._searchManual();
} }
else { else {
this._showMainView(); this._showMainView();
} }
}, },
_searchAuto : function(e){
if(e) { _searchAuto : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
CommandController.Execute('episodeSearch', {episodeIds : [this.model.get('id')]});
CommandController.Execute('episodeSearch', {
episodeIds : [this.model.get('id')]
});
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
}, },
_searchManual : function(e){
if(e) { _searchManual : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.mainView = new LoadingView(); this.mainView = new LoadingView();
this._showMainView(); this._showMainView();
this.releaseCollection.fetchEpisodeReleases(this.model.id); this.releaseCollection.fetchEpisodeReleases(this.model.id);
}, },
_showMainView : function(){
_showMainView : function() {
this.main.show(this.mainView); this.main.show(this.mainView);
}, },
_showButtons : function(){
_showButtons : function() {
this.mainView = new ButtonsView(); this.mainView = new ButtonsView();
this._showMainView(); this._showMainView();
}, },
_showSearchResults : function(){
if(this.releaseCollection.length === 0) { _showSearchResults : function() {
if (this.releaseCollection.length === 0) {
this.mainView = new NoResultsView(); this.mainView = new NoResultsView();
} }
else { else {
this.mainView = new ManualSearchLayout({collection : this.releaseCollection}); this.mainView = new ManualSearchLayout({ collection : this.releaseCollection });
} }
this._showMainView(); this._showMainView();
} }
}); });

@ -11,48 +11,63 @@ var PeersCell = require('../../Release/PeersCell');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Episode/Search/ManualLayoutTemplate', template : 'Episode/Search/ManualLayoutTemplate',
regions : {grid : '#episode-release-grid'},
columns : [{ regions : {
name : 'protocol', grid : '#episode-release-grid'
label : 'Source', },
cell : ProtocolCell
}, { columns : [
name : 'age', {
label : 'Age', name : 'protocol',
cell : AgeCell label : 'Source',
}, { cell : ProtocolCell
name : 'title', },
label : 'Title', {
cell : ReleaseTitleCell name : 'age',
}, { label : 'Age',
name : 'indexer', cell : AgeCell
label : 'Indexer', },
cell : Backgrid.StringCell {
}, { name : 'title',
name : 'size', label : 'Title',
label : 'Size', cell : ReleaseTitleCell
cell : FileSizeCell },
}, { {
name : 'seeders', name : 'indexer',
label : 'Peers', label : 'Indexer',
cell : PeersCell cell : Backgrid.StringCell
}, { },
name : 'quality', {
label : 'Quality', name : 'size',
cell : QualityCell label : 'Size',
}, { cell : FileSizeCell
name : 'rejections', },
label : '', {
cell : ApprovalStatusCell, name : 'seeders',
sortable : false label : 'Peers',
}, { cell : PeersCell
name : 'download', },
label : '', {
cell : DownloadReportCell, name : 'quality',
sortable : true label : 'Quality',
}], cell : QualityCell
onShow : function(){ },
if(!this.isClosed) { {
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({ this.grid.show(new Backgrid.Grid({
row : Backgrid.Row, row : Backgrid.Row,
columns : this.columns, columns : this.columns,

@ -1,3 +1,5 @@
var Marionette = require('marionette'); var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({template : 'Episode/Search/NoResultsViewTemplate'}); module.exports = Marionette.ItemView.extend({
template : 'Episode/Search/NoResultsViewTemplate'
});

@ -10,66 +10,84 @@ var NoFileView = require('./NoFileView');
var LoadingView = require('../../Shared/LoadingView'); var LoadingView = require('../../Shared/LoadingView');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Episode/Summary/EpisodeSummaryLayoutTemplate', template : 'Episode/Summary/EpisodeSummaryLayoutTemplate',
regions : {
regions : {
overview : '.episode-overview', overview : '.episode-overview',
activity : '.episode-file-info' activity : '.episode-file-info'
}, },
columns : [{
name : 'path', columns : [
label : 'Path', {
cell : 'string', name : 'path',
sortable : false label : 'Path',
}, { cell : 'string',
name : 'size', sortable : false
label : 'Size', },
cell : FileSizeCell, {
sortable : false name : 'size',
}, { label : 'Size',
name : 'quality', cell : FileSizeCell,
label : 'Quality', sortable : false
cell : QualityCell, },
sortable : false, {
editable : true name : 'quality',
}, { label : 'Quality',
name : 'this', cell : QualityCell,
label : '', sortable : false,
cell : DeleteEpisodeFileCell, editable : true
sortable : false },
}], {
templateHelpers : {}, name : 'this',
initialize : function(options){ label : '',
if(!this.model.series) { cell : DeleteEpisodeFileCell,
sortable : false
}
],
templateHelpers : {},
initialize : function(options) {
if (!this.model.series) {
this.templateHelpers.series = options.series.toJSON(); 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'); 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); 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.listenTo(episodeFile, 'destroy', this._episodeFileDeleted);
this._showTable(); this._showTable();
} }
else { else {
this.activity.show(new LoadingView()); this.activity.show(new LoadingView());
var self = this; var self = this;
var newEpisodeFile = new EpisodeFileModel({id : episodeFileId}); var newEpisodeFile = new EpisodeFileModel({ id : episodeFileId });
this.episodeFileCollection = new EpisodeFileCollection(newEpisodeFile, {seriesId : this.model.get('seriesId')}); this.episodeFileCollection = new EpisodeFileCollection(newEpisodeFile, { seriesId : this.model.get('seriesId') });
var promise = newEpisodeFile.fetch(); var promise = newEpisodeFile.fetch();
this.listenTo(newEpisodeFile, 'destroy', this._episodeFileDeleted); this.listenTo(newEpisodeFile, 'destroy', this._episodeFileDeleted);
promise.done(function(){
promise.done(function() {
self._showTable(); self._showTable();
}); });
} }
this.listenTo(this.episodeFileCollection, 'add remove', this._collectionChanged); this.listenTo(this.episodeFileCollection, 'add remove', this._collectionChanged);
} }
else { else {
this._showNoFileView(); this._showNoFileView();
} }
}, },
_showTable : function(){
_showTable : function() {
this.activity.show(new Backgrid.Grid({ this.activity.show(new Backgrid.Grid({
collection : this.episodeFileCollection, collection : this.episodeFileCollection,
columns : this.columns, columns : this.columns,
@ -77,18 +95,22 @@ module.exports = Marionette.Layout.extend({
emptyText : 'Nothing to see here!' emptyText : 'Nothing to see here!'
})); }));
}, },
_showNoFileView : function(){
_showNoFileView : function() {
this.activity.show(new NoFileView()); this.activity.show(new NoFileView());
}, },
_collectionChanged : function(){
if(!this.episodeFileCollection.any()) { _collectionChanged : function() {
if (!this.episodeFileCollection.any()) {
this._showNoFileView(); this._showNoFileView();
} }
else { else {
this._showTable(); this._showTable();
} }
}, },
_episodeFileDeleted : function(){
_episodeFileDeleted : function() {
this.model.set({ this.model.set({
episodeFileId : 0, episodeFileId : 0,
hasFile : false hasFile : false

@ -1,3 +1,5 @@
var Marionette = require('marionette'); var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({template : 'Episode/Summary/NoFileViewTemplate'}); module.exports = Marionette.ItemView.extend({
template : 'Episode/Summary/NoFileViewTemplate'
});
Loading…
Cancel
Save