Add setting to auto-run web app when server starts

This commit is contained in:
Luke Pulverenti 2017-12-03 17:14:35 -05:00
parent 70b0dd968f
commit 8717f81bf4
6 changed files with 45 additions and 10 deletions

View File

@ -148,6 +148,34 @@ namespace Emby.Server.Implementations
}
}
public virtual bool CanLaunchWebBrowser
{
get
{
if (!Environment.UserInteractive)
{
return false;
}
if (StartupOptions.ContainsOption("-service"))
{
return false;
}
if (EnvironmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows)
{
return true;
}
if (EnvironmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.OSX)
{
return true;
}
return false;
}
}
/// <summary>
/// Occurs when [has pending restart changed].
/// </summary>
@ -1936,6 +1964,7 @@ namespace Emby.Server.Implementations
OperatingSystemDisplayName = OperatingSystemDisplayName,
CanSelfRestart = CanSelfRestart,
CanSelfUpdate = CanSelfUpdate,
CanLaunchWebBrowser = CanLaunchWebBrowser,
WanAddress = ConnectManager.WanApiAddress,
HasUpdateAvailable = HasUpdateAvailable,
SupportsAutoRunAtStartup = SupportsAutoRunAtStartup,
@ -2358,13 +2387,7 @@ namespace Emby.Server.Implementations
public virtual void LaunchUrl(string url)
{
if (EnvironmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows &&
EnvironmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.OSX)
{
throw new NotSupportedException();
}
if (!Environment.UserInteractive)
if (!CanLaunchWebBrowser)
{
throw new NotSupportedException();
}

View File

@ -35,15 +35,20 @@ namespace Emby.Server.Implementations.EntryPoints
/// </summary>
public void Run()
{
if (!_appHost.CanLaunchWebBrowser)
{
return;
}
if (_appHost.IsFirstRun)
{
BrowserLauncher.OpenDashboardPage("wizardstart.html", _appHost);
}
else if (_config.Configuration.IsStartupWizardCompleted)
else if (_config.Configuration.IsStartupWizardCompleted && _config.Configuration.AutoRunWebApp)
{
var options = ((ApplicationHost)_appHost).StartupOptions;
if (!options.ContainsOption("-service") && !options.ContainsOption("-nobrowser"))
if (!options.ContainsOption("-noautorunwebapp"))
{
BrowserLauncher.OpenDashboardPage("index.html", _appHost);
}

View File

@ -67,6 +67,7 @@ namespace MediaBrowser.Api
public void Post(ReportStartupWizardComplete request)
{
_config.Configuration.IsStartupWizardCompleted = true;
_config.Configuration.AutoRunWebApp = true;
_config.SetOptimalValues();
_config.SaveConfiguration();

View File

@ -30,6 +30,8 @@ namespace MediaBrowser.Controller
/// <value><c>true</c> if [supports automatic run at startup]; otherwise, <c>false</c>.</value>
bool SupportsAutoRunAtStartup { get; }
bool CanLaunchWebBrowser { get; }
/// <summary>
/// Gets the HTTP server port.
/// </summary>

View File

@ -61,6 +61,8 @@ namespace MediaBrowser.Model.Configuration
/// <value><c>true</c> if this instance is port authorized; otherwise, <c>false</c>.</value>
public bool IsPortAuthorized { get; set; }
public bool AutoRunWebApp { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [enable case sensitive item ids].
/// </summary>

View File

@ -68,6 +68,8 @@ namespace MediaBrowser.Model.System
/// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
public bool CanSelfUpdate { get; set; }
public bool CanLaunchWebBrowser { get; set; }
/// <summary>
/// Gets or sets plugin assemblies that failed to load.
/// </summary>