The Free Software Media System - Server Backend & API
added a photo view
Luke Pulverenti37f22e67f97e
diff --git a/MediaBrowser.Api/UserLibrary/UserViewsService.cs b/MediaBrowser.Api/UserLibrary/UserViewsService.csindex 9b00b42f76..43d8dbc169 100644--- a/MediaBrowser.Api/UserLibrary/UserViewsService.cs+++ b/MediaBrowser.Api/UserLibrary/UserViewsService.cs@@ -88,7 +88,7 @@ namespace MediaBrowser.Api.UserLibraryvar views = user.RootFolder.GetChildren(user, true)- .OfType<CollectionFolder>()+ .OfType<ICollectionFolder>().Where(i => IsEligibleForSpecialView(i)).ToList();@@ -105,9 +105,9 @@ namespace MediaBrowser.Api.UserLibraryreturn ToOptimizedResult(list);}- private bool IsEligibleForSpecialView(CollectionFolder view)+ private bool IsEligibleForSpecialView(ICollectionFolder view){- var types = new[] { CollectionType.Movies, CollectionType.TvShows, CollectionType.Games, CollectionType.Music };+ var types = new[] { CollectionType.Movies, CollectionType.TvShows, CollectionType.Games, CollectionType.Music, CollectionType.Photos };return types.Contains(view.CollectionType ?? string.Empty, StringComparer.OrdinalIgnoreCase);}diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.csindex a6d123fe86..1672bda926 100644--- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs+++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs@@ -121,7 +121,6 @@ namespace MediaBrowser.Controller.Entities}case CollectionType.Books:- case CollectionType.Photos:case CollectionType.HomeVideos:case CollectionType.MusicVideos:return GetResult(queryParent.GetChildren(user, true), queryParent, query);@@ -138,6 +137,9 @@ namespace MediaBrowser.Controller.Entitiescase CollectionType.BoxSets:return await GetBoxsetView(queryParent, user, query).ConfigureAwait(false);+ case CollectionType.Photos:+ return await GetPhotosView(queryParent, user, query).ConfigureAwait(false);+case CollectionType.TvShows:return await GetTvView(queryParent, user, query).ConfigureAwait(false);@@ -247,16 +249,16 @@ namespace MediaBrowser.Controller.Entitiesreturn GetFavoriteSongs(queryParent, user, query);default:- {- if (queryParent is UserView)- {- return GetResult(GetMediaFolders(user).SelectMany(i => i.GetChildren(user, true)), queryParent, query);- }- else{- return GetResult(queryParent.GetChildren(user, true), queryParent, query);+ if (queryParent is UserView)+ {+ return GetResult(GetMediaFolders(user).SelectMany(i => i.GetChildren(user, true)), queryParent, query);+ }+ else+ {+ return GetResult(queryParent.GetChildren(user, true), queryParent, query);+ }}- }}}@@ -645,6 +647,19 @@ namespace MediaBrowser.Controller.Entities}), parent, query);}+ private async Task<QueryResult<BaseItem>> GetPhotosView(Folder queryParent, User user, InternalItemsQuery query)+ {+ if (query.Recursive)+ {+ var mediaTypes = new[] { MediaType.Video, MediaType.Photo };+ var items = GetRecursiveChildren(queryParent, user, new[] { CollectionType.Photos, string.Empty }, i => (i is PhotoAlbum || mediaTypes.Contains(i.MediaType ?? string.Empty, StringComparer.OrdinalIgnoreCase)) && FilterItem(i, query));++ return PostFilterAndSort(items, queryParent, null, query);+ }++ return GetResult(queryParent.GetChildren(user, true), queryParent, query);+ }+private async Task<QueryResult<BaseItem>> GetTvView(Folder parent, User user, InternalItemsQuery query){if (query.Recursive)diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.csindex 966e0a3e48..3fa0df7608 100644--- a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs+++ b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs@@ -1,5 +1,4 @@-using System.Linq;-using MediaBrowser.Controller;+using MediaBrowser.Controller;using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Plugins;using MediaBrowser.Model.Logging;@@ -139,55 +138,24 @@ namespace MediaBrowser.Server.Implementations.EntryPoints// On some systems the device discovered event seems to fire repeatedly// This check will help ensure we're not trying to port map the same device over and over- List<Mapping> currentMappings = null;-- try- {- currentMappings = device.GetAllMappings().ToList();- }- catch (NotSupportedException)- {- }-var address = device.LocalAddress.ToString();if (!_createdRules.Contains(address)){_createdRules.Add(address);- CreatePortMap(device, currentMappings, _appHost.HttpPort, _config.Configuration.PublicPort);- CreatePortMap(device, currentMappings, _appHost.HttpsPort, _config.Configuration.PublicHttpsPort);+ CreatePortMap(device, _appHost.HttpPort, _config.Configuration.PublicPort);+ CreatePortMap(device, _appHost.HttpsPort, _config.Configuration.PublicHttpsPort);}}- private void CreatePortMap(INatDevice device, List<Mapping> currentMappings, int privatePort, int publicPort)+ private void CreatePortMap(INatDevice device, int privatePort, int publicPort){- var hasMapping = false;-- if (currentMappings != null)- {- hasMapping = currentMappings.Any(i => i.PublicPort == publicPort && i.PrivatePort == privatePort);- }- else+ _logger.Debug("Creating port map on port {0}", privatePort);+ device.CreatePortMap(new Mapping(Protocol.Tcp, privatePort, publicPort){- try- {- var mapping = device.GetSpecificMapping(Protocol.Tcp, publicPort);- hasMapping = mapping != null;- }- catch (NotSupportedException)- {- }- }-- if (!hasMapping)- {- _logger.Debug("Creating port map on port {0}", privatePort);- device.CreatePortMap(new Mapping(Protocol.Tcp, privatePort, publicPort)- {- Description = _appHost.Name- });- }+ Description = _appHost.Name+ });}// As I said before, this method will be never invoked. You can remove it.diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.jsonindex 1affc43bf8..f464dad4ba 100644--- a/MediaBrowser.Server.Implementations/Localization/Server/server.json+++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json@@ -1433,5 +1433,7 @@"ToAccessPreferencesHelp": "To access your preferences later, click your user icon in the top right header and select My Preferences.","HeaderViewStyles": "View Styles","LabelSelectViewStyles": "Enable rich presentations for:",- "LabelSelectViewStylesHelp": "If enabled, views will be built with metadata to offer categories such as Suggestions, Latest, Genres, and more. If disabled, they'll be displayed with simple folders."+ "LabelSelectViewStylesHelp": "If enabled, views will be built with metadata to offer categories such as Suggestions, Latest, Genres, and more. If disabled, they'll be displayed with simple folders.",+ "TabPhotos": "Photos",+ "TabVideos": "Videos"}diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.csindex 90af13b579..030d687918 100644--- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs+++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs@@ -470,6 +470,7 @@ namespace MediaBrowser.WebDashboard.Api"notificationlist.js","notificationsetting.js","notificationsettings.js",+ "photos.js","playlists.js","playlistedit.js",diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csprojindex 7abe2ded98..5c4aab1e4f 100644--- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj+++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj@@ -132,6 +132,9 @@<Content Include="dashboard-ui\mysyncjob.html"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>+ <Content Include="dashboard-ui\photos.html">+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>+ </Content><Content Include="dashboard-ui\scripts\dashboardhosting.js"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>@@ -147,6 +150,9 @@<Content Include="dashboard-ui\scripts\livetvitems.js"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>+ <Content Include="dashboard-ui\scripts\photos.js">+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>+ </Content><Content Include="dashboard-ui\scripts\selectserver.js"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>