diff --git a/NzbDrone.Web/Content/Settings.css b/NzbDrone.Web/Content/Settings.css index 7498a7ee6..fc6b64591 100644 --- a/NzbDrone.Web/Content/Settings.css +++ b/NzbDrone.Web/Content/Settings.css @@ -111,3 +111,17 @@ color: #FFFFFF; font-weight: normal; } + +/* Common Validation Settings */ +.field-validation-error { + color: red; +} + +.input-validation-error { + background-color: #FFEEEE; + border: 1px solid #FF0000; +} + +.settingsForm .validation-error { + background: url("../Content/jQueryUI/images/ui-bg_flat_30_b40404_40x100.png") repeat-x scroll 50% 50% #B40404; + } \ No newline at end of file diff --git a/NzbDrone.Web/Models/DownloadClientSettingsModel.cs b/NzbDrone.Web/Models/DownloadClientSettingsModel.cs index 29d35288f..66e2e5a8f 100644 --- a/NzbDrone.Web/Models/DownloadClientSettingsModel.cs +++ b/NzbDrone.Web/Models/DownloadClientSettingsModel.cs @@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations; using System.Web.Mvc; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Sabnzbd; +using NzbDrone.Web.Helpers.Validation; namespace NzbDrone.Web.Models { @@ -12,16 +13,16 @@ namespace NzbDrone.Web.Models public SelectList PrioritySelectList = new SelectList(new[] {"Default", "Paused", "Low", "Normal", "High", "Force"}); - [Required(ErrorMessage = "Please enter a valid host")] [DataType(DataType.Text)] [DisplayName("SABnzbd Host")] [Description("Hostname or IP Address running SABnzbd")] + [RequiredIf("DownloadClient", (int)DownloadClientType.Sabnzbd, ErrorMessage = "Required when Download Client is SABnzbd")] public String SabHost { get; set; } - [Required(ErrorMessage = "Please enter a valid port")] [DataType(DataType.Text)] [DisplayName("SABnzbd Port")] [Description("Port for SABnzbd web interface")] + [RequiredIf("DownloadClient", (int)DownloadClientType.Sabnzbd, ErrorMessage = "Required when Download Client is SABnzbd")] public int SabPort { get; set; } [DataType(DataType.Text)] @@ -53,14 +54,16 @@ namespace NzbDrone.Web.Models [Description("Priority to use when sending NZBs to SABnzbd")] public SabPriorityType SabTvPriority { get; set; } + [Required(ErrorMessage = "Required so NzbDrone can sort downloads")] [DisplayName("Download Client TV Directory")] - [Description("The directory where your download client downloads TV shows to (NzbDrone will sort them for you)")] + [Description("The directory where your download client downloads TV shows to")] [DisplayFormat(ConvertEmptyStringToNull = false)] public string DownloadClientDropDirectory { get; set; } [DisplayName("Blackhole Directory")] [Description("The directory where your download client will pickup NZB files")] [DisplayFormat(ConvertEmptyStringToNull = false)] + [RequiredIf("DownloadClient", (int)DownloadClientType.Blackhole, ErrorMessage = "Required when Download Client is Blackhole")] public string BlackholeDirectory { get; set; } [DisplayName("Download Client")] diff --git a/NzbDrone.Web/Models/IndexerSettingsModel.cs b/NzbDrone.Web/Models/IndexerSettingsModel.cs index 8198b4a6b..876cfc438 100644 --- a/NzbDrone.Web/Models/IndexerSettingsModel.cs +++ b/NzbDrone.Web/Models/IndexerSettingsModel.cs @@ -13,7 +13,7 @@ namespace NzbDrone.Web.Models [DisplayName("Username")] [Description("Username for NZB Matrix")] [DisplayFormat(ConvertEmptyStringToNull = false)] - [RequiredIf("NzbMatrixEnabled", true, ErrorMessage = "USername Required when NZBMatrix is enabled")] + [RequiredIf("NzbMatrixEnabled", true, ErrorMessage = "Username Required when NZBMatrix is enabled")] public String NzbMatrixUsername { get; set; } [DataType(DataType.Text)] diff --git a/NzbDrone.Web/Models/NotificationSettingsModel.cs b/NzbDrone.Web/Models/NotificationSettingsModel.cs index d274cda8f..d9596e2b3 100644 --- a/NzbDrone.Web/Models/NotificationSettingsModel.cs +++ b/NzbDrone.Web/Models/NotificationSettingsModel.cs @@ -1,6 +1,8 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Web.Mvc; +using NzbDrone.Core.Model; +using NzbDrone.Web.Helpers.Validation; namespace NzbDrone.Web.Models { @@ -31,6 +33,7 @@ namespace NzbDrone.Web.Models [DisplayName("Hosts")] [Description("XBMC hosts with port, comma separated")] [DisplayFormat(ConvertEmptyStringToNull = false)] + [RequiredIf("XbmcEnabled", true, ErrorMessage = "Required when XBMC Notifications are enabled")] public string XbmcHosts { get; set; } [DataType(DataType.Text)] @@ -62,12 +65,14 @@ namespace NzbDrone.Web.Models [DisplayName("Server")] [Description("SMTP Server Hostname")] [DisplayFormat(ConvertEmptyStringToNull = false)] + [RequiredIf("SmtpEnabled", true, ErrorMessage = "Required when SMTP Notifications are enabled")] public string SmtpServer{ get; set; } [DataType(DataType.Text)] [DisplayName("Port")] [Description("SMTP Server Port")] [DisplayFormat(ConvertEmptyStringToNull = false)] + [RequiredIf("SmtpEnabled", true, ErrorMessage = "Required when SMTP Notifications are enabled")] public int SmtpPort { get; set; } [DisplayName("SSL")] @@ -91,12 +96,14 @@ namespace NzbDrone.Web.Models [DisplayName("Send From Address")] [Description("Sender Email address")] [DisplayFormat(ConvertEmptyStringToNull = false)] + [RequiredIf("SmtpEnabled", true, ErrorMessage = "Required when SMTP Notifications are enabled")] public string SmtpFromAddress { get; set; } [DataType(DataType.Text)] [DisplayName("Send To Addresses")] [Description("Comma separated list of addresses to email")] [DisplayFormat(ConvertEmptyStringToNull = false)] + [RequiredIf("SmtpEnabled", true, ErrorMessage = "Required when SMTP Notifications are enabled")] public string SmtpToAddresses { get; set; } //Twitter @@ -129,6 +136,7 @@ namespace NzbDrone.Web.Models [DisplayName("Host running Growl")] [Description("Host or IP Address:Port")] [DisplayFormat(ConvertEmptyStringToNull = false)] + [RequiredIf("GrowlEnabled", true, ErrorMessage = "Required when Growl Notifications are enabled")] public string GrowlHost { get; set; } [DataType(DataType.Text)] @@ -155,6 +163,7 @@ namespace NzbDrone.Web.Models [DisplayName("API Keys")] [Description("Comma-Separated list of API Keys")] [DisplayFormat(ConvertEmptyStringToNull = false)] + [RequiredIf("ProwlEnabled", true, ErrorMessage = "Required when Prowl Notifications are enabled")] public string ProwlApiKeys { get; set; } [DataType(DataType.Text)] @@ -186,11 +195,13 @@ namespace NzbDrone.Web.Models [DisplayName("Server Host")] [Description("Plex Server host with port")] [DisplayFormat(ConvertEmptyStringToNull = false)] + [RequiredIf("PlexUpdateLibrary", true, ErrorMessage = "Required when Plex Library Update is Enabled")] public string PlexServerHost { get; set; } [DataType(DataType.Text)] [DisplayName("Client Hosts")] [Description("Plex client hosts with port, comma separated for multiple clients")] + [RequiredIf("PlexNotifyOnGrab", true, ErrorMessage = "Required when Plex Notifications are enabled")] [DisplayFormat(ConvertEmptyStringToNull = false)] public string PlexClientHosts { get; set; } diff --git a/NzbDrone.Web/Models/SystemSettingsModel.cs b/NzbDrone.Web/Models/SystemSettingsModel.cs index c13e25538..d8a2c1a2a 100644 --- a/NzbDrone.Web/Models/SystemSettingsModel.cs +++ b/NzbDrone.Web/Models/SystemSettingsModel.cs @@ -11,6 +11,7 @@ namespace NzbDrone.Web.Models [DisplayName("Port")] [Description("Port that NzbDrone runs on")] [Range(1, 65535, ErrorMessage = "Port must be between 1 and 65535")] + [Required(ErrorMessage = "Port must be between 1 and 65535")] public int Port { get; set; } [DisplayName("Launch Browser")] diff --git a/NzbDrone.Web/Views/Settings/Blackhole.cshtml b/NzbDrone.Web/Views/Settings/Blackhole.cshtml index b0ec2a606..335b10065 100644 --- a/NzbDrone.Web/Views/Settings/Blackhole.cshtml +++ b/NzbDrone.Web/Views/Settings/Blackhole.cshtml @@ -8,6 +8,7 @@