From c6ef82842956fba5867b97d6fec6420252c60808 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 19 Apr 2011 16:46:21 -0700 Subject: [PATCH] New UI for Indexer Settings, RAZOR! Renamed NzbMatrix and NzbsRUs Providers --- NzbDrone.Core/CentralDispatch.cs | 3 + NzbDrone.Core/NzbDrone.Core.csproj | 5 +- .../Providers/Core/ConfigProvider.cs | 15 +- .../Providers/Indexer/NewzbinProvider.cs | 36 +++ ...ixFeedProvider.cs => NzbMatrixProvider.cs} | 4 +- ...sRUsFeedProvider.cs => NzbsRUsProvider.cs} | 4 +- NzbDrone.Core/Providers/IndexerProvider.cs | 2 - .../Controllers/SettingsController.cs | 41 +++- NzbDrone.Web/Models/IndexerSettingsModel.cs | 34 ++- NzbDrone.Web/NzbDrone.Web.csproj | 11 +- NzbDrone.Web/Views/Settings/Indexers.ascx | 135 ------------ NzbDrone.Web/Views/Settings/Indexers.cshtml | 206 ++++++++++++++++++ 12 files changed, 323 insertions(+), 173 deletions(-) create mode 100644 NzbDrone.Core/Providers/Indexer/NewzbinProvider.cs rename NzbDrone.Core/Providers/Indexer/{NzbMatrixFeedProvider.cs => NzbMatrixProvider.cs} (77%) rename NzbDrone.Core/Providers/Indexer/{NzbsRUsFeedProvider.cs => NzbsRUsProvider.cs} (76%) delete mode 100644 NzbDrone.Web/Views/Settings/Indexers.ascx create mode 100644 NzbDrone.Web/Views/Settings/Indexers.cshtml diff --git a/NzbDrone.Core/CentralDispatch.cs b/NzbDrone.Core/CentralDispatch.cs index a8e78471f..404932d16 100644 --- a/NzbDrone.Core/CentralDispatch.cs +++ b/NzbDrone.Core/CentralDispatch.cs @@ -140,6 +140,9 @@ namespace NzbDrone.Core private static void BindIndexers() { _kernel.Bind().To().InSingletonScope(); + _kernel.Bind().To().InSingletonScope(); + _kernel.Bind().To().InSingletonScope(); + _kernel.Bind().To().InSingletonScope(); var indexers = _kernel.GetAll(); _kernel.Get().InitializeIndexers(indexers.ToList()); } diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 7290c3408..b6455d6f3 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -169,8 +169,9 @@ - - + + + diff --git a/NzbDrone.Core/Providers/Core/ConfigProvider.cs b/NzbDrone.Core/Providers/Core/ConfigProvider.cs index 6fdf61bde..be928d4aa 100644 --- a/NzbDrone.Core/Providers/Core/ConfigProvider.cs +++ b/NzbDrone.Core/Providers/Core/ConfigProvider.cs @@ -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"); } diff --git a/NzbDrone.Core/Providers/Indexer/NewzbinProvider.cs b/NzbDrone.Core/Providers/Indexer/NewzbinProvider.cs new file mode 100644 index 000000000..87c71cdd6 --- /dev/null +++ b/NzbDrone.Core/Providers/Indexer/NewzbinProvider.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/NzbDrone.Core/Providers/Indexer/NzbMatrixFeedProvider.cs b/NzbDrone.Core/Providers/Indexer/NzbMatrixProvider.cs similarity index 77% rename from NzbDrone.Core/Providers/Indexer/NzbMatrixFeedProvider.cs rename to NzbDrone.Core/Providers/Indexer/NzbMatrixProvider.cs index 54a9cde94..09d6e9050 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbMatrixFeedProvider.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbMatrixProvider.cs @@ -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) { } diff --git a/NzbDrone.Core/Providers/Indexer/NzbsRUsFeedProvider.cs b/NzbDrone.Core/Providers/Indexer/NzbsRUsProvider.cs similarity index 76% rename from NzbDrone.Core/Providers/Indexer/NzbsRUsFeedProvider.cs rename to NzbDrone.Core/Providers/Indexer/NzbsRUsProvider.cs index c04388ac1..d75721147 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbsRUsFeedProvider.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbsRUsProvider.cs @@ -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) { } diff --git a/NzbDrone.Core/Providers/IndexerProvider.cs b/NzbDrone.Core/Providers/IndexerProvider.cs index 6359e7dcc..cc6be013c 100644 --- a/NzbDrone.Core/Providers/IndexerProvider.cs +++ b/NzbDrone.Core/Providers/IndexerProvider.cs @@ -75,7 +75,5 @@ namespace NzbDrone.Core.Providers } } } - - } } \ No newline at end of file diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 34ba16973..15c4a13a4 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -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); - } + var nzbsOrgSettings = _indexerProvider.GetSettings(typeof(NzbsOrgProvider)); + nzbsOrgSettings.Enable = data.NzbsOrgEnabled; + _indexerProvider.SaveSettings(nzbsOrgSettings); - _configProvider.NzbMatrixUsername = data.NzbMatrixUsername; - _configProvider.NzbMatrixApiKey = data.NzbMatrixApiKey; - _configProvider.NzbsrusUId = data.NzbsrusUId; - _configProvider.NzbsrusHash = data.NzbsrusHash; + 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); - var nzbsOrgSettings = _indexerProvider.GetSettings(typeof(NzbsOrgProvider)); _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); } diff --git a/NzbDrone.Web/Models/IndexerSettingsModel.cs b/NzbDrone.Web/Models/IndexerSettingsModel.cs index 54e434c67..4d5b70082 100644 --- a/NzbDrone.Web/Models/IndexerSettingsModel.cs +++ b/NzbDrone.Web/Models/IndexerSettingsModel.cs @@ -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 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; } } } \ No newline at end of file diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 192136459..cb8eb1d32 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -628,7 +628,6 @@ - @@ -661,6 +660,7 @@ + @@ -812,15 +812,6 @@ - False - True - 21704 - / - http://localhost/NzbDrone - False - False - http://localhost:8989 - False True diff --git a/NzbDrone.Web/Views/Settings/Indexers.ascx b/NzbDrone.Web/Views/Settings/Indexers.ascx deleted file mode 100644 index 0cc8469d3..000000000 --- a/NzbDrone.Web/Views/Settings/Indexers.ascx +++ /dev/null @@ -1,135 +0,0 @@ -<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> - - - -<% - 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.")%> -
- Indexers -
    - <% - for (int i = 0; i < Model.Indexers.Count(); i++) - {%> -
  • - <%=Html.CheckBoxFor(c => c.Indexers[i].Enable)%><%=Html.DisplayTextFor(c => c.Indexers[i].Name)%>
  • - <% - }%> -
- <% - for (int i = 0; i < Model.Indexers.Count(); i++) - {%> - <% - }%> - <%--NZBMatrix--%> -
- <%=Html.LabelFor(m => m.NzbMatrixUsername)%> -
-
- <%=Html.TextBoxFor(m => m.NzbMatrixUsername)%> - <%=Html.ValidationMessageFor(m => m.NzbMatrixUsername)%> -
-
- <%=Html.LabelFor(m => m.NzbMatrixApiKey)%> -
-
- <%=Html.TextBoxFor(m => m.NzbMatrixApiKey)%> - <%=Html.ValidationMessageFor(m => m.NzbMatrixApiKey)%> -
-
- <%--NZBs.Org--%> -
- <%=Html.LabelFor(m => m.NzbsOrgUId)%> -
-
- <%=Html.TextBoxFor(m => m.NzbsOrgUId)%> - <%=Html.ValidationMessageFor(m => m.NzbsOrgUId)%> -
-
- <%=Html.LabelFor(m => m.NzbsOrgHash)%> -
-
- <%=Html.TextBoxFor(m => m.NzbsOrgHash)%> - <%=Html.ValidationMessageFor(m => m.NzbsOrgHash)%> -
-
- <%--NZBsrus--%> -
- <%=Html.LabelFor(m => m.NzbsrusUId)%> -
-
- <%=Html.TextBoxFor(m => m.NzbsrusUId)%> - <%=Html.ValidationMessageFor(m => m.NzbsrusUId)%> -
-
- <%=Html.LabelFor(m => m.NzbsrusHash)%> -
-
- <%=Html.TextBoxFor(m => m.NzbsrusHash)%> - <%=Html.ValidationMessageFor(m => m.NzbsrusHash)%> -
-
- -
-<% - }%> -
-
diff --git a/NzbDrone.Web/Views/Settings/Indexers.cshtml b/NzbDrone.Web/Views/Settings/Indexers.cshtml new file mode 100644 index 000000000..f13443057 --- /dev/null +++ b/NzbDrone.Web/Views/Settings/Indexers.cshtml @@ -0,0 +1,206 @@ +@model NzbDrone.Web.Models.IndexerSettingsModel + + + + + +@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.") + +
+ Indexers +
+ @{ 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( + "
" + + + "
" + + "
" + + "Enabled" + + "
" + + "
" + + Html.CheckBoxFor(m => m.NzbsOrgEnabled, new { @class = "indexer_checkbox" }) + + "
" + + "
" + + + "
" + + "
" + + Html.LabelFor(m => m.NzbsOrgUId) + + "
" + + "
" + + Html.TextBoxFor(m => m.NzbsOrgUId) + + "
" + + "
" + + "
" + + "
" + + Html.LabelFor(m => m.NzbsOrgHash) + + "
" + + "
" + + Html.TextBoxFor(m => m.NzbsOrgHash) + + "
" + + "
" + + "
" + ); + item.Add() + .Text("NZB Matrix") + .Content( + "
" + + + "
" + + "
" + + "Enabled" + + "
" + + "
" + + Html.CheckBoxFor(m => m.NzbMatrixEnabled, new { @class = "indexer_checkbox" }) + + "
" + + "
" + + + "
" + + "
" + + Html.LabelFor(m => m.NzbMatrixUsername) + + "
" + + "
" + + Html.TextBoxFor(m => m.NzbMatrixUsername) + + "
" + + "
" + + "
" + + "
" + + Html.LabelFor(m => m.NzbMatrixApiKey) + + "
" + + "
" + + Html.TextBoxFor(m => m.NzbMatrixApiKey) + + "
" + + "
" + + "
" + ); + item.Add() + .Text("NZBsRUs") + .Content( + "
" + + + "
" + + "
" + + "Enabled" + + "
" + + "
" + + Html.CheckBoxFor(m => m.NzbsRUsEnabled, new { @class = "indexer_checkbox" }) + + "
" + + "
" + + + "
" + + "
" + + Html.LabelFor(m => m.NzbsrusUId) + + "
" + + "
" + + Html.TextBoxFor(m => m.NzbsrusUId) + + "
" + + "
" + + "
" + + "
" + + Html.LabelFor(m => m.NzbsrusHash) + + "
" + + "
" + + Html.TextBoxFor(m => m.NzbsrusHash) + + "
" + + "
" + + "
" + ); + item.Add() + .Text("Newzbin") + .Content( + "
" + + + "
" + + "
" + + "Enabled" + + "
" + + "
" + + Html.CheckBoxFor(m => m.NewzbinEnabled, new { @class = "indexer_checkbox" }) + + "
" + + "
" + + + "
" + + "
" + + Html.LabelFor(m => m.NewzbinUsername) + + "
" + + "
" + + Html.TextBoxFor(m => m.NewzbinUsername) + + "
" + + "
" + + "
" + + "
" + + Html.LabelFor(m => m.NewzbinPassword) + + "
" + + "
" + + Html.TextBoxFor(m => m.NewzbinPassword) + + "
" + + "
" + + "
" + ); + }).Render(); + } +
+ +
+
+ +
+
+} +
\ No newline at end of file