diff --git a/src/NzbDrone.Api/Music/ArtistModule.cs b/src/NzbDrone.Api/Music/ArtistModule.cs index d616becfb..1f7c433cf 100644 --- a/src/NzbDrone.Api/Music/ArtistModule.cs +++ b/src/NzbDrone.Api/Music/ArtistModule.cs @@ -98,7 +98,7 @@ namespace NzbDrone.Api.Music { //var seriesStats = _seriesStatisticsService.SeriesStatistics(); var artistResources = _artistService.GetAllArtists().ToResource(); - + Console.WriteLine("[DEBUG] Returning {0} Artists", artistResources.Count); MapCoversToLocal(artistResources.ToArray()); //LinkSeriesStatistics(seriesResources, seriesStats); //PopulateAlternateTitles(seriesResources); diff --git a/src/UI/AddSeries/AddSeriesLayout.js b/src/UI/AddSeries/AddSeriesLayout.js index 166aedb5a..949ae4942 100644 --- a/src/UI/AddSeries/AddSeriesLayout.js +++ b/src/UI/AddSeries/AddSeriesLayout.js @@ -6,7 +6,7 @@ var ExistingSeriesCollectionView = require('./Existing/AddExistingSeriesCollecti var AddSeriesView = require('./AddSeriesView'); var ProfileCollection = require('../Profile/ProfileCollection'); var RootFolderCollection = require('./RootFolders/RootFolderCollection'); -require('../Series/SeriesCollection'); +require('../Artist/ArtistCollection'); module.exports = Marionette.Layout.extend({ template : 'AddSeries/AddSeriesLayoutTemplate', diff --git a/src/UI/Artist/ArtistController.js b/src/UI/Artist/ArtistController.js index 838018670..4805bd9bf 100644 --- a/src/UI/Artist/ArtistController.js +++ b/src/UI/Artist/ArtistController.js @@ -1,34 +1,33 @@ var NzbDroneController = require('../Shared/NzbDroneController'); var AppLayout = require('../AppLayout'); var ArtistCollection = require('./ArtistCollection'); -var SeriesIndexLayout = require('./Index/SeriesIndexLayout'); +var SeriesIndexLayout = require('../Series/Index/SeriesIndexLayout'); var SeriesDetailsLayout = require('../Series/Details/SeriesDetailsLayout'); module.exports = NzbDroneController.extend({ _originalInit : NzbDroneController.prototype.initialize, initialize : function() { - this.route('', this.series); - this.route('artist', this.series); - this.route('artist/:query', this.seriesDetails); + this.route('', this.artist); + this.route('artist', this.artist); + this.route('artist/:query', this.artistDetails); this._originalInit.apply(this, arguments); }, artist : function() { this.setTitle('Lidarr'); - this.setArtistName('Lidarr'); this.showMainRegion(new SeriesIndexLayout()); }, - seriesDetails : function(query) { + artistDetails : function(query) { var artists = ArtistCollection.where({ artistNameSlug : query }); - console.log('seriesDetails, artists: ', artists); + console.log('artistDetails, artists: ', artists); if (artists.length !== 0) { var targetSeries = artists[0]; console.log("[ArtistController] targetSeries: ", targetSeries); - this.setTitle(targetSeries.get('title')); - this.setArtistName(targetSeries.get('artistName')); + this.setTitle(targetSeries.get('artistName')); // TODO: Update NzbDroneController + //this.setArtistName(targetSeries.get('artistName')); this.showMainRegion(new SeriesDetailsLayout({ model : targetSeries })); } else { this.showNotFound(); diff --git a/src/UI/Handlebars/Helpers/Series.js b/src/UI/Handlebars/Helpers/Series.js index ff3ffd7f1..ecade70eb 100644 --- a/src/UI/Handlebars/Helpers/Series.js +++ b/src/UI/Handlebars/Helpers/Series.js @@ -71,6 +71,16 @@ Handlebars.registerHelper('seasonCountHelper', function() { return new Handlebars.SafeString('{0} Seasons'.format(seasonCount)); }); +Handlebars.registerHelper('albumCountHelper', function() { + var albumCount = this.albumCount; + + if (albumCount === 1) { + return new Handlebars.SafeString('{0} Albums'.format(albumCount)); + } + + return new Handlebars.SafeString('{0} Albums'.format(albumCount)); +}); + /*Handlebars.registerHelper('titleWithYear', function() { if (this.title.endsWith(' ({0})'.format(this.year))) { return this.title; diff --git a/src/UI/Series/Index/Overview/SeriesOverviewItemViewTemplate.hbs b/src/UI/Series/Index/Overview/SeriesOverviewItemViewTemplate.hbs index 1bc7f1a3b..4e9785b50 100644 --- a/src/UI/Series/Index/Overview/SeriesOverviewItemViewTemplate.hbs +++ b/src/UI/Series/Index/Overview/SeriesOverviewItemViewTemplate.hbs @@ -8,14 +8,14 @@
- - + +
@@ -35,15 +35,17 @@
- {{#if_eq status compare="ended"}} + + - {{seasonCountHelper}} + {{albumCountHelper}} {{profile profileId}}
diff --git a/src/UI/Series/Index/SeriesIndexLayout.js b/src/UI/Series/Index/SeriesIndexLayout.js index 9cd77d08e..049bd267b 100644 --- a/src/UI/Series/Index/SeriesIndexLayout.js +++ b/src/UI/Series/Index/SeriesIndexLayout.js @@ -4,7 +4,7 @@ var Backgrid = require('backgrid'); var PosterCollectionView = require('./Posters/SeriesPostersCollectionView'); var ListCollectionView = require('./Overview/SeriesOverviewCollectionView'); var EmptyView = require('./EmptyView'); -var SeriesCollection = require('../SeriesCollection'); +var ArtistCollection = require('../../Artist/ArtistCollection'); var RelativeDateCell = require('../../Cells/RelativeDateCell'); var SeriesTitleCell = require('../../Cells/SeriesTitleCell'); var TemplatedCell = require('../../Cells/TemplatedCell'); @@ -111,28 +111,28 @@ module.exports = Marionette.Layout.extend({ }, initialize : function() { - this.seriesCollection = SeriesCollection.clone(); - this.seriesCollection.shadowCollection.bindSignalR(); + this.artistCollection = ArtistCollection.clone(); + this.artistCollection.shadowCollection.bindSignalR(); - this.listenTo(this.seriesCollection.shadowCollection, 'sync', function(model, collection, options) { - this.seriesCollection.fullCollection.resetFiltered(); + this.listenTo(this.artistCollection, 'sync', function(model, collection, options) { + this.artistCollection.fullCollection.resetFiltered(); this._renderView(); }); - this.listenTo(this.seriesCollection.shadowCollection, 'add', function(model, collection, options) { - this.seriesCollection.fullCollection.resetFiltered(); + this.listenTo(this.artistCollection, 'add', function(model, collection, options) { + this.artistCollection.fullCollection.resetFiltered(); this._renderView(); }); - this.listenTo(this.seriesCollection.shadowCollection, 'remove', function(model, collection, options) { - this.seriesCollection.fullCollection.resetFiltered(); + this.listenTo(this.artistCollection, 'remove', function(model, collection, options) { + this.artistCollection.fullCollection.resetFiltered(); this._renderView(); }); this.sortingOptions = { type : 'sorting', storeState : false, - viewCollection : this.seriesCollection, + viewCollection : this.artistCollection, items : [ { title : 'Title', @@ -243,7 +243,7 @@ module.exports = Marionette.Layout.extend({ _showTable : function() { this.currentView = new Backgrid.Grid({ - collection : this.seriesCollection, + collection : this.artistCollection, columns : this.columns, className : 'table table-hover' }); @@ -253,7 +253,7 @@ module.exports = Marionette.Layout.extend({ _showList : function() { this.currentView = new ListCollectionView({ - collection : this.seriesCollection + collection : this.artistCollection }); this._renderView(); @@ -261,14 +261,15 @@ module.exports = Marionette.Layout.extend({ _showPosters : function() { this.currentView = new PosterCollectionView({ - collection : this.seriesCollection + collection : this.artistCollection }); this._renderView(); }, _renderView : function() { - if (SeriesCollection.length === 0) { + // Problem is this is calling before artistCollection has updated. Where are the promises with backbone? + if (this.artistCollection.length === 0) { this.seriesRegion.show(new EmptyView()); this.toolbar.close(); @@ -282,13 +283,14 @@ module.exports = Marionette.Layout.extend({ }, _fetchCollection : function() { - this.seriesCollection.fetch(); + this.artistCollection.fetch(); + console.log('index page, collection: ', this.artistCollection); }, _setFilter : function(buttonContext) { var mode = buttonContext.model.get('key'); - this.seriesCollection.setFilterMode(mode); + this.artistCollection.setFilterMode(mode); }, _showToolbar : function() { @@ -317,22 +319,22 @@ module.exports = Marionette.Layout.extend({ _showFooter : function() { var footerModel = new FooterModel(); - var series = SeriesCollection.models.length; + var series = this.artistCollection.models.length; var episodes = 0; var episodeFiles = 0; var ended = 0; var continuing = 0; var monitored = 0; - _.each(SeriesCollection.models, function(model) { - episodes += model.get('episodeCount'); + _.each(this.artistCollection.models, function(model) { + episodes += model.get('episodeCount'); // TODO: Refactor to Seasons and Tracks episodeFiles += model.get('episodeFileCount'); - if (model.get('status').toLowerCase() === 'ended') { + /*if (model.get('status').toLowerCase() === 'ended') { ended++; } else { continuing++; - } + }*/ if (model.get('monitored')) { monitored++; diff --git a/src/UI/main.js b/src/UI/main.js index f46f68b93..40b9e9efe 100644 --- a/src/UI/main.js +++ b/src/UI/main.js @@ -5,7 +5,7 @@ var RouteBinder = require('./jQuery/RouteBinder'); var SignalRBroadcaster = require('./Shared/SignalRBroadcaster'); var NavbarLayout = require('./Navbar/NavbarLayout'); var AppLayout = require('./AppLayout'); -var SeriesController = require('./Series/SeriesController'); +var ArtistController = require('./Artist/ArtistController'); var Router = require('./Router'); var ModalController = require('./Shared/Modal/ModalController'); var ControlPanelController = require('./Shared/ControlPanel/ControlPanelController'); @@ -20,7 +20,7 @@ require('./Hotkeys/Hotkeys'); require('./Shared/piwikCheck'); require('./Shared/VersionChangeMonitor'); -new SeriesController(); +new ArtistController(); new ModalController(); new ControlPanelController(); new Router(); diff --git a/src/UI/vent.js b/src/UI/vent.js index 1b9346529..0baf8d0d4 100644 --- a/src/UI/vent.js +++ b/src/UI/vent.js @@ -5,6 +5,8 @@ var vent = new Wreqr.EventAggregator(); vent.Events = { SeriesAdded : 'series:added', SeriesDeleted : 'series:deleted', + ArtistAdded : 'artist:added', + ArtistDeleted : 'artist:deleted', CommandComplete : 'command:complete', ServerUpdated : 'server:updated', EpisodeFileDeleted : 'episodefile:deleted'