diff --git a/NzbDrone.Web/Controllers/HomeController.cs b/NzbDrone.Web/Controllers/HomeController.cs index cd8cedf4a..7e0700c57 100644 --- a/NzbDrone.Web/Controllers/HomeController.cs +++ b/NzbDrone.Web/Controllers/HomeController.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Web; using System.Web.Mvc; +using NzbDrone.Web.Models; namespace NzbDrone.Web.Controllers { @@ -20,5 +21,18 @@ public ActionResult About() { return View(); } + + public ActionResult Test() + { + var model = new TestModel(); + return View(model); + } + + [HttpPost] + public ActionResult Test(TestModel model) + { + + return View(); + } } } diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index fa73ab99a..df9c96140 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -127,7 +127,16 @@ public ActionResult Quality() public ViewResult AddUserProfile() { - return View("UserProfileSection", new QualityProfile()); + var qualityTypes = new List(); + + foreach (QualityTypes qual in Enum.GetValues(typeof(QualityTypes))) + { + qualityTypes.Add(qual); + } + + ViewData["Qualities"] = qualityTypes; + + return View("UserProfileSection", new QualityProfile { Name = "New Profile", UserProfile = true }); } public ActionResult SubMenu() @@ -290,6 +299,27 @@ public ActionResult SaveQuality(QualityModel data) try { _configProvider.SetValue("DefaultQualityProfile", data.DefaultProfileId.ToString()); + + foreach (var profile in data.UserProfiles) + { + profile.Allowed = new List(); + foreach (var quality in profile.AllowedString.Split(',')) + { + var qType = (QualityTypes)Enum.Parse(typeof (QualityTypes), quality); + profile.Allowed.Add(qType); + } + + //If the Cutoff value selected is not in the allowed list then use the last allowed value, this should be validated on submit + if (!profile.Allowed.Contains(profile.Cutoff)) + profile.Cutoff = profile.Allowed.Last(); + + if (profile.ProfileId > 0) + _qualityProvider.Update(profile); + + else + _qualityProvider.Add(profile); + } + } catch (Exception e) diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index ab6e86e82..ab85c70b3 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -88,8 +88,8 @@ - + @@ -260,6 +260,7 @@ + @@ -269,7 +270,6 @@ - diff --git a/NzbDrone.Web/Views/Settings/Index.aspx b/NzbDrone.Web/Views/Settings/Index.aspx index 7778e955e..b28d9c51f 100644 --- a/NzbDrone.Web/Views/Settings/Index.aspx +++ b/NzbDrone.Web/Views/Settings/Index.aspx @@ -1,5 +1,4 @@ <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> -<%@ Import Namespace="NzbDrone.Core.Repository.Quality" %> Settings diff --git a/NzbDrone.Web/Views/Settings/UserProfileSection.ascx b/NzbDrone.Web/Views/Settings/UserProfileSection.ascx index dc5c93513..80eaec80e 100644 --- a/NzbDrone.Web/Views/Settings/UserProfileSection.ascx +++ b/NzbDrone.Web/Views/Settings/UserProfileSection.ascx @@ -4,9 +4,9 @@ <% using (Html.BeginCollectionItem("UserProfiles")) { %> - @@ -16,11 +16,17 @@ connectWith: ".connectedSortable", placeholder: "ui-state-highlight", dropOnEmpty: true, - update: function (event, ui) { + create: function (event, ui) { + var order = $('#sortable1').sortable("toArray"); + $("#allowedString").val(order); + }, + + update: function (event, ui) { var order = $('#sortable1').sortable("toArray"); $("#allowedString").val(order); } + }).disableSelection(); }); @@ -29,12 +35,11 @@
+ <%----%> - <%= Html.TextBoxFor(m => m.AllowedString, new { @id = "allowedString", @style = "display:none" })%> - <%--<%= Html.TextBoxFor(m => m.AllowedString, new { @id = "allowedString" })%>--%> - - - + <%= Html.TextBoxFor(m => m.AllowedString, new { @id = "allowedString", @style = "display:none" })%> + <%--<%= Html.TextBoxFor(m => m.AllowedString, new { @id = "allowedString" })%>--%> + <%--<%= Html.TextBox("Name", "Empty", new { @id = "allowedString2" })%>--%>
<%= Html.LabelFor(x => x.Name)%> @@ -52,16 +57,21 @@
-
    - <%for (int i = 0; i < Model.Allowed.Count(); i++){%> -
  • - <%= Html.DisplayTextFor(c => c.Allowed[i]) %> -
  • +

    Allowed

    +
      + <% if (Model.Allowed != null) { %> + <%for (int i = 0; i < Model.Allowed.Count(); i++){%> +
    • + <%=Html.RadioButtonFor(x => x.Cutoff, Model.Allowed[i])%> + <%= Html.DisplayTextFor(c => c.Allowed[i]) %> +
    • + <%}%> <%}%>
+

Not-Allowed

    <% var qualitiesList = (List) ViewData["Qualities"]; %> @@ -70,18 +80,24 @@ //Skip Unknown and any item that is in the allowed list if (qualitiesList[i].ToString() == "Unknown") continue; - if (Model.Allowed.Contains(qualitiesList[i])) - continue; + + if (Model.Allowed != null) + { + if (Model.Allowed.Contains(qualitiesList[i])) + continue; + } %>
  • + <%=Html.RadioButtonFor(x => x.Cutoff, qualitiesList[i])%> <%= Html.Label(qualitiesList[i].ToString()) %> <%--<%= Html.RenderPartial("ProfileAllowedQualities", Model.Allowed[i]) %>--%>
  • - <% } %> + <% } %>
-
+
+
<% } %> \ No newline at end of file diff --git a/NzbDrone.sln b/NzbDrone.sln index 39d9e680f..046425977 100644 --- a/NzbDrone.sln +++ b/NzbDrone.sln @@ -59,6 +59,7 @@ Global {43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|x64.ActiveCfg = Debug|Any CPU {43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|x86.ActiveCfg = Debug|Any CPU + {43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|x86.Build.0 = Debug|Any CPU {43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Release|Any CPU.ActiveCfg = Release|Any CPU {43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Release|Any CPU.Build.0 = Release|Any CPU {43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU