1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-31 07:52:37 +01:00

Merge branch 'markus' into kay.one

This commit is contained in:
kay.one 2011-11-28 22:50:26 -08:00
commit 711d729e72
12 changed files with 172 additions and 159 deletions

View File

@ -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)]

View File

@ -120,29 +120,14 @@ namespace NzbDrone.Web.Controllers
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 @@ namespace NzbDrone.Web.Controllers
Bluray1080pMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 7).MaxSize
};
ViewData["Profiles"] = profiles;
return View(model);
}
@ -197,9 +184,9 @@ namespace NzbDrone.Web.Controllers
return View(model);
}
public ActionResult EpisodeSorting()
public ActionResult Naming()
{
var model = new EpisodeSortingModel();
var model = new EpisodeNamingModel();
model.SeriesName = _configProvider.SortingIncludeSeriesName;
model.EpisodeName = _configProvider.SortingIncludeEpisodeTitle;
@ -239,17 +226,8 @@ namespace NzbDrone.Web.Controllers
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 @@ namespace NzbDrone.Web.Controllers
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 @@ namespace NzbDrone.Web.Controllers
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);
}
@ -559,7 +547,7 @@ namespace NzbDrone.Web.Controllers
}
[HttpPost]
public JsonResult SaveEpisodeSorting(EpisodeSortingModel data)
public JsonResult SaveNaming(EpisodeNamingModel data)
{
if (ModelState.IsValid)
{

View File

@ -4,7 +4,7 @@ using System.Web.Mvc;
namespace NzbDrone.Web.Models
{
public class EpisodeSortingModel
public class EpisodeNamingModel
{
[DisplayName("Series Name")]
[Description("Should filenames contain the series name when renamed?")]

View File

@ -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")]

View 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; }
}
}

View File

@ -221,7 +221,8 @@
<Compile Include="Helpers\DescriptionExtension.cs" />
<Compile Include="Helpers\HtmlPrefixScopeExtensions.cs" />
<Compile Include="Helpers\IsCurrentActionHelper.cs" />
<Compile Include="Models\CodeFile1.cs" />
<Compile Include="Models\QualityProfileModel.cs" />
<Compile Include="Models\FooterModel.cs" />
<Compile Include="Models\ExistingSeriesModel.cs" />
<Compile Include="Models\AddNewSeriesModel.cs" />
<Compile Include="Models\JobQueueItemModel.cs" />
@ -231,7 +232,7 @@
<Compile Include="Models\QualityTypeModel.cs" />
<Compile Include="Models\RootDirModel.cs" />
<Compile Include="Models\SabnzbdSettingsModel.cs" />
<Compile Include="Models\EpisodeSortingModel.cs" />
<Compile Include="Models\EpisodeNamingModel.cs" />
<Compile Include="Models\HistoryModel.cs" />
<Compile Include="Models\IndexerSettingsModel.cs" />
<Compile Include="Models\MappingModel.cs" />
@ -408,7 +409,7 @@
<Content Include="Views\Settings\Indexers.cshtml" />
<Content Include="Views\System\Jobs.cshtml" />
<Content Include="Views\Settings\Sabnzbd.cshtml" />
<Content Include="Views\Settings\EpisodeSorting.cshtml" />
<Content Include="Views\Settings\Naming.cshtml" />
<Content Include="Views\Settings\Notifications.cshtml" />
<Content Include="Views\Settings\Quality.cshtml" />
<Content Include="Views\AddSeries\RootDir.cshtml" />

View File

@ -1,5 +1,5 @@
@using NzbDrone.Web.Helpers
@model NzbDrone.Web.Models.EpisodeSortingModel
@model NzbDrone.Web.Models.EpisodeNamingModel
@section HeaderContent{
<link rel="stylesheet" type="text/css" href="../../Content/Settings.css" />
@ -7,10 +7,15 @@
<style>
#examples
{
margin-top: 25px;
margin-bottom: 15px;
margin-top: 5px;
margin-bottom: 20px;
padding-left: 20px;
}
.settingsContainer
{
overflow: auto;
}
</style>
}
@ -24,8 +29,9 @@
@section MainContent{
<div id="stylized">
@using (Html.BeginForm("SaveEpisodeSorting", "Settings", FormMethod.Post, new { id = "form", name = "form", @class = "settingsForm" }))
@using (Html.BeginForm("SaveNaming", "Settings", FormMethod.Post, new { id = "form", name = "form", @class = "settingsForm" }))
{
<div class="settingsContainer">
@Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.")
<label class="labelClass">@Html.LabelFor(m => m.SeriesName)
<span class="small">@Html.DescriptionFor(m => m.SeriesName)</span>
@ -71,10 +77,10 @@
<span class="small">@Html.DescriptionFor(m => m.MultiEpisodeStyle)</span>
</label>
@Html.DropDownListFor(m => m.MultiEpisodeStyle, Model.MultiEpisodeStyles, new { @class = "inputClass selectClass" })
</div>
<div id ="examples">
<div id="singleEpisodeExample"></div>
<div id="multiEpisodeExample"></div>
<div id="singleEpisodeExample"><b>Single Episode Example: </b><span class="result"></span></div>
<div id="multiEpisodeExample"><b>Multi-Episode Example: </b><span class="result"></span></div>
</div>
<button type="submit" id="save_button" disabled="disabled">Save</button>
@ -129,9 +135,9 @@
if ($('#ReplaceSpaces').attr('checked'))
result = result.replace(/\s/g, '.');
result = '<b>Single Episode Example: </b>' + result;
//result = '<b>Single Episode Example: </b>' + result;
$('#singleEpisodeExample').html(result);
$('#singleEpisodeExample').children('.result').text(result);
}
function createMultiEpisodeExample() {
@ -194,9 +200,9 @@
if ($('#ReplaceSpaces').attr('checked'))
result = result.replace(/\s/g, '.');
result = '<b>Multi-Episode Example: </b>' + result;
//result = '<b>Multi-Episode Example: </b>' + result;
$('#multiEpisodeExample').html(result);
$('#multiEpisodeExample').children('.result').text(result);
}
</script>
}

View File

@ -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;

View File

@ -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>

View File

@ -1,6 +1,6 @@
<ul class="sub-menu">
<li>@Html.ActionLink("Quality", "Quality", "Settings")</li>
<li>@Html.ActionLink("Naming", "EpisodeSorting", "Settings")</li>
<li>@Html.ActionLink("Naming", "Naming", "Settings")</li>
<li>@Html.ActionLink("Notifications", "Notifications", "Settings")</li>
<li>@Html.ActionLink("Indexers", "Indexers", "Settings")</li>
<li>@Html.ActionLink("SABnzbd", "Sabnzbd", "Settings")</li>

View File

@ -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>