update timeline view

This commit is contained in:
Luke Pulverenti 2015-11-14 11:58:01 -05:00
parent c97a88377f
commit e32dcb38e4
8 changed files with 74 additions and 61 deletions

View File

@ -16,6 +16,11 @@ namespace MediaBrowser.Controller.Entities
IEnumerable<string> PhysicalLocations { get; } IEnumerable<string> PhysicalLocations { get; }
} }
public interface ISupportsUserSpecificView
{
bool EnableUserSpecificView { get; }
}
public static class CollectionFolderExtensions public static class CollectionFolderExtensions
{ {
public static string GetViewType(this ICollectionFolder folder, User user) public static string GetViewType(this ICollectionFolder folder, User user)

View File

@ -144,12 +144,22 @@ namespace MediaBrowser.Controller.Entities
return false; return false;
} }
var supportsUserSpecific = folder as ISupportsUserSpecificView;
if (supportsUserSpecific != null && supportsUserSpecific.EnableUserSpecificView)
{
return true;
}
return standaloneTypes.Contains(collectionFolder.CollectionType ?? string.Empty); return standaloneTypes.Contains(collectionFolder.CollectionType ?? string.Empty);
} }
public static bool IsEligibleForEnhancedView(string viewType) public static bool IsEligibleForEnhancedView(string viewType)
{ {
var types = new[] { CollectionType.Movies, CollectionType.TvShows }; var types = new[]
{
CollectionType.Movies,
CollectionType.TvShows
};
return types.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase); return types.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
} }

View File

@ -78,24 +78,9 @@ namespace MediaBrowser.Server.Implementations.Collections
return Task.FromResult(GetFinalItems(items, 2)); return Task.FromResult(GetFinalItems(items, 2));
} }
protected override async Task<string> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) protected override Task<string> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
{ {
var image = itemsWithImages return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
.Where(i => i.HasImage(ImageType.Primary) && i.GetImageInfo(ImageType.Primary, 0).IsLocalFile && Path.HasExtension(i.GetImagePath(ImageType.Primary)))
.Select(i => i.GetImagePath(ImageType.Primary))
.FirstOrDefault();
if (string.IsNullOrWhiteSpace(image))
{
return null;
}
var ext = Path.GetExtension(image);
var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ext);
File.Copy(image, outputPath);
return outputPath;
} }
} }
} }

View File

@ -3,15 +3,15 @@ using MediaBrowser.Controller.Entities;
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.Serialization;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using CommonIO; using CommonIO;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
namespace MediaBrowser.Server.Implementations.Devices namespace MediaBrowser.Server.Implementations.Devices
{ {
public class CameraUploadsFolder : BasePluginFolder public class CameraUploadsFolder : BasePluginFolder, ISupportsUserSpecificView
{ {
public CameraUploadsFolder() public CameraUploadsFolder()
{ {
@ -54,6 +54,12 @@ namespace MediaBrowser.Server.Implementations.Devices
_hasChildren = null; _hasChildren = null;
return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService); return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService);
} }
[IgnoreDataMember]
public bool EnableUserSpecificView
{
get { return true; }
}
} }
public class CameraUploadsDynamicFolder : IVirtualFolderCreator public class CameraUploadsDynamicFolder : IVirtualFolderCreator

View File

@ -73,21 +73,27 @@ namespace MediaBrowser.Server.Implementations.Library
var enableUserViews = _config.Configuration.EnableUserViews || user.EnableUserViews; var enableUserViews = _config.Configuration.EnableUserViews || user.EnableUserViews;
if (enableUserViews) foreach (var folder in standaloneFolders)
{ {
foreach (var folder in standaloneFolders) var collectionFolder = folder as ICollectionFolder;
{ var folderViewType = collectionFolder == null ? null : collectionFolder.CollectionType;
var collectionFolder = folder as ICollectionFolder;
var folderViewType = collectionFolder == null ? null : collectionFolder.CollectionType;
if (UserView.IsUserSpecific(folder)) if (UserView.IsUserSpecific(folder))
{ {
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, true, string.Empty, user, cancellationToken).ConfigureAwait(false)); list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, true, string.Empty, user, cancellationToken).ConfigureAwait(false));
} continue;
else if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType)) }
if (enableUserViews)
{
if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType))
{ {
list.Add(await GetUserView(folder, folderViewType, false, string.Empty, cancellationToken).ConfigureAwait(false)); list.Add(await GetUserView(folder, folderViewType, false, string.Empty, cancellationToken).ConfigureAwait(false));
} }
else if (_config.Configuration.EnableSharedCollectionViewImage)
{
list.Add(folder);
}
else if (!string.IsNullOrWhiteSpace(folderViewType)) else if (!string.IsNullOrWhiteSpace(folderViewType))
{ {
list.Add(await GetUserView(folder, folderViewType, true, string.Empty, cancellationToken).ConfigureAwait(false)); list.Add(await GetUserView(folder, folderViewType, true, string.Empty, cancellationToken).ConfigureAwait(false));
@ -97,20 +103,10 @@ namespace MediaBrowser.Server.Implementations.Library
list.Add(folder); list.Add(folder);
} }
} }
} else
else
{
// TODO: Deprecate this whole block
foreach (var folder in standaloneFolders)
{ {
var collectionFolder = folder as ICollectionFolder; // TODO: Deprecate this whole block
var folderViewType = collectionFolder == null ? null : collectionFolder.CollectionType; if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType))
if (UserView.IsUserSpecific(folder))
{
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, true, string.Empty, user, cancellationToken).ConfigureAwait(false));
}
else if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType))
{ {
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, false, string.Empty, user, cancellationToken).ConfigureAwait(false)); list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, false, string.Empty, user, cancellationToken).ConfigureAwait(false));
} }
@ -203,10 +199,15 @@ namespace MediaBrowser.Server.Implementations.Library
return GetUserSubView(name, parentId, type, sortName, cancellationToken); return GetUserSubView(name, parentId, type, sortName, cancellationToken);
} }
private async Task<UserView> GetUserView(List<ICollectionFolder> parents, string viewType, string sortName, User user, bool enableUserViews, CancellationToken cancellationToken) private async Task<Folder> GetUserView(List<ICollectionFolder> parents, string viewType, string sortName, User user, bool enableUserViews, CancellationToken cancellationToken)
{ {
if (parents.Count == 1 && parents.All(i => string.Equals((enableUserViews ? i.GetViewType(user) : i.CollectionType), viewType, StringComparison.OrdinalIgnoreCase))) if (parents.Count == 1 && parents.All(i => string.Equals((enableUserViews ? i.GetViewType(user) : i.CollectionType), viewType, StringComparison.OrdinalIgnoreCase)))
{ {
if (enableUserViews || _config.Configuration.EnableSharedCollectionViewImage)
{
return (Folder)parents[0];
}
var parentId = parents[0].Id; var parentId = parents[0].Id;
var enableRichView = !user.Configuration.PlainFolderViews.Contains(parentId.ToString("N"), StringComparer.OrdinalIgnoreCase); var enableRichView = !user.Configuration.PlainFolderViews.Contains(parentId.ToString("N"), StringComparer.OrdinalIgnoreCase);

View File

@ -70,6 +70,7 @@
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Net" /> <Reference Include="System.Net" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" /> <Reference Include="System.Security" />
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />

View File

@ -285,5 +285,25 @@ namespace MediaBrowser.Server.Implementations.Photos
return 0; return 0;
} }
} }
protected async Task<string> CreateSingleImage(List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType)
{
var image = itemsWithImages
.Where(i => i.HasImage(imageType) && i.GetImageInfo(imageType, 0).IsLocalFile && Path.HasExtension(i.GetImagePath(imageType)))
.Select(i => i.GetImagePath(imageType))
.FirstOrDefault();
if (string.IsNullOrWhiteSpace(image))
{
return null;
}
var ext = Path.GetExtension(image);
var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ext);
File.Copy(image, outputPath);
return outputPath;
}
} }
} }

View File

@ -26,24 +26,9 @@ namespace MediaBrowser.Server.Implementations.Photos
return Task.FromResult(items); return Task.FromResult(items);
} }
protected override async Task<string> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) protected override Task<string> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
{ {
var image = itemsWithImages return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
.Where(i => i.HasImage(ImageType.Primary) && i.GetImageInfo(ImageType.Primary, 0).IsLocalFile && Path.HasExtension(i.GetImagePath(ImageType.Primary)))
.Select(i => i.GetImagePath(ImageType.Primary))
.FirstOrDefault();
if (string.IsNullOrWhiteSpace(image))
{
return null;
}
var ext = Path.GetExtension(image);
var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ext);
File.Copy(image, outputPath);
return outputPath;
} }
} }
} }