From 8f45fe0afe7aaf6a780c8fcea38fe093f6b5dd17 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 23 Sep 2017 00:30:52 -0400 Subject: [PATCH] Rework Tags for Music --- .../src/Artist/Editor/Tags/TagsModalContent.js | 8 ++++---- .../Editor/Tags/TagsModalContentConnector.js | 4 ++-- src/Lidarr.Api.V3/Tags/TagDetailsResource.cs | 6 +++--- src/NzbDrone.Core/Music/ArtistService.cs | 9 ++++++++- src/NzbDrone.Core/Tags/TagDetails.cs | 6 +++--- src/NzbDrone.Core/Tags/TagService.cs | 14 +++++++------- 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/frontend/src/Artist/Editor/Tags/TagsModalContent.js b/frontend/src/Artist/Editor/Tags/TagsModalContent.js index 067553977..153c8a0e8 100644 --- a/frontend/src/Artist/Editor/Tags/TagsModalContent.js +++ b/frontend/src/Artist/Editor/Tags/TagsModalContent.js @@ -49,7 +49,7 @@ class TagsModalContent extends Component { render() { const { - seriesTags, + artistTags, tagList, onModalClose, onApplyTagsPress @@ -108,7 +108,7 @@ class TagsModalContent extends Component {
{ - seriesTags.map((t) => { + artistTags.map((t) => { const tag = _.find(tagList, { id: t }); if (!tag) { @@ -140,7 +140,7 @@ class TagsModalContent extends Component { return null; } - if (seriesTags.indexOf(t) > -1) { + if (artistTags.indexOf(t) > -1) { return null; } @@ -179,7 +179,7 @@ class TagsModalContent extends Component { } TagsModalContent.propTypes = { - seriesTags: PropTypes.arrayOf(PropTypes.number).isRequired, + artistTags: PropTypes.arrayOf(PropTypes.number).isRequired, tagList: PropTypes.arrayOf(PropTypes.object).isRequired, onModalClose: PropTypes.func.isRequired, onApplyTagsPress: PropTypes.func.isRequired diff --git a/frontend/src/Artist/Editor/Tags/TagsModalContentConnector.js b/frontend/src/Artist/Editor/Tags/TagsModalContentConnector.js index 5acae0402..dfc897096 100644 --- a/frontend/src/Artist/Editor/Tags/TagsModalContentConnector.js +++ b/frontend/src/Artist/Editor/Tags/TagsModalContentConnector.js @@ -15,10 +15,10 @@ function createMapStateToProps() { return s.id === id; }); - const seriesTags = _.uniq(_.concat(..._.map(series, 'tags'))); + const artistTags = _.uniq(_.concat(..._.map(series, 'tags'))); return { - seriesTags, + artistTags, tagList }; } diff --git a/src/Lidarr.Api.V3/Tags/TagDetailsResource.cs b/src/Lidarr.Api.V3/Tags/TagDetailsResource.cs index 297a87ff4..10675b3c1 100644 --- a/src/Lidarr.Api.V3/Tags/TagDetailsResource.cs +++ b/src/Lidarr.Api.V3/Tags/TagDetailsResource.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using NzbDrone.Core.Tags; using Lidarr.Api.V3.Notifications; @@ -14,7 +14,7 @@ namespace Lidarr.Api.V3.Tags public List DelayProfiles { get; set; } public List Notifications { get; set; } public List Restrictions { get; set; } - public List SeriesIds { get; set; } + public List ArtistIds { get; set; } } public static class TagDetailsResourceMapper @@ -32,7 +32,7 @@ namespace Lidarr.Api.V3.Tags DelayProfiles = model.DelayProfiles.ToResource(), Notifications = model.Notifications.Select(NotificationResourceMapper.ToResource).ToList(), Restrictions = model.Restrictions.ToResource(), - SeriesIds = model.Series.Select(s => s.Id).ToList() + ArtistIds = model.Artist.Select(s => s.Id).ToList() }; } diff --git a/src/NzbDrone.Core/Music/ArtistService.cs b/src/NzbDrone.Core/Music/ArtistService.cs index 1297a42e9..c44f73a5b 100644 --- a/src/NzbDrone.Core/Music/ArtistService.cs +++ b/src/NzbDrone.Core/Music/ArtistService.cs @@ -1,4 +1,4 @@ -using NLog; +using NLog; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Music.Events; using NzbDrone.Core.Organizer; @@ -22,6 +22,7 @@ namespace NzbDrone.Core.Music Artist FindByTitleInexact(string title); void DeleteArtist(int artistId, bool deleteFiles); List GetAllArtists(); + List AllForTag(int tagId); Artist UpdateArtist(Artist artist); List UpdateArtists(List artist); bool ArtistPathExists(string folder); @@ -89,6 +90,12 @@ namespace NzbDrone.Core.Music return _artistRepository.All().ToList(); } + public List AllForTag(int tagId) + { + return GetAllArtists().Where(s => s.Tags.Contains(tagId)) + .ToList(); + } + public Artist GetArtist(int artistDBId) { return _artistRepository.Get(artistDBId); diff --git a/src/NzbDrone.Core/Tags/TagDetails.cs b/src/NzbDrone.Core/Tags/TagDetails.cs index 963fd6003..39df71be0 100644 --- a/src/NzbDrone.Core/Tags/TagDetails.cs +++ b/src/NzbDrone.Core/Tags/TagDetails.cs @@ -1,16 +1,16 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Core.Datastore; using NzbDrone.Core.Notifications; using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Restrictions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Tags { public class TagDetails : ModelBase { public string Label { get; set; } - public List Series { get; set; } + public List Artist { get; set; } public List Notifications { get; set; } public List Restrictions { get; set; } public List DelayProfiles { get; set; } diff --git a/src/NzbDrone.Core/Tags/TagService.cs b/src/NzbDrone.Core/Tags/TagService.cs index 05a6f156c..d7ee7b28d 100644 --- a/src/NzbDrone.Core/Tags/TagService.cs +++ b/src/NzbDrone.Core/Tags/TagService.cs @@ -1,10 +1,10 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Notifications; using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Restrictions; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Music; namespace NzbDrone.Core.Tags { @@ -26,21 +26,21 @@ namespace NzbDrone.Core.Tags private readonly IDelayProfileService _delayProfileService; private readonly INotificationFactory _notificationFactory; private readonly IRestrictionService _restrictionService; - private readonly ISeriesService _seriesService; + private readonly IArtistService _artistService; public TagService(ITagRepository repo, IEventAggregator eventAggregator, IDelayProfileService delayProfileService, INotificationFactory notificationFactory, IRestrictionService restrictionService, - ISeriesService seriesService) + IArtistService artistService) { _repo = repo; _eventAggregator = eventAggregator; _delayProfileService = delayProfileService; _notificationFactory = notificationFactory; _restrictionService = restrictionService; - _seriesService = seriesService; + _artistService = artistService; } public Tag GetTag(int tagId) @@ -66,7 +66,7 @@ namespace NzbDrone.Core.Tags var delayProfiles = _delayProfileService.AllForTag(tagId); var notifications = _notificationFactory.AllForTag(tagId); var restrictions = _restrictionService.AllForTag(tagId); - var series = _seriesService.AllForTag(tagId); + var artist = _artistService.AllForTag(tagId); return new TagDetails { @@ -75,7 +75,7 @@ namespace NzbDrone.Core.Tags DelayProfiles = delayProfiles, Notifications = notifications, Restrictions = restrictions, - Series = series + Artist = artist }; }