From a2fa8c459449192f2c0e91d9d55be0cfacee2bce Mon Sep 17 00:00:00 2001 From: Qstick Date: Wed, 28 Mar 2018 12:54:50 -0400 Subject: [PATCH] Fixed: Multiple Calendar Issues, Other UI Fixes (#2685) Fixes #2683 Fixes #1172 Fixes #563 --- src/UI/Activity/Queue/QueueCollection.js | 30 -- src/UI/Activity/Queue/QueueLayout.js | 13 - src/UI/Calendar/CalendarCollection.js | 4 +- src/UI/Calendar/CalendarView.js | 34 +- src/UI/Calendar/UpcomingCollection.js | 18 +- src/UI/Calendar/UpcomingItemView.js | 16 - src/UI/Calendar/UpcomingItemViewTemplate.hbs | 19 +- src/UI/Calendar/calendar.less | 1 - src/UI/Cells/EpisodeProgressCell.js | 28 -- src/UI/Cells/EpisodeProgressCellTemplate.hbs | 1 - src/UI/Cells/EpisodeStatusCell.js | 127 -------- src/UI/Cells/EpisodeTitleCell.js | 29 -- src/UI/Handlebars/Helpers/Episode.js | 66 ---- .../Helpers/{Series.js => Movie.js} | 137 ++++---- .../backbone.marionette.templates.js | 3 +- src/UI/Movies/Details/EpisodeNumberCell.js | 47 --- .../Details/EpisodeNumberCellTemplate.hbs | 39 --- src/UI/Movies/Details/EpisodeWarningCell.js | 21 -- src/UI/Movies/Details/MoviesDetailsLayout.js | 10 - .../Movies/Details/MoviesDetailsTemplate.hbs | 3 - src/UI/Movies/Details/SeasonCollectionView.js | 44 --- src/UI/Movies/Details/SeasonLayout.js | 301 ------------------ .../Movies/Details/SeasonLayoutTemplate.hbs | 50 --- .../Movies/Index/EpisodeProgressPartial.hbs | 4 - src/UI/Movies/MoviesCollection.js | 8 - src/UI/Release/ReleaseLayout.js | 7 - src/UI/Series/SeriesCollection.js | 9 - 27 files changed, 112 insertions(+), 957 deletions(-) delete mode 100644 src/UI/Cells/EpisodeProgressCell.js delete mode 100644 src/UI/Cells/EpisodeProgressCellTemplate.hbs delete mode 100644 src/UI/Cells/EpisodeStatusCell.js delete mode 100644 src/UI/Cells/EpisodeTitleCell.js delete mode 100644 src/UI/Handlebars/Helpers/Episode.js rename src/UI/Handlebars/Helpers/{Series.js => Movie.js} (75%) delete mode 100644 src/UI/Movies/Details/EpisodeNumberCell.js delete mode 100644 src/UI/Movies/Details/EpisodeNumberCellTemplate.hbs delete mode 100644 src/UI/Movies/Details/EpisodeWarningCell.js delete mode 100644 src/UI/Movies/Details/SeasonCollectionView.js delete mode 100644 src/UI/Movies/Details/SeasonLayout.js delete mode 100644 src/UI/Movies/Details/SeasonLayoutTemplate.hbs delete mode 100644 src/UI/Movies/Index/EpisodeProgressPartial.hbs diff --git a/src/UI/Activity/Queue/QueueCollection.js b/src/UI/Activity/Queue/QueueCollection.js index 37a4983ae..52c4659ce 100644 --- a/src/UI/Activity/Queue/QueueCollection.js +++ b/src/UI/Activity/Queue/QueueCollection.js @@ -20,12 +20,6 @@ var QueueCollection = PageableCollection.extend({ mode : 'client', - findEpisode : function(episodeId) { - return _.find(this.fullCollection.models, function(queueModel) { - return queueModel.get('episode').id === episodeId; - }); - }, - findMovie : function(movieId) { return _.find(this.fullCollection.models, function(queueModel) { return queueModel.get('movie').id === movieId; @@ -33,14 +27,6 @@ var QueueCollection = PageableCollection.extend({ }, sortMappings : { - series : { - sortValue : function(model, attr) { - var series = model.get(attr); - - return series.get('sortTitle'); - } - }, - movie : { sortValue : function(model, attr) { var movie = model.get(attr); @@ -49,22 +35,6 @@ var QueueCollection = PageableCollection.extend({ } }, - episode : { - sortValue : function(model, attr) { - var episode = model.get('episode'); - - return FormatHelpers.pad(episode.get('seasonNumber'), 4) + FormatHelpers.pad(episode.get('episodeNumber'), 4); - } - }, - - episodeTitle : { - sortValue : function(model, attr) { - var episode = model.get('episode'); - - return episode.get('title'); - } - }, - timeleft : { sortValue : function(model, attr) { var eta = model.get('estimatedCompletionTime'); diff --git a/src/UI/Activity/Queue/QueueLayout.js b/src/UI/Activity/Queue/QueueLayout.js index 0fc561165..128f6c70c 100644 --- a/src/UI/Activity/Queue/QueueLayout.js +++ b/src/UI/Activity/Queue/QueueLayout.js @@ -2,8 +2,6 @@ var Marionette = require('marionette'); var Backgrid = require('backgrid'); var QueueCollection = require('./QueueCollection'); var MovieTitleCell = require('../../Cells/MovieTitleCell'); -var EpisodeNumberCell = require('../../Cells/EpisodeNumberCell'); -var EpisodeTitleCell = require('../../Cells/EpisodeTitleCell'); var QualityCell = require('../../Cells/QualityCell'); var QueueStatusCell = require('./QueueStatusCell'); var QueueActionsCell = require('./QueueActionsCell'); @@ -32,17 +30,6 @@ module.exports = Marionette.Layout.extend({ label : 'Movie', cell : MovieTitleCell }, - /*{ - name : 'episode', - label : 'Episode', - cell : EpisodeNumberCell - }, - { - name : 'episodeTitle', - label : 'Episode Title', - cell : EpisodeTitleCell, - cellValue : 'episode' - },*/ { name : 'quality', label : 'Quality', diff --git a/src/UI/Calendar/CalendarCollection.js b/src/UI/Calendar/CalendarCollection.js index c60ed3722..a2a80683e 100644 --- a/src/UI/Calendar/CalendarCollection.js +++ b/src/UI/Calendar/CalendarCollection.js @@ -1,9 +1,9 @@ var Backbone = require('backbone'); -var EpisodeModel = require('../Movies/MovieModel'); +var MovieModel = require('../Movies/MovieModel'); module.exports = Backbone.Collection.extend({ url : window.NzbDrone.ApiRoot + '/calendar', - model : EpisodeModel, + model : MovieModel, tableName : 'calendar', comparator : function(model) { diff --git a/src/UI/Calendar/CalendarView.js b/src/UI/Calendar/CalendarView.js index 81389df6f..389150148 100644 --- a/src/UI/Calendar/CalendarView.js +++ b/src/UI/Calendar/CalendarView.js @@ -1,10 +1,12 @@ var $ = require('jquery'); var vent = require('vent'); var Marionette = require('marionette'); +var AppLayout = require('../AppLayout'); var moment = require('moment'); var CalendarCollection = require('./CalendarCollection'); var UiSettings = require('../Shared/UiSettingsModel'); var QueueCollection = require('../Activity/Queue/QueueCollection'); +var MoviesDetailsLayout = require('../Movies/Details/MoviesDetailsLayout'); var Config = require('../Config'); require('../Mixins/backbone.signalr.mixin'); @@ -89,7 +91,7 @@ module.exports = Marionette.ItemView.extend({ }); element.find('.chart').tooltip({ - title : 'Episode is downloading - {0}% {1}'.format(progress.toFixed(1), releaseTitle), + title : 'Movie is downloading - {0}% {1}'.format(progress.toFixed(1), releaseTitle), container : '.fc' }); } @@ -144,7 +146,7 @@ module.exports = Marionette.ItemView.extend({ var self = this; collection.each(function(model) { - var seriesTitle = model.get('title'); + var movieTitle = model.get('title'); var start = model.get('inCinemas'); var startDate = new Date(start); if (!(startD <= startDate && startDate <= endD)) { @@ -154,14 +156,15 @@ module.exports = Marionette.ItemView.extend({ var end = moment(start).add(runtime, 'minutes').toISOString(); var event = { - title : seriesTitle, + title : movieTitle, start : moment(start), end : moment(end), allDay : true, statusLevel : self._getStatusLevel(model, end), downloading : QueueCollection.findMovie(model.get('id')), model : model, - sortOrder : 0 + sortOrder : 0, + url : "movies/" + model.get("titleSlug") }; events.push(event); @@ -229,11 +232,7 @@ module.exports = Marionette.ItemView.extend({ viewRender : this._viewRender.bind(this), eventRender : this._eventRender.bind(this), eventAfterAllRender : this._eventAfterAllRender.bind(this), - windowResize : this._windowResize.bind(this), - eventClick : function(event) { - //vent.trigger(vent.Commands.ShowMovieDetails, { movie : event.model }); - window.location.href = "movies/"+event.model.get("titleSlug"); - } + windowResize : this._windowResize.bind(this) }; if ($(window).width() < 768) { @@ -256,13 +255,16 @@ module.exports = Marionette.ItemView.extend({ }; } - options.titleFormat = "L"; - - options.columnFormat = "L"; /*{ - month : 'ddd', - week : UiSettings.get('calendarWeekColumnHeader'), - day : 'dddd' - };*///For now ignore settings. TODO update that. + options.views = { + month: { + titleFormat: 'MMMM YYYY', + columnFormat: 'ddd' + }, + list: { + titleFormat: 'L', + columnFormat: 'L' + } + }, options.timeFormat = UiSettings.get('timeFormat'); diff --git a/src/UI/Calendar/UpcomingCollection.js b/src/UI/Calendar/UpcomingCollection.js index 14c76f411..bec94cf64 100644 --- a/src/UI/Calendar/UpcomingCollection.js +++ b/src/UI/Calendar/UpcomingCollection.js @@ -1,17 +1,29 @@ var Backbone = require('backbone'); var moment = require('moment'); -var EpisodeModel = require('../Movies/MovieModel'); +var MovieModel = require('../Movies/MovieModel'); module.exports = Backbone.Collection.extend({ url : window.NzbDrone.ApiRoot + '/calendar', - model : EpisodeModel, + model : MovieModel, comparator : function(model1, model2) { + var airDate1 = model1.get('inCinemas'); + var airDate2 = model2.get('inCinemas'); + var status1 = model1.get('status'); + var status2 = model2.get('status'); + + if (status1 === 'inCinemas') { + airDate1 = model1.get('physicalRelease'); + } + + if (status2 === 'inCinemas') { + airDate2 = model2.get('physicalRelease'); + } + var date1 = moment(airDate1); var time1 = date1.unix(); - var airDate2 = model2.get('inCinemas'); var date2 = moment(airDate2); var time2 = date2.unix(); diff --git a/src/UI/Calendar/UpcomingItemView.js b/src/UI/Calendar/UpcomingItemView.js index d34371d73..62ae87304 100644 --- a/src/UI/Calendar/UpcomingItemView.js +++ b/src/UI/Calendar/UpcomingItemView.js @@ -6,23 +6,7 @@ module.exports = Marionette.ItemView.extend({ template : 'Calendar/UpcomingItemViewTemplate', tagName : 'div', - events : { - 'click .x-episode-title' : '_showEpisodeDetails' - }, - initialize : function() { - var start = this.model.get('inCinemas'); - var runtime = this.model.get('runtime'); - var end = moment(start).add(runtime, 'minutes'); - - this.model.set({ - end : end.toISOString() - }); - this.listenTo(this.model, 'change', this.render); - }, - - _showEpisodeDetails : function() { - vent.trigger(vent.Commands.ShowEpisodeDetails, { episode : this.model }); } }); diff --git a/src/UI/Calendar/UpcomingItemViewTemplate.hbs b/src/UI/Calendar/UpcomingItemViewTemplate.hbs index eae2491bd..d5fca9bd5 100644 --- a/src/UI/Calendar/UpcomingItemViewTemplate.hbs +++ b/src/UI/Calendar/UpcomingItemViewTemplate.hbs @@ -1,18 +1,15 @@
-

{{Day airDateUtc}}

-

{{Month airDateUtc}}

+ {{#if_eq status compare="announced"}} +

{{Day inCinemas}}

+

{{Month inCinemas}}

+ {{else}} +

{{Day physicalRelease}}

+

{{Month physicalRelease}}

+ {{/if_eq}}
- {{#with series}} +

{{title}}

- {{/with}} -

{{StartTime airDateUtc}} {{#unless_today airDateUtc}}{{ShortDate airDateUtc}}{{/unless_today}}

-

- - {{title}} - - {{seasonNumber}}x{{Pad2 episodeNumber}} -

diff --git a/src/UI/Calendar/calendar.less b/src/UI/Calendar/calendar.less index 6941e9fe1..a0d704d5b 100644 --- a/src/UI/Calendar/calendar.less +++ b/src/UI/Calendar/calendar.less @@ -96,7 +96,6 @@ .primary { border-color : @btn-primary-bg; - color: white; } .info { diff --git a/src/UI/Cells/EpisodeProgressCell.js b/src/UI/Cells/EpisodeProgressCell.js deleted file mode 100644 index 84f39cb8a..000000000 --- a/src/UI/Cells/EpisodeProgressCell.js +++ /dev/null @@ -1,28 +0,0 @@ -var Marionette = require('marionette'); -var NzbDroneCell = require('./NzbDroneCell'); - -module.exports = NzbDroneCell.extend({ - className : 'episode-progress-cell', - template : 'Cells/EpisodeProgressCellTemplate', - - render : function() { - - var episodeCount = this.model.get('episodeCount'); - var episodeFileCount = this.model.get('episodeFileCount'); - - var percent = 100; - - if (episodeCount > 0) { - percent = episodeFileCount / episodeCount * 100; - } - - this.model.set('percentOfEpisodes', percent); - - this.templateFunction = Marionette.TemplateCache.get(this.template); - var data = this.model.toJSON(); - var html = this.templateFunction(data); - this.$el.html(html); - - return this; - } -}); diff --git a/src/UI/Cells/EpisodeProgressCellTemplate.hbs b/src/UI/Cells/EpisodeProgressCellTemplate.hbs deleted file mode 100644 index 98c06f4c0..000000000 --- a/src/UI/Cells/EpisodeProgressCellTemplate.hbs +++ /dev/null @@ -1 +0,0 @@ -{{> EpisodeProgressPartial }} \ No newline at end of file diff --git a/src/UI/Cells/EpisodeStatusCell.js b/src/UI/Cells/EpisodeStatusCell.js deleted file mode 100644 index 5913e372d..000000000 --- a/src/UI/Cells/EpisodeStatusCell.js +++ /dev/null @@ -1,127 +0,0 @@ -var reqres = require('../reqres'); -var Backbone = require('backbone'); -var NzbDroneCell = require('./NzbDroneCell'); -var QueueCollection = require('../Activity/Queue/QueueCollection'); -var moment = require('moment'); -var FormatHelpers = require('../Shared/FormatHelpers'); - -module.exports = NzbDroneCell.extend({ - className : 'episode-status-cell', - - render : function() { - this.listenTo(QueueCollection, 'sync', this._renderCell); - - this._renderCell(); - - return this; - }, - - _renderCell : function() { - - if (this.episodeFile) { - this.stopListening(this.episodeFile, 'change', this._refresh); - } - - this.$el.empty(); - - if (this.model) { - - var icon; - var tooltip; - - var hasAired = moment(this.model.get('airDateUtc')).isBefore(moment()); - this.episodeFile = this._getFile(); - - if (this.episodeFile) { - this.listenTo(this.episodeFile, 'change', this._refresh); - - var quality = this.episodeFile.get('quality'); - var revision = quality.revision; - var size = FormatHelpers.bytes(this.episodeFile.get('size')); - var title = 'Episode downloaded'; - - if (revision.real && revision.real > 0) { - title += '[REAL]'; - } - - if (revision.version && revision.version > 1) { - title += ' [PROPER]'; - } - - if (size !== '') { - title += ' - {0}'.format(size); - } - - if (this.episodeFile.get('qualityCutoffNotMet')) { - this.$el.html('{1}'.format(title, quality.quality.name)); - } else { - this.$el.html('{1}'.format(title, quality.quality.name)); - } - - return; - } - - else { - var model = this.model; - var downloading = QueueCollection.findEpisode(model.get('id')); - - if (downloading) { - var progress = 100 - (downloading.get('sizeleft') / downloading.get('size') * 100); - - if (progress === 0) { - icon = 'icon-sonarr-downloading'; - tooltip = 'Episode is downloading'; - } - - else { - this.$el.html('
'.format(progress.toFixed(1), downloading.get('title')) + - '
'.format(progress)); - return; - } - } - - else if (this.model.get('grabbed')) { - icon = 'icon-sonarr-downloading'; - tooltip = 'Episode is downloading'; - } - - else if (!this.model.get('airDateUtc')) { - icon = 'icon-sonarr-tba'; - tooltip = 'TBA'; - } - - else if (hasAired) { - icon = 'icon-sonarr-missing'; - tooltip = 'Episode missing from disk'; - } else { - icon = 'icon-sonarr-not-aired'; - tooltip = 'Episode has not aired'; - } - } - - this.$el.html(''.format(icon, tooltip)); - } - }, - - _getFile : function() { - var hasFile = this.model.get('hasFile'); - - if (hasFile) { - var episodeFile; - - if (reqres.hasHandler(reqres.Requests.GetEpisodeFileById)) { - episodeFile = reqres.request(reqres.Requests.GetEpisodeFileById, this.model.get('episodeFileId')); - } - - else if (this.model.has('episodeFile')) { - episodeFile = new Backbone.Model(this.model.get('episodeFile')); - } - - if (episodeFile) { - return episodeFile; - } - } - - return undefined; - } -}); \ No newline at end of file diff --git a/src/UI/Cells/EpisodeTitleCell.js b/src/UI/Cells/EpisodeTitleCell.js deleted file mode 100644 index 7dce10ede..000000000 --- a/src/UI/Cells/EpisodeTitleCell.js +++ /dev/null @@ -1,29 +0,0 @@ -var vent = require('vent'); -var NzbDroneCell = require('./NzbDroneCell'); - -module.exports = NzbDroneCell.extend({ - className : 'episode-title-cell', - - events : { - 'click' : '_showDetails' - }, - - render : function() { - var title = this.cellValue.get('title'); - - if (!title || title === '') { - title = 'TBA'; - } - - this.$el.html(title); - return this; - }, - - _showDetails : function() { - var hideSeriesLink = this.column.get('hideSeriesLink'); - vent.trigger(vent.Commands.ShowEpisodeDetails, { - episode : this.cellValue, - hideSeriesLink : hideSeriesLink - }); - } -}); \ No newline at end of file diff --git a/src/UI/Handlebars/Helpers/Episode.js b/src/UI/Handlebars/Helpers/Episode.js deleted file mode 100644 index 3db6cfcc4..000000000 --- a/src/UI/Handlebars/Helpers/Episode.js +++ /dev/null @@ -1,66 +0,0 @@ -var Handlebars = require('handlebars'); -var FormatHelpers = require('../../Shared/FormatHelpers'); -var moment = require('moment'); -require('../../Activity/Queue/QueueCollection'); - -Handlebars.registerHelper('EpisodeNumber', function() { - - if (this.series.seriesType === 'daily') { - return moment(this.airDate).format('L'); - } else if (this.series.seriesType === 'anime' && this.absoluteEpisodeNumber !== undefined) { - return '{0}x{1} ({2})'.format(this.seasonNumber, FormatHelpers.pad(this.episodeNumber, 2), FormatHelpers.pad(this.absoluteEpisodeNumber, 2)); - } else { - return '{0}x{1}'.format(this.seasonNumber, FormatHelpers.pad(this.episodeNumber, 2)); - } -}); - -Handlebars.registerHelper('StatusLevel', function() { - var hasFile = this.hasFile; - var downloading = require('../../Activity/Queue/QueueCollection').findEpisode(this.id) || this.downloading; - var currentTime = moment(); - var start = moment(this.airDateUtc); - var end = moment(this.end); - var monitored = this.series.monitored && this.monitored; - - if (hasFile) { - return 'success'; - } - - if (downloading) { - return 'purple'; - } - - else if (!monitored) { - return 'unmonitored'; - } - - if (this.episodeNumber === 1) { - return 'premiere'; - } - - if (currentTime.isAfter(start) && currentTime.isBefore(end)) { - return 'warning'; - } - - if (start.isBefore(currentTime) && !hasFile) { - return 'danger'; - } - - return 'primary'; -}); - -Handlebars.registerHelper('EpisodeProgressClass', function() { - if (this.episodeFileCount === this.episodeCount) { - if (this.status === 'continuing') { - return ''; - } - - return 'progress-bar-success'; - } - - if (this.monitored) { - return 'progress-bar-danger'; - } - - return 'progress-bar-warning'; -}); diff --git a/src/UI/Handlebars/Helpers/Series.js b/src/UI/Handlebars/Helpers/Movie.js similarity index 75% rename from src/UI/Handlebars/Helpers/Series.js rename to src/UI/Handlebars/Helpers/Movie.js index dcbf29ff7..13ca0d51f 100644 --- a/src/UI/Handlebars/Helpers/Series.js +++ b/src/UI/Handlebars/Helpers/Movie.js @@ -1,6 +1,73 @@ var Handlebars = require('handlebars'); var StatusModel = require('../../System/StatusModel'); +var FormatHelpers = require('../../Shared/FormatHelpers'); +var moment = require('moment'); var _ = require('underscore'); +require('../../Activity/Queue/QueueCollection'); + +Handlebars.registerHelper('GetStatus', function() { + var monitored = this.monitored; + var status = this.status; + //var inCinemas = this.inCinemas; + //var date = new Date(inCinemas); + //var timeSince = new Date().getTime() - date.getTime(); + //var numOfMonths = timeSince / 1000 / 60 / 60 / 24 / 30; + + + if (status === "announced") { + return new Handlebars.SafeString(' Announced'); + } + + + if (status ==="inCinemas") { + return new Handlebars.SafeString(' In Cinemas'); + } + + if (status === 'released') { + return new Handlebars.SafeString(' Released'); + } + + if (!monitored) { + return new Handlebars.SafeString(' Not Monitored'); + } + }); + +Handlebars.registerHelper('route', function() { + return StatusModel.get('urlBase') + '/movies/' + this.titleSlug; +}); + +Handlebars.registerHelper('StatusLevel', function() { + var hasFile = this.hasFile; + var downloading = require('../../Activity/Queue/QueueCollection').findMovie(this.id) || this.downloading; + var currentTime = moment(); + var monitored = this.monitored; + + if (hasFile) { + return 'success'; + } + + else if (downloading) { + return 'purple'; + } + + else if (!monitored) { + return 'unmonitored'; + } + + else if (this.status === "inCinemas") { + return 'premiere'; + } + + else if (this.status === "released") { + return 'danger'; + } + + else if (this.status === "announced") { + return 'primary'; + } + + return 'primary'; +}); Handlebars.registerHelper('poster', function() { @@ -75,33 +142,6 @@ Handlebars.registerHelper('alternativeTitlesString', function() { return '"' + titles.slice(0,titles.length-1).join('", "') + '" and "' + titles[titles.length-1] + '"'; }); -Handlebars.registerHelper('GetStatus', function() { - var monitored = this.monitored; - var status = this.status; - //var inCinemas = this.inCinemas; - //var date = new Date(inCinemas); - //var timeSince = new Date().getTime() - date.getTime(); - //var numOfMonths = timeSince / 1000 / 60 / 60 / 24 / 30; - - - if (status === "announced") { - return new Handlebars.SafeString(' Announced'); - } - - - if (status ==="inCinemas") { - return new Handlebars.SafeString(' In Cinemas'); - } - - if (status === 'released') { - return new Handlebars.SafeString(' Released'); - } - - if (!monitored) { - return new Handlebars.SafeString(' Not Monitored'); - } -}); - Handlebars.registerHelper('GetBannerStatus', function() { var monitored = this.monitored; var status = this.status; @@ -161,7 +201,6 @@ Handlebars.registerHelper("DownloadedQuality", function() { return ""; }); - Handlebars.registerHelper('inCinemas', function() { var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" @@ -184,46 +223,6 @@ Handlebars.registerHelper('inCinemas', function() { return "To be announced"; }); -Handlebars.registerHelper('tvRageUrl', function() { - return 'http://www.tvrage.com/shows/id-' + this.tvRageId; -}); - -Handlebars.registerHelper('tvMazeUrl', function() { - return 'http://www.tvmaze.com/shows/' + this.tvMazeId + '/_'; -}); - -Handlebars.registerHelper('route', function() { - return StatusModel.get('urlBase') + '/movies/' + this.titleSlug; -}); - -Handlebars.registerHelper('percentOfEpisodes', function() { - var episodeCount = this.episodeCount; - var episodeFileCount = this.episodeFileCount; - - var percent = 100; - - if (episodeCount > 0) { - percent = episodeFileCount / episodeCount * 100; - } - - return percent; -}); - -Handlebars.registerHelper('seasonCountHelper', function() { - var seasonCount = this.seasonCount; - var continuing = this.status === 'continuing'; - - if (continuing) { - return new Handlebars.SafeString('Season {0}'.format(seasonCount)); - } - - if (seasonCount === 1) { - return new Handlebars.SafeString('{0} Season'.format(seasonCount)); - } - - return new Handlebars.SafeString('{0} Seasons'.format(seasonCount)); -}); - Handlebars.registerHelper('titleWithYear', function() { if (this.title.endsWith(' ({0})'.format(this.year))) { return this.title; @@ -234,4 +233,4 @@ Handlebars.registerHelper('titleWithYear', function() { } return new Handlebars.SafeString('{0} ({1})'.format(this.title, this.year)); -}); +}); \ No newline at end of file diff --git a/src/UI/Handlebars/backbone.marionette.templates.js b/src/UI/Handlebars/backbone.marionette.templates.js index 82bf4ec62..d82549740 100644 --- a/src/UI/Handlebars/backbone.marionette.templates.js +++ b/src/UI/Handlebars/backbone.marionette.templates.js @@ -3,8 +3,7 @@ require('handlebars.helpers'); require('./Helpers/DateTime'); require('./Helpers/Html'); require('./Helpers/Numbers'); -require('./Helpers/Episode'); -require('./Helpers/Series'); +require('./Helpers/Movie'); require('./Helpers/Quality'); require('./Helpers/System'); require('./Helpers/EachReverse'); diff --git a/src/UI/Movies/Details/EpisodeNumberCell.js b/src/UI/Movies/Details/EpisodeNumberCell.js deleted file mode 100644 index 4e09a7603..000000000 --- a/src/UI/Movies/Details/EpisodeNumberCell.js +++ /dev/null @@ -1,47 +0,0 @@ -var Marionette = require('marionette'); -var NzbDroneCell = require('../../Cells/NzbDroneCell'); -var reqres = require('../../reqres'); -var SeriesCollection = require('../SeriesCollection'); - -module.exports = NzbDroneCell.extend({ - className : 'episode-number-cell', - template : 'Movies/Details/EpisodeNumberCellTemplate', - - render : function() { - this.$el.empty(); - this.$el.html(this.model.get('episodeNumber')); - - var series = SeriesCollection.get(this.model.get('seriesId')); - - if (series.get('seriesType') === 'anime' && this.model.has('absoluteEpisodeNumber')) { - this.$el.html('{0} ({1})'.format(this.model.get('episodeNumber'), this.model.get('absoluteEpisodeNumber'))); - } - - var alternateTitles = []; - - if (reqres.hasHandler(reqres.Requests.GetAlternateNameBySeasonNumber)) { - alternateTitles = reqres.request(reqres.Requests.GetAlternateNameBySeasonNumber, this.model.get('seriesId'), this.model.get('seasonNumber'), this.model.get('sceneSeasonNumber')); - } - - if (this.model.get('sceneSeasonNumber') > 0 || this.model.get('sceneEpisodeNumber') > 0 || this.model.has('sceneAbsoluteEpisodeNumber') || alternateTitles.length > 0) { - this.templateFunction = Marionette.TemplateCache.get(this.template); - - var json = this.model.toJSON(); - json.alternateTitles = alternateTitles; - - var html = this.templateFunction(json); - - this.$el.popover({ - content : html, - html : true, - trigger : 'hover', - title : 'Scene Information', - placement : 'right', - container : this.$el - }); - } - - this.delegateEvents(); - return this; - } -}); \ No newline at end of file diff --git a/src/UI/Movies/Details/EpisodeNumberCellTemplate.hbs b/src/UI/Movies/Details/EpisodeNumberCellTemplate.hbs deleted file mode 100644 index a9028a423..000000000 --- a/src/UI/Movies/Details/EpisodeNumberCellTemplate.hbs +++ /dev/null @@ -1,39 +0,0 @@ -
- {{#if sceneSeasonNumber}} -
-
Season
-
{{sceneSeasonNumber}}
-
- {{/if}} - - {{#if sceneEpisodeNumber}} -
-
Episode
-
{{sceneEpisodeNumber}}
-
- {{/if}} - - {{#if sceneAbsoluteEpisodeNumber}} -
-
Absolute
-
{{sceneAbsoluteEpisodeNumber}}
-
- {{/if}} - - {{#if alternateTitles}} -
- {{#if_gt alternateTitles.length compare="1"}} -
Titles
- {{else}} -
Title
- {{/if_gt}} -
-
    - {{#each alternateTitles}} -
  • {{title}}
  • - {{/each}} -
-
-
- {{/if}} -
\ No newline at end of file diff --git a/src/UI/Movies/Details/EpisodeWarningCell.js b/src/UI/Movies/Details/EpisodeWarningCell.js deleted file mode 100644 index c9befe7a1..000000000 --- a/src/UI/Movies/Details/EpisodeWarningCell.js +++ /dev/null @@ -1,21 +0,0 @@ -var NzbDroneCell = require('../../Cells/NzbDroneCell'); -var SeriesCollection = require('../SeriesCollection'); - -module.exports = NzbDroneCell.extend({ - className : 'episode-warning-cell', - - render : function() { - this.$el.empty(); - - if (this.model.get('unverifiedSceneNumbering')) { - this.$el.html(''); - } - - else if (SeriesCollection.get(this.model.get('seriesId')).get('seriesType') === 'anime' && this.model.get('seasonNumber') > 0 && !this.model.has('absoluteEpisodeNumber')) { - this.$el.html(''); - } - - this.delegateEvents(); - return this; - } -}); \ No newline at end of file diff --git a/src/UI/Movies/Details/MoviesDetailsLayout.js b/src/UI/Movies/Details/MoviesDetailsLayout.js index 403f15cd6..5d4452121 100644 --- a/src/UI/Movies/Details/MoviesDetailsLayout.js +++ b/src/UI/Movies/Details/MoviesDetailsLayout.js @@ -45,7 +45,6 @@ module.exports = Marionette.Layout.extend({ }, events : { - 'click .x-episode-file-editor' : '_showFiles', 'click .x-monitored' : '_toggleMonitored', 'click .x-edit' : '_editMovie', 'click .x-refresh' : '_refreshMovies', @@ -251,15 +250,6 @@ module.exports = Marionette.Layout.extend({ this._showInfo(); }, - // _openEpisodeFileEditor : function() { - // var view = new EpisodeFileEditorLayout({ - // movies : this.model, - // episodeCollection : this.episodeCollection - // }); - - // vent.trigger(vent.Commands.OpenModalCommand, view); - // }, - _updateImages : function () { var poster = this._getImage('poster'); diff --git a/src/UI/Movies/Details/MoviesDetailsTemplate.hbs b/src/UI/Movies/Details/MoviesDetailsTemplate.hbs index 90dbd6a5f..89a4f413c 100644 --- a/src/UI/Movies/Details/MoviesDetailsTemplate.hbs +++ b/src/UI/Movies/Details/MoviesDetailsTemplate.hbs @@ -9,9 +9,6 @@ {{title}} ({{year}}{{#if secondaryYear}} / {{secondaryYear}}{{/if}})
-
- -
diff --git a/src/UI/Movies/Details/SeasonCollectionView.js b/src/UI/Movies/Details/SeasonCollectionView.js deleted file mode 100644 index 24da6171c..000000000 --- a/src/UI/Movies/Details/SeasonCollectionView.js +++ /dev/null @@ -1,44 +0,0 @@ -var _ = require('underscore'); -var Marionette = require('marionette'); -var SeasonLayout = require('./SeasonLayout'); -var AsSortedCollectionView = require('../../Mixins/AsSortedCollectionView'); - -var view = Marionette.CollectionView.extend({ - - itemView : SeasonLayout, - - initialize : function(options) { - if (!options.episodeCollection) { - throw 'episodeCollection is needed'; - } - - this.episodeCollection = options.episodeCollection; - this.series = options.series; - }, - - itemViewOptions : function() { - return { - episodeCollection : this.episodeCollection, - series : this.series - }; - }, - - onEpisodeGrabbed : function(message) { - if (message.episode.series.id !== this.episodeCollection.seriesId) { - return; - } - - var self = this; - - _.each(message.episode.episodes, function(episode) { - var ep = self.episodeCollection.get(episode.id); - ep.set('downloading', true); - }); - - this.render(); - } -}); - -AsSortedCollectionView.call(view); - -module.exports = view; \ No newline at end of file diff --git a/src/UI/Movies/Details/SeasonLayout.js b/src/UI/Movies/Details/SeasonLayout.js deleted file mode 100644 index fa362c775..000000000 --- a/src/UI/Movies/Details/SeasonLayout.js +++ /dev/null @@ -1,301 +0,0 @@ -var vent = require('vent'); -var Marionette = require('marionette'); -var Backgrid = require('backgrid'); -var ToggleCell = require('../../Cells/EpisodeMonitoredCell'); -var EpisodeTitleCell = require('../../Cells/EpisodeTitleCell'); -var RelativeDateCell = require('../../Cells/RelativeDateCell'); -var EpisodeStatusCell = require('../../Cells/EpisodeStatusCell'); -var EpisodeActionsCell = require('../../Cells/EpisodeActionsCell'); -var EpisodeNumberCell = require('./EpisodeNumberCell'); -var EpisodeWarningCell = require('./EpisodeWarningCell'); -var CommandController = require('../../Commands/CommandController'); -var EpisodeFileEditorLayout = require('../../EpisodeFile/Editor/EpisodeFileEditorLayout'); -var moment = require('moment'); -var _ = require('underscore'); -var Messenger = require('../../Shared/Messenger'); - -module.exports = Marionette.Layout.extend({ - template : 'Movies/Details/SeasonLayoutTemplate', - - ui : { - seasonSearch : '.x-season-search', - seasonMonitored : '.x-season-monitored', - seasonRename : '.x-season-rename' - }, - - events : { - 'click .x-season-episode-file-editor' : '_openEpisodeFileEditor', - 'click .x-season-monitored' : '_seasonMonitored', - 'click .x-season-search' : '_seasonSearch', - 'click .x-season-rename' : '_seasonRename', - 'click .x-show-hide-episodes' : '_showHideEpisodes', - 'dblclick .series-season h2' : '_showHideEpisodes' - }, - - regions : { - episodeGrid : '.x-episode-grid' - }, - - columns : [ - { - name : 'monitored', - label : '', - cell : ToggleCell, - trueClass : 'icon-sonarr-monitored', - falseClass : 'icon-sonarr-unmonitored', - tooltip : 'Toggle monitored status', - sortable : false - }, - { - name : 'episodeNumber', - label : '#', - cell : EpisodeNumberCell - }, - { - name : 'this', - label : '', - cell : EpisodeWarningCell, - sortable : false, - className : 'episode-warning-cell' - }, - { - name : 'this', - label : 'Title', - hideSeriesLink : true, - cell : EpisodeTitleCell, - sortable : false - }, - { - name : 'airDateUtc', - label : 'Air Date', - cell : RelativeDateCell - }, - { - name : 'status', - label : 'Status', - cell : EpisodeStatusCell, - sortable : false - }, - { - name : 'this', - label : '', - cell : EpisodeActionsCell, - sortable : false - } - ], - - templateHelpers : function() { - var episodeCount = this.episodeCollection.filter(function(episode) { - return episode.get('hasFile') || episode.get('monitored') && moment(episode.get('airDateUtc')).isBefore(moment()); - }).length; - - var episodeFileCount = this.episodeCollection.where({ hasFile : true }).length; - var percentOfEpisodes = 100; - - if (episodeCount > 0) { - percentOfEpisodes = episodeFileCount / episodeCount * 100; - } - - return { - showingEpisodes : this.showingEpisodes, - episodeCount : episodeCount, - episodeFileCount : episodeFileCount, - percentOfEpisodes : percentOfEpisodes - }; - }, - - initialize : function(options) { - if (!options.episodeCollection) { - throw 'episodeCollection is required'; - } - - this.series = options.series; - this.fullEpisodeCollection = options.episodeCollection; - this.episodeCollection = this.fullEpisodeCollection.bySeason(this.model.get('seasonNumber')); - this._updateEpisodeCollection(); - - this.showingEpisodes = this._shouldShowEpisodes(); - - this.listenTo(this.model, 'sync', this._afterSeasonMonitored); - this.listenTo(this.episodeCollection, 'sync', this.render); - - this.listenTo(this.fullEpisodeCollection, 'sync', this._refreshEpisodes); - }, - - onRender : function() { - if (this.showingEpisodes) { - this._showEpisodes(); - } - - this._setSeasonMonitoredState(); - - CommandController.bindToCommand({ - element : this.ui.seasonSearch, - command : { - name : 'seasonSearch', - seriesId : this.series.id, - seasonNumber : this.model.get('seasonNumber') - } - }); - - CommandController.bindToCommand({ - element : this.ui.seasonRename, - command : { - name : 'renameFiles', - seriesId : this.series.id, - seasonNumber : this.model.get('seasonNumber') - } - }); - }, - - _seasonSearch : function() { - CommandController.Execute('seasonSearch', { - name : 'seasonSearch', - seriesId : this.series.id, - seasonNumber : this.model.get('seasonNumber') - }); - }, - - _seasonRename : function() { - vent.trigger(vent.Commands.ShowRenamePreview, { - series : this.series, - seasonNumber : this.model.get('seasonNumber') - }); - }, - - _seasonMonitored : 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)); - this.series.setSeasonMonitored(this.model.get('seasonNumber')); - - var savePromise = this.series.save().always(this._afterSeasonMonitored.bind(this)); - - this.ui.seasonMonitored.spinForPromise(savePromise); - }, - - _afterSeasonMonitored : function() { - var self = this; - - _.each(this.episodeCollection.models, function(episode) { - episode.set({ monitored : self.model.get('monitored') }); - }); - - this.render(); - }, - - _setSeasonMonitoredState : function() { - this.ui.seasonMonitored.removeClass('icon-sonarr-spinner fa-spin'); - - if (this.model.get('monitored')) { - this.ui.seasonMonitored.addClass('icon-sonarr-monitored'); - this.ui.seasonMonitored.removeClass('icon-sonarr-unmonitored'); - } else { - this.ui.seasonMonitored.addClass('icon-sonarr-unmonitored'); - this.ui.seasonMonitored.removeClass('icon-sonarr-monitored'); - } - }, - - _showEpisodes : function() { - this.episodeGrid.show(new Backgrid.Grid({ - columns : this.columns, - collection : this.episodeCollection, - className : 'table table-hover season-grid' - })); - }, - - _shouldShowEpisodes : function() { - var startDate = moment().add(-1, 'month'); - var endDate = moment().add(1, 'year'); - - return this.episodeCollection.some(function(episode) { - var airDate = episode.get('airDateUtc'); - - if (airDate) { - var airDateMoment = moment(airDate); - - if (airDateMoment.isAfter(startDate) && airDateMoment.isBefore(endDate)) { - return true; - } - } - - return false; - }); - }, - - _showHideEpisodes : function() { - if (this.showingEpisodes) { - this.showingEpisodes = false; - this.episodeGrid.close(); - } else { - this.showingEpisodes = true; - this._showEpisodes(); - } - - this.templateHelpers.showingEpisodes = this.showingEpisodes; - this.render(); - }, - - _episodeMonitoredToggled : function(options) { - var model = options.model; - var shiftKey = options.shiftKey; - - if (!this.episodeCollection.get(model.get('id'))) { - return; - } - - if (!shiftKey) { - return; - } - - var lastToggled = this.episodeCollection.lastToggled; - - if (!lastToggled) { - return; - } - - var currentIndex = this.episodeCollection.indexOf(model); - var lastIndex = this.episodeCollection.indexOf(lastToggled); - - var low = Math.min(currentIndex, lastIndex); - var high = Math.max(currentIndex, lastIndex); - var range = _.range(low + 1, high); - - this.episodeCollection.lastToggled = model; - }, - - _updateEpisodeCollection : function() { - var self = this; - - this.episodeCollection.add(this.fullEpisodeCollection.bySeason(this.model.get('seasonNumber')).models, { merge : true }); - - this.episodeCollection.each(function(model) { - model.episodeCollection = self.episodeCollection; - }); - }, - - _refreshEpisodes : function() { - this._updateEpisodeCollection(); - this.episodeCollection.fullCollection.sort(); - this.render(); - }, - - _openEpisodeFileEditor : function() { - var view = new EpisodeFileEditorLayout({ - model : this.model, - series : this.series, - episodeCollection : this.episodeCollection - }); - - vent.trigger(vent.Commands.OpenModalCommand, view); - } -}); diff --git a/src/UI/Movies/Details/SeasonLayoutTemplate.hbs b/src/UI/Movies/Details/SeasonLayoutTemplate.hbs deleted file mode 100644 index 06034f19d..000000000 --- a/src/UI/Movies/Details/SeasonLayoutTemplate.hbs +++ /dev/null @@ -1,50 +0,0 @@ -
-

- - - {{#if seasonNumber}} - Season {{seasonNumber}} - {{else}} - Specials - {{/if}} - - - {{#if_eq episodeCount compare=0}} - {{#if monitored}} -   - {{else}} -   - {{/if}} - {{else}} - {{#if_eq percentOfEpisodes compare=100}} - {{episodeFileCount}} / {{episodeCount}} - {{else}} - {{episodeFileCount}} / {{episodeCount}} - {{/if_eq}} - {{/if_eq}} - - -
- -
-
- -
- -
-

-
-

- {{#if showingEpisodes}} - - Hide Episodes - {{else}} - - Show Episodes - {{/if}} -

-
-
-
diff --git a/src/UI/Movies/Index/EpisodeProgressPartial.hbs b/src/UI/Movies/Index/EpisodeProgressPartial.hbs deleted file mode 100644 index db5c49a2b..000000000 --- a/src/UI/Movies/Index/EpisodeProgressPartial.hbs +++ /dev/null @@ -1,4 +0,0 @@ -
- {{episodeFileCount}} / {{episodeCount}} -
{{episodeFileCount}} / {{episodeCount}}
-
\ No newline at end of file diff --git a/src/UI/Movies/MoviesCollection.js b/src/UI/Movies/MoviesCollection.js index e4e5e615f..cc6b4d78b 100644 --- a/src/UI/Movies/MoviesCollection.js +++ b/src/UI/Movies/MoviesCollection.js @@ -222,14 +222,6 @@ var Collection = PageableCollection.extend({ return 0; } }, - percentOfEpisodes : { - sortValue : function(model, attr) { - var percentOfEpisodes = model.get(attr); - var episodeCount = model.get('episodeCount'); - - return percentOfEpisodes + episodeCount / 1000000; - } - }, inCinemas : { sortValue : function(model, attr) { diff --git a/src/UI/Release/ReleaseLayout.js b/src/UI/Release/ReleaseLayout.js index 41beb74ce..a2a01df3b 100644 --- a/src/UI/Release/ReleaseLayout.js +++ b/src/UI/Release/ReleaseLayout.js @@ -2,7 +2,6 @@ var Marionette = require('marionette'); var Backgrid = require('backgrid'); var ReleaseCollection = require('./ReleaseCollection'); var IndexerCell = require('../Cells/IndexerCell'); -var EpisodeNumberCell = require('../Cells/EpisodeNumberCell'); var FileSizeCell = require('../Cells/FileSizeCell'); var QualityCell = require('../Cells/QualityCell'); var ApprovalStatusCell = require('../Cells/ApprovalStatusCell'); @@ -37,12 +36,6 @@ module.exports = Marionette.Layout.extend({ sortable : true, cell : ReleaseTitleCell }, - /*{ - name : 'episodeNumbers', - episodes : 'episodeNumbers', - label : 'season', - cell : EpisodeNumberCell - },*/ { name : 'size', label : 'Size', diff --git a/src/UI/Series/SeriesCollection.js b/src/UI/Series/SeriesCollection.js index 3d7914864..eb06c66a2 100644 --- a/src/UI/Series/SeriesCollection.js +++ b/src/UI/Series/SeriesCollection.js @@ -92,15 +92,6 @@ var Collection = PageableCollection.extend({ } }, - percentOfEpisodes : { - sortValue : function(model, attr) { - var percentOfEpisodes = model.get(attr); - var episodeCount = model.get('episodeCount'); - - return percentOfEpisodes + episodeCount / 1000000; - } - }, - path : { sortValue : function(model) { var path = model.get('path');