Rework Tags for Music

pull/94/head
Qstick 8 years ago
parent d6efae537f
commit 8f45fe0afe

@ -49,7 +49,7 @@ class TagsModalContent extends Component {
render() { render() {
const { const {
seriesTags, artistTags,
tagList, tagList,
onModalClose, onModalClose,
onApplyTagsPress onApplyTagsPress
@ -108,7 +108,7 @@ class TagsModalContent extends Component {
<div className={styles.result}> <div className={styles.result}>
{ {
seriesTags.map((t) => { artistTags.map((t) => {
const tag = _.find(tagList, { id: t }); const tag = _.find(tagList, { id: t });
if (!tag) { if (!tag) {
@ -140,7 +140,7 @@ class TagsModalContent extends Component {
return null; return null;
} }
if (seriesTags.indexOf(t) > -1) { if (artistTags.indexOf(t) > -1) {
return null; return null;
} }
@ -179,7 +179,7 @@ class TagsModalContent extends Component {
} }
TagsModalContent.propTypes = { TagsModalContent.propTypes = {
seriesTags: PropTypes.arrayOf(PropTypes.number).isRequired, artistTags: PropTypes.arrayOf(PropTypes.number).isRequired,
tagList: PropTypes.arrayOf(PropTypes.object).isRequired, tagList: PropTypes.arrayOf(PropTypes.object).isRequired,
onModalClose: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired,
onApplyTagsPress: PropTypes.func.isRequired onApplyTagsPress: PropTypes.func.isRequired

@ -15,10 +15,10 @@ function createMapStateToProps() {
return s.id === id; return s.id === id;
}); });
const seriesTags = _.uniq(_.concat(..._.map(series, 'tags'))); const artistTags = _.uniq(_.concat(..._.map(series, 'tags')));
return { return {
seriesTags, artistTags,
tagList tagList
}; };
} }

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NzbDrone.Core.Tags; using NzbDrone.Core.Tags;
using Lidarr.Api.V3.Notifications; using Lidarr.Api.V3.Notifications;
@ -14,7 +14,7 @@ namespace Lidarr.Api.V3.Tags
public List<DelayProfileResource> DelayProfiles { get; set; } public List<DelayProfileResource> DelayProfiles { get; set; }
public List<NotificationResource> Notifications { get; set; } public List<NotificationResource> Notifications { get; set; }
public List<RestrictionResource> Restrictions { get; set; } public List<RestrictionResource> Restrictions { get; set; }
public List<int> SeriesIds { get; set; } public List<int> ArtistIds { get; set; }
} }
public static class TagDetailsResourceMapper public static class TagDetailsResourceMapper
@ -32,7 +32,7 @@ namespace Lidarr.Api.V3.Tags
DelayProfiles = model.DelayProfiles.ToResource(), DelayProfiles = model.DelayProfiles.ToResource(),
Notifications = model.Notifications.Select(NotificationResourceMapper.ToResource).ToList(), Notifications = model.Notifications.Select(NotificationResourceMapper.ToResource).ToList(),
Restrictions = model.Restrictions.ToResource(), Restrictions = model.Restrictions.ToResource(),
SeriesIds = model.Series.Select(s => s.Id).ToList() ArtistIds = model.Artist.Select(s => s.Id).ToList()
}; };
} }

@ -1,4 +1,4 @@
using NLog; using NLog;
using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Music.Events; using NzbDrone.Core.Music.Events;
using NzbDrone.Core.Organizer; using NzbDrone.Core.Organizer;
@ -22,6 +22,7 @@ namespace NzbDrone.Core.Music
Artist FindByTitleInexact(string title); Artist FindByTitleInexact(string title);
void DeleteArtist(int artistId, bool deleteFiles); void DeleteArtist(int artistId, bool deleteFiles);
List<Artist> GetAllArtists(); List<Artist> GetAllArtists();
List<Artist> AllForTag(int tagId);
Artist UpdateArtist(Artist artist); Artist UpdateArtist(Artist artist);
List<Artist> UpdateArtists(List<Artist> artist); List<Artist> UpdateArtists(List<Artist> artist);
bool ArtistPathExists(string folder); bool ArtistPathExists(string folder);
@ -89,6 +90,12 @@ namespace NzbDrone.Core.Music
return _artistRepository.All().ToList(); return _artistRepository.All().ToList();
} }
public List<Artist> AllForTag(int tagId)
{
return GetAllArtists().Where(s => s.Tags.Contains(tagId))
.ToList();
}
public Artist GetArtist(int artistDBId) public Artist GetArtist(int artistDBId)
{ {
return _artistRepository.Get(artistDBId); return _artistRepository.Get(artistDBId);

@ -1,16 +1,16 @@
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.Notifications; using NzbDrone.Core.Notifications;
using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Profiles.Delay;
using NzbDrone.Core.Restrictions; using NzbDrone.Core.Restrictions;
using NzbDrone.Core.Tv; using NzbDrone.Core.Music;
namespace NzbDrone.Core.Tags namespace NzbDrone.Core.Tags
{ {
public class TagDetails : ModelBase public class TagDetails : ModelBase
{ {
public string Label { get; set; } public string Label { get; set; }
public List<Series> Series { get; set; } public List<Artist> Artist { get; set; }
public List<NotificationDefinition> Notifications { get; set; } public List<NotificationDefinition> Notifications { get; set; }
public List<Restriction> Restrictions { get; set; } public List<Restriction> Restrictions { get; set; }
public List<DelayProfile> DelayProfiles { get; set; } public List<DelayProfile> DelayProfiles { get; set; }

@ -1,10 +1,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Notifications; using NzbDrone.Core.Notifications;
using NzbDrone.Core.Profiles.Delay; using NzbDrone.Core.Profiles.Delay;
using NzbDrone.Core.Restrictions; using NzbDrone.Core.Restrictions;
using NzbDrone.Core.Tv; using NzbDrone.Core.Music;
namespace NzbDrone.Core.Tags namespace NzbDrone.Core.Tags
{ {
@ -26,21 +26,21 @@ namespace NzbDrone.Core.Tags
private readonly IDelayProfileService _delayProfileService; private readonly IDelayProfileService _delayProfileService;
private readonly INotificationFactory _notificationFactory; private readonly INotificationFactory _notificationFactory;
private readonly IRestrictionService _restrictionService; private readonly IRestrictionService _restrictionService;
private readonly ISeriesService _seriesService; private readonly IArtistService _artistService;
public TagService(ITagRepository repo, public TagService(ITagRepository repo,
IEventAggregator eventAggregator, IEventAggregator eventAggregator,
IDelayProfileService delayProfileService, IDelayProfileService delayProfileService,
INotificationFactory notificationFactory, INotificationFactory notificationFactory,
IRestrictionService restrictionService, IRestrictionService restrictionService,
ISeriesService seriesService) IArtistService artistService)
{ {
_repo = repo; _repo = repo;
_eventAggregator = eventAggregator; _eventAggregator = eventAggregator;
_delayProfileService = delayProfileService; _delayProfileService = delayProfileService;
_notificationFactory = notificationFactory; _notificationFactory = notificationFactory;
_restrictionService = restrictionService; _restrictionService = restrictionService;
_seriesService = seriesService; _artistService = artistService;
} }
public Tag GetTag(int tagId) public Tag GetTag(int tagId)
@ -66,7 +66,7 @@ namespace NzbDrone.Core.Tags
var delayProfiles = _delayProfileService.AllForTag(tagId); var delayProfiles = _delayProfileService.AllForTag(tagId);
var notifications = _notificationFactory.AllForTag(tagId); var notifications = _notificationFactory.AllForTag(tagId);
var restrictions = _restrictionService.AllForTag(tagId); var restrictions = _restrictionService.AllForTag(tagId);
var series = _seriesService.AllForTag(tagId); var artist = _artistService.AllForTag(tagId);
return new TagDetails return new TagDetails
{ {
@ -75,7 +75,7 @@ namespace NzbDrone.Core.Tags
DelayProfiles = delayProfiles, DelayProfiles = delayProfiles,
Notifications = notifications, Notifications = notifications,
Restrictions = restrictions, Restrictions = restrictions,
Series = series Artist = artist
}; };
} }

Loading…
Cancel
Save