diff --git a/NzbDrone.Core/Controllers/DbConfigController.cs b/NzbDrone.Core/Controllers/DbConfigController.cs index e12e8ab98..7c91277f3 100644 --- a/NzbDrone.Core/Controllers/DbConfigController.cs +++ b/NzbDrone.Core/Controllers/DbConfigController.cs @@ -9,6 +9,7 @@ namespace NzbDrone.Core.Controllers { public class DbConfigController : IConfigController { + private const string _seriesroots = "SeriesRoots"; private readonly IDiskController _diskController; private readonly ILog _logger; private readonly IRepository _sonicRepo; @@ -21,20 +22,27 @@ namespace NzbDrone.Core.Controllers _sonicRepo = dataRepository; } - #region IConfigController Members - public List GetTvRoots() + private string GetValue(string key) { - return (GetValue("tvRoot").Trim(';').Split(';').Where(path => _diskController.Exists(path))).ToList(); + return GetValue(key, String.Empty, false); } - #endregion - - private string GetValue(string key) + public String SeriesRoot { - return GetValue(key, String.Empty, false); + get + { + return GetValue(_seriesroots); + } + + set + { + SetValue(_seriesroots, value); + } + } + private string GetValue(string key, object defaultValue, bool makePermanent) { string value; @@ -62,7 +70,7 @@ namespace NzbDrone.Core.Controllers { _logger.DebugFormat("Writing Setting to file. Key:'{0}' Value:'{1}'", key, value); - _sonicRepo.Add(new Config {Key = key, Value = value}); + _sonicRepo.Add(new Config { Key = key, Value = value }); } } } \ No newline at end of file diff --git a/NzbDrone.Core/Controllers/FileConfigController.cs b/NzbDrone.Core/Controllers/FileConfigController.cs deleted file mode 100644 index a1c8a26ea..000000000 --- a/NzbDrone.Core/Controllers/FileConfigController.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.IO; -using System.Linq; -using log4net; - -namespace NzbDrone.Core.Controllers -{ - public class FileConfigController : IConfigController - { - private readonly Configuration _config = ConfigurationManager.OpenExeConfiguration(Path.Combine(Main.AppPath, @"NzbDrone.exe")); - private readonly IDiskController _diskController; - private readonly ILog _logger; - - public FileConfigController(ILog logger, IDiskController diskController) - { - _logger = logger; - _diskController = diskController; - } - - #region IConfigController Members - - public List GetTvRoots() - { - return (GetValue("tvRoot").Trim(';').Split(';').Where(path => _diskController.Exists(path))).ToList(); - } - - #endregion - - private string GetValue(string key) - { - return GetValue(key, String.Empty, false); - } - - private string GetValue(string key, object defaultValue, bool makePermanent) - { - string value; - - if (_config.AppSettings.Settings[key] != null) - { - value = _config.AppSettings.Settings[key].Value; - } - else - { - _logger.WarnFormat("Unable to find config key '{0}' defaultValue:'{1}'", key, defaultValue); - if (makePermanent) - { - SetValue(key, defaultValue.ToString()); - } - value = defaultValue.ToString(); - } - - return value; - } - - private void SetValue(string key, object value) - { - _logger.DebugFormat("Writing Setting to file. Key:'{0}' Value:'{1}'", key, value); - _config.AppSettings.Settings.Remove(key); - _config.AppSettings.Settings.Add(key, value.ToString()); - _config.Save(); - } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/Controllers/IConfigController.cs b/NzbDrone.Core/Controllers/IConfigController.cs index 7480bd074..697aa90bc 100644 --- a/NzbDrone.Core/Controllers/IConfigController.cs +++ b/NzbDrone.Core/Controllers/IConfigController.cs @@ -1,9 +1,15 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace NzbDrone.Core.Controllers { public interface IConfigController { - List GetTvRoots(); + String SeriesRoot + { + get; + + set; + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Controllers/SeriesController.cs b/NzbDrone.Core/Controllers/SeriesController.cs index ca464a110..bb19b1c76 100644 --- a/NzbDrone.Core/Controllers/SeriesController.cs +++ b/NzbDrone.Core/Controllers/SeriesController.cs @@ -34,18 +34,17 @@ namespace NzbDrone.Core.Controllers public void SyncSeriesWithDisk() { - foreach (string root in _config.GetTvRoots()) + + foreach (string seriesFolder in _diskController.GetDirectories(_config.SeriesRoot)) { - foreach (string seriesFolder in _diskController.GetDirectories(root)) + var dirInfo = new DirectoryInfo(seriesFolder); + if (!_sonioRepo.Exists(s => s.Path == _diskController.CleanPath(dirInfo.FullName))) { - var dirInfo = new DirectoryInfo(seriesFolder); - if (!_sonioRepo.Exists(s => s.Path == _diskController.CleanPath(dirInfo.FullName))) - { - _logger.InfoFormat("Folder '{0} isn't mapped to a series in the database. Trying to map it.'", seriesFolder); - AddShow(seriesFolder); - } + _logger.InfoFormat("Folder '{0} isn't mapped to a series in the database. Trying to map it.'", seriesFolder); + AddShow(seriesFolder); } } + } #endregion @@ -61,7 +60,7 @@ namespace NzbDrone.Core.Controllers private void AddShow(string path, TvdbSeries series) { - _sonioRepo.Add(new Series {Id = series.Id, SeriesName = series.SeriesName, AirTimes = series.AirsTime, AirsDayOfWeek = series.AirsDayOfWeek, Overview = series.Overview, Status = series.Status, Language = series.Language.Name, Path = path}); + _sonioRepo.Add(new Series { Id = series.Id, SeriesName = series.SeriesName, AirTimes = series.AirsTime, AirsDayOfWeek = series.AirsDayOfWeek, Overview = series.Overview, Status = series.Status, Language = series.Language.Name, Path = path }); } } } \ No newline at end of file diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 82585837e..48e57839b 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -140,7 +140,6 @@ - diff --git a/NzbDrone.Web/Bin/NzbDrone.Core.dll b/NzbDrone.Web/Bin/NzbDrone.Core.dll index 5fa89af4c..4096b783d 100644 Binary files a/NzbDrone.Web/Bin/NzbDrone.Core.dll and b/NzbDrone.Web/Bin/NzbDrone.Core.dll differ diff --git a/NzbDrone.Web/Bin/NzbDrone.Core.pdb b/NzbDrone.Web/Bin/NzbDrone.Core.pdb index ee0acb298..fc120f26b 100644 Binary files a/NzbDrone.Web/Bin/NzbDrone.Core.pdb and b/NzbDrone.Web/Bin/NzbDrone.Core.pdb differ diff --git a/NzbDrone.Web/Bin/NzbDrone.Web.dll b/NzbDrone.Web/Bin/NzbDrone.Web.dll index a61b091a1..7884a5d0b 100644 Binary files a/NzbDrone.Web/Bin/NzbDrone.Web.dll and b/NzbDrone.Web/Bin/NzbDrone.Web.dll differ diff --git a/NzbDrone.Web/Bin/NzbDrone.Web.pdb b/NzbDrone.Web/Bin/NzbDrone.Web.pdb index b68fe29c5..1652a1255 100644 Binary files a/NzbDrone.Web/Bin/NzbDrone.Web.pdb and b/NzbDrone.Web/Bin/NzbDrone.Web.pdb differ diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index d3155ee28..8db1a5033 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; +using NzbDrone.Core.Controllers; +using NzbDrone.Web.Models; namespace NzbDrone.Web.Controllers { @@ -10,10 +12,27 @@ namespace NzbDrone.Web.Controllers { // // GET: /Settings/ + private IConfigController _configController; + + public SettingsController(IConfigController configController) + { + _configController = configController; + } public ActionResult Index() { - return View(); + return View(new SettingsModel() { RootPath = _configController.SeriesRoot }); + } + + [HttpPost] + public ActionResult Save(SettingsModel model) + { + if (ModelState.IsValid) + { + _configController.SeriesRoot = model.RootPath; + } + + return RedirectToAction("index"); } } diff --git a/NzbDrone.Web/Models/SettingsModels.cs b/NzbDrone.Web/Models/SettingsModels.cs index 409e08832..a1305b896 100644 --- a/NzbDrone.Web/Models/SettingsModels.cs +++ b/NzbDrone.Web/Models/SettingsModels.cs @@ -11,65 +11,13 @@ using System.Web.Security; namespace NzbDrone.Web.Models { - #region Models - [PropertiesMustMatch("NewPassword", "ConfirmPassword", ErrorMessage = "The new password and confirmation password do not match.")] - public class ChangePasswordModel1 + public class SettingsModel { - [Required] - [DataType(DataType.Password)] - [DisplayName("Current password")] - public string OldPassword { get; set; } - - [Required] - [ValidatePasswordLength] - [DataType(DataType.Password)] - [DisplayName("New password")] - public string NewPassword { get; set; } - - [Required] - [DataType(DataType.Password)] - [DisplayName("Confirm new password")] - public string ConfirmPassword { get; set; } - } - - public class LogOnModel1 - { - [Required] - [DisplayName("User name")] - public string UserName { get; set; } - - [Required] - [DataType(DataType.Password)] - [DisplayName("Password")] - public string Password { get; set; } - - [DisplayName("Remember me?")] - public bool RememberMe { get; set; } - } - - [PropertiesMustMatch("Password", "ConfirmPassword", ErrorMessage = "The password and confirmation password do not match.")] - public class RegisterModel1 - { - [Required] - [DisplayName("User name")] - public string UserName { get; set; } - - [Required] - [DataType(DataType.EmailAddress)] - [DisplayName("Email address")] - public string Email { get; set; } - - [Required] - [ValidatePasswordLength] - [DataType(DataType.Password)] - [DisplayName("Password")] - public string Password { get; set; } - - [Required] - [DataType(DataType.Password)] - [DisplayName("Confirm password")] - public string ConfirmPassword { get; set; } + public String RootPath + { + get; + set; + } } - #endregion } diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 3a1a0fa98..156aa18b4 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -82,6 +82,7 @@ + Designer @@ -117,7 +118,6 @@ - diff --git a/NzbDrone.Web/Views/Account/ChangePassword.aspx b/NzbDrone.Web/Views/Account/ChangePassword.aspx index a05ea2923..4504974b6 100644 --- a/NzbDrone.Web/Views/Account/ChangePassword.aspx +++ b/NzbDrone.Web/Views/Account/ChangePassword.aspx @@ -12,7 +12,7 @@

New passwords are required to be a minimum of <%: ViewData["PasswordLength"] %> characters in length.

- + <% using (Html.BeginForm()) { %> <%: Html.ValidationSummary(true, "Password change was unsuccessful. Please correct the errors and try again.") %>
diff --git a/NzbDrone.Web/Views/Settings/Index.aspx b/NzbDrone.Web/Views/Settings/Index.aspx new file mode 100644 index 000000000..671b08517 --- /dev/null +++ b/NzbDrone.Web/Views/Settings/Index.aspx @@ -0,0 +1,27 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> +<%@ Import Namespace="NzbDrone.Web.Controllers" %> + + + Index + + +

+ Settings

+ <% using (Html.BeginForm()) + { %> +
+
+ General +
+ <%: Html.LabelFor(m => m.RootPath) %> +
+
+ <%: Html.TextBoxFor(m => m.RootPath) %> +
+

+ +

+
+
+ <% } %> +
diff --git a/NzbDrone.Web/Views/Shared/Site.Master b/NzbDrone.Web/Views/Shared/Site.Master index 7dc0da352..80fce96c3 100644 --- a/NzbDrone.Web/Views/Shared/Site.Master +++ b/NzbDrone.Web/Views/Shared/Site.Master @@ -23,7 +23,7 @@