From 21538b972d63ed0514f0b7b2babc58c0a260e551 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 +++++++++++++++++ .../Configuration/ConfigFileProvider.cs | 6 ++++++ src/NzbDrone.Core/Localization/Core/en.json | 6 ++++-- .../Validation/RuleBuilderExtensions.cs | 6 ++++++ .../Config/HostConfigController.cs | 1 + src/Readarr.Api.V1/Config/HostConfigResource.cs | 2 ++ 6 files changed, 36 insertions(+), 2 deletions(-) diff --git a/frontend/src/Settings/General/HostSettings.js b/frontend/src/Settings/General/HostSettings.js index 525bb0a59..8f617cea0 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, @@ -78,6 +79,22 @@ function HostSettings(props) { /> + + {translate('InstanceName')} + + + + BuildInfo.IsDebug ? Path.Combine("..", "UI") : "UI"; + public string InstanceName => GetValue("InstanceName", BuildInfo.AppName); public bool UpdateAutomatically => GetValueBoolean("UpdateAutomatically", false, false); @@ -212,8 +215,11 @@ 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 string SyslogLevel => GetValue("SyslogLevel", LogLevel).ToLowerInvariant(); + public int GetValueInt(string key, int defaultValue, bool persist = true) { return Convert.ToInt32(GetValue(key, defaultValue, persist)); diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index 57368b019..01f4f743d 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -336,6 +336,8 @@ "IndexersSettingsSummary": "Indexers and release restrictions", "IndexerStatusCheckAllClientMessage": "All indexers are unavailable due to failures", "IndexerStatusCheckSingleClientMessage": "Indexers unavailable due to failures: {0}", + "InstanceName": "Instance Name", + "InstanceNameHelpText": "Instance name in tab and for Syslog app name", "Interval": "Interval", "ISBN": "ISBN", "IsCalibreLibraryHelpText": "Use Calibre Content Server to manipulate library", @@ -805,6 +807,7 @@ "UnselectAll": "Unselect All", "UpdateAll": "Update all", "UpdateAutomaticallyHelpText": "Automatically download and install updates. You will still be able to install from System: Updates", + "UpdateAvailable": "New update is available", "UpdateCheckStartupNotWritableMessage": "Cannot install update because startup folder '{0}' is not writable by the user '{1}'.", "UpdateCheckStartupTranslocationMessage": "Cannot install update because startup folder '{0}' is in an App Translocation folder.", "UpdateCheckUINotWritableMessage": "Cannot install update because UI folder '{0}' is not writable by the user '{1}'.", @@ -848,6 +851,5 @@ "WriteTagsSync": "All files; keep in sync with Goodreads", "Year": "Year", "YesCancel": "Yes, Cancel", - "Yesterday": "Yesterday", - "UpdateAvailable": "New update is available" + "Yesterday": "Yesterday" } diff --git a/src/NzbDrone.Core/Validation/RuleBuilderExtensions.cs b/src/NzbDrone.Core/Validation/RuleBuilderExtensions.cs index ab9726034..b5e6f3be9 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 ContainsReadarr(this IRuleBuilder ruleBuilder) + { + ruleBuilder.SetValidator(new NotEmptyValidator(null)); + return ruleBuilder.SetValidator(new RegularExpressionValidator("readarr", RegexOptions.IgnoreCase)).WithMessage("Must contain readarr"); + } } } diff --git a/src/Readarr.Api.V1/Config/HostConfigController.cs b/src/Readarr.Api.V1/Config/HostConfigController.cs index 6f7df1600..aec1eb717 100644 --- a/src/Readarr.Api.V1/Config/HostConfigController.cs +++ b/src/Readarr.Api.V1/Config/HostConfigController.cs @@ -40,6 +40,7 @@ namespace Readarr.Api.V1.Config SharedValidator.RuleFor(c => c.Port).ValidPort(); SharedValidator.RuleFor(c => c.UrlBase).ValidUrlBase(); + SharedValidator.RuleFor(c => c.InstanceName).ContainsReadarr().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/Readarr.Api.V1/Config/HostConfigResource.cs b/src/Readarr.Api.V1/Config/HostConfigResource.cs index d4a504e1b..ac6099a33 100644 --- a/src/Readarr.Api.V1/Config/HostConfigResource.cs +++ b/src/Readarr.Api.V1/Config/HostConfigResource.cs @@ -25,6 +25,7 @@ namespace Readarr.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 Readarr.Api.V1.Config SslCertPath = model.SslCertPath, SslCertPassword = model.SslCertPassword, UrlBase = model.UrlBase, + InstanceName = model.InstanceName, UpdateAutomatically = model.UpdateAutomatically, UpdateMechanism = model.UpdateMechanism, UpdateScriptPath = model.UpdateScriptPath,