2011-05-18 05:39:26 +02:00
|
|
|
@using NzbDrone.Web.Helpers;
|
|
|
|
@model NzbDrone.Web.Models.QualityModel
|
2011-06-30 07:22:34 +02:00
|
|
|
|
|
|
|
@section HeaderContent{
|
|
|
|
<link rel="stylesheet" type="text/css" href="../../Content/Settings.css" />
|
2011-07-01 11:10:42 +02:00
|
|
|
<link href="../../Content/QualitySettings.css" rel="stylesheet" type="text/css" />
|
|
|
|
|
|
|
|
<script src="../../Scripts/jquery-1.6.1.js" type="text/javascript"></script>
|
|
|
|
<script type="text/javascript">
|
|
|
|
function renameOption(text, value) {
|
|
|
|
$("#DefaultQualityProfileId option[value='" + value + "']").html(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
function addOption(text, value) {
|
|
|
|
var myCombo = $('#DefaultQualityProfileId');
|
|
|
|
|
|
|
|
var exists = $("#DefaultQualityProfileId option[value='" + value + "']");
|
|
|
|
|
|
|
|
if (exists.length == 0)
|
|
|
|
myCombo.append($('\<option\> \</option\>').val(value).html(text));
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeOption(value) {
|
|
|
|
$("#DefaultQualityProfileId option[value='" + value + "']").remove();
|
|
|
|
}
|
|
|
|
</script>
|
2011-06-30 07:22:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@section TitleContent{
|
|
|
|
Settings
|
|
|
|
}
|
|
|
|
|
|
|
|
@section ActionMenu{
|
|
|
|
@{Html.RenderPartial("SubMenu");}
|
|
|
|
}
|
|
|
|
|
|
|
|
@section MainContent{
|
2011-07-01 11:10:42 +02:00
|
|
|
<div id="stylized">
|
|
|
|
@using (Html.BeginForm("SaveQuality", "Settings", FormMethod.Post, new { id = "form", name = "form" }))
|
|
|
|
{
|
|
|
|
<div id="top" class="settingsForm clearfix">
|
|
|
|
<h1>Quality</h1>
|
|
|
|
<p></p>
|
|
|
|
<label class="labelClass">@Html.LabelFor(m => m.DefaultQualityProfileId)
|
|
|
|
<span class="small">@Html.DescriptionFor(m => m.DefaultQualityProfileId)</span>
|
|
|
|
</label>
|
|
|
|
@Html.DropDownListFor(m => m.DefaultQualityProfileId, Model.QualityProfileSelectList, new { @class = "inputClass" })
|
2011-06-28 04:24:42 +02:00
|
|
|
</div>
|
2011-07-01 11:10:42 +02:00
|
|
|
|
|
|
|
<div id="bottom" class="clearfix">
|
|
|
|
<div id="profileContainer">
|
|
|
|
<div id="profileHeader">
|
|
|
|
<a id="addItem" href="@Url.Action("AddProfile", "Settings")">
|
|
|
|
<img src="../../Content/Images/Plus.png" alt="Add New Profile" width="20px" height="20px" /> Add New Profile</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="profiles" class="clearfix">
|
|
|
|
@foreach (var item in Model.Profiles)
|
|
|
|
{
|
|
|
|
Html.RenderAction("GetQualityProfileView", item);
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button type="submit" id="save_button" >Save</button><img src="../../Content/Images/ajax-loader.gif" alt="Loader" id="saveAjax"/>
|
2011-06-28 04:24:42 +02:00
|
|
|
</div>
|
2011-07-01 11:10:42 +02:00
|
|
|
|
|
|
|
}
|
2011-06-28 04:24:42 +02:00
|
|
|
</div>
|
2011-07-01 11:10:42 +02:00
|
|
|
|
|
|
|
<div id="result" class="hiddenResult"></div>
|
2011-06-30 07:22:34 +02:00
|
|
|
}
|
2011-05-18 05:39:26 +02:00
|
|
|
|
2011-06-30 07:22:34 +02:00
|
|
|
@section Scripts{
|
|
|
|
<script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
|
|
|
|
<script src="/Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
|
2011-05-18 05:39:26 +02:00
|
|
|
|
2011-06-30 07:22:34 +02:00
|
|
|
<script type="text/javascript">
|
2011-06-28 04:24:42 +02:00
|
|
|
$("#addItem").click(function () {
|
|
|
|
$.ajax({
|
|
|
|
url: this.href,
|
|
|
|
cache: false,
|
|
|
|
success: function (html) {
|
|
|
|
$("#profiles").append(html);
|
2011-02-05 19:27:14 +01:00
|
|
|
|
2011-06-28 04:24:42 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
2011-02-05 19:27:14 +01:00
|
|
|
});
|
2011-04-22 02:30:19 +02:00
|
|
|
|
2011-06-28 04:24:42 +02:00
|
|
|
var deleteQualityProfileUrl = '@Url.Action("DeleteQualityProfile", "Settings")';
|
|
|
|
|
|
|
|
function deleteProfile(id) {
|
|
|
|
sendToServer(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
function sendToServer(id) {
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: deleteQualityProfileUrl,
|
|
|
|
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") {
|
|
|
|
$("#profile_" + id).remove();
|
|
|
|
removeOption(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
alert(data);
|
|
|
|
}
|
2011-05-29 06:07:11 +02:00
|
|
|
}
|
2011-06-28 04:24:42 +02:00
|
|
|
});
|
|
|
|
}
|
2011-06-30 07:22:34 +02:00
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
var options = {
|
|
|
|
target: '#result',
|
|
|
|
beforeSubmit: showRequest,
|
|
|
|
success: showResponse,
|
|
|
|
type: 'post',
|
|
|
|
resetForm: false
|
|
|
|
};
|
|
|
|
$('#form').ajaxForm(options);
|
|
|
|
});
|
|
|
|
|
|
|
|
function showRequest(formData, jqForm, options) {
|
|
|
|
$("#result").empty().html('Saving...');
|
|
|
|
$("#form :input").attr("disabled", true);
|
|
|
|
$('#saveAjax').show();
|
|
|
|
}
|
|
|
|
|
|
|
|
function showResponse(responseText, statusText, xhr, $form) {
|
|
|
|
$("#result").empty().html(responseText);
|
|
|
|
$("#form :input").attr("disabled", false);
|
|
|
|
$('#saveAjax').hide();
|
|
|
|
}
|
2011-07-01 11:10:42 +02:00
|
|
|
|
|
|
|
function getProfileId(obj) {
|
|
|
|
var parentProfileSection = $(obj).parents('.profileSection');
|
|
|
|
return parentProfileSection.children('.qualityProfileId').val();
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCleanId(obj) {
|
|
|
|
var parentProfileSection = $(obj).parents('.profileSection');
|
|
|
|
return parentProfileSection.children('.cleanId').val();
|
|
|
|
}
|
|
|
|
|
|
|
|
$(".profileName_textbox").live('keyup', function () {
|
|
|
|
var value = $(this).val();
|
|
|
|
var profileId = getProfileId(this);
|
|
|
|
$("#title_" + profileId).text(value);
|
|
|
|
renameOption(value, profileId);
|
|
|
|
}).keyup();
|
|
|
|
|
|
|
|
$('.quality-selectee').live('click', function () {
|
|
|
|
var profileId = getProfileId(this);
|
|
|
|
var cleanId = getCleanId(this);
|
|
|
|
var cutoff = '#' + cleanId + '_Cutoff';
|
|
|
|
var allowedString = '#' + cleanId + '_AllowedString';
|
|
|
|
|
|
|
|
$(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;
|
|
|
|
|
|
|
|
$(cutoff + ' option').each(function () {
|
|
|
|
if ($(this).text().indexOf(toRemove) > -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);
|
|
|
|
});
|
2011-06-28 04:24:42 +02:00
|
|
|
</script>
|
|
|
|
}
|