New UI for Indexer Settings, RAZOR!

Renamed NzbMatrix and NzbsRUs Providers
This commit is contained in:
Mark McDowall 2011-04-19 16:46:21 -07:00
parent 0241e80c8a
commit c6ef828429
12 changed files with 324 additions and 174 deletions

View File

@ -140,6 +140,9 @@ namespace NzbDrone.Core
private static void BindIndexers()
{
_kernel.Bind<IndexerProviderBase>().To<NzbsOrgProvider>().InSingletonScope();
_kernel.Bind<IndexerProviderBase>().To<NzbMatrixProvider>().InSingletonScope();
_kernel.Bind<IndexerProviderBase>().To<NzbsRUsProvider>().InSingletonScope();
_kernel.Bind<IndexerProviderBase>().To<NewzbinProvider>().InSingletonScope();
var indexers = _kernel.GetAll<IndexerProviderBase>();
_kernel.Get<IndexerProvider>().InitializeIndexers(indexers.ToList());
}

View File

@ -169,8 +169,9 @@
<Compile Include="Instrumentation\SubsonicTarget.cs" />
<Compile Include="Instrumentation\ExceptioneerTarget.cs" />
<Compile Include="Instrumentation\NlogWriter.cs" />
<Compile Include="Providers\Indexer\NzbMatrixFeedProvider.cs" />
<Compile Include="Providers\Indexer\NzbsRUsFeedProvider.cs" />
<Compile Include="Providers\Indexer\NzbMatrixProvider.cs" />
<Compile Include="Providers\Indexer\NewzbinProvider.cs" />
<Compile Include="Providers\Indexer\NzbsRUsProvider.cs" />
<Compile Include="Repository\IndexerSetting.cs" />
<Compile Include="Model\EpisodeParseResult.cs" />
<Compile Include="Model\EpisodeRenameModel.cs" />

View File

@ -26,7 +26,6 @@ namespace NzbDrone.Core.Providers.Core
set { SetValue("ApiKey", value); }
}
public virtual String EpisodeNameFormat
{
get { return GetValue("EpisodeNameFormat"); }
@ -83,6 +82,20 @@ namespace NzbDrone.Core.Providers.Core
set { SetValue("NzbsrusHash", value); }
}
public virtual String NewzbinUsername
{
get { return GetValue("NewzbinUsername"); }
set { SetValue("NewzbinUsername", value); }
}
public virtual String NewzbinPassword
{
get { return GetValue("NewzbinPassword"); }
set { SetValue("NewzbinPassword", value); }
}
public virtual String SyncFrequency
{
get { return GetValue("SyncFrequency"); }

View File

@ -0,0 +1,36 @@
using System.ServiceModel.Syndication;
using NzbDrone.Core.Providers.Core;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers.Indexer
{
public class NewzbinProvider : IndexerProviderBase
{
public NewzbinProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider, IRepository repository, IndexerProvider indexerProvider)
: base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider, repository, indexerProvider)
{
}
protected override string[] Url
{
get
{
return new[]
{
string.Format("http://www.newzbin.com", _configProvider.NewzbinUsername, _configProvider.NewzbinPassword)
};
}
}
public override string Name
{
get { return "Newzbin"; }
}
protected override string NzbDownloadUrl(SyndicationItem item)
{
return item.Id;
}
}
}

View File

@ -4,9 +4,9 @@ using SubSonic.Repository;
namespace NzbDrone.Core.Providers.Indexer
{
internal class NzbMatrixFeedProvider : IndexerProviderBase
public class NzbMatrixProvider : IndexerProviderBase
{
public NzbMatrixFeedProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider, IRepository repository, IndexerProvider indexerProvider)
public NzbMatrixProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider, IRepository repository, IndexerProvider indexerProvider)
: base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider, repository, indexerProvider)
{
}

View File

@ -4,9 +4,9 @@ using SubSonic.Repository;
namespace NzbDrone.Core.Providers.Indexer
{
internal class NzbsRUsFeedProvider : IndexerProviderBase
public class NzbsRUsProvider : IndexerProviderBase
{
public NzbsRUsFeedProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider, IRepository repository, IndexerProvider indexerProvider)
public NzbsRUsProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider, IRepository repository, IndexerProvider indexerProvider)
: base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider, repository, indexerProvider)
{
}

View File

@ -75,7 +75,5 @@ namespace NzbDrone.Core.Providers
}
}
}
}
}

View File

@ -58,6 +58,7 @@ namespace NzbDrone.Web.Controllers
public ActionResult Indexers()
{
ViewData["viewName"] = "Indexers";
return View("Index", new IndexerSettingsModel
{
NzbMatrixUsername =
@ -71,8 +72,13 @@ namespace NzbDrone.Web.Controllers
NzbsOrgHash = _configProvider.NzbsrusHash,
NzbsOrgUId = _configProvider.NzbsrusUId,
Indexers = _indexerProvider.AllIndexers()
NewzbinUsername = _configProvider.NewzbinUsername,
NewzbinPassword = _configProvider.NewzbinPassword,
NzbsOrgEnabled = _indexerProvider.GetSettings(typeof(NzbsOrgProvider)).Enable,
NzbMatrixEnabled = _indexerProvider.GetSettings(typeof(NzbMatrixProvider)).Enable,
NzbsRUsEnabled = _indexerProvider.GetSettings(typeof(NzbsRUsProvider)).Enable,
NewzbinEnabled = _indexerProvider.GetSettings(typeof(NewzbinProvider)).Enable
});
}
@ -268,22 +274,33 @@ namespace NzbDrone.Web.Controllers
{
if (ModelState.IsValid)
{
foreach (var indexer in data.Indexers)
{
var setting =_indexerProvider.GetSettings(indexer.Id);
setting.Enable = indexer.Enable;
_indexerProvider.SaveSettings(setting);
}
_configProvider.NzbMatrixUsername = data.NzbMatrixUsername;
_configProvider.NzbMatrixApiKey = data.NzbMatrixApiKey;
_configProvider.NzbsrusUId = data.NzbsrusUId;
_configProvider.NzbsrusHash = data.NzbsrusHash;
var nzbsOrgSettings = _indexerProvider.GetSettings(typeof(NzbsOrgProvider));
nzbsOrgSettings.Enable = data.NzbsOrgEnabled;
_indexerProvider.SaveSettings(nzbsOrgSettings);
var nzbMatrixSettings = _indexerProvider.GetSettings(typeof(NzbMatrixProvider));
nzbMatrixSettings.Enable = data.NzbMatrixEnabled;
_indexerProvider.SaveSettings(nzbMatrixSettings);
var nzbsRUsSettings = _indexerProvider.GetSettings(typeof(NzbsRUsProvider));
nzbsRUsSettings.Enable = data.NzbsRUsEnabled;
_indexerProvider.SaveSettings(nzbsRUsSettings);
var newzbinSettings = _indexerProvider.GetSettings(typeof(NewzbinProvider));
newzbinSettings.Enable = data.NewzbinEnabled;
_indexerProvider.SaveSettings(newzbinSettings);
_configProvider.NzbsrusHash = data.NzbsOrgHash;
_configProvider.NzbsOrgUId = data.NzbsOrgUId;
_configProvider.NzbMatrixUsername = data.NzbMatrixUsername;
_configProvider.NzbMatrixApiKey = data.NzbMatrixApiKey;
_configProvider.NzbsrusUId = data.NzbsrusUId;
_configProvider.NzbsOrgUId = data.NzbsrusHash;
_configProvider.NewzbinUsername = data.NewzbinUsername;
_configProvider.NewzbinPassword = data.NewzbinPassword;
return Content(SETTINGS_SAVED);
}

View File

@ -9,35 +9,55 @@ namespace NzbDrone.Web.Models
public class IndexerSettingsModel
{
[DataType(DataType.Text)]
[DisplayName("NZBMatrix Username")]
[DisplayName("Username")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbMatrixUsername { get; set; }
[DataType(DataType.Text)]
[DisplayName("NZBMatrix API Key")]
[DisplayName("API Key")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbMatrixApiKey { get; set; }
[DataType(DataType.Text)]
[DisplayName("NZBs.Org UID")]
[DisplayName("UID")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsOrgUId { get; set; }
[DataType(DataType.Text)]
[DisplayName("NZBs.Org Hash")]
[DisplayName("Hash")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsOrgHash { get; set; }
[DataType(DataType.Text)]
[DisplayName("NZBsRus UID")]
[DisplayName("UID")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsrusUId { get; set; }
[DataType(DataType.Text)]
[DisplayName("NZBsRus Hash")]
[DisplayName("Hash")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsrusHash { get; set; }
public List<IndexerSetting> Indexers { get; set; }
[DataType(DataType.Text)]
[DisplayName("Username")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NewzbinUsername { get; set; }
[DataType(DataType.Text)]
[DisplayName("Password")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NewzbinPassword { get; set; }
[DisplayName("NZBs.org")]
public bool NzbsOrgEnabled { get; set; }
[DisplayName("NZB Matrix")]
public bool NzbMatrixEnabled { get; set; }
[DisplayName("NZBsRUs")]
public bool NzbsRUsEnabled { get; set; }
[DisplayName("Newzbin")]
public bool NewzbinEnabled { get; set; }
}
}

View File

@ -628,7 +628,6 @@
<Content Include="Views\Settings\EpisodeSorting.ascx" />
<Content Include="Views\Settings\General.ascx" />
<Content Include="Views\Settings\Index.aspx" />
<Content Include="Views\Settings\Indexers.ascx" />
<Content Include="Views\Settings\Quality.ascx" />
<Content Include="Views\Settings\SubMenu.ascx" />
<Content Include="Views\Settings\UserProfileSection.ascx" />
@ -661,6 +660,7 @@
<Content Include="Scripts\jquery.validate.unobtrusive.js" />
<Content Include="Scripts\jquery.validate.unobtrusive.min.js" />
<Content Include="Views\Web.config" />
<Content Include="Views\Settings\Indexers.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
@ -812,15 +812,6 @@
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>21704</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost/NzbDrone</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>http://localhost:8989</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
<SaveServerSettingsInUserFile>True</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>

View File

@ -1,135 +0,0 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NzbDrone.Web.Models.IndexerSettingsModel>" %>
<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>
<style type="text/css">
#sortable
{
list-style-type: none;
margin: 0;
padding: 0;
width: 30%;
}
#sortable li
{
margin: 0 5px 5px 5px;
padding: 5px;
font-size: 1.2em;
height: 1.5em;
}
#sortable li
{
height: 1.5em;
line-height: 1.2em;
}
.ui-state-highlight
{
height: 1.5em;
line-height: 1.2em;
}
</style>
<script type="text/javascript">
$(function () {
$("#sortable").sortable({
placeholder: "ui-state-highlight"
});
$("#sortable").disableSelection();
});
</script>
<%
using (Html.BeginForm("SaveIndexers", "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>Indexers</legend>
<ul id="sortable">
<%
for (int i = 0; i < Model.Indexers.Count(); i++)
{%>
<li class="ui-state-default" id="<%=Model.Indexers[i].Id%>">
<%=Html.CheckBoxFor(c => c.Indexers[i].Enable)%><%=Html.DisplayTextFor(c => c.Indexers[i].Name)%></li>
<%
}%>
</ul>
<%
for (int i = 0; i < Model.Indexers.Count(); i++)
{%>
<%
}%>
<%--NZBMatrix--%>
<div class="editor-label">
<%=Html.LabelFor(m => m.NzbMatrixUsername)%>
</div>
<div class="editor-field">
<%=Html.TextBoxFor(m => m.NzbMatrixUsername)%>
<%=Html.ValidationMessageFor(m => m.NzbMatrixUsername)%>
</div>
<div class="editor-label">
<%=Html.LabelFor(m => m.NzbMatrixApiKey)%>
</div>
<div class="editor-field">
<%=Html.TextBoxFor(m => m.NzbMatrixApiKey)%>
<%=Html.ValidationMessageFor(m => m.NzbMatrixApiKey)%>
</div>
<br />
<%--NZBs.Org--%>
<div class="editor-label">
<%=Html.LabelFor(m => m.NzbsOrgUId)%>
</div>
<div class="editor-field">
<%=Html.TextBoxFor(m => m.NzbsOrgUId)%>
<%=Html.ValidationMessageFor(m => m.NzbsOrgUId)%>
</div>
<div class="editor-label">
<%=Html.LabelFor(m => m.NzbsOrgHash)%>
</div>
<div class="editor-field">
<%=Html.TextBoxFor(m => m.NzbsOrgHash)%>
<%=Html.ValidationMessageFor(m => m.NzbsOrgHash)%>
</div>
<br />
<%--NZBsrus--%>
<div class="editor-label">
<%=Html.LabelFor(m => m.NzbsrusUId)%>
</div>
<div class="editor-field">
<%=Html.TextBoxFor(m => m.NzbsrusUId)%>
<%=Html.ValidationMessageFor(m => m.NzbsrusUId)%>
</div>
<div class="editor-label">
<%=Html.LabelFor(m => m.NzbsrusHash)%>
</div>
<div class="editor-field">
<%=Html.TextBoxFor(m => m.NzbsrusHash)%>
<%=Html.ValidationMessageFor(m => m.NzbsrusHash)%>
</div>
<br />
<input type="submit" id="save_button" value="Save" disabled="disabled" />
</fieldset>
<%
}%>
<div id="result">
</div>

View File

@ -0,0 +1,206 @@
@model NzbDrone.Web.Models.IndexerSettingsModel
<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>
<style>
.section_content
{
padding-left: 15px;
}
.indexer_group
{
width: 220px;
}
.indexer_left
{
display: inline;
}
.indexer_right
{
display:inline;
float: right;
}
.indexer_checkbox
{
margin-right: 135px;
}
</style>
@using (Html.BeginForm("SaveIndexers", "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>Indexers</legend>
<div>
@{ Html.Telerik().PanelBar()
.Name("PanelBar")
.HtmlAttributes(new { style = "width: 300px; float: left; margin-bottom: 30px;" })
.ExpandMode(PanelBarExpandMode.Single)
.SelectedIndex(0)
.Items(item =>
{
item.Add()
.Text("NZBs.org")
.Content(
"<div class=\"section_content\">" +
"<div class=\"indexer_group\">" +
"<div class=\"indexer_left\">" +
"Enabled" +
"</div>" +
"<div class=\"indexer_right\">" +
Html.CheckBoxFor(m => m.NzbsOrgEnabled, new { @class = "indexer_checkbox" }) +
"</div>" +
"</div>" +
"<div class=\"indexer_group\">" +
"<div class=\"indexer_left\">" +
Html.LabelFor(m => m.NzbsOrgUId) +
"</div>" +
"<div class=\"indexer_right\">" +
Html.TextBoxFor(m => m.NzbsOrgUId) +
"</div>" +
"</div>" +
"<div class=\"indexer_group\">" +
"<div class=\"indexer_left\">" +
Html.LabelFor(m => m.NzbsOrgHash) +
"</div>" +
"<div class=\"indexer_right\">" +
Html.TextBoxFor(m => m.NzbsOrgHash) +
"</div>" +
"</div>" +
"</div>"
);
item.Add()
.Text("NZB Matrix")
.Content(
"<div class=\"section_content\">" +
"<div class=\"indexer_group\">" +
"<div class=\"indexer_left\">" +
"Enabled" +
"</div>" +
"<div class=\"indexer_right\">" +
Html.CheckBoxFor(m => m.NzbMatrixEnabled, new { @class = "indexer_checkbox" }) +
"</div>" +
"</div>" +
"<div class=\"indexer_group\">" +
"<div class=\"indexer_left\">" +
Html.LabelFor(m => m.NzbMatrixUsername) +
"</div>" +
"<div class=\"indexer_right\">" +
Html.TextBoxFor(m => m.NzbMatrixUsername) +
"</div>" +
"</div>" +
"<div class=\"indexer_group\">" +
"<div class=\"indexer_left\">" +
Html.LabelFor(m => m.NzbMatrixApiKey) +
"</div>" +
"<div class=\"indexer_right\">" +
Html.TextBoxFor(m => m.NzbMatrixApiKey) +
"</div>" +
"</div>" +
"</div>"
);
item.Add()
.Text("NZBsRUs")
.Content(
"<div class=\"section_content\">" +
"<div class=\"indexer_group\">" +
"<div class=\"indexer_left\">" +
"Enabled" +
"</div>" +
"<div class=\"indexer_right\">" +
Html.CheckBoxFor(m => m.NzbsRUsEnabled, new { @class = "indexer_checkbox" }) +
"</div>" +
"</div>" +
"<div class=\"indexer_group\">" +
"<div class=\"indexer_left\">" +
Html.LabelFor(m => m.NzbsrusUId) +
"</div>" +
"<div class=\"indexer_right\">" +
Html.TextBoxFor(m => m.NzbsrusUId) +
"</div>" +
"</div>" +
"<div class=\"indexer_group\">" +
"<div class=\"indexer_left\">" +
Html.LabelFor(m => m.NzbsrusHash) +
"</div>" +
"<div class=\"indexer_right\">" +
Html.TextBoxFor(m => m.NzbsrusHash) +
"</div>" +
"</div>" +
"</div>"
);
item.Add()
.Text("Newzbin")
.Content(
"<div class=\"section_content\">" +
"<div class=\"indexer_group\">" +
"<div class=\"indexer_left\">" +
"Enabled" +
"</div>" +
"<div class=\"indexer_right\">" +
Html.CheckBoxFor(m => m.NewzbinEnabled, new { @class = "indexer_checkbox" }) +
"</div>" +
"</div>" +
"<div class=\"indexer_group\">" +
"<div class=\"indexer_left\">" +
Html.LabelFor(m => m.NewzbinUsername) +
"</div>" +
"<div class=\"indexer_right\">" +
Html.TextBoxFor(m => m.NewzbinUsername) +
"</div>" +
"</div>" +
"<div class=\"indexer_group\">" +
"<div class=\"indexer_left\">" +
Html.LabelFor(m => m.NewzbinPassword) +
"</div>" +
"<div class=\"indexer_right\">" +
Html.TextBoxFor(m => m.NewzbinPassword) +
"</div>" +
"</div>" +
"</div>"
);
}).Render();
}
</div>
<br/>
<div id="save_button_div">
<input type="submit" id="save_button" value="Save" disabled="disabled" />
</div>
</fieldset>
}
<div id="result"></div>