The Free Software Media System - Server Backend & API
add library display settings
Luke Pulverenti020b1d9a6425
diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.csindex 989dea6c60..dbb6478a18 100644--- a/MediaBrowser.Api/StartupWizardService.cs+++ b/MediaBrowser.Api/StartupWizardService.cs@@ -113,6 +113,7 @@ namespace MediaBrowser.Apiconfig.EnableCustomPathSubFolders = true;config.EnableStandaloneMusicKeys = true;config.EnableCaseSensitiveItemIds = true;+ config.EnableFolderView = true;config.SchemaVersion = 89;}diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.csindex df0e42869b..e89aafacaa 100644--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs@@ -198,6 +198,7 @@ namespace MediaBrowser.Model.Configurationpublic bool EnableAnonymousUsageReporting { get; set; }public bool EnableStandaloneMusicKeys { get; set; }public bool EnableLocalizedGuids { get; set; }+ public bool EnableFolderView { get; set; }/// <summary>/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.csindex 6c88f506b1..e6a571f07d 100644--- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs+++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs@@ -105,6 +105,12 @@ namespace MediaBrowser.Server.Implementations.Library}}+ if (_config.Configuration.EnableFolderView)+ {+ var name = _localizationManager.GetLocalizedString("ViewType" + CollectionType.Folders);+ list.Add(await _libraryManager.GetNamedView(name, CollectionType.Folders, string.Empty, cancellationToken).ConfigureAwait(false));+ }+if (query.IncludeExternalContent){var channelResult = await _channelManager.GetChannelsInternal(new ChannelQuerydiff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.csindex 59a8a4f78a..75e3bb7f5c 100644--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs@@ -380,7 +380,8 @@ namespace MediaBrowser.Server.Startup.Common{new OmdbEpisodeProviderMigration(ServerConfigurationManager),new MovieDbEpisodeProviderMigration(ServerConfigurationManager),- new DbMigration(ServerConfigurationManager, TaskManager)+ new DbMigration(ServerConfigurationManager, TaskManager),+ new FolderViewSettingMigration(ServerConfigurationManager, UserManager)};foreach (var task in migrations)@@ -568,7 +569,7 @@ namespace MediaBrowser.Server.Startup.CommonSubtitleEncoder = new SubtitleEncoder(LibraryManager, LogManager.GetLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer, HttpClient, MediaSourceManager);RegisterSingleInstance(SubtitleEncoder);-+await displayPreferencesRepo.Initialize(NativeApp.GetDbConnector()).ConfigureAwait(false);await ConfigureUserDataRepositories().ConfigureAwait(false);await itemRepo.Initialize(NativeApp.GetDbConnector()).ConfigureAwait(false);diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csprojindex d0769f4888..a6d09d343a 100644--- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj+++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj@@ -71,6 +71,7 @@<Compile Include="FFMpeg\FFmpegValidator.cs" /><Compile Include="INativeApp.cs" /><Compile Include="MbLinkShortcutHandler.cs" />+ <Compile Include="Migrations\FolderViewSettingMigration.cs" /><Compile Include="Migrations\IVersionMigration.cs" /><Compile Include="Migrations\DbMigration.cs" /><Compile Include="Migrations\MovieDbEpisodeProviderMigration.cs" />diff --git a/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.csnew file mode 100644index 0000000000..4049d17548--- /dev/null+++ b/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs@@ -0,0 +1,37 @@+using System.Linq;+using MediaBrowser.Controller.Configuration;+using MediaBrowser.Controller.Library;++namespace MediaBrowser.Server.Startup.Common.Migrations+{+ public class FolderViewSettingMigration : IVersionMigration+ {+ private readonly IServerConfigurationManager _config;+ private readonly IUserManager _userManager;++ public FolderViewSettingMigration(IServerConfigurationManager config, IUserManager userManager)+ {+ _config = config;+ _userManager = userManager;+ }++ public void Run()+ {+ var migrationKey = this.GetType().Name;+ var migrationKeyList = _config.Configuration.Migrations.ToList();++ if (!migrationKeyList.Contains(migrationKey))+ {+ if (_config.Configuration.IsStartupWizardCompleted)+ {+ _config.Configuration.EnableFolderView = _userManager.Users.Any(i => i.Configuration.DisplayFoldersView);+ }++ migrationKeyList.Add(migrationKey);+ _config.Configuration.Migrations = migrationKeyList.ToArray();+ _config.SaveConfiguration();+ }++ }+ }+}diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csprojindex 1d860ed29f..36693ad8e7 100644--- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj+++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj@@ -272,6 +272,9 @@<Content Include="dashboard-ui\legacy\selectmenu.js"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>+ <Content Include="dashboard-ui\librarydisplay.html">+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>+ </Content><Content Include="dashboard-ui\livetvguideprovider.html"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>@@ -308,6 +311,9 @@<Content Include="dashboard-ui\scripts\homeupcoming.js"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>+ <Content Include="dashboard-ui\scripts\librarydisplay.js">+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>+ </Content><Content Include="dashboard-ui\scripts\livetvguideprovider.js"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>