EpisodeSorting setup, setting page created and usable, needs labels still.

pull/4/head
markus101 14 years ago
parent 165beda55b
commit 46830a2777

@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Model;
namespace NzbDrone.Core
{
public static class EpisodeSortingHelper
{
private static readonly List<EpisodeSortingType> SeparatorStyles = new List<EpisodeSortingType>
{
new EpisodeSortingType {Id = 0, Name = "Dash", Pattern = " - "},
new EpisodeSortingType {Id = 1, Name = "Space", Pattern = " "}
};
private static readonly List<EpisodeSortingType> NumberStyles = new List<EpisodeSortingType>
{
new EpisodeSortingType { Id = 0, Name = "1x05", Pattern = "%sx%0e"},
new EpisodeSortingType { Id = 1, Name = "01x05", Pattern = "%0sx%0e"},
new EpisodeSortingType { Id = 2, Name = "S01E05", Pattern = "S%0sE%0e"},
new EpisodeSortingType { Id = 3, Name = "s01e05", Pattern = "s%0se%0e"}
};
private static readonly List<EpisodeSortingType> MultiEpisodeStyles = new List<EpisodeSortingType>
{
new EpisodeSortingType { Id = 0, Name = "Extend", Pattern = "" },
new EpisodeSortingType { Id = 1, Name = "Duplicate", Pattern = "" },
new EpisodeSortingType { Id = 2, Name = "Repeat", Pattern = "" }
};
public static List<EpisodeSortingType> GetSeparatorStyles()
{
return SeparatorStyles;
}
public static List<EpisodeSortingType> GetNumberStyles()
{
return NumberStyles;
}
public static List<EpisodeSortingType> GetMultiEpisodeStyles()
{
return MultiEpisodeStyles;
}
public static EpisodeSortingType GetSeparatorStyle(int id)
{
return SeparatorStyles.Single(s => s.Id == id);
}
public static EpisodeSortingType GetNumberStyle(int id)
{
return NumberStyles.Single(s => s.Id == id);
}
public static EpisodeSortingType GetMultiEpisodeStyle(int id)
{
return MultiEpisodeStyles.Single(s => s.Id == id);
}
public static EpisodeSortingType GetSeparatorStyle(string name)
{
return SeparatorStyles.Single(s => s.Name == name);
}
public static EpisodeSortingType GetNumberStyle(string name)
{
return NumberStyles.Single(s => s.Name == name);
}
public static EpisodeSortingType GetMultiEpisodeStyle(string name)
{
return MultiEpisodeStyles.Single(s => s.Name == name);
}
}
}

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
{
public class EpisodeSortingType
{
public int Id { get; set; }
public string Name { get; set; }
public string Pattern { get; set; }
}
}

@ -156,6 +156,7 @@
<Reference Include="UPnP, Version=1.0.3932.37442, Culture=neutral, processorArchitecture=MSIL" />
</ItemGroup>
<ItemGroup>
<Compile Include="EpisodeSortingHelper.cs" />
<Compile Include="Instrumentation\ILogProvider.cs" />
<Compile Include="Instrumentation\LogLevel.cs" />
<Compile Include="Instrumentation\LogProvider.cs" />
@ -165,6 +166,7 @@
<Compile Include="Model\EpisodeParseResult.cs" />
<Compile Include="Model\EpisodeModel.cs" />
<Compile Include="Model\EpisodeRenameModel.cs" />
<Compile Include="Model\EpisodeSortingType.cs" />
<Compile Include="Model\EpisodeStatusType.cs" />
<Compile Include="Model\FeedInfoModel.cs" />
<Compile Include="Model\NzbInfoModel.cs" />

@ -208,7 +208,7 @@ namespace NzbDrone.Core.Providers
private string GetSeasonFolder(int seasonNumber)
{
return
_configProvider.GetValue("SeasonFolder", "Season %s", true).Replace("%s", seasonNumber.ToString()).
_configProvider.GetValue("Sorting_SeasonFolderFormat", "Season %s", true).Replace("%s", seasonNumber.ToString()).
Replace("%0s", seasonNumber.ToString("00"));
}
}

@ -113,7 +113,7 @@ namespace NzbDrone.Core.Providers
repoSeries.QualityProfileId = Convert.ToInt32(_config.GetValue("DefaultQualityProfile", "1", true));
repoSeries.SeasonFolder = true;
if (!Convert.ToBoolean(_config.GetValue("SeasonFolder", true, true)))
if (!Convert.ToBoolean(_config.GetValue("Sorting_SeasonFolder", true, true)))
repoSeries.SeasonFolder = false;
_sonioRepo.Add(repoSeries);

@ -5,6 +5,7 @@ using System.Threading;
using System.Web;
using System.Web.Mvc;
using NLog;
using NzbDrone.Core;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository.Quality;
@ -120,6 +121,30 @@ namespace NzbDrone.Web.Controllers
return View("Index", model);
}
public ActionResult EpisodeSorting()
{
ViewData["viewName"] = "EpisodeSorting";
var model = new EpisodeSortingModel();
model.ShowName = Convert.ToBoolean(_configProvider.GetValue("Sorting_ShowName", true, true));
model.EpisodeName = Convert.ToBoolean(_configProvider.GetValue("Sorting_EpisodeName", true, true));
model.ReplaceSpaces = Convert.ToBoolean(_configProvider.GetValue("Sorting_ReplaceSpaces", false, true));
model.AppendQuality = Convert.ToBoolean(_configProvider.GetValue("Sorting_AppendQuality", false, true));
model.UseAirByDate = Convert.ToBoolean(_configProvider.GetValue("Sorting_UseAirByDate", true, true));
model.SeasonFolders = Convert.ToBoolean(_configProvider.GetValue("Sorting_SeasonFolder", true, true));
model.SeasonFolderFormat = _configProvider.GetValue("Sorting_SeasonFolderFormat", "Season %s", true);
model.SeparatorStyle = Convert.ToInt32(_configProvider.GetValue("Sorting_SeparatorStyle", 0, true));
model.NumberStyle = Convert.ToInt32(_configProvider.GetValue("Sorting_NumberStyle", 2, true));
model.MultiEpisodeStyle = Convert.ToInt32(_configProvider.GetValue("Sorting_MultiEpisodeStyle", 0, true));
model.SeparatorStyles = new SelectList(EpisodeSortingHelper.GetSeparatorStyles(), "Id", "Name");
model.NumberStyles = new SelectList(EpisodeSortingHelper.GetNumberStyles(), "Id", "Name");
model.MultiEpisodeStyles = new SelectList(EpisodeSortingHelper.GetMultiEpisodeStyles(), "Id", "Name");
return View("Index", model);
}
public ViewResult AddUserProfile()
{
var qualityTypes = new List<QualityTypes>();
@ -249,5 +274,27 @@ namespace NzbDrone.Web.Controllers
return Content(_settingsFailed);
}
[HttpPost]
public ActionResult SaveEpisodeSorting(EpisodeSortingModel data)
{
if (ModelState.IsValid)
{
_configProvider.SetValue("Sorting_ShowName", data.ShowName.ToString());
_configProvider.SetValue("Sorting_EpisodeName", data.EpisodeName.ToString());
_configProvider.SetValue("Sorting_ReplaceSpaces", data.ReplaceSpaces.ToString());
_configProvider.SetValue("Sorting_AppendQuality", data.AppendQuality.ToString());
_configProvider.SetValue("Sorting_UseAirByDate", data.UseAirByDate.ToString());
_configProvider.SetValue("Sorting_SeasonFolder", data.SeasonFolders.ToString());
_configProvider.SetValue("Sorting_SeasonFolderFormat", data.SeasonFolderFormat);
_configProvider.SetValue("Sorting_SeparatorStyle", data.SeparatorStyle.ToString());
_configProvider.SetValue("Sorting_NumberStyle", data.NumberStyle.ToString());
_configProvider.SetValue("Sorting_MultiEpisodeStyle", data.MultiEpisodeStyle.ToString());
return Content(_settingsSaved);
}
return Content(_settingsFailed);
}
}
}

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Model;
namespace NzbDrone.Web.Models
{
public class EpisodeSortingModel
{
public bool ShowName { get; set; }
public bool EpisodeName { get; set; }
public bool ReplaceSpaces { get; set; }
public bool AppendQuality { get; set; }
public bool UseAirByDate { get; set; }
public bool SeasonFolders { get; set; }
public string SeasonFolderFormat { get; set; }
public int SeparatorStyle { get; set; }
public int NumberStyle { get; set; }
public int MultiEpisodeStyle { get; set; }
public SelectList SeparatorStyles { get; set; }
public SelectList NumberStyles { get; set; }
public SelectList MultiEpisodeStyles { get; set; }
}
}

@ -86,6 +86,7 @@
<Compile Include="Helpers\IsCurrentActionHelper.cs" />
<Compile Include="Models\AccountModels.cs" />
<Compile Include="Models\DownloadSettingsModel.cs" />
<Compile Include="Models\EpisodeSortingModel.cs" />
<Compile Include="Models\IndexerSettingsModel.cs" />
<Compile Include="Models\MappingModel.cs" />
<Compile Include="Models\EpisodeModel.cs" />
@ -272,6 +273,7 @@
<Content Include="Views\Series\index.aspx" />
<Content Include="Views\Series\Unmapped.aspx" />
<Content Include="Views\Settings\Downloads.ascx" />
<Content Include="Views\Settings\EpisodeSorting.ascx" />
<Content Include="Views\Settings\General.ascx" />
<Content Include="Views\Settings\Index.aspx" />
<Content Include="Views\Settings\Indexers.ascx" />

@ -57,6 +57,14 @@
<%: Html.CheckBoxFor(model => model.Monitored) %>
<%: Html.ValidationMessageFor(model => model.Monitored) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.SeasonFolder) %>
</div>
<div class="editor-field">
<%: Html.CheckBoxFor(model => model.SeasonFolder)%>
<%: Html.ValidationMessageFor(model => model.SeasonFolder)%>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.QualityProfileId) %>

@ -0,0 +1,126 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NzbDrone.Web.Models.EpisodeSortingModel>" %>
<script type="text/javascript">
$(document).ready(function () {
var options = {
target: '#result',
beforeSubmit: showRequest,
success: showResponse,
type: 'post',
resetForm: false
};
$('#form').ajaxForm(options);
$('#save_button').attr('disabled', '');
});
function showRequest(formData, jqForm, options) {
$("#result").empty().html('Saving...');
$("#form :input").attr("disabled", true);
}
function showResponse(responseText, statusText, xhr, $form) {
$("#result").empty().html(responseText);
$("#form :input").attr("disabled", false);
}
</script>
<% Html.EnableClientValidation(); %>
<% using (Html.BeginForm("SaveEpisodeSorting", "Settings", FormMethod.Post, new { id = "form", name = "form" }))
{%>
<%--<%: Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.") %>--%>
<fieldset>
<legend>Episode Sorting</legend>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.ShowName)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.ShowName)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.ShowName)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.EpisodeName)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.EpisodeName)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.EpisodeName)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.ReplaceSpaces)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.ReplaceSpaces)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.ReplaceSpaces)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.AppendQuality)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.AppendQuality)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.AppendQuality)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.UseAirByDate)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.UseAirByDate)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.UseAirByDate)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.SeasonFolders)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.SeasonFolders)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.SeasonFolders)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.SeasonFolderFormat)%></div>
<div class="config-value"><%= Html.TextBoxFor(m => m.SeasonFolderFormat)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.SeasonFolderFormat)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.SeparatorStyle) %></div>
<div class="config-value"><%= Html.DropDownListFor(m => m.SeparatorStyle, Model.SeparatorStyles)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.SeparatorStyle)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.NumberStyle) %></div>
<div class="config-value"><%= Html.DropDownListFor(m => m.NumberStyle, Model.NumberStyles)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.NumberStyle)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.MultiEpisodeStyle) %></div>
<div class="config-value"><%= Html.DropDownListFor(m => m.MultiEpisodeStyle, Model.MultiEpisodeStyles)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.MultiEpisodeStyle)%></div>
</div>
<input type="submit" id="save_button" value="Save" disabled="disabled" />
<% } %>
</fieldset>
<div id="result"></div>

@ -3,11 +3,14 @@
<%@ Import Namespace="Telerik.Web.Mvc.UI" %>
<%
Html.Telerik().Menu().Name("Menu").Items(items => {items.Add().Text("General").Action("General", "Settings"); })
.Items(items => items.Add().Text("Indexers").Action("Indexers", "Settings"))
.Items(items => items.Add().Text("Downloads").Action("Downloads", "Settings"))
.Items(items => items.Add().Text("Quality").Action("Quality", "Settings"))
.Render();
Html.Telerik().Menu().Name("Menu").Items(items =>
{
items.Add().Text("General").Action("General", "Settings");
items.Add().Text("Indexers").Action("Indexers", "Settings");
items.Add().Text("Downloads").Action("Downloads", "Settings");
items.Add().Text("Quality").Action("Quality", "Settings");
items.Add().Text("Episode Sorting").Action("EpisodeSorting", "Settings");
}).Render();
%>
Loading…
Cancel
Save