fixes #506 - Song list - make columns headers clickable for sorting
This commit is contained in:
parent
83dd13cc7c
commit
1d9c163f5f
|
@ -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")]
|
[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; }
|
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; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the air days.
|
/// Gets or sets the air days.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -576,6 +579,13 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
items = items.Where(i => string.Compare(request.NameStartsWithOrGreater, i.SortName, StringComparison.CurrentCultureIgnoreCase) < 1);
|
items = items.Where(i => string.Compare(request.NameStartsWithOrGreater, i.SortName, StringComparison.CurrentCultureIgnoreCase) < 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(request.AlbumArtistStartsWithOrGreater))
|
||||||
|
{
|
||||||
|
items = items.OfType<IHasAlbumArtist>()
|
||||||
|
.Where(i => string.Compare(request.AlbumArtistStartsWithOrGreater, i.AlbumArtist, StringComparison.CurrentCultureIgnoreCase) < 1)
|
||||||
|
.Cast<BaseItem>();
|
||||||
|
}
|
||||||
|
|
||||||
// Filter by Series Status
|
// Filter by Series Status
|
||||||
if (!string.IsNullOrEmpty(request.SeriesStatus))
|
if (!string.IsNullOrEmpty(request.SeriesStatus))
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class Audio
|
/// Class Audio
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Audio : BaseItem, IHasMediaStreams
|
public class Audio : BaseItem, IHasMediaStreams, IHasAlbumArtist
|
||||||
{
|
{
|
||||||
public Audio()
|
public Audio()
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
namespace MediaBrowser.Controller.Entities.Audio
|
||||||
|
{
|
||||||
|
public interface IHasAlbumArtist
|
||||||
|
{
|
||||||
|
string AlbumArtist { get; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class MusicAlbum
|
/// Class MusicAlbum
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MusicAlbum : Folder
|
public class MusicAlbum : Folder, IHasAlbumArtist
|
||||||
{
|
{
|
||||||
public string LastFmImageUrl { get; set; }
|
public string LastFmImageUrl { get; set; }
|
||||||
|
|
||||||
|
@ -62,6 +62,17 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||||
{
|
{
|
||||||
return RecursiveChildren.OfType<Audio>().Any(i => i.HasArtist(artist));
|
return RecursiveChildren.OfType<Audio>().Any(i => i.HasArtist(artist));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string AlbumArtist
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return RecursiveChildren
|
||||||
|
.OfType<Audio>()
|
||||||
|
.Select(i => i.AlbumArtist)
|
||||||
|
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MusicAlbumDisc : Folder
|
public class MusicAlbumDisc : Folder
|
||||||
|
|
|
@ -73,6 +73,7 @@
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Dto\IDtoService.cs" />
|
<Compile Include="Dto\IDtoService.cs" />
|
||||||
<Compile Include="Entities\AdultVideo.cs" />
|
<Compile Include="Entities\AdultVideo.cs" />
|
||||||
|
<Compile Include="Entities\Audio\IHasAlbumArtist.cs" />
|
||||||
<Compile Include="Entities\Book.cs" />
|
<Compile Include="Entities\Book.cs" />
|
||||||
<Compile Include="Configuration\IServerConfigurationManager.cs" />
|
<Compile Include="Configuration\IServerConfigurationManager.cs" />
|
||||||
<Compile Include="Entities\Audio\MusicGenre.cs" />
|
<Compile Include="Entities\Audio\MusicGenre.cs" />
|
||||||
|
|
|
@ -46,6 +46,7 @@ namespace MediaBrowser.Model.Querying
|
||||||
/// The sort name
|
/// The sort name
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string SortName = "SortName";
|
public const string SortName = "SortName";
|
||||||
|
public const string Name = "Name";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The random
|
/// The random
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -892,7 +892,6 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
if (audio != null)
|
if (audio != null)
|
||||||
{
|
{
|
||||||
dto.Album = audio.Album;
|
dto.Album = audio.Album;
|
||||||
dto.AlbumArtist = audio.AlbumArtist;
|
|
||||||
dto.Artists = audio.Artists.ToArray();
|
dto.Artists = audio.Artists.ToArray();
|
||||||
|
|
||||||
var albumParent = audio.FindParent<MusicAlbum>();
|
var albumParent = audio.FindParent<MusicAlbum>();
|
||||||
|
@ -916,14 +915,19 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
{
|
{
|
||||||
var songs = album.RecursiveChildren.OfType<Audio>().ToList();
|
var songs = album.RecursiveChildren.OfType<Audio>().ToList();
|
||||||
|
|
||||||
dto.AlbumArtist = songs.Select(i => i.AlbumArtist).FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
|
||||||
|
|
||||||
dto.Artists =
|
dto.Artists =
|
||||||
songs.SelectMany(i => i.Artists)
|
songs.SelectMany(i => i.Artists)
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hasAlbumArtist = item as IHasAlbumArtist;
|
||||||
|
|
||||||
|
if (hasAlbumArtist != null)
|
||||||
|
{
|
||||||
|
dto.AlbumArtist = hasAlbumArtist.AlbumArtist;
|
||||||
|
}
|
||||||
|
|
||||||
// Add video info
|
// Add video info
|
||||||
var video = item as Video;
|
var video = item as Video;
|
||||||
if (video != null)
|
if (video != null)
|
||||||
|
|
|
@ -178,6 +178,7 @@
|
||||||
<Compile Include="Sorting\DatePlayedComparer.cs" />
|
<Compile Include="Sorting\DatePlayedComparer.cs" />
|
||||||
<Compile Include="Sorting\IsFolderComparer.cs" />
|
<Compile Include="Sorting\IsFolderComparer.cs" />
|
||||||
<Compile Include="Sorting\IsUnplayedComparer.cs" />
|
<Compile Include="Sorting\IsUnplayedComparer.cs" />
|
||||||
|
<Compile Include="Sorting\NameComparer.cs" />
|
||||||
<Compile Include="Sorting\OfficialRatingComparer.cs" />
|
<Compile Include="Sorting\OfficialRatingComparer.cs" />
|
||||||
<Compile Include="Sorting\PlayCountComparer.cs" />
|
<Compile Include="Sorting\PlayCountComparer.cs" />
|
||||||
<Compile Include="Sorting\PremiereDateComparer.cs" />
|
<Compile Include="Sorting\PremiereDateComparer.cs" />
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Linq;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities;
|
|
||||||
using MediaBrowser.Controller.Entities.Audio;
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
using MediaBrowser.Controller.Sorting;
|
using MediaBrowser.Controller.Sorting;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
|
@ -30,28 +29,9 @@ namespace MediaBrowser.Server.Implementations.Sorting
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
private string GetValue(BaseItem x)
|
private string GetValue(BaseItem x)
|
||||||
{
|
{
|
||||||
var audio = x as Audio;
|
var audio = x as IHasAlbumArtist;
|
||||||
|
|
||||||
if (audio != null)
|
return audio != null ? audio.AlbumArtist : null;
|
||||||
{
|
|
||||||
return audio.AlbumArtist;
|
|
||||||
}
|
|
||||||
|
|
||||||
var album = x as MusicAlbum;
|
|
||||||
|
|
||||||
if (album != null)
|
|
||||||
{
|
|
||||||
var song = album.RecursiveChildren
|
|
||||||
.OfType<Audio>()
|
|
||||||
.FirstOrDefault(i => !string.IsNullOrEmpty(i.AlbumArtist));
|
|
||||||
|
|
||||||
if (song != null)
|
|
||||||
{
|
|
||||||
return song.AlbumArtist;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
33
MediaBrowser.Server.Implementations/Sorting/NameComparer.cs
Normal file
33
MediaBrowser.Server.Implementations/Sorting/NameComparer.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Sorting;
|
||||||
|
using MediaBrowser.Model.Querying;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Server.Implementations.Sorting
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class NameComparer
|
||||||
|
/// </summary>
|
||||||
|
public class NameComparer : IBaseItemComparer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Compares the specified x.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x">The x.</param>
|
||||||
|
/// <param name="y">The y.</param>
|
||||||
|
/// <returns>System.Int32.</returns>
|
||||||
|
public int Compare(BaseItem x, BaseItem y)
|
||||||
|
{
|
||||||
|
return string.Compare(x.Name, y.Name, StringComparison.CurrentCultureIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the name.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The name.</value>
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return ItemSortBy.Name; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user