diff --git a/NzbDrone.Core/CentralDispatch.cs b/NzbDrone.Core/CentralDispatch.cs index 8574d75a8..a39d7ef13 100644 --- a/NzbDrone.Core/CentralDispatch.cs +++ b/NzbDrone.Core/CentralDispatch.cs @@ -281,7 +281,8 @@ namespace NzbDrone.Core //Add or Update SDTV Logger.Debug(String.Format("Checking for default QualityProfile: {0}", sdtv.Name)); - if (!repository.Exists(i => i.Name == sdtv.Name)) + var sdtvDb = repository.Single(i => i.Name == sdtv.Name); + if (sdtvDb == null) { Logger.Debug(String.Format("Adding new default QualityProfile: {0}", sdtv.Name)); repository.Add(sdtv); @@ -290,12 +291,14 @@ namespace NzbDrone.Core else { Logger.Debug(String.Format("Updating default QualityProfile: {0}", sdtv.Name)); + sdtv.ProfileId = sdtvDb.ProfileId; repository.Update(sdtv); } //Add or Update DVD Logger.Debug(String.Format("Checking for default QualityProfile: {0}", dvd.Name)); - if (!repository.Exists(i => i.Name == dvd.Name)) + var dvdDb = repository.Single(i => i.Name == dvd.Name); + if (dvdDb == null) { Logger.Debug(String.Format("Adding new default QualityProfile: {0}", dvd.Name)); repository.Add(dvd); @@ -304,12 +307,14 @@ namespace NzbDrone.Core else { Logger.Debug(String.Format("Updating default QualityProfile: {0}", dvd.Name)); + dvd.ProfileId = dvdDb.ProfileId; repository.Update(dvd); } //Add or Update BDRip Logger.Debug(String.Format("Checking for default QualityProfile: {0}", bdrip.Name)); - if (!repository.Exists(i => i.Name == bdrip.Name)) + var bdripDb = repository.Single(i => i.Name == bdrip.Name); + if (bdripDb == null) { Logger.Debug(String.Format("Adding new default QualityProfile: {0}", bdrip.Name)); repository.Add(bdrip); @@ -318,12 +323,14 @@ namespace NzbDrone.Core else { Logger.Debug(String.Format("Updating default QualityProfile: {0}", bdrip.Name)); + bdrip.ProfileId = bdripDb.ProfileId; repository.Update(bdrip); } //Add or Update HDTV Logger.Debug(String.Format("Checking for default QualityProfile: {0}", hdtv.Name)); - if (!repository.Exists(i => i.Name == hdtv.Name)) + var hdtvDb = repository.Single(i => i.Name == hdtv.Name); + if (hdtvDb == null) { Logger.Debug(String.Format("Adding new default QualityProfile: {0}", hdtv.Name)); repository.Add(hdtv); @@ -332,12 +339,14 @@ namespace NzbDrone.Core else { Logger.Debug(String.Format("Updating default QualityProfile: {0}", hdtv.Name)); + hdtv.ProfileId = hdtvDb.ProfileId; repository.Update(hdtv); } //Add or Update WEBDL Logger.Debug(String.Format("Checking for default QualityProfile: {0}", webdl.Name)); - if (!repository.Exists(i => i.Name == webdl.Name)) + var webdlDb = repository.Single(i => i.Name == webdl.Name); + if (webdlDb == null) { Logger.Debug(String.Format("Adding new default QualityProfile: {0}", webdl.Name)); repository.Add(webdl); @@ -346,12 +355,14 @@ namespace NzbDrone.Core else { Logger.Debug(String.Format("Updating default QualityProfile: {0}", webdl.Name)); + webdl.ProfileId = webdlDb.ProfileId; repository.Update(webdl); } //Add or Update Bluray Logger.Debug(String.Format("Checking for default QualityProfile: {0}", bluray.Name)); - if (!repository.Exists(i => i.Name == bluray.Name)) + var blurayDb = repository.Single(i => i.Name == bluray.Name); + if (blurayDb == null) { Logger.Debug(String.Format("Adding new default QualityProfile: {0}", bluray.Name)); repository.Add(bluray); @@ -360,6 +371,7 @@ namespace NzbDrone.Core else { Logger.Debug(String.Format("Updating default QualityProfile: {0}", bluray.Name)); + bluray.ProfileId = blurayDb.ProfileId; repository.Update(bluray); } } diff --git a/NzbDrone.Core/Providers/IQualityProvider.cs b/NzbDrone.Core/Providers/IQualityProvider.cs index 49e6b949f..865fd47da 100644 --- a/NzbDrone.Core/Providers/IQualityProvider.cs +++ b/NzbDrone.Core/Providers/IQualityProvider.cs @@ -12,5 +12,6 @@ namespace NzbDrone.Core.Providers void Update(QualityProfile profile); void Delete(int profileId); List GetAllProfiles(); + QualityProfile Find(int profileId); } } diff --git a/NzbDrone.Core/Providers/QualityProvider.cs b/NzbDrone.Core/Providers/QualityProvider.cs index 6deac32fc..dac6797fa 100644 --- a/NzbDrone.Core/Providers/QualityProvider.cs +++ b/NzbDrone.Core/Providers/QualityProvider.cs @@ -48,6 +48,11 @@ namespace NzbDrone.Core.Providers return profiles; } + public QualityProfile Find(int profileId) + { + return _sonicRepo.Single(q => q.ProfileId == profileId); + } + #endregion } } diff --git a/NzbDrone.Core/Repository/Quality/QualityTypes.cs b/NzbDrone.Core/Repository/Quality/QualityTypes.cs index e9ed82bc3..d18f211d4 100644 --- a/NzbDrone.Core/Repository/Quality/QualityTypes.cs +++ b/NzbDrone.Core/Repository/Quality/QualityTypes.cs @@ -21,19 +21,19 @@ namespace NzbDrone.Core.Repository.Quality /// /// SD File (HD Source) /// - BDRip = 2, + BDRip = 3, /// /// HD File (HDTV Source) /// - HDTV = 3, + HDTV = 4, /// /// HD File (Online Source) /// - WEBDL = 4, + WEBDL = 5, /// /// HD File (Blu-ray Source could be 1080p or 720p) /// - Bluray = 5, + Bluray = 6, } } \ No newline at end of file diff --git a/NzbDrone.Web/Content/style.css b/NzbDrone.Web/Content/style.css index 5d8ab3c3a..d3ca990da 100644 --- a/NzbDrone.Web/Content/style.css +++ b/NzbDrone.Web/Content/style.css @@ -215,13 +215,13 @@ input[type="text"]:hover background: #ff6; } -.submitButton +.button { border: 1px solid #006; background: #ccf; } -.submitButton:hover +.button:hover { border: 1px solid #f00; background: #eef; diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index e999cb5f6..b14643346 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -5,7 +5,8 @@ using System.Threading; using System.Web; using System.Web.Mvc; using NLog; -using NzbDrone.Core.Providers; +using NzbDrone.Core.Providers; +using NzbDrone.Core.Repository.Quality; using NzbDrone.Web.Models; namespace NzbDrone.Web.Controllers @@ -98,9 +99,26 @@ namespace NzbDrone.Web.Controllers ViewData["viewName"] = "Quality"; var userProfiles = _qualityProvider.GetAllProfiles().Where(q => q.UserProfile).ToList(); - var profiles = _qualityProvider.GetAllProfiles().Where(q => q.UserProfile == false).ToList(); + var profiles = _qualityProvider.GetAllProfiles().ToList(); + var qualityTypes = new List(); - QualityModel model = new QualityModel {Profiles = profiles, UserProfiles = userProfiles}; + foreach (QualityTypes qual in Enum.GetValues(typeof(QualityTypes))) + { + qualityTypes.Add(qual); + } + + var defaultQualityProfileId = Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].ProfileId, true)); + + var selectList = new SelectList(profiles, "ProfileId", "Name"); + + var model = new QualityModel + { + Profiles = profiles, + UserProfiles = userProfiles, + Qualities = qualityTypes, + DefaultProfileId = defaultQualityProfileId, + SelectList = selectList + }; return View("Index", model); } @@ -264,9 +282,9 @@ namespace NzbDrone.Web.Controllers { try { - - + _configProvider.SetValue("DefaultQualityProfile", data.DefaultProfileId.ToString()); } + catch (Exception e) { Logger.ErrorException(e.Message, e); diff --git a/NzbDrone.Web/Models/QualityModel.cs b/NzbDrone.Web/Models/QualityModel.cs index 5e896f6ff..18ef5f6d4 100644 --- a/NzbDrone.Web/Models/QualityModel.cs +++ b/NzbDrone.Web/Models/QualityModel.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Web; +using System.Web.Mvc; using NzbDrone.Core.Repository.Quality; namespace NzbDrone.Web.Models @@ -10,5 +12,11 @@ namespace NzbDrone.Web.Models { public List Profiles { get; set; } public List UserProfiles { get; set; } + public List Qualities { get; set; } + + [DisplayName("Default Quality Profile")] + public int DefaultProfileId { get; set; } + + public SelectList SelectList { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/Quality.ascx b/NzbDrone.Web/Views/Settings/Quality.ascx index ce613ee65..1193ed0ff 100644 --- a/NzbDrone.Web/Views/Settings/Quality.ascx +++ b/NzbDrone.Web/Views/Settings/Quality.ascx @@ -60,32 +60,21 @@ <% using (Html.BeginForm("SaveQuality", "Settings", FormMethod.Post, new { id = "form", name = "form" })) {%> -<%: Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.") %> - - - -
-
-
-
-
-
-
-
+
+ Indexers + <%: Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.") %> +
+ <%= Html.LabelFor(m => m.DefaultProfileId) %> +
+
+ <%: Html.DropDownListFor(m => m.DefaultProfileId, Model.SelectList)%> + <%= Html.ValidationMessageFor(m => m.DefaultProfileId)%> +
+ +
+ +
<%}%>
\ No newline at end of file