diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 50257c750..414ca01a6 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -29,11 +29,12 @@ namespace NzbDrone.Web.Controllers private readonly AutoConfigureProvider _autoConfigureProvider; private readonly NotificationProvider _notificationProvider; private readonly DiskProvider _diskProvider; + private readonly SeriesProvider _seriesProvider; public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider, QualityProvider qualityProvider, RootDirProvider rootDirProvider, AutoConfigureProvider autoConfigureProvider, NotificationProvider notificationProvider, - DiskProvider diskProvider) + DiskProvider diskProvider, SeriesProvider seriesProvider) { _configProvider = configProvider; _indexerProvider = indexerProvider; @@ -42,6 +43,7 @@ namespace NzbDrone.Web.Controllers _autoConfigureProvider = autoConfigureProvider; _notificationProvider = notificationProvider; _diskProvider = diskProvider; + _seriesProvider = seriesProvider; } public ActionResult Test() @@ -131,21 +133,19 @@ namespace NzbDrone.Web.Controllers ViewData["Qualities"] = qualityTypes; - var userProfiles = _qualityProvider.GetAllProfiles().Where(q => q.UserProfile).ToList(); var profiles = _qualityProvider.GetAllProfiles().ToList(); var defaultQualityQualityProfileId = Convert.ToInt32(_configProvider.DefaultQualityProfile); var downloadPropers = _configProvider.DownloadPropers; - var selectList = new SelectList(profiles, "QualityProfileId", "Name"); + var qualityProfileSelectList = new SelectList(profiles, "QualityProfileId", "Name"); var model = new QualityModel { Profiles = profiles, - UserProfiles = userProfiles, DefaultQualityProfileId = defaultQualityQualityProfileId, DownloadPropers = downloadPropers, - SelectList = selectList + QualityProfileSelectList = qualityProfileSelectList }; return View("Index", model); @@ -199,7 +199,7 @@ namespace NzbDrone.Web.Controllers return View("Index", model); } - public ViewResult AddUserProfile() + public ViewResult AddProfile() { var qualityTypes = new List(); @@ -208,12 +208,11 @@ namespace NzbDrone.Web.Controllers qualityTypes.Add(qual); } - ViewData["Qualities"] = qualityTypes; + ViewData["Qualities"] = new SelectList(qualityTypes); var qualityProfile = new QualityProfile { Name = "New Profile", - UserProfile = true, Allowed = new List { QualityTypes.Unknown }, Cutoff = QualityTypes.Unknown, }; @@ -224,7 +223,7 @@ namespace NzbDrone.Web.Controllers ViewData["ProfileId"] = id; - return View("UserProfileSection", qualityProfile); + return View("QualityProfileItem", qualityProfile); } public ActionResult GetQualityProfileView(QualityProfile profile) @@ -235,10 +234,11 @@ namespace NzbDrone.Web.Controllers { qualityTypes.Add(qual); } + ViewData["Qualities"] = qualityTypes; ViewData["ProfileId"] = profile.QualityProfileId; - return PartialView("UserProfileSection", profile); + return PartialView("QualityProfileItem", profile); } public ViewResult AddRootDir() @@ -287,13 +287,16 @@ namespace NzbDrone.Web.Controllers Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId, true)); var selectList = new SelectList(profiles, "QualityProfileId", "Name"); - return new QualityModel { DefaultQualityProfileId = defaultQualityQualityProfileId, SelectList = selectList }; + return new QualityModel { DefaultQualityProfileId = defaultQualityQualityProfileId, QualityProfileSelectList = selectList }; } public JsonResult DeleteQualityProfile(int profileId) { try { + if (_seriesProvider.GetAllSeries().Where(s => s.QualityProfileId == profileId).Count() != 0) + return new JsonResult { Data = "Unable to delete Profile, it is still in use." }; + _qualityProvider.Delete(profileId); } @@ -460,14 +463,18 @@ namespace NzbDrone.Web.Controllers _configProvider.DownloadPropers = data.DownloadPropers; //Saves only the Default Quality, skips User Profiles since none exist - if (data.UserProfiles == null) + if (data.Profiles == null) return Content(SETTINGS_SAVED); - foreach (var profile in data.UserProfiles) + foreach (var profile in data.Profiles) { - Logger.Debug(String.Format("Updating User Profile: {0}", profile)); + Logger.Debug(String.Format("Updating Profile: {0}", profile)); profile.Allowed = new List(); + + //Remove the extra comma from the end and replace double commas with a single one (the Javascript gets a little crazy) + profile.AllowedString = profile.AllowedString.Replace(",,", ",").Trim(','); + foreach (var quality in profile.AllowedString.Split(',')) { var qType = (QualityTypes)Enum.Parse(typeof(QualityTypes), quality); diff --git a/NzbDrone.Web/Models/QualityModel.cs b/NzbDrone.Web/Models/QualityModel.cs index ef5716f3d..43794feec 100644 --- a/NzbDrone.Web/Models/QualityModel.cs +++ b/NzbDrone.Web/Models/QualityModel.cs @@ -8,7 +8,6 @@ namespace NzbDrone.Web.Models public class QualityModel { public List Profiles { get; set; } - public List UserProfiles { get; set; } [DisplayName("Default Quality Profile")] [Description("The default quality to use when adding series to NzbDrone")] @@ -18,6 +17,6 @@ namespace NzbDrone.Web.Models [Description("Should NzbDrone download proper releases (to replace non-proper files)?")] public bool DownloadPropers { get; set; } - public SelectList SelectList { get; set; } + public SelectList QualityProfileSelectList { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Web/Models/QualityTypeModel.cs b/NzbDrone.Web/Models/QualityTypeModel.cs new file mode 100644 index 000000000..357395ddf --- /dev/null +++ b/NzbDrone.Web/Models/QualityTypeModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using NzbDrone.Core.Repository.Quality; + +namespace NzbDrone.Web.Models +{ + public class QualityTypeModel + { + public int Id { get; set; } + public QualityTypes Name { get; set; } + } +} \ No newline at end of file diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 6599bccbe..a75cebce3 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -237,6 +237,7 @@ + @@ -712,7 +713,7 @@ - + diff --git a/NzbDrone.Web/Views/Settings/Quality.cshtml b/NzbDrone.Web/Views/Settings/Quality.cshtml index e89970f4b..f25800fa9 100644 --- a/NzbDrone.Web/Views/Settings/Quality.cshtml +++ b/NzbDrone.Web/Views/Settings/Quality.cshtml @@ -62,7 +62,7 @@
@Html.LabelFor(m => m.DefaultQualityProfileId)
-
@Html.DropDownListFor(m => m.DefaultQualityProfileId, Model.SelectList)
+
@Html.DropDownListFor(m => m.DefaultQualityProfileId, Model.QualityProfileSelectList)
@Html.ValidationMessageFor(m => m.DefaultQualityProfileId)
@@ -74,13 +74,13 @@
-
- @foreach (var item in Model.UserProfiles) +
+ @foreach (var item in Model.Profiles) { Html.RenderAction("GetQualityProfileView", item); } @@ -103,7 +103,7 @@ url: this.href, cache: false, success: function (html) { - $("#user-profiles").prepend(html); + $("#profiles").prepend(html); } }); @@ -114,8 +114,6 @@ function deleteProfile(id) { sendToServer(id); - $("#div_" + id).remove(); - removeOption(id); } function sendToServer(id) { @@ -125,6 +123,16 @@ data: jQuery.param({ profileId: id }), error: function (req, status, error) { alert("Sorry! We could not delete your Profile at this time. " + error); + }, + success: function (data, textStatus, jqXHR) { + if (data == "ok") { + $("#div_" + id).remove(); + removeOption(id); + } + + else { + alert(data); + } } }); } diff --git a/NzbDrone.Web/Views/Settings/QualityProfileItem.cshtml b/NzbDrone.Web/Views/Settings/QualityProfileItem.cshtml new file mode 100644 index 000000000..aea894c63 --- /dev/null +++ b/NzbDrone.Web/Views/Settings/QualityProfileItem.cshtml @@ -0,0 +1,118 @@ +@model NzbDrone.Core.Repository.Quality.QualityProfile +@using System.Collections +@using NzbDrone.Core.Repository.Quality +@using NzbDrone.Web.Helpers + +@{ + Layout = null; +} + + + +@using (Html.BeginCollectionItem("Profiles")) +{ + var idClean = ViewData.TemplateInfo.HtmlFieldPrefix.Replace('[', '_').Replace(']', '_'); + var ugly = ViewData.TemplateInfo.HtmlFieldPrefix; + + string selectable = String.Format("{0}_selectable", idClean); + string allowedStringName = String.Format("{0}_AllowedString", idClean); + string title = String.Format("{0}_Title", idClean); + string nameBox = String.Format("{0}_Name", idClean); + string cutoff = String.Format("{0}.Cutoff", ugly); + + + + + +
+ +
+
+
+

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

+ Delete +
+ +
+
@Html.LabelFor(x => x.Name)
+
@Html.TextBoxFor(x => x.Name, new { maxlength = 16 })
+
@Html.ValidationMessageFor(x => x.Name)
+
+ +
+
@Html.LabelFor(x => x.Cutoff)
+
@Html.DropDownListFor(m => m.Cutoff, new SelectList(ViewData["Qualities"] as IEnumerable, Model.Cutoff))
+
@Html.ValidationMessageFor(x => x.Cutoff)
+
+
+ +
+
    + + @{var qualitiesList = (List)ViewData["Qualities"];} + + @for (int i = 0; i < qualitiesList.Count(); i++) + { + if (Model.Allowed != null) + { + if (Model.Allowed.Contains(qualitiesList[i])) + { +
  1. + @Html.Label(qualitiesList[i].ToString()) +
  2. + continue; + } + } + +
  3. + @Html.Label(qualitiesList[i].ToString()) +
  4. + } +
+
+ +
+ @Html.HiddenFor(x => x.QualityProfileId) + @Html.HiddenFor(x => x.UserProfile) + @Html.HiddenFor(m => m.AllowedString) +
+
+
+ + +} \ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/Test.cshtml b/NzbDrone.Web/Views/Settings/Test.cshtml index 05eac029f..5f27b2002 100644 --- a/NzbDrone.Web/Views/Settings/Test.cshtml +++ b/NzbDrone.Web/Views/Settings/Test.cshtml @@ -1 +1,58 @@ -Hello World \ No newline at end of file +Hello World + +Check 1
+ Check 2
+ Check 3
+ Check 4
+ Check 5
+ Check 6
+ Check 7
+ + + + + + + + + +
    +
  1. Unknown
  2. +
  3. SDTV
  4. +
  5. DVD
  6. +
  7. HDTV
  8. +
  9. WEBDL
  10. +
  11. Bluray720p
  12. +
  13. Bluray1080p
  14. +
\ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/UserProfileSection.cshtml b/NzbDrone.Web/Views/Settings/UserProfileSection.cshtml deleted file mode 100644 index d43f4fe6e..000000000 --- a/NzbDrone.Web/Views/Settings/UserProfileSection.cshtml +++ /dev/null @@ -1,148 +0,0 @@ -@model NzbDrone.Core.Repository.Quality.QualityProfile -@using NzbDrone.Core.Repository.Quality -@using NzbDrone.Web.Helpers - -@{ - Layout = null; -} - - - -@using (Html.BeginCollectionItem("UserProfiles")) -{ - var idClean = ViewData.TemplateInfo.HtmlFieldPrefix.Replace('[', '_').Replace(']', '_'); - var ugly = ViewData.TemplateInfo.HtmlFieldPrefix; - - string sortable1 = String.Format("{0}_sortable1", idClean); - string sortable2 = String.Format("{0}_sortable2", idClean); - string allowedStringName = String.Format("{0}_AllowedString", idClean); - string connectedSortable = String.Format("connected{0}", idClean); - string title = String.Format("{0}_Title", idClean); - string nameBox = String.Format("{0}_Name", idClean); - string cutoff = String.Format("{0}.Cutoff", ugly); - - - - - -
- -
-
- -
-

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

- Delete -
- -
-
@Html.LabelFor(x => x.Name)
-
@Html.TextBoxFor(x => x.Name, new { maxlength = 16})
-
@Html.ValidationMessageFor(x => x.Name)
-
- -
-
-

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"];} - - @for (int i = 0; i < qualitiesList.Count(); i++) - { - //Skip Unknown and any item that is in the allowed list - //if (qualitiesList[i].ToString() == "Unknown") - //{ - // 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.ValidationMessageFor(x => x.Cutoff) - -
- @Html.TextBoxFor(x => x.QualityProfileId, new { @style = "display:none" }) - @Html.CheckBoxFor(x => x.UserProfile, new { @style = "display:none" }) - @Html.TextBoxFor(m => m.AllowedString, new { @style = "display:none" }) -
-
-
- - -} \ No newline at end of file