New: Set Instance Name
This commit is contained in:
parent
6c0f22a11e
commit
4a2f120bc1
|
@ -20,6 +20,7 @@ const requiresRestartKeys = [
|
||||||
'bindAddress',
|
'bindAddress',
|
||||||
'port',
|
'port',
|
||||||
'urlBase',
|
'urlBase',
|
||||||
|
'instanceName',
|
||||||
'enableSsl',
|
'enableSsl',
|
||||||
'sslPort',
|
'sslPort',
|
||||||
'sslCertHash',
|
'sslCertHash',
|
||||||
|
|
|
@ -19,6 +19,7 @@ function HostSettings(props) {
|
||||||
bindAddress,
|
bindAddress,
|
||||||
port,
|
port,
|
||||||
urlBase,
|
urlBase,
|
||||||
|
instanceName,
|
||||||
enableSsl,
|
enableSsl,
|
||||||
sslPort,
|
sslPort,
|
||||||
sslCertHash,
|
sslCertHash,
|
||||||
|
@ -71,6 +72,22 @@ function HostSettings(props) {
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</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
|
<FormGroup
|
||||||
advancedSettings={advancedSettings}
|
advancedSettings={advancedSettings}
|
||||||
isAdvanced={true}
|
isAdvanced={true}
|
||||||
|
|
|
@ -39,6 +39,7 @@ namespace NzbDrone.Core.Configuration
|
||||||
string SslCertHash { get; }
|
string SslCertHash { get; }
|
||||||
string UrlBase { get; }
|
string UrlBase { get; }
|
||||||
string UiFolder { get; }
|
string UiFolder { get; }
|
||||||
|
string InstanceName { get; }
|
||||||
bool UpdateAutomatically { get; }
|
bool UpdateAutomatically { get; }
|
||||||
UpdateMechanism UpdateMechanism { get; }
|
UpdateMechanism UpdateMechanism { get; }
|
||||||
string UpdateScriptPath { get; }
|
string UpdateScriptPath { get; }
|
||||||
|
@ -205,6 +206,19 @@ namespace NzbDrone.Core.Configuration
|
||||||
// public string UiFolder => GetValue("UiFolder", "UI", false);GetValue("UiFolder", "UI", false);
|
// public string UiFolder => GetValue("UiFolder", "UI", false);GetValue("UiFolder", "UI", false);
|
||||||
public string UiFolder => "UI";
|
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);
|
public bool UpdateAutomatically => GetValueBoolean("UpdateAutomatically", false, false);
|
||||||
|
|
||||||
|
@ -218,7 +232,6 @@ namespace NzbDrone.Core.Configuration
|
||||||
|
|
||||||
public string SyslogLevel => GetValue("SyslogLevel", LogLevel, persist: false).ToLowerInvariant();
|
public string SyslogLevel => GetValue("SyslogLevel", LogLevel, persist: false).ToLowerInvariant();
|
||||||
|
|
||||||
|
|
||||||
public int GetValueInt(string key, int defaultValue, bool persist = true)
|
public int GetValueInt(string key, int defaultValue, bool persist = true)
|
||||||
{
|
{
|
||||||
return Convert.ToInt32(GetValue(key, defaultValue));
|
return Convert.ToInt32(GetValue(key, defaultValue));
|
||||||
|
|
|
@ -62,5 +62,11 @@ namespace NzbDrone.Core.Validation
|
||||||
{
|
{
|
||||||
return ruleBuilder.WithState(v => NzbDroneValidationState.Warning);
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace Sonarr.Api.V3.Config
|
||||||
SharedValidator.RuleFor(c => c.Port).ValidPort();
|
SharedValidator.RuleFor(c => c.Port).ValidPort();
|
||||||
|
|
||||||
SharedValidator.RuleFor(c => c.UrlBase).ValidUrlBase();
|
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.Username).NotEmpty().When(c => c.AuthenticationMethod != AuthenticationType.None);
|
||||||
SharedValidator.RuleFor(c => c.Password).NotEmpty().When(c => c.AuthenticationMethod != AuthenticationType.None);
|
SharedValidator.RuleFor(c => c.Password).NotEmpty().When(c => c.AuthenticationMethod != AuthenticationType.None);
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace Sonarr.Api.V3.Config
|
||||||
public string ApiKey { get; set; }
|
public string ApiKey { get; set; }
|
||||||
public string SslCertHash { get; set; }
|
public string SslCertHash { get; set; }
|
||||||
public string UrlBase { get; set; }
|
public string UrlBase { get; set; }
|
||||||
|
public string InstanceName { get; set; }
|
||||||
public bool UpdateAutomatically { get; set; }
|
public bool UpdateAutomatically { get; set; }
|
||||||
public UpdateMechanism UpdateMechanism { get; set; }
|
public UpdateMechanism UpdateMechanism { get; set; }
|
||||||
public string UpdateScriptPath { get; set; }
|
public string UpdateScriptPath { get; set; }
|
||||||
|
@ -63,6 +64,7 @@ namespace Sonarr.Api.V3.Config
|
||||||
ApiKey = model.ApiKey,
|
ApiKey = model.ApiKey,
|
||||||
SslCertHash = model.SslCertHash,
|
SslCertHash = model.SslCertHash,
|
||||||
UrlBase = model.UrlBase,
|
UrlBase = model.UrlBase,
|
||||||
|
InstanceName = model.InstanceName,
|
||||||
UpdateAutomatically = model.UpdateAutomatically,
|
UpdateAutomatically = model.UpdateAutomatically,
|
||||||
UpdateMechanism = model.UpdateMechanism,
|
UpdateMechanism = model.UpdateMechanism,
|
||||||
UpdateScriptPath = model.UpdateScriptPath,
|
UpdateScriptPath = model.UpdateScriptPath,
|
||||||
|
|
Loading…
Reference in New Issue