From 1b5999a1bc11ee386131e4bbce561896c0e1bced Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Tue, 25 Feb 2020 17:01:57 +0100 Subject: [PATCH] Open the Swagger API page on server start if not hosting the static web content --- Emby.Server.Implementations/ApplicationHost.cs | 3 +++ Emby.Server.Implementations/Browser/BrowserLauncher.cs | 10 ++++++++++ .../EntryPoints/StartupWizard.cs | 6 +++++- MediaBrowser.Controller/IServerApplicationHost.cs | 5 +++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index a5b88f64f2..789b8724c3 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -244,6 +244,9 @@ namespace Emby.Server.Implementations /// public string ContentRoot { get; private set; } + /// + public bool IsHostingContent => ContentRoot != null; + /// /// Gets the server configuration manager. /// diff --git a/Emby.Server.Implementations/Browser/BrowserLauncher.cs b/Emby.Server.Implementations/Browser/BrowserLauncher.cs index f5da0d0183..b17c2b2700 100644 --- a/Emby.Server.Implementations/Browser/BrowserLauncher.cs +++ b/Emby.Server.Implementations/Browser/BrowserLauncher.cs @@ -29,6 +29,16 @@ namespace Emby.Server.Implementations.Browser OpenDashboardPage("index.html", appHost); } + /// + /// Opens the swagger API page. + /// + /// The app host. + public static void OpenSwaggerPage(IServerApplicationHost appHost) + { + var url = appHost.GetLocalApiUrl("localhost") + "/swagger/index.html"; + OpenUrl(appHost, url); + } + /// /// Opens the URL. /// diff --git a/Emby.Server.Implementations/EntryPoints/StartupWizard.cs b/Emby.Server.Implementations/EntryPoints/StartupWizard.cs index 5f2d629fea..6b7e2805bd 100644 --- a/Emby.Server.Implementations/EntryPoints/StartupWizard.cs +++ b/Emby.Server.Implementations/EntryPoints/StartupWizard.cs @@ -36,7 +36,11 @@ namespace Emby.Server.Implementations.EntryPoints return Task.CompletedTask; } - if (!_config.Configuration.IsStartupWizardCompleted) + if (!_appHost.IsHostingContent) + { + BrowserLauncher.OpenSwaggerPage(_appHost); + } + else if (!_config.Configuration.IsStartupWizardCompleted) { BrowserLauncher.OpenWebApp(_appHost); } diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index 25f0905eb8..134ed110ba 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -16,6 +16,11 @@ namespace MediaBrowser.Controller { event EventHandler HasUpdateAvailableChanged; + /// + /// Gets a value indicating whether the server is hosting the static web content from jellyfin-web. + /// + bool IsHostingContent { get; } + /// /// Gets the system info. ///