From 8e214029c9654793c126fa0ca7f59ded0d6d8dad Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 17 May 2011 20:39:26 -0700 Subject: [PATCH] Renamed Download settings to Sabnzbd settings. Moved Download Propers to Quality settings. Cleaned up Quality UI and enhanced it with some jQuery goodness. Mmmmm jQuery. --- .../Providers/Core/ConfigProvider.cs | 2 +- .../Controllers/SettingsController.cs | 26 +- NzbDrone.Web/Models/QualityModel.cs | 5 + ...ttingsModel.cs => SabnzbdSettingsModel.cs} | 29 +-- NzbDrone.Web/NzbDrone.Web.csproj | 4 +- NzbDrone.Web/Views/Settings/Downloads.cshtml | 241 ------------------ NzbDrone.Web/Views/Settings/Quality.cshtml | 47 +++- NzbDrone.Web/Views/Settings/Sabnzbd.cshtml | 137 ++++++++++ NzbDrone.Web/Views/Settings/SubMenu.cshtml | 2 +- .../Views/Settings/UserProfileSection.cshtml | 16 +- 10 files changed, 208 insertions(+), 301 deletions(-) rename NzbDrone.Web/Models/{DownloadSettingsModel.cs => SabnzbdSettingsModel.cs} (63%) delete mode 100644 NzbDrone.Web/Views/Settings/Downloads.cshtml create mode 100644 NzbDrone.Web/Views/Settings/Sabnzbd.cshtml diff --git a/NzbDrone.Core/Providers/Core/ConfigProvider.cs b/NzbDrone.Core/Providers/Core/ConfigProvider.cs index 409ad1048..46811aa5c 100644 --- a/NzbDrone.Core/Providers/Core/ConfigProvider.cs +++ b/NzbDrone.Core/Providers/Core/ConfigProvider.cs @@ -162,7 +162,7 @@ namespace NzbDrone.Core.Providers.Core public virtual String SabTvCategory { - get { return GetValue("SabTvCategory"); } + get { return GetValue("SabTvCategory", "TV", false); } set { SetValue("SabTvCategory", value); } } diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 9726b1a89..db8b0c3f6 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -100,15 +100,12 @@ namespace NzbDrone.Web.Controllers }); } - public ActionResult Downloads() + public ActionResult Sabnzbd() { - ViewData["viewName"] = "Downloads"; + ViewData["viewName"] = "Sabnzbd"; - var model = new DownloadSettingsModel + var model = new SabnzbdSettingsModel { - SyncFrequency = _configProvider.SyncFrequency, - DownloadPropers = _configProvider.DownloadPropers, - Retention = _configProvider.Retention, SabHost = _configProvider.SabHost, SabPort =_configProvider.SabPort, SabApiKey = _configProvider.SabApiKey, @@ -116,8 +113,6 @@ namespace NzbDrone.Web.Controllers SabPassword = _configProvider.SabPassword, SabTvCategory = _configProvider.SabTvCategory, SabTvPriority = _configProvider.SabTvPriority, - UseBlackHole = _configProvider.UseBlackhole, - BlackholeDirectory = _configProvider.BlackholeDirectory }; return View("Index", model); @@ -139,8 +134,8 @@ namespace NzbDrone.Web.Controllers var userProfiles = _qualityProvider.GetAllProfiles().Where(q => q.UserProfile).ToList(); var profiles = _qualityProvider.GetAllProfiles().ToList(); - var defaultQualityQualityProfileId = - Convert.ToInt32(_configProvider.DefaultQualityProfile); + var defaultQualityQualityProfileId = Convert.ToInt32(_configProvider.DefaultQualityProfile); + var downloadPropers = _configProvider.DownloadPropers; var selectList = new SelectList(profiles, "QualityProfileId", "Name"); @@ -149,6 +144,7 @@ namespace NzbDrone.Web.Controllers Profiles = profiles, UserProfiles = userProfiles, DefaultQualityProfileId = defaultQualityQualityProfileId, + DownloadPropers = downloadPropers, SelectList = selectList }; @@ -426,7 +422,7 @@ namespace NzbDrone.Web.Controllers } [HttpPost] - public ActionResult SaveDownloads(DownloadSettingsModel data) + public ActionResult SaveSabnzbd(SabnzbdSettingsModel data) { var basicNotification = new BasicNotification(); basicNotification.Type = BasicNotificationType.Info; @@ -434,9 +430,6 @@ namespace NzbDrone.Web.Controllers if (ModelState.IsValid) { - _configProvider.SyncFrequency = data.SyncFrequency; - _configProvider.DownloadPropers = data.DownloadPropers; - _configProvider.Retention = data.Retention; _configProvider.SabHost = data.SabHost; _configProvider.SabPort = data.SabPort; _configProvider.SabApiKey = data.SabApiKey; @@ -444,8 +437,6 @@ namespace NzbDrone.Web.Controllers _configProvider.SabTvCategory = data.SabTvCategory; _configProvider.SabUsername = data.SabUsername; _configProvider.SabTvPriority = data.SabTvPriority; - _configProvider.UseBlackhole = data.UseBlackHole; - _configProvider.BlackholeDirectory = data.BlackholeDirectory; basicNotification.Title = SETTINGS_SAVED; _notificationProvider.Register(basicNotification); @@ -466,7 +457,8 @@ namespace NzbDrone.Web.Controllers if (ModelState.IsValid) { - _configProvider.SetValue("DefaultQualityProfile", data.DefaultQualityProfileId.ToString()); + _configProvider.DefaultQualityProfile = data.DefaultQualityProfileId; + _configProvider.DownloadPropers = data.DownloadPropers; //Saves only the Default Quality, skips User Profiles since none exist if (data.UserProfiles == null) diff --git a/NzbDrone.Web/Models/QualityModel.cs b/NzbDrone.Web/Models/QualityModel.cs index 9329a1679..ef5716f3d 100644 --- a/NzbDrone.Web/Models/QualityModel.cs +++ b/NzbDrone.Web/Models/QualityModel.cs @@ -11,8 +11,13 @@ namespace NzbDrone.Web.Models public List UserProfiles { get; set; } [DisplayName("Default Quality Profile")] + [Description("The default quality to use when adding series to NzbDrone")] public int DefaultQualityProfileId { get; set; } + [DisplayName("Download Propers")] + [Description("Should NzbDrone download proper releases (to replace non-proper files)?")] + public bool DownloadPropers { get; set; } + public SelectList SelectList { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Web/Models/DownloadSettingsModel.cs b/NzbDrone.Web/Models/SabnzbdSettingsModel.cs similarity index 63% rename from NzbDrone.Web/Models/DownloadSettingsModel.cs rename to NzbDrone.Web/Models/SabnzbdSettingsModel.cs index f80b33322..3b022e12e 100644 --- a/NzbDrone.Web/Models/DownloadSettingsModel.cs +++ b/NzbDrone.Web/Models/SabnzbdSettingsModel.cs @@ -6,28 +6,11 @@ using NzbDrone.Core.Model; namespace NzbDrone.Web.Models { - public class DownloadSettingsModel + public class SabnzbdSettingsModel { public SelectList PrioritySelectList = new SelectList(new[] {"Default", "Paused", "Low", "Normal", "High", "Top"}); - [Required] - [Range(15, 120, ErrorMessage = "Must be between 15 and 120 minutes")] - [DataType(DataType.Text)] - [DisplayName("Sync Frequency")] - [Description("Specifies how often NzbDrone should check RSS Feeds (Minutes)")] - public int SyncFrequency { get; set; } - - [DisplayName("Download Propers")] - [Description("Should NzbDrone download proper releases (to replace non-proper files)?")] - public bool DownloadPropers { get; set; } - - [Required(ErrorMessage = "Please enter a valid number")] - [DataType(DataType.Text)] - [DisplayName("Retention")] - [Description("Your newsgroup provider retention (Days)")] - public int Retention { get; set; } - [Required(ErrorMessage = "Please enter a valid host")] [DataType(DataType.Text)] [DisplayName("SABnzbd Host")] @@ -68,15 +51,5 @@ namespace NzbDrone.Web.Models [DisplayName("SABnzbd Priority")] [Description("Priority to use when sending NZBs to SABnzbd")] public SabnzbdPriorityType SabTvPriority { get; set; } - - [DisplayName("Use Blackhole")] - [Description("Whether to use the blackhole directory instead of sending NZB to SABnzbd")] - public bool UseBlackHole { get; set; } - - [DataType(DataType.Text)] - [DisplayFormat(ConvertEmptyStringToNull = false)] - [DisplayName("Blackhole Directory")] - [Description("Path to the blackhole directory")] - public String BlackholeDirectory { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 8da9302c7..2a7be8987 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -234,7 +234,7 @@ - + @@ -677,7 +677,7 @@ - + diff --git a/NzbDrone.Web/Views/Settings/Downloads.cshtml b/NzbDrone.Web/Views/Settings/Downloads.cshtml deleted file mode 100644 index 7141bfa85..000000000 --- a/NzbDrone.Web/Views/Settings/Downloads.cshtml +++ /dev/null @@ -1,241 +0,0 @@ -@using NzbDrone.Web.Helpers; -@model NzbDrone.Web.Models.DownloadSettingsModel - - - -@using (Html.BeginForm("SaveDownloads", "Settings", FormMethod.Post, new { id = "form", name = "form" })) -{ -
- Download Settings - -
- Usenet Variables - -
-
-
@Html.LabelFor(m => m.SyncFrequency)
-
@Html.TextBoxFor(m => m.SyncFrequency)
-
-
-
@Html.ValidationMessageFor(m => m.SyncFrequency)
-
@Html.DescriptionFor(m => m.SyncFrequency)
-
-
- -
-
-
@Html.LabelFor(m => m.DownloadPropers)
-
@Html.CheckBoxFor(m => m.DownloadPropers, new { @class = "config-checkbox" })
-
-
-
@Html.ValidationMessageFor(m => m.DownloadPropers)
-
@Html.DescriptionFor(m => m.DownloadPropers)
-
-
- -
-
-
@Html.LabelFor(m => m.Retention)
-
@Html.TextBoxFor(m => m.Retention)
-
-
-
@Html.ValidationMessageFor(m => m.Retention)
-
@Html.DescriptionFor(m => m.Retention)
-
-
- -
- -
-
- @Html.LabelFor(m => m.UseBlackHole) - @Html.CheckBoxFor(m => m.UseBlackHole, new { style="display:none" }) -
-
- @Html.RadioButton("UseBlackhole", true, new { @class="blackhole_radio" })Blackhole -
-
- @Html.RadioButton("UseBlackhole", false, new { @class="blackhole_radio" })SABnzbd -
-
- - - - - - - - -
-} -
- - \ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/Quality.cshtml b/NzbDrone.Web/Views/Settings/Quality.cshtml index 1c0f51134..e89970f4b 100644 --- a/NzbDrone.Web/Views/Settings/Quality.cshtml +++ b/NzbDrone.Web/Views/Settings/Quality.cshtml @@ -1,4 +1,5 @@ -@model NzbDrone.Web.Models.QualityModel +@using NzbDrone.Web.Helpers; +@model NzbDrone.Web.Models.QualityModel @using (Html.BeginForm("SaveQuality", "Settings", FormMethod.Post, new {id = "form", name = "form"})) @@ -30,16 +48,29 @@ Quality
-
- -
+
+
+
@Html.LabelFor(m => m.DownloadPropers)
+
@Html.CheckBoxFor(m => m.DownloadPropers)
+
+
+
@Html.ValidationMessageFor(m => m.DownloadPropers)
+
@Html.DescriptionFor(m => m.DownloadPropers)
+
+
+ +
+
@Html.LabelFor(m => m.DefaultQualityProfileId)
@Html.DropDownListFor(m => m.DefaultQualityProfileId, Model.SelectList)
+
+
@Html.ValidationMessageFor(m => m.DefaultQualityProfileId)
+
@Html.DescriptionFor(m => m.DefaultQualityProfileId)
- +
@@ -71,7 +102,10 @@ $.ajax({ url: this.href, cache: false, - success: function (html) { $("#user-profiles").prepend(html); } + success: function (html) { + $("#user-profiles").prepend(html); + + } }); return false; }); @@ -81,6 +115,7 @@ function deleteProfile(id) { sendToServer(id); $("#div_" + id).remove(); + removeOption(id); } function sendToServer(id) { diff --git a/NzbDrone.Web/Views/Settings/Sabnzbd.cshtml b/NzbDrone.Web/Views/Settings/Sabnzbd.cshtml new file mode 100644 index 000000000..11e76d7a8 --- /dev/null +++ b/NzbDrone.Web/Views/Settings/Sabnzbd.cshtml @@ -0,0 +1,137 @@ +@using NzbDrone.Web.Helpers; +@model NzbDrone.Web.Models.SabnzbdSettingsModel + + + +@using (Html.BeginForm("SaveSabnzbd", "Settings", FormMethod.Post, new { id = "form", name = "form" })) +{ +
+ SABnzbd + + + +
+
+
@Html.LabelFor(m => m.SabHost)
+
@Html.TextBoxFor(m => m.SabHost)
+
+
+
@Html.ValidationMessageFor(m => m.SabHost)
+
@Html.DescriptionFor(m => m.SabHost)
+
+
+ +
+
+
@Html.LabelFor(m => m.SabPort)
+
@Html.TextBoxFor(m => m.SabPort)
+
+
+
@Html.ValidationMessageFor(m => m.SabPort)
+
@Html.DescriptionFor(m => m.SabPort)
+
+
+ +
+
+
@Html.LabelFor(m => m.SabApiKey)
+
@Html.TextBoxFor(m => m.SabApiKey)
+
+
+
@Html.ValidationMessageFor(m => m.SabApiKey)
+
@Html.DescriptionFor(m => m.SabApiKey)
+
+
+ +
+
+
@Html.LabelFor(m => m.SabUsername)
+
@Html.TextBoxFor(m => m.SabUsername)
+
+
+
@Html.ValidationMessageFor(m => m.SabUsername)
+
@Html.DescriptionFor(m => m.SabUsername)
+
+
+ +
+
+
@Html.LabelFor(m => m.SabPassword)
+
@Html.TextBoxFor(m => m.SabPassword)
+
+
+
@Html.ValidationMessageFor(m => m.SabPassword)
+
@Html.DescriptionFor(m => m.SabPassword)
+
+
+ +
+
+
@Html.LabelFor(m => m.SabTvCategory)
+
@Html.TextBoxFor(m => m.SabTvCategory)
+
+
+
@Html.ValidationMessageFor(m => m.SabTvCategory)
+
@Html.DescriptionFor(m => m.SabTvCategory)
+
+
+ +
+
+
@Html.LabelFor(m => m.SabTvPriority)
+
@Html.DropDownListFor(m => m.SabTvPriority, Model.PrioritySelectList)
+
+
+
@Html.ValidationMessageFor(m => m.SabTvPriority)
+
@Html.DescriptionFor(m => m.SabTvPriority)
+
+
+ + +
+} +
+ + \ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/SubMenu.cshtml b/NzbDrone.Web/Views/Settings/SubMenu.cshtml index e796bb556..da594c40b 100644 --- a/NzbDrone.Web/Views/Settings/SubMenu.cshtml +++ b/NzbDrone.Web/Views/Settings/SubMenu.cshtml @@ -2,7 +2,7 @@ { items.Add().Text("General").Action("General", "Settings"); items.Add().Text("Indexers").Action("Indexers", "Settings"); - items.Add().Text("Downloads").Action("Downloads", "Settings"); + items.Add().Text("SABnzbd").Action("Sabnzbd", "Settings"); items.Add().Text("Quality").Action("Quality", "Settings"); items.Add().Text("Episode Sorting").Action("EpisodeSorting", "Settings"); diff --git a/NzbDrone.Web/Views/Settings/UserProfileSection.cshtml b/NzbDrone.Web/Views/Settings/UserProfileSection.cshtml index 084c7ec39..d43f4fe6e 100644 --- a/NzbDrone.Web/Views/Settings/UserProfileSection.cshtml +++ b/NzbDrone.Web/Views/Settings/UserProfileSection.cshtml @@ -6,9 +6,14 @@ Layout = null; } + + @using (Html.BeginCollectionItem("UserProfiles")) { - var idClean = ViewData.TemplateInfo.HtmlFieldPrefix.Replace('[', '_').Replace(']', '_'); var ugly = ViewData.TemplateInfo.HtmlFieldPrefix; @@ -61,17 +66,17 @@
-
+

@{Html.DisplayTextFor(m => m.Name);}

- Delete + Delete
-
+
@Html.LabelFor(x => x.Name)
-
@Html.TextBoxFor(x => x.Name)
+
@Html.TextBoxFor(x => x.Name, new { maxlength = 16})
@Html.ValidationMessageFor(x => x.Name)
@@ -137,6 +142,7 @@ $("#@nameBox").keyup(function () { var value = $(this).val(); $("#@title").text(value); + renameOption(value, '@ViewData["ProfileId"]'); }).keyup(); } \ No newline at end of file