From 1553a8f37bfe77c7d09a4f8444a3cf21a8d5dbc0 Mon Sep 17 00:00:00 2001 From: Robin Dadswell <19610103+RobinDadswell@users.noreply.github.com> Date: Thu, 12 May 2022 17:10:10 +0100 Subject: [PATCH] New: Set Instance Name --- frontend/src/Settings/General/HostSettings.js | 17 +++++++++++++++++ .../Config/HostConfigController.cs | 1 + src/Lidarr.Api.V1/Config/HostConfigResource.cs | 2 ++ .../Configuration/ConfigFileProvider.cs | 3 +++ src/NzbDrone.Core/Localization/Core/en.json | 2 ++ .../Validation/RuleBuilderExtensions.cs | 6 ++++++ 6 files changed, 31 insertions(+) diff --git a/frontend/src/Settings/General/HostSettings.js b/frontend/src/Settings/General/HostSettings.js index 02ea603ff..acb70eaa1 100644 --- a/frontend/src/Settings/General/HostSettings.js +++ b/frontend/src/Settings/General/HostSettings.js @@ -20,6 +20,7 @@ function HostSettings(props) { bindAddress, port, urlBase, + instanceName, enableSsl, sslPort, sslCertPath, @@ -79,6 +80,22 @@ function HostSettings(props) { /> + + {translate('InstanceName')} + + + + c.Port).ValidPort(); SharedValidator.RuleFor(c => c.UrlBase).ValidUrlBase(); + SharedValidator.RuleFor(c => c.InstanceName).ContainsLidarr().When(c => c.InstanceName.IsNotNullOrWhiteSpace()); SharedValidator.RuleFor(c => c.Username).NotEmpty().When(c => c.AuthenticationMethod != AuthenticationType.None); SharedValidator.RuleFor(c => c.Password).NotEmpty().When(c => c.AuthenticationMethod != AuthenticationType.None); diff --git a/src/Lidarr.Api.V1/Config/HostConfigResource.cs b/src/Lidarr.Api.V1/Config/HostConfigResource.cs index b6f022976..ea40de553 100644 --- a/src/Lidarr.Api.V1/Config/HostConfigResource.cs +++ b/src/Lidarr.Api.V1/Config/HostConfigResource.cs @@ -25,6 +25,7 @@ namespace Lidarr.Api.V1.Config public string SslCertPath { get; set; } public string SslCertPassword { get; set; } public string UrlBase { get; set; } + public string InstanceName { get; set; } public bool UpdateAutomatically { get; set; } public UpdateMechanism UpdateMechanism { get; set; } public string UpdateScriptPath { get; set; } @@ -66,6 +67,7 @@ namespace Lidarr.Api.V1.Config SslCertPath = model.SslCertPath, SslCertPassword = model.SslCertPassword, UrlBase = model.UrlBase, + InstanceName = model.InstanceName, UpdateAutomatically = model.UpdateAutomatically, UpdateMechanism = model.UpdateMechanism, UpdateScriptPath = model.UpdateScriptPath, diff --git a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs index 861cd6949..477f35641 100644 --- a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -41,6 +41,7 @@ namespace NzbDrone.Core.Configuration string SslCertPassword { get; } string UrlBase { get; } string UiFolder { get; } + string InstanceName { get; } bool UpdateAutomatically { get; } UpdateMechanism UpdateMechanism { get; } string UpdateScriptPath { get; } @@ -203,6 +204,7 @@ namespace NzbDrone.Core.Configuration } public string UiFolder => BuildInfo.IsDebug ? Path.Combine("..", "UI") : "UI"; + public string InstanceName => GetValue("InstanceName", BuildInfo.AppName); public bool UpdateAutomatically => GetValueBoolean("UpdateAutomatically", false, false); @@ -211,6 +213,7 @@ namespace NzbDrone.Core.Configuration public string UpdateScriptPath => GetValue("UpdateScriptPath", "", false); public string SyslogServer => GetValue("SyslogServer", "", persist: false); + public int SyslogPort => GetValueInt("SyslogPort", 514, persist: false); public int GetValueInt(string key, int defaultValue, bool persist = true) diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index 8dc396cab..c7f927830 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -276,6 +276,8 @@ "IndexerPriority": "Indexer Priority", "Indexers": "Indexers", "IndexerSettings": "Indexer Settings", + "InstanceName": "Instance Name", + "InstanceNameHelpText": "Instance name in tab and for Syslog app name", "InteractiveSearch": "Interactive Search", "Interval": "Interval", "IsCutoffCutoff": "Cutoff", diff --git a/src/NzbDrone.Core/Validation/RuleBuilderExtensions.cs b/src/NzbDrone.Core/Validation/RuleBuilderExtensions.cs index 900ddf152..012c74a53 100644 --- a/src/NzbDrone.Core/Validation/RuleBuilderExtensions.cs +++ b/src/NzbDrone.Core/Validation/RuleBuilderExtensions.cs @@ -61,5 +61,11 @@ namespace NzbDrone.Core.Validation { return ruleBuilder.WithState(v => NzbDroneValidationState.Warning); } + + public static IRuleBuilderOptions ContainsLidarr(this IRuleBuilder ruleBuilder) + { + ruleBuilder.SetValidator(new NotEmptyValidator(null)); + return ruleBuilder.SetValidator(new RegularExpressionValidator("lidarr", RegexOptions.IgnoreCase)).WithMessage("Must contain lidarr"); + } } }