From 1d9c163f5ff0207442ff008d8799a5bc602c3d39 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 6 Sep 2013 15:17:15 -0400 Subject: [PATCH] fixes #506 - Song list - make columns headers clickable for sorting --- MediaBrowser.Api/UserLibrary/ItemsService.cs | 10 ++++++ .../Entities/Audio/Audio.cs | 2 +- .../Entities/Audio/IHasAlbumArtist.cs | 8 +++++ .../Entities/Audio/MusicAlbum.cs | 13 +++++++- .../MediaBrowser.Controller.csproj | 1 + MediaBrowser.Model/Querying/ItemSortBy.cs | 1 + .../Dto/DtoService.cs | 10 ++++-- ...MediaBrowser.Server.Implementations.csproj | 1 + .../Sorting/AlbumArtistComparer.cs | 26 ++------------- .../Sorting/NameComparer.cs | 33 +++++++++++++++++++ 10 files changed, 77 insertions(+), 28 deletions(-) create mode 100644 MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs create mode 100644 MediaBrowser.Server.Implementations/Sorting/NameComparer.cs diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 288b67057..c9218c6b5 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -126,6 +126,9 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "NameStartsWithOrGreater", Description = "Optional filter by items whose name is sorted equally or greater than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string NameStartsWithOrGreater { get; set; } + [ApiMember(Name = "AlbumArtistStartsWithOrGreater", Description = "Optional filter by items whose album artist is sorted equally or greater than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string AlbumArtistStartsWithOrGreater { get; set; } + /// /// Gets or sets the air days. /// @@ -576,6 +579,13 @@ namespace MediaBrowser.Api.UserLibrary items = items.Where(i => string.Compare(request.NameStartsWithOrGreater, i.SortName, StringComparison.CurrentCultureIgnoreCase) < 1); } + if (!string.IsNullOrEmpty(request.AlbumArtistStartsWithOrGreater)) + { + items = items.OfType() + .Where(i => string.Compare(request.AlbumArtistStartsWithOrGreater, i.AlbumArtist, StringComparison.CurrentCultureIgnoreCase) < 1) + .Cast(); + } + // Filter by Series Status if (!string.IsNullOrEmpty(request.SeriesStatus)) { diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 7c226864b..ff632c981 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -9,7 +9,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// /// Class Audio /// - public class Audio : BaseItem, IHasMediaStreams + public class Audio : BaseItem, IHasMediaStreams, IHasAlbumArtist { public Audio() { diff --git a/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs b/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs new file mode 100644 index 000000000..d9dac077f --- /dev/null +++ b/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs @@ -0,0 +1,8 @@ + +namespace MediaBrowser.Controller.Entities.Audio +{ + public interface IHasAlbumArtist + { + string AlbumArtist { get; } + } +} diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 7bfbbaf19..834fc6943 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// /// Class MusicAlbum /// - public class MusicAlbum : Folder + public class MusicAlbum : Folder, IHasAlbumArtist { public string LastFmImageUrl { get; set; } @@ -62,6 +62,17 @@ namespace MediaBrowser.Controller.Entities.Audio { return RecursiveChildren.OfType