UI Cleanup - Updated Episode subtree.

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

@ -5,17 +5,27 @@ 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'},
events : {
'click .x-failed' : '_markAsFailed'
},
render : function() { 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;
} }
}); });

@ -11,38 +11,51 @@ 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 : {
activityTable : '.activity-table'
},
columns : [
{
name : 'eventType', name : 'eventType',
label : '', label : '',
cell : EventTypeCell, cell : EventTypeCell,
cellValue : 'this' cellValue : 'this'
}, { },
{
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
}, { },
{
name : 'date', name : 'date',
label : 'Date', label : 'Date',
cell : RelativeDateCell cell : RelativeDateCell
}, { },
{
name : 'this', name : 'this',
label : '', label : '',
cell : EpisodeActivityDetailsCell, cell : EpisodeActivityDetailsCell,
sortable : false sortable : false
}, { },
{
name : 'this', name : 'this',
label : '', label : '',
cell : EpisodeActivityActionsCell, cell : EpisodeActivityActionsCell,
sortable : false sortable : false
}], }
],
initialize : function(options) { 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,9 +63,11 @@ 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() { _showTable : function() {
if (this.collection.any()) { if (this.collection.any()) {
this.activityTable.show(new Backgrid.Grid({ this.activityTable.show(new Backgrid.Grid({
@ -61,6 +76,7 @@ module.exports = Marionette.Layout.extend({
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'
});

@ -8,95 +8,121 @@ 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 : { events : {
"click .x-episode-summary" : '_showSummary',
"click .x-episode-activity" : '_showActivity', 'click .x-episode-summary' : '_showSummary',
"click .x-episode-search" : '_showSearch', 'click .x-episode-activity' : '_showActivity',
"click .x-episode-monitored" : '_toggleMonitored' 'click .x-episode-search' : '_showSearch',
'click .x-episode-monitored' : '_toggleMonitored'
}, },
templateHelpers : {}, templateHelpers : {},
initialize : function(options) { 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() { onShow : function() {
this.searchLayout = new SearchLayout({ model : this.model }); this.searchLayout = new SearchLayout({ model : this.model });
if (this.openingTab === 'search') { 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) { _showSummary : function(e) {
if (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) { _showActivity : function(e) {
if (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) { _showSearch : function(e) {
if (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() { _toggleMonitored : function() {
if (!this.series.get('monitored')) { 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'
});

@ -10,54 +10,74 @@ 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'},
regions : {
main : '#episode-search-region'
},
events : { events : {
"click .x-search-auto" : '_searchAuto', 'click .x-search-auto' : '_searchAuto',
"click .x-search-manual" : '_searchManual', 'click .x-search-manual' : '_searchManual',
"click .x-search-back" : '_showButtons' 'click .x-search-back' : '_showButtons'
}, },
initialize : function() { 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() { onShow : function() {
if (this.startManualSearch) { if (this.startManualSearch) {
this._searchManual(); this._searchManual();
} }
else { else {
this._showMainView(); this._showMainView();
} }
}, },
_searchAuto : function(e) { _searchAuto : function(e) {
if (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) { _searchManual : function(e) {
if (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() { _showSearchResults : function() {
if (this.releaseCollection.length === 0) { 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,46 +11,61 @@ 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 : {
grid : '#episode-release-grid'
},
columns : [
{
name : 'protocol', name : 'protocol',
label : 'Source', label : 'Source',
cell : ProtocolCell cell : ProtocolCell
}, { },
{
name : 'age', name : 'age',
label : 'Age', label : 'Age',
cell : AgeCell cell : AgeCell
}, { },
{
name : 'title', name : 'title',
label : 'Title', label : 'Title',
cell : ReleaseTitleCell cell : ReleaseTitleCell
}, { },
{
name : 'indexer', name : 'indexer',
label : 'Indexer', label : 'Indexer',
cell : Backgrid.StringCell cell : Backgrid.StringCell
}, { },
{
name : 'size', name : 'size',
label : 'Size', label : 'Size',
cell : FileSizeCell cell : FileSizeCell
}, { },
{
name : 'seeders', name : 'seeders',
label : 'Peers', label : 'Peers',
cell : PeersCell cell : PeersCell
}, { },
{
name : 'quality', name : 'quality',
label : 'Quality', label : 'Quality',
cell : QualityCell cell : QualityCell
}, { },
{
name : 'rejections', name : 'rejections',
label : '', label : '',
cell : ApprovalStatusCell, cell : ApprovalStatusCell,
sortable : false sortable : false
}, { },
{
name : 'download', name : 'download',
label : '', label : '',
cell : DownloadReportCell, cell : DownloadReportCell,
sortable : true sortable : true
}], }
],
onShow : function() { onShow : function() {
if (!this.isClosed) { if (!this.isClosed) {
this.grid.show(new Backgrid.Grid({ this.grid.show(new Backgrid.Grid({

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

@ -11,64 +11,82 @@ 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 : [{
columns : [
{
name : 'path', name : 'path',
label : 'Path', label : 'Path',
cell : 'string', cell : 'string',
sortable : false sortable : false
}, { },
{
name : 'size', name : 'size',
label : 'Size', label : 'Size',
cell : FileSizeCell, cell : FileSizeCell,
sortable : false sortable : false
}, { },
{
name : 'quality', name : 'quality',
label : 'Quality', label : 'Quality',
cell : QualityCell, cell : QualityCell,
sortable : false, sortable : false,
editable : true editable : true
}, { },
{
name : 'this', name : 'this',
label : '', label : '',
cell : DeleteEpisodeFileCell, cell : DeleteEpisodeFileCell,
sortable : false sortable : false
}], }
],
templateHelpers : {}, templateHelpers : {},
initialize : function(options) { initialize : function(options) {
if (!this.model.series) { if (!this.model.series) {
this.templateHelpers.series = options.series.toJSON(); this.templateHelpers.series = options.series.toJSON();
} }
}, },
onShow : function() { onShow : function() {
if (this.model.get('hasFile')) { 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,
@ -77,17 +95,21 @@ 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() { _collectionChanged : function() {
if (!this.episodeFileCollection.any()) { 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,

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