mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
Adding/Deleting QualityProfiles will now save/delete the profile from the database to make the process less hacky.
RootDir and UserProfileSection do not inherit the master layout automatically.
This commit is contained in:
parent
a977443676
commit
ec8c83760b
@ -21,9 +21,9 @@ public QualityProvider(IRepository sonicRepo)
|
|||||||
_sonicRepo = sonicRepo;
|
_sonicRepo = sonicRepo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Add(QualityProfile profile)
|
public virtual int Add(QualityProfile profile)
|
||||||
{
|
{
|
||||||
_sonicRepo.Add(profile);
|
return Convert.ToInt32(_sonicRepo.Add(profile));
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Update(QualityProfile profile)
|
public virtual void Update(QualityProfile profile)
|
||||||
|
@ -94,7 +94,6 @@ public ActionResult RenderPartial(string path)
|
|||||||
"QualityProfileId",
|
"QualityProfileId",
|
||||||
"Name",
|
"Name",
|
||||||
defaultQuality);
|
defaultQuality);
|
||||||
;
|
|
||||||
|
|
||||||
return PartialView("AddSeriesItem", suggestions);
|
return PartialView("AddSeriesItem", suggestions);
|
||||||
}
|
}
|
||||||
|
@ -70,22 +70,15 @@ public ActionResult _AjaxSeasonGrid(int seasonId)
|
|||||||
var episodes = _episodeProvider.GetEpisodeBySeason(seasonId).Select(c => new EpisodeModel
|
var episodes = _episodeProvider.GetEpisodeBySeason(seasonId).Select(c => new EpisodeModel
|
||||||
{
|
{
|
||||||
EpisodeId = c.EpisodeId,
|
EpisodeId = c.EpisodeId,
|
||||||
EpisodeNumber =
|
EpisodeNumber = c.EpisodeNumber,
|
||||||
c.EpisodeNumber,
|
SeasonNumber = c.SeasonNumber,
|
||||||
SeasonNumber =
|
|
||||||
c.SeasonNumber,
|
|
||||||
Title = c.Title,
|
Title = c.Title,
|
||||||
Overview = c.Overview,
|
Overview = c.Overview,
|
||||||
AirDate = c.AirDate,
|
AirDate = c.AirDate,
|
||||||
Path =
|
Path = GetEpisodePath(c.EpisodeFile),
|
||||||
GetEpisodePath(
|
Quality = c.EpisodeFile == null
|
||||||
c.EpisodeFile),
|
|
||||||
Quality =
|
|
||||||
c.EpisodeFile == null
|
|
||||||
? String.Empty
|
? String.Empty
|
||||||
: c.EpisodeFile.
|
: c.EpisodeFile.Quality.ToString()
|
||||||
Quality.
|
|
||||||
ToString()
|
|
||||||
});
|
});
|
||||||
return View(new GridModel(episodes));
|
return View(new GridModel(episodes));
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,35 @@ public ViewResult AddUserProfile()
|
|||||||
|
|
||||||
ViewData["Qualities"] = qualityTypes;
|
ViewData["Qualities"] = qualityTypes;
|
||||||
|
|
||||||
return View("UserProfileSection", new QualityProfile { Name = "New Profile", UserProfile = true });
|
var qualityProfile = new QualityProfile
|
||||||
|
{
|
||||||
|
Name = "New Profile",
|
||||||
|
UserProfile = true,
|
||||||
|
Allowed = new List<QualityTypes> {QualityTypes.Unknown},
|
||||||
|
Cutoff = QualityTypes.Unknown,
|
||||||
|
};
|
||||||
|
|
||||||
|
var id = _qualityProvider.Add(qualityProfile);
|
||||||
|
qualityProfile.QualityProfileId = id;
|
||||||
|
qualityProfile.Allowed = null;
|
||||||
|
|
||||||
|
ViewData["ProfileId"] = id;
|
||||||
|
|
||||||
|
return View("UserProfileSection", qualityProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionResult GetQualityProfileView(QualityProfile profile)
|
||||||
|
{
|
||||||
|
var qualityTypes = new List<QualityTypes>();
|
||||||
|
|
||||||
|
foreach (QualityTypes qual in Enum.GetValues(typeof(QualityTypes)))
|
||||||
|
{
|
||||||
|
qualityTypes.Add(qual);
|
||||||
|
}
|
||||||
|
ViewData["Qualities"] = qualityTypes;
|
||||||
|
ViewData["ProfileId"] = profile.QualityProfileId;
|
||||||
|
|
||||||
|
return PartialView("UserProfileSection", profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewResult AddRootDir()
|
public ViewResult AddRootDir()
|
||||||
@ -233,6 +261,21 @@ public QualityModel GetUpdatedProfileList()
|
|||||||
return new QualityModel { DefaultQualityProfileId = defaultQualityQualityProfileId, SelectList = selectList };
|
return new QualityModel { DefaultQualityProfileId = defaultQualityQualityProfileId, SelectList = selectList };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JsonResult DeleteQualityProfile(int profileId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_qualityProvider.Delete(profileId);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return new JsonResult { Data = "failed" };
|
||||||
|
}
|
||||||
|
|
||||||
|
return new JsonResult { Data = "ok" };
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult SaveGeneral(SettingsModel data)
|
public ActionResult SaveGeneral(SettingsModel data)
|
||||||
{
|
{
|
||||||
@ -343,12 +386,6 @@ public ActionResult SaveQuality(QualityModel data)
|
|||||||
if (data.UserProfiles == null)
|
if (data.UserProfiles == null)
|
||||||
return Content(SETTINGS_SAVED);
|
return Content(SETTINGS_SAVED);
|
||||||
|
|
||||||
foreach (var dbProfile in _qualityProvider.GetAllProfiles().Where(q => q.UserProfile))
|
|
||||||
{
|
|
||||||
if (!data.UserProfiles.Exists(p => p.QualityProfileId == dbProfile.QualityProfileId))
|
|
||||||
_qualityProvider.Delete(dbProfile.QualityProfileId);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var profile in data.UserProfiles)
|
foreach (var profile in data.UserProfiles)
|
||||||
{
|
{
|
||||||
Logger.Debug(String.Format("Updating User Profile: {0}", profile));
|
Logger.Debug(String.Format("Updating User Profile: {0}", profile));
|
||||||
@ -365,14 +402,9 @@ public ActionResult SaveQuality(QualityModel data)
|
|||||||
return Content("Error Saving Settings, please fix any errors");
|
return Content("Error Saving Settings, please fix any errors");
|
||||||
//profile.Cutoff = profile.Allowed.Last();
|
//profile.Cutoff = profile.Allowed.Last();
|
||||||
|
|
||||||
if (profile.QualityProfileId > 0)
|
_qualityProvider.Update(profile);
|
||||||
_qualityProvider.Update(profile);
|
|
||||||
|
|
||||||
else
|
|
||||||
_qualityProvider.Add(profile);
|
|
||||||
|
|
||||||
return Content(SETTINGS_SAVED);
|
|
||||||
}
|
}
|
||||||
|
return Content(SETTINGS_SAVED);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Content(SETTINGS_FAILED);
|
return Content(SETTINGS_FAILED);
|
||||||
|
@ -617,7 +617,6 @@
|
|||||||
<Content Include="Views\AddSeries\AddExisting.cshtml" />
|
<Content Include="Views\AddSeries\AddExisting.cshtml" />
|
||||||
<Content Include="Views\AddSeries\AddNew.cshtml" />
|
<Content Include="Views\AddSeries\AddNew.cshtml" />
|
||||||
<None Include="Views\AddSeries\AddSeriesItem.cshtml" />
|
<None Include="Views\AddSeries\AddSeriesItem.cshtml" />
|
||||||
<Content Include="Views\Series\SeriesSearchResults2.ascx" />
|
|
||||||
<Content Include="Web.config">
|
<Content Include="Web.config">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Content>
|
</Content>
|
||||||
@ -635,8 +634,6 @@
|
|||||||
<Content Include="Scripts\MicrosoftMvcAjax.debug.js" />
|
<Content Include="Scripts\MicrosoftMvcAjax.debug.js" />
|
||||||
<Content Include="Scripts\MicrosoftMvcValidation.js" />
|
<Content Include="Scripts\MicrosoftMvcValidation.js" />
|
||||||
<Content Include="Scripts\MicrosoftMvcValidation.debug.js" />
|
<Content Include="Scripts\MicrosoftMvcValidation.debug.js" />
|
||||||
<Content Include="Views\Shared\Error.aspx" />
|
|
||||||
<Content Include="Views\Shared\Site.Master" />
|
|
||||||
<Content Include="Scripts\jquery-ui.js" />
|
<Content Include="Scripts\jquery-ui.js" />
|
||||||
<Content Include="Scripts\jquery-ui.min.js" />
|
<Content Include="Scripts\jquery-ui.min.js" />
|
||||||
<Content Include="Scripts\jquery.validate.min.js" />
|
<Content Include="Scripts\jquery.validate.min.js" />
|
||||||
@ -654,7 +651,6 @@
|
|||||||
<Content Include="Views\Settings\Quality.cshtml" />
|
<Content Include="Views\Settings\Quality.cshtml" />
|
||||||
<Content Include="Views\Settings\RootDir.cshtml" />
|
<Content Include="Views\Settings\RootDir.cshtml" />
|
||||||
<Content Include="Views\Settings\SubMenu.cshtml" />
|
<Content Include="Views\Settings\SubMenu.cshtml" />
|
||||||
<Content Include="Views\Settings\UserProfileSection.cshtml" />
|
|
||||||
<Content Include="Views\Shared\SiteLayout.cshtml" />
|
<Content Include="Views\Shared\SiteLayout.cshtml" />
|
||||||
<Content Include="Views\Shared\Footer.cshtml" />
|
<Content Include="Views\Shared\Footer.cshtml" />
|
||||||
<Content Include="Views\Settings\Index.cshtml" />
|
<Content Include="Views\Settings\Index.cshtml" />
|
||||||
@ -666,7 +662,9 @@
|
|||||||
<Content Include="Views\Series\Edit.cshtml" />
|
<Content Include="Views\Series\Edit.cshtml" />
|
||||||
<Content Include="Views\Series\Index.cshtml" />
|
<Content Include="Views\Series\Index.cshtml" />
|
||||||
<Content Include="Views\Series\SubMenu.cshtml" />
|
<Content Include="Views\Series\SubMenu.cshtml" />
|
||||||
<Content Include="Views\Series\SeriesSearchResult.cshtml" />
|
<Content Include="Views\Series\SeriesSearchResults.cshtml" />
|
||||||
|
<Content Include="Views\Shared\Error.cshtml" />
|
||||||
|
<Content Include="Views\Settings\UserProfileSection.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="App_Data\" />
|
<Folder Include="App_Data\" />
|
||||||
|
@ -49,11 +49,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="user-profiles">
|
<div id="user-profiles">
|
||||||
|
@foreach (var item in Model.UserProfiles)
|
||||||
@foreach (var item in Model.UserProfiles)
|
{
|
||||||
{
|
Html.RenderAction("GetQualityProfileView", item);
|
||||||
Html.RenderPartial("UserProfileSection", item);
|
}
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -77,8 +76,27 @@
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$("a.deleteRow").live("click", function () {
|
// $("a.deleteRow").live("click", function () {
|
||||||
$(this).parents("div.userProfileSectionEditor:first").remove();
|
// $(this).parents("div.userProfileSectionEditor:first").remove();
|
||||||
return false;
|
// return false;
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
var deleteQualityProfileUrl = '@Url.Action("DeleteQualityProfile", "Settings")';
|
||||||
|
|
||||||
|
function deleteProfile(id) {
|
||||||
|
//$(this).parents("div.userProfileSectionEditor:first").remove();
|
||||||
|
sendToServer(id);
|
||||||
|
$("#div_" + id).hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendToServer(id) {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: deleteQualityProfileUrl,
|
||||||
|
data: jQuery.param({ profileId: id }),
|
||||||
|
error: function (req, status, error) {
|
||||||
|
alert("Sorry! We could not add " + path + " at this time. " + error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
@ -1,5 +1,9 @@
|
|||||||
@model NzbDrone.Core.Repository.RootDir
|
@model NzbDrone.Core.Repository.RootDir
|
||||||
@using NzbDrone.Web.Helpers;
|
@using NzbDrone.Web.Helpers;
|
||||||
|
|
||||||
|
@{
|
||||||
|
Layout = null;
|
||||||
|
}
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
.root_dir_text
|
.root_dir_text
|
||||||
|
@ -2,10 +2,15 @@
|
|||||||
@using NzbDrone.Core.Repository.Quality
|
@using NzbDrone.Core.Repository.Quality
|
||||||
@using NzbDrone.Web.Helpers
|
@using NzbDrone.Web.Helpers
|
||||||
|
|
||||||
|
@{
|
||||||
|
Layout = null;
|
||||||
|
}
|
||||||
|
|
||||||
@using (Html.BeginCollectionItem("UserProfiles"))
|
@using (Html.BeginCollectionItem("UserProfiles"))
|
||||||
{
|
{
|
||||||
|
|
||||||
var idClean = ViewData.TemplateInfo.HtmlFieldPrefix.Replace('[', '_').Replace(']', '_');
|
var idClean = ViewData.TemplateInfo.HtmlFieldPrefix.Replace('[', '_').Replace(']', '_');
|
||||||
|
var ugly = ViewData.TemplateInfo.HtmlFieldPrefix;
|
||||||
|
|
||||||
string sortable1 = String.Format("{0}_sortable1", idClean);
|
string sortable1 = String.Format("{0}_sortable1", idClean);
|
||||||
string sortable2 = String.Format("{0}_sortable2", idClean);
|
string sortable2 = String.Format("{0}_sortable2", idClean);
|
||||||
@ -13,6 +18,7 @@
|
|||||||
string connectedSortable = String.Format("connected{0}", idClean);
|
string connectedSortable = String.Format("connected{0}", idClean);
|
||||||
string title = String.Format("{0}_Title", idClean);
|
string title = String.Format("{0}_Title", idClean);
|
||||||
string nameBox = String.Format("{0}_Name", idClean);
|
string nameBox = String.Format("{0}_Name", idClean);
|
||||||
|
string cutoff = String.Format("{0}.Cutoff", ugly);
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
.sortable1, .sortable2 { list-style-type: none; margin-right: 10px; background: #eee; padding-left: 5px; padding-right: 5px; padding-top: 0px; padding-bottom: 6px; width: 117px; margin-bottom: 3px; }
|
.sortable1, .sortable2 { list-style-type: none; margin-right: 10px; background: #eee; padding-left: 5px; padding-right: 5px; padding-top: 0px; padding-bottom: 6px; width: 117px; margin-bottom: 3px; }
|
||||||
@ -35,25 +41,32 @@
|
|||||||
|
|
||||||
create: function (event, ui) {
|
create: function (event, ui) {
|
||||||
var order = $('#@sortable1').sortable("toArray");
|
var order = $('#@sortable1').sortable("toArray");
|
||||||
$("#@allowedStringName>").val(order);
|
$("#@allowedStringName").val(order);
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function (event, ui) {
|
update: function (event, ui) {
|
||||||
var order = $('#@sortable1').sortable("toArray");
|
var order = $('#@sortable1').sortable("toArray");
|
||||||
$("#@allowedStringName").val(order);
|
$("#@allowedStringName").val(order);
|
||||||
}
|
|
||||||
|
|
||||||
|
//If this is the first QualityType added to the Profile select it as the cutoff value (in-case the user forgets)
|
||||||
|
var $list = $('#@sortable1 li');
|
||||||
|
if ($list.length == 1) {
|
||||||
|
var $radios = $('input[name="@cutoff"]');
|
||||||
|
$radios.filter('[value=' + order + ']').attr('checked', true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}).disableSelection();
|
}).disableSelection();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="userProfileSectionEditor">
|
<div class="userProfileSectionEditor" id="div_@(ViewData["ProfileId"])">
|
||||||
|
|
||||||
<fieldset style="width:285px; margin:5px; margin-top: 0px; border-color:#CCCCCD">
|
<fieldset style="width:285px; margin:5px; margin-top: 0px; border-color:#CCCCCD">
|
||||||
|
<div id="tester"></div>
|
||||||
|
|
||||||
<div id="qualityHeader" style="padding-bottom: 5px; margin: 0px;">
|
<div id="qualityHeader" style="padding-bottom: 5px; margin: 0px;">
|
||||||
<h2 style="display:inline; padding-right: 4px; margin-left: 4px;" id="@title"><@Html.DisplayTextFor(m => m.Name)</h2>
|
<h2 style="display:inline; padding-right: 4px; margin-left: 4px;" id="@title">@{Html.DisplayTextFor(m => m.Name);}</h2>
|
||||||
<a href="#" class="deleteRow"><img src="../../Content/Images/X.png" alt="Delete" /></a>
|
<a href="#" id="@Model.QualityProfileId" class="deleteRow" onclick="deleteProfile('@ViewData["ProfileId"]')"><img src="../../Content/Images/X.png" alt="Delete" /></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="config-group" style="width: 250px; margin-bottom: 5px; margin-left: 5px;">
|
<div class="config-group" style="width: 250px; margin-bottom: 5px; margin-left: 5px;">
|
||||||
@ -88,10 +101,10 @@
|
|||||||
@for (int i = 0; i < qualitiesList.Count(); i++)
|
@for (int i = 0; i < qualitiesList.Count(); i++)
|
||||||
{
|
{
|
||||||
//Skip Unknown and any item that is in the allowed list
|
//Skip Unknown and any item that is in the allowed list
|
||||||
if (qualitiesList[i].ToString() == "Unknown")
|
//if (qualitiesList[i].ToString() == "Unknown")
|
||||||
{
|
//{
|
||||||
continue;
|
// continue;
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (Model.Allowed != null)
|
if (Model.Allowed != null)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user