1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-24 08:42:19 +02:00

New: Set Instance Name

This commit is contained in:
Robin Dadswell 2022-05-12 17:10:10 +01:00 committed by Mark McDowall
parent 6c0f22a11e
commit 4a2f120bc1
6 changed files with 41 additions and 1 deletions

View File

@ -20,6 +20,7 @@ const requiresRestartKeys = [
'bindAddress',
'port',
'urlBase',
'instanceName',
'enableSsl',
'sslPort',
'sslCertHash',

View File

@ -19,6 +19,7 @@ function HostSettings(props) {
bindAddress,
port,
urlBase,
instanceName,
enableSsl,
sslPort,
sslCertHash,
@ -71,6 +72,22 @@ function HostSettings(props) {
/>
</FormGroup>
<FormGroup
advancedSettings={advancedSettings}
isAdvanced={true}
>
<FormLabel>Instance Name</FormLabel>
<FormInputGroup
type={inputTypes.TEXT}
name="instanceName"
helpText="Instance name in tab and for Syslog app name"
helpTextWarning="Requires restart to take effect"
onChange={onInputChange}
{...instanceName}
/>
</FormGroup>
<FormGroup
advancedSettings={advancedSettings}
isAdvanced={true}

View File

@ -39,6 +39,7 @@ public interface IConfigFileProvider : IHandleAsync<ApplicationStartedEvent>,
string SslCertHash { get; }
string UrlBase { get; }
string UiFolder { get; }
string InstanceName { get; }
bool UpdateAutomatically { get; }
UpdateMechanism UpdateMechanism { get; }
string UpdateScriptPath { get; }
@ -205,6 +206,19 @@ public string UrlBase
// public string UiFolder => GetValue("UiFolder", "UI", false);GetValue("UiFolder", "UI", false);
public string UiFolder => "UI";
public string InstanceName
{
get
{
var instanceName = GetValue("InstanceName", BuildInfo.AppName);
if (instanceName.StartsWith(BuildInfo.AppName) || instanceName.EndsWith(BuildInfo.AppName) )
{
return instanceName;
}
return BuildInfo.AppName;
}
}
public bool UpdateAutomatically => GetValueBoolean("UpdateAutomatically", false, false);
@ -218,7 +232,6 @@ public string UrlBase
public string SyslogLevel => GetValue("SyslogLevel", LogLevel, persist: false).ToLowerInvariant();
public int GetValueInt(string key, int defaultValue, bool persist = true)
{
return Convert.ToInt32(GetValue(key, defaultValue));

View File

@ -62,5 +62,11 @@ public static IRuleBuilderOptions<T, TProp> AsWarning<T, TProp>(this IRuleBuilde
{
return ruleBuilder.WithState(v => NzbDroneValidationState.Warning);
}
public static IRuleBuilderOptions<T, string> StartsOrEndsWithSonarr<T>(this IRuleBuilder<T, string> ruleBuilder)
{
ruleBuilder.SetValidator(new NotEmptyValidator(null));
return ruleBuilder.SetValidator(new RegularExpressionValidator("^Sonarr|Sonarr$")).WithMessage("Must start or end with Sonarr");
}
}
}

View File

@ -38,6 +38,7 @@ public HostConfigModule(IConfigFileProvider configFileProvider, IConfigService c
SharedValidator.RuleFor(c => c.Port).ValidPort();
SharedValidator.RuleFor(c => c.UrlBase).ValidUrlBase();
SharedValidator.RuleFor(c => c.InstanceName).StartsOrEndsWithSonarr();
SharedValidator.RuleFor(c => c.Username).NotEmpty().When(c => c.AuthenticationMethod != AuthenticationType.None);
SharedValidator.RuleFor(c => c.Password).NotEmpty().When(c => c.AuthenticationMethod != AuthenticationType.None);

View File

@ -24,6 +24,7 @@ public class HostConfigResource : RestResource
public string ApiKey { get; set; }
public string SslCertHash { 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; }
@ -63,6 +64,7 @@ public static HostConfigResource ToResource(this IConfigFileProvider model, ICon
ApiKey = model.ApiKey,
SslCertHash = model.SslCertHash,
UrlBase = model.UrlBase,
InstanceName = model.InstanceName,
UpdateAutomatically = model.UpdateAutomatically,
UpdateMechanism = model.UpdateMechanism,
UpdateScriptPath = model.UpdateScriptPath,