Quality config complete (needs to look better, but it is functional, minus deleting).

This commit is contained in:
markus101 2011-02-05 23:13:17 -08:00
parent 6d790f8939
commit 2ba6057ec7
6 changed files with 80 additions and 20 deletions

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using NzbDrone.Web.Models;
namespace NzbDrone.Web.Controllers namespace NzbDrone.Web.Controllers
{ {
@ -20,5 +21,18 @@ namespace NzbDrone.Web.Controllers
{ {
return View(); return View();
} }
public ActionResult Test()
{
var model = new TestModel();
return View(model);
}
[HttpPost]
public ActionResult Test(TestModel model)
{
return View();
}
} }
} }

View File

@ -127,7 +127,16 @@ namespace NzbDrone.Web.Controllers
public ViewResult AddUserProfile() public ViewResult AddUserProfile()
{ {
return View("UserProfileSection", new QualityProfile()); var qualityTypes = new List<QualityTypes>();
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() public ActionResult SubMenu()
@ -290,6 +299,27 @@ namespace NzbDrone.Web.Controllers
try try
{ {
_configProvider.SetValue("DefaultQualityProfile", data.DefaultProfileId.ToString()); _configProvider.SetValue("DefaultQualityProfile", data.DefaultProfileId.ToString());
foreach (var profile in data.UserProfiles)
{
profile.Allowed = new List<QualityTypes>();
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) catch (Exception e)

View File

@ -88,8 +88,8 @@
<Compile Include="Models\MappingModel.cs" /> <Compile Include="Models\MappingModel.cs" />
<Compile Include="Models\EpisodeModel.cs" /> <Compile Include="Models\EpisodeModel.cs" />
<Compile Include="Models\QualityModel.cs" /> <Compile Include="Models\QualityModel.cs" />
<Compile Include="Models\QualityProfileModel.cs" />
<Compile Include="Models\SettingsModels.cs" /> <Compile Include="Models\SettingsModels.cs" />
<Compile Include="Models\TestModel.cs" />
<Compile Include="Ninject.Web.Mvc\ControllerMissingBindingResolver.cs" /> <Compile Include="Ninject.Web.Mvc\ControllerMissingBindingResolver.cs" />
<Compile Include="Ninject.Web.Mvc\FilterInjector.cs" /> <Compile Include="Ninject.Web.Mvc\FilterInjector.cs" />
<Compile Include="Ninject.Web.Mvc\IFilterInjector.cs" /> <Compile Include="Ninject.Web.Mvc\IFilterInjector.cs" />
@ -260,6 +260,7 @@
<Content Include="Scripts\jquery-tgc-countdown-1.0.js" /> <Content Include="Scripts\jquery-tgc-countdown-1.0.js" />
<Content Include="Scripts\jquery.simpledropdown.js" /> <Content Include="Scripts\jquery.simpledropdown.js" />
<Content Include="Scripts\Notification.js" /> <Content Include="Scripts\Notification.js" />
<Content Include="Views\Home\Test.aspx" />
<Content Include="Views\Log\Index.aspx" /> <Content Include="Views\Log\Index.aspx" />
<Content Include="Views\Series\Details.aspx" /> <Content Include="Views\Series\Details.aspx" />
<Content Include="Views\Series\EpisodeDetail.ascx" /> <Content Include="Views\Series\EpisodeDetail.ascx" />
@ -269,7 +270,6 @@
<Content Include="Views\Settings\General.ascx" /> <Content Include="Views\Settings\General.ascx" />
<Content Include="Views\Settings\Index.aspx" /> <Content Include="Views\Settings\Index.aspx" />
<Content Include="Views\Settings\Indexers.ascx" /> <Content Include="Views\Settings\Indexers.ascx" />
<Content Include="Views\Settings\ProfileAllowedQualities.ascx" />
<Content Include="Views\Settings\Quality.ascx" /> <Content Include="Views\Settings\Quality.ascx" />
<Content Include="Views\Settings\SubMenu.ascx" /> <Content Include="Views\Settings\SubMenu.ascx" />
<Content Include="Views\Settings\UserProfileSection.ascx" /> <Content Include="Views\Settings\UserProfileSection.ascx" />

View File

@ -1,5 +1,4 @@
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %> <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<%@ Import Namespace="NzbDrone.Core.Repository.Quality" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Settings Settings

View File

@ -4,9 +4,9 @@
<% using (Html.BeginCollectionItem("UserProfiles")) <% using (Html.BeginCollectionItem("UserProfiles"))
{ %> { %>
<style type="text/css"> <style type="text/css">
#sortable1, #sortable2 { list-style-type: none; margin: 0; padding: 0; float: left; margin-right: 10px; background: #eee; padding: 5px; width: 143px;} #sortable1, #sortable2 { list-style-type: none; margin: 0; padding: 0; float: left; margin-right: 10px; background: #eee; padding: 5px; width: 143px;}
.allowedQualities, .otherQualities { list-style-type: none; margin: 0; padding: 0; float: left; margin-right: 10px; background: #eee; padding: 5px; width: 148px;}
#sortable1 li, #sortable2 li { margin: 5px; padding: 5px; font-size: 1.2em; width: 120px; } #sortable1 li, #sortable2 li { margin: 5px; padding: 5px; font-size: 1.2em; width: 120px; }
</style> </style>
@ -16,11 +16,17 @@
connectWith: ".connectedSortable", connectWith: ".connectedSortable",
placeholder: "ui-state-highlight", placeholder: "ui-state-highlight",
dropOnEmpty: true, 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"); var order = $('#sortable1').sortable("toArray");
$("#allowedString").val(order); $("#allowedString").val(order);
} }
}).disableSelection(); }).disableSelection();
}); });
@ -29,12 +35,11 @@
<div class="userProfileSectionEditor"> <div class="userProfileSectionEditor">
<fieldset> <fieldset>
<%--<label><%= Model.Name %></label>--%>
<%= Html.TextBoxFor(m => m.AllowedString, new { @id = "allowedString", @style = "display:none" })%> <%= 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" })%>--%>
<%--<%= Html.TextBox("Name", "Empty", new { @id = "allowedString2" })%>--%>
<label><%= Model.Name %></label>
<div class="removeDiv"><a href="#" class="deleteRow">Remove</a></div>
<div class="editor-label"> <div class="editor-label">
<%= Html.LabelFor(x => x.Name)%> <%= Html.LabelFor(x => x.Name)%>
@ -52,16 +57,21 @@
<br /> <br />
<div class="allowedQualities"> <div class="allowedQualities">
<ul id="sortable1" class="connectedSortable" title="Allowed"> <h4 style="padding:0">Allowed</h4>
<%for (int i = 0; i < Model.Allowed.Count(); i++){%> <ul id="sortable1" class="connectedSortable" title>
<li class="ui-state-default" id="<%= Model.Allowed[i].ToString() %>"> <% if (Model.Allowed != null) { %>
<%= Html.DisplayTextFor(c => c.Allowed[i]) %> <%for (int i = 0; i < Model.Allowed.Count(); i++){%>
</li> <li class="ui-state-default" id="<%= Model.Allowed[i].ToString() %>">
<%=Html.RadioButtonFor(x => x.Cutoff, Model.Allowed[i])%>
<%= Html.DisplayTextFor(c => c.Allowed[i]) %>
</li>
<%}%>
<%}%> <%}%>
</ul> </ul>
</div> </div>
<div class="otherQualities"> <div class="otherQualities">
<h4 padding-left="10px">Not-Allowed</h4>
<ul id="sortable2" class="connectedSortable"> <ul id="sortable2" class="connectedSortable">
<% var qualitiesList = (List<QualityTypes>) ViewData["Qualities"]; %> <% var qualitiesList = (List<QualityTypes>) ViewData["Qualities"]; %>
@ -70,18 +80,24 @@
//Skip Unknown and any item that is in the allowed list //Skip Unknown and any item that is in the allowed list
if (qualitiesList[i].ToString() == "Unknown") if (qualitiesList[i].ToString() == "Unknown")
continue; continue;
if (Model.Allowed.Contains(qualitiesList[i]))
continue; if (Model.Allowed != null)
{
if (Model.Allowed.Contains(qualitiesList[i]))
continue;
}
%> %>
<li class="ui-state-default" id="<%= qualitiesList[i].ToString() %>"> <li class="ui-state-default" id="<%= qualitiesList[i].ToString() %>">
<%=Html.RadioButtonFor(x => x.Cutoff, qualitiesList[i])%>
<%= Html.Label(qualitiesList[i].ToString()) %> <%= Html.Label(qualitiesList[i].ToString()) %>
<%--<%= Html.RenderPartial("ProfileAllowedQualities", Model.Allowed[i]) %>--%> <%--<%= Html.RenderPartial("ProfileAllowedQualities", Model.Allowed[i]) %>--%>
</li> </li>
<% } %> <% } %>
</ul> </ul>
</div> </div>
<div class="removeDiv"><a href="#" class="deleteRow">Remove</a></div>
</fieldset> </fieldset>
</div> </div>
<% } %> <% } %>

View File

@ -59,6 +59,7 @@ Global
{43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {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|x64.ActiveCfg = Debug|Any CPU
{43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Debug|x86.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.ActiveCfg = Release|Any CPU
{43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Release|Any CPU.Build.0 = 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 {43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU