#247 - Web client - Hide views that have no content
This commit is contained in:
parent
c2be223828
commit
ae4c4c6ce5
|
@ -1,10 +1,16 @@
|
|||
using System.Threading;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using ServiceStack.ServiceHost;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Api
|
||||
|
@ -43,7 +49,15 @@ namespace MediaBrowser.Api
|
|||
public class RefreshLibrary : IReturnVoid
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
[Route("/Items/Counts", "GET")]
|
||||
[Api(Description = "Gets counts of various item types")]
|
||||
public class GetItemCounts : IReturn<ItemCounts>
|
||||
{
|
||||
[ApiMember(Name = "UserId", Description = "Optional. Get counts from a specific user's library.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public Guid? UserId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class LibraryService
|
||||
/// </summary>
|
||||
|
@ -55,16 +69,19 @@ namespace MediaBrowser.Api
|
|||
private readonly IItemRepository _itemRepo;
|
||||
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryService" /> class.
|
||||
/// </summary>
|
||||
/// <param name="itemRepo">The item repo.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
public LibraryService(IItemRepository itemRepo, ILibraryManager libraryManager)
|
||||
/// <param name="userManager">The user manager.</param>
|
||||
public LibraryService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager)
|
||||
{
|
||||
_itemRepo = itemRepo;
|
||||
_libraryManager = libraryManager;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -79,6 +96,41 @@ namespace MediaBrowser.Api
|
|||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetItemCounts request)
|
||||
{
|
||||
var items = GetItems(request.UserId).ToList();
|
||||
|
||||
var counts = new ItemCounts
|
||||
{
|
||||
AlbumCount = items.OfType<MusicAlbum>().Count(),
|
||||
EpisodeCount = items.OfType<Episode>().Count(),
|
||||
GameCount = items.OfType<BaseGame>().Count(),
|
||||
MovieCount = items.OfType<Movie>().Count(),
|
||||
SeriesCount = items.OfType<Series>().Count(),
|
||||
SongCount = items.OfType<Audio>().Count(),
|
||||
TrailerCount = items.OfType<Trailer>().Count()
|
||||
};
|
||||
|
||||
return ToOptimizedResult(counts);
|
||||
}
|
||||
|
||||
protected IEnumerable<BaseItem> GetItems(Guid? userId)
|
||||
{
|
||||
if (userId.HasValue)
|
||||
{
|
||||
var user = _userManager.GetUserById(userId.Value);
|
||||
|
||||
return _userManager.GetUserById(userId.Value).RootFolder.GetRecursiveChildren(user);
|
||||
}
|
||||
|
||||
return _libraryManager.RootFolder.RecursiveChildren;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts the specified request.
|
||||
/// </summary>
|
||||
|
|
45
MediaBrowser.Model/Dto/ItemCounts.cs
Normal file
45
MediaBrowser.Model/Dto/ItemCounts.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
|
||||
namespace MediaBrowser.Model.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// Class LibrarySummary
|
||||
/// </summary>
|
||||
public class ItemCounts
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the movie count.
|
||||
/// </summary>
|
||||
/// <value>The movie count.</value>
|
||||
public int MovieCount { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the series count.
|
||||
/// </summary>
|
||||
/// <value>The series count.</value>
|
||||
public int SeriesCount { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the episode count.
|
||||
/// </summary>
|
||||
/// <value>The episode count.</value>
|
||||
public int EpisodeCount { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the game count.
|
||||
/// </summary>
|
||||
/// <value>The game count.</value>
|
||||
public int GameCount { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the trailer count.
|
||||
/// </summary>
|
||||
/// <value>The trailer count.</value>
|
||||
public int TrailerCount { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the song count.
|
||||
/// </summary>
|
||||
/// <value>The song count.</value>
|
||||
public int SongCount { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the album count.
|
||||
/// </summary>
|
||||
/// <value>The album count.</value>
|
||||
public int AlbumCount { get; set; }
|
||||
}
|
||||
}
|
|
@ -47,6 +47,7 @@
|
|||
<Compile Include="Dto\IItemDto.cs" />
|
||||
<Compile Include="Dto\ImageInfo.cs" />
|
||||
<Compile Include="Dto\ItemByNameCounts.cs" />
|
||||
<Compile Include="Dto\ItemCounts.cs" />
|
||||
<Compile Include="Dto\StudioDto.cs" />
|
||||
<Compile Include="Entities\IByReferenceItem.cs" />
|
||||
<Compile Include="Entities\ItemReview.cs" />
|
||||
|
|
|
@ -102,7 +102,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|||
self.encodeName = function (name) {
|
||||
|
||||
name = name.split('/').join('-');
|
||||
|
||||
|
||||
name = name.split('?').join('-');
|
||||
|
||||
var val = $.param({ name: name });
|
||||
|
@ -2279,6 +2279,23 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|||
});
|
||||
};
|
||||
|
||||
self.getItemCounts = function (userId) {
|
||||
|
||||
var options = {};
|
||||
|
||||
if (userId) {
|
||||
options.userId = userId;
|
||||
}
|
||||
|
||||
var url = self.getUrl("Items/Counts", options);
|
||||
|
||||
return self.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
dataType: "json"
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
Gets a variety of item counts that a person appears in
|
||||
*/
|
||||
|
|
|
@ -201,6 +201,18 @@
|
|||
<Content Include="dashboard-ui\css\images\userdata\played.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="dashboard-ui\css\images\views\games.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="dashboard-ui\css\images\views\movies.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="dashboard-ui\css\images\views\music.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="dashboard-ui\css\images\views\tvshows.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="dashboard-ui\css\librarybrowser.css">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.110" targetFramework="net45" />
|
||||
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.111" targetFramework="net45" />
|
||||
<package id="ServiceStack.Common" version="3.9.44" targetFramework="net45" />
|
||||
<package id="ServiceStack.Text" version="3.9.44" targetFramework="net45" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user