mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-05 10:32:35 +01:00
QualityProfiles now use jQuery UI Buttons to enable/disable.
This commit is contained in:
parent
041ad20bb3
commit
2ed683159f
@ -12,23 +12,13 @@ namespace NzbDrone.Core.Repository.Quality
|
||||
public class QualityProfile
|
||||
{
|
||||
public virtual int QualityProfileId { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A Name is Required")]
|
||||
[DisplayName("Name")]
|
||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Ignore]
|
||||
[DisplayName("Allowed Qualities")]
|
||||
public List<QualityTypes> Allowed { get; set; }
|
||||
|
||||
[Ignore]
|
||||
[DisplayName("Allowed Qualities String")]
|
||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||
public string AllowedString { get; set; }
|
||||
|
||||
[DisplayName("Cut-off")]
|
||||
[Required(ErrorMessage = "Valid Cut-off is Required")]
|
||||
public QualityTypes Cutoff { get; set; }
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
|
@ -120,29 +120,14 @@ public ActionResult Sabnzbd()
|
||||
|
||||
public ActionResult Quality()
|
||||
{
|
||||
var qualityTypes = new List<QualityTypes>();
|
||||
|
||||
foreach (QualityTypes qual in Enum.GetValues(typeof(QualityTypes)))
|
||||
{
|
||||
qualityTypes.Add(qual);
|
||||
}
|
||||
|
||||
ViewData["Qualities"] = qualityTypes;
|
||||
|
||||
var profiles = _qualityProvider.All().ToList();
|
||||
|
||||
foreach (var qualityProfile in profiles)
|
||||
{
|
||||
qualityProfile.AllowedString = string.Join(",", qualityProfile.Allowed);
|
||||
}
|
||||
|
||||
var defaultQualityQualityProfileId = Convert.ToInt32(_configProvider.DefaultQualityProfile);
|
||||
var qualityProfileSelectList = new SelectList(profiles, "QualityProfileId", "Name");
|
||||
var qualityTypesFromDb = _qualityTypeProvider.All();
|
||||
|
||||
var model = new QualityModel
|
||||
{
|
||||
Profiles = profiles,
|
||||
DefaultQualityProfileId = defaultQualityQualityProfileId,
|
||||
QualityProfileSelectList = qualityProfileSelectList,
|
||||
SdtvMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 1).MaxSize,
|
||||
@ -153,6 +138,8 @@ public ActionResult Quality()
|
||||
Bluray1080pMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 7).MaxSize
|
||||
};
|
||||
|
||||
ViewData["Profiles"] = profiles;
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@ -239,17 +226,8 @@ public ActionResult System()
|
||||
return View(model);
|
||||
}
|
||||
|
||||
public ViewResult AddProfile()
|
||||
public PartialViewResult AddProfile()
|
||||
{
|
||||
var qualityTypes = new List<QualityTypes>();
|
||||
|
||||
foreach (QualityTypes qual in Enum.GetValues(typeof(QualityTypes)))
|
||||
{
|
||||
qualityTypes.Add(qual);
|
||||
}
|
||||
|
||||
ViewData["Qualities"] = qualityTypes;
|
||||
|
||||
var qualityProfile = new QualityProfile
|
||||
{
|
||||
Name = "New Profile",
|
||||
@ -257,28 +235,25 @@ public ViewResult AddProfile()
|
||||
Cutoff = QualityTypes.Unknown
|
||||
};
|
||||
|
||||
var id = _qualityProvider.Add(qualityProfile);
|
||||
qualityProfile.QualityProfileId = id;
|
||||
qualityProfile.AllowedString = "Unknown";
|
||||
qualityProfile.QualityProfileId = _qualityProvider.Add(qualityProfile);
|
||||
|
||||
ViewData["ProfileId"] = id;
|
||||
|
||||
return View("QualityProfileItem", qualityProfile);
|
||||
return GetQualityProfileView(qualityProfile);
|
||||
}
|
||||
|
||||
public ActionResult GetQualityProfileView(QualityProfile profile)
|
||||
public PartialViewResult GetQualityProfileView(QualityProfile profile)
|
||||
{
|
||||
var qualityTypes = new List<QualityTypes>();
|
||||
var model = new QualityProfileModel();
|
||||
model.QualityProfileId = profile.QualityProfileId;
|
||||
model.Name = profile.Name;
|
||||
model.Allowed = profile.Allowed;
|
||||
model.Sdtv = profile.Allowed.Contains(QualityTypes.SDTV);
|
||||
model.Dvd = profile.Allowed.Contains(QualityTypes.DVD);
|
||||
model.Hdtv = profile.Allowed.Contains(QualityTypes.HDTV);
|
||||
model.Webdl = profile.Allowed.Contains(QualityTypes.WEBDL);
|
||||
model.Bluray720p = profile.Allowed.Contains(QualityTypes.Bluray720p);
|
||||
model.Bluray1080p = profile.Allowed.Contains(QualityTypes.Bluray1080p);
|
||||
|
||||
foreach (QualityTypes qual in Enum.GetValues(typeof(QualityTypes)))
|
||||
{
|
||||
qualityTypes.Add(qual);
|
||||
}
|
||||
|
||||
ViewData["Qualities"] = qualityTypes;
|
||||
ViewData["ProfileId"] = profile.QualityProfileId;
|
||||
|
||||
return PartialView("QualityProfileItem", profile);
|
||||
return PartialView("QualityProfileItem", model);
|
||||
}
|
||||
|
||||
public JsonResult DeleteQualityProfile(int profileId)
|
||||
@ -451,25 +426,38 @@ public JsonResult SaveQuality(QualityModel data)
|
||||
if (data.Profiles == null)
|
||||
return GetSuccessResult();
|
||||
|
||||
foreach (var profile in data.Profiles)
|
||||
foreach (var profileModel in data.Profiles)
|
||||
{
|
||||
Logger.Debug(String.Format("Updating Profile: {0}", profile));
|
||||
Logger.Debug(String.Format("Updating Profile: {0}", profileModel));
|
||||
|
||||
var profile = new QualityProfile();
|
||||
profile.QualityProfileId = profileModel.QualityProfileId;
|
||||
profile.Name = profileModel.Name;
|
||||
profile.Cutoff = profileModel.Cutoff;
|
||||
|
||||
profile.Allowed = new List<QualityTypes>();
|
||||
|
||||
//Remove the extra comma from the end
|
||||
profile.AllowedString = profile.AllowedString.Trim(',');
|
||||
if (profileModel.Sdtv)
|
||||
profile.Allowed.Add(QualityTypes.SDTV);
|
||||
|
||||
foreach (var quality in profile.AllowedString.Split(','))
|
||||
{
|
||||
var qType = (QualityTypes)Enum.Parse(typeof(QualityTypes), quality);
|
||||
profile.Allowed.Add(qType);
|
||||
}
|
||||
if (profileModel.Dvd)
|
||||
profile.Allowed.Add(QualityTypes.DVD);
|
||||
|
||||
//If the Cutoff value selected is not in the allowed list then use the last allowed value, this should be validated on submit
|
||||
if (profileModel.Hdtv)
|
||||
profile.Allowed.Add(QualityTypes.HDTV);
|
||||
|
||||
if (profileModel.Webdl)
|
||||
profile.Allowed.Add(QualityTypes.WEBDL);
|
||||
|
||||
if (profileModel.Bluray720p)
|
||||
profile.Allowed.Add(QualityTypes.Bluray720p);
|
||||
|
||||
if (profileModel.Bluray1080p)
|
||||
profile.Allowed.Add(QualityTypes.Bluray1080p);
|
||||
|
||||
//If the Cutoff value selected is not in the allowed list then return an error
|
||||
if (!profile.Allowed.Contains(profile.Cutoff))
|
||||
return GetInvalidModelResult();
|
||||
//profile.Cutoff = profile.Allowed.Last();
|
||||
|
||||
_qualityProvider.Update(profile);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace NzbDrone.Web.Models
|
||||
{
|
||||
public class QualityModel
|
||||
{
|
||||
public List<QualityProfile> Profiles { get; set; }
|
||||
public List<QualityProfileModel> Profiles { get; set; }
|
||||
|
||||
[DisplayName("Default Quality Profile")]
|
||||
[Description("The default quality to use when adding series to NzbDrone")]
|
||||
|
45
NzbDrone.Web/Models/QualityProfileModel.cs
Normal file
45
NzbDrone.Web/Models/QualityProfileModel.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Web.Mvc;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Web.Models
|
||||
{
|
||||
public class QualityProfileModel
|
||||
{
|
||||
public int QualityProfileId { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A Name is Required")]
|
||||
[DisplayName("Name")]
|
||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DisplayName("Cut-off")]
|
||||
[Required(ErrorMessage = "Valid Cut-off is Required")]
|
||||
public QualityTypes Cutoff { get; set; }
|
||||
|
||||
[DisplayName("Allowed Qualities")]
|
||||
public List<QualityTypes> Allowed { get; set; }
|
||||
|
||||
//Quality Booleans
|
||||
[DisplayName("SDTV")]
|
||||
public bool Sdtv { get; set; }
|
||||
|
||||
[DisplayName("DVD")]
|
||||
public bool Dvd { get; set; }
|
||||
|
||||
[DisplayName("HDTV")]
|
||||
public bool Hdtv { get; set; }
|
||||
|
||||
[DisplayName("WEBDL")]
|
||||
public bool Webdl { get; set; }
|
||||
|
||||
[DisplayName("Bluray720p")]
|
||||
public bool Bluray720p { get; set; }
|
||||
|
||||
[DisplayName("Bluray1080p")]
|
||||
public bool Bluray1080p { get; set; }
|
||||
}
|
||||
}
|
@ -221,6 +221,7 @@
|
||||
<Compile Include="Helpers\DescriptionExtension.cs" />
|
||||
<Compile Include="Helpers\HtmlPrefixScopeExtensions.cs" />
|
||||
<Compile Include="Helpers\IsCurrentActionHelper.cs" />
|
||||
<Compile Include="Models\QualityProfileModel.cs" />
|
||||
<Compile Include="Models\FooterModel.cs" />
|
||||
<Compile Include="Models\ExistingSeriesModel.cs" />
|
||||
<Compile Include="Models\AddNewSeriesModel.cs" />
|
||||
|
@ -1,4 +1,5 @@
|
||||
@using NzbDrone.Web.Helpers;
|
||||
@using NzbDrone.Core.Repository.Quality
|
||||
@using NzbDrone.Web.Helpers;
|
||||
@model NzbDrone.Web.Models.QualityModel
|
||||
@section HeaderContent{
|
||||
<link rel="stylesheet" type="text/css" href="../../Content/Settings.css" />
|
||||
@ -73,7 +74,7 @@ Settings > Quality
|
||||
Add New Profile</a>
|
||||
</div>
|
||||
<div id="profiles">
|
||||
@foreach (var item in Model.Profiles)
|
||||
@foreach (var item in (List<QualityProfile>)ViewData["Profiles"])
|
||||
{
|
||||
Html.RenderAction("GetQualityProfileView", item);
|
||||
}
|
||||
@ -91,6 +92,12 @@ Settings > Quality
|
||||
type="text/javascript"></script>
|
||||
<script src="../../Scripts/NzbDrone/settingsForm.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var deleteQualityProfileUrl = '@Url.Action("DeleteQualityProfile", "Settings")';
|
||||
|
||||
$(document).ready(function () {
|
||||
setupSliders();
|
||||
});
|
||||
|
||||
$("#addItem").live('click', function () {
|
||||
$.ajax({
|
||||
url: this.href,
|
||||
@ -103,8 +110,6 @@ Settings > Quality
|
||||
return false;
|
||||
});
|
||||
|
||||
var deleteQualityProfileUrl = '@Url.Action("DeleteQualityProfile", "Settings")';
|
||||
|
||||
function deleteProfile(id) {
|
||||
sendToServer(id);
|
||||
}
|
||||
@ -165,34 +170,26 @@ Settings > Quality
|
||||
}).keyup();
|
||||
|
||||
$('.quality-selectee').live('click', function () {
|
||||
var profileId = getProfileId(this);
|
||||
var id = $(this).attr('id');
|
||||
var cleanId = getCleanId(this);
|
||||
var cutoff = '#' + cleanId + '_Cutoff';
|
||||
var allowedString = '#' + cleanId + '_AllowedString';
|
||||
var name = jQuery('[for="' + id + '"]').children('.ui-button-text').text();
|
||||
|
||||
//Remove 'Unknown'
|
||||
$(cutoff + ' option').each(function () { if ($(this).text().indexOf('Unknown') > -1) $(cutoff + ' option').remove(':contains("' + $(this).text() + '")'); });
|
||||
|
||||
if ($(this).hasClass('quality-selected')) {
|
||||
$(this).removeClass('quality-selected');
|
||||
var toRemove = this.firstChild.data;
|
||||
//Add option to cutoff SelectList
|
||||
if ($(this).attr('checked')) {
|
||||
$('<option>' + name + '</option>').appendTo(cutoff);
|
||||
}
|
||||
|
||||
//Remove option from cutoff SelectList
|
||||
else {
|
||||
$(cutoff + ' option').each(function () {
|
||||
if ($(this).text().indexOf(toRemove) > -1)
|
||||
if ($(this).text().indexOf(name) > -1)
|
||||
$(cutoff + ' option').remove(':contains("' + $(this).text() + '")');
|
||||
});
|
||||
}
|
||||
|
||||
else {
|
||||
$(this).addClass('quality-selected');
|
||||
$('<option>' + this.firstChild.data + '</option>').appendTo(cutoff);
|
||||
}
|
||||
|
||||
var result = "";
|
||||
$("#selectable_" + profileId + " .quality-selected").each(function () {
|
||||
result += this.firstChild.data + ",";
|
||||
});
|
||||
|
||||
$(allowedString).empty().val(result);
|
||||
});
|
||||
|
||||
var sliderOptions = {
|
||||
@ -212,10 +209,6 @@ Settings > Quality
|
||||
}
|
||||
};
|
||||
|
||||
$(document).ready(function () {
|
||||
setupSliders();
|
||||
});
|
||||
|
||||
function setupSliders() {
|
||||
$(".slider").each(function() {
|
||||
var localOptions = sliderOptions;
|
||||
|
@ -1,4 +1,4 @@
|
||||
@model NzbDrone.Core.Repository.Quality.QualityProfile
|
||||
@model NzbDrone.Web.Models.QualityProfileModel
|
||||
@using System.Collections
|
||||
@using NzbDrone.Core.Repository.Quality
|
||||
@using NzbDrone.Web.Helpers
|
||||
@ -25,29 +25,37 @@
|
||||
@Html.LabelFor(x => x.Cutoff)
|
||||
@Html.DropDownListFor(m => m.Cutoff, new SelectList(Model.Allowed, Model.Cutoff))
|
||||
</div>
|
||||
<div id = "selectable_@(Model.QualityProfileId)" class="qualitySelector">
|
||||
@{ var qualitiesList = (List<QualityTypes>) ViewData["Qualities"]; }
|
||||
@for (int i = 0; i < qualitiesList.Count(); i++)
|
||||
{
|
||||
if (qualitiesList[i].ToString() == "Unknown")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
<div class="qualitySelector">
|
||||
@Html.CheckBoxFor(m => m.Sdtv, new { @class = "quality-selectee sdtv-selector" })
|
||||
@Html.LabelFor(m => m.Sdtv)
|
||||
|
||||
if (Model.Allowed != null)
|
||||
{
|
||||
if (Model.Allowed.Contains(qualitiesList[i]))
|
||||
{
|
||||
<div class="quality-selectee quality-selected">@qualitiesList[i].ToString()</div>
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@Html.CheckBoxFor(m => m.Dvd, new { @class = "quality-selectee dvd-selector" })
|
||||
@Html.LabelFor(m => m.Dvd)
|
||||
|
||||
<div class="quality-selectee">@qualitiesList[i].ToString()</div>
|
||||
}
|
||||
@Html.CheckBoxFor(m => m.Hdtv, new { @class = "quality-selectee hdtv-selector" })
|
||||
@Html.LabelFor(m => m.Hdtv)
|
||||
|
||||
@Html.CheckBoxFor(m => m.Webdl, new { @class = "quality-selectee webdl-selector" })
|
||||
@Html.LabelFor(m => m.Webdl)
|
||||
|
||||
@Html.CheckBoxFor(m => m.Bluray720p, new { @class = "quality-selectee bluray720p-selector" })
|
||||
@Html.LabelFor(m => m.Bluray720p)
|
||||
|
||||
@Html.CheckBoxFor(m => m.Bluray1080p, new { @class = "quality-selectee bluray1080p-selector" })
|
||||
@Html.LabelFor(m => m.Bluray1080p)
|
||||
</div>
|
||||
@Html.HiddenFor(x => x.QualityProfileId, new {@class = "qualityProfileId"})
|
||||
@Html.HiddenFor(m => m.AllowedString)
|
||||
@Html.Hidden("cleanId", idClean, new {@class = "cleanId"})
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
$('.sdtv-selector').button();
|
||||
$('.dvd-selector').button();
|
||||
$('.hdtv-selector').button();
|
||||
$('.webdl-selector').button();
|
||||
$('.bluray720p-selector').button();
|
||||
$('.bluray1080p-selector').button();
|
||||
});
|
||||
</script>
|
@ -1,30 +1,12 @@
|
||||
@{ Layout = null; }
|
||||
<script>
|
||||
$(function () {
|
||||
// $(".quality-selectee").each(function() {
|
||||
// $(this).button();
|
||||
// });
|
||||
$('#test').button();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
@*Specific to each slider*@
|
||||
#seriesSearchSlider {
|
||||
right: 150px;
|
||||
}
|
||||
|
||||
.sliderContent .localSeriesLookup {
|
||||
width: 94%;
|
||||
}
|
||||
|
||||
.sliderContent {
|
||||
height: 53px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
<div id="seriesSearchSlider" class="top-slider">
|
||||
<div class="sliderContent">
|
||||
Local Series Search
|
||||
<input class="localSeriesLookup" type="text" />
|
||||
</div>
|
||||
<div class="openCloseWrapper">
|
||||
<div class="sliderButtonContainer">
|
||||
Search<div class="sliderImage sliderClosed"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="checkbox" id="test" class="quality-selectee" /><label for="shuffle">SDTV</label>
|
||||
<input type="checkbox" class="quality-selectee" /><label for="shuffle">DVD</label>
|
||||
<input type="checkbox" class="quality-selectee" /><label for="shuffle">HDTV</label>
|
Loading…
Reference in New Issue
Block a user