|
|
|
@ -19,6 +19,8 @@ namespace NzbDrone.Web.Controllers
|
|
|
|
|
private IIndexerProvider _indexerProvider;
|
|
|
|
|
private IQualityProvider _qualityProvider;
|
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
private string _settingsSaved = "Settings Saved.";
|
|
|
|
|
private string _settingsFailed = "Error Saving Settings, please fix any errors";
|
|
|
|
|
|
|
|
|
|
public SettingsController(IConfigProvider configProvider, IIndexerProvider indexerProvider, IQualityProvider qualityProvider)
|
|
|
|
|
{
|
|
|
|
@ -146,60 +148,22 @@ namespace NzbDrone.Web.Controllers
|
|
|
|
|
return new QualityModel {DefaultProfileId = defaultQualityProfileId, SelectList = selectList};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult Index(SettingsModel data)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_configProvider.SeriesRoot = data.TvFolder;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
Logger.Error("Error saving settings.");
|
|
|
|
|
|
|
|
|
|
if (Request.IsAjaxRequest())
|
|
|
|
|
return Content("Error saving settings.");
|
|
|
|
|
|
|
|
|
|
return Content("Error saving settings.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Request.IsAjaxRequest())
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult SaveGeneral(SettingsModel data)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
|
{
|
|
|
|
|
if (data.TvFolder != null)
|
|
|
|
|
_configProvider.SeriesRoot = data.TvFolder;
|
|
|
|
|
|
|
|
|
|
//if (data.Quality != null)
|
|
|
|
|
// _configProvider.SetValue("Quality", data.Quality);
|
|
|
|
|
return Content(_settingsSaved);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException(e.Message, e);
|
|
|
|
|
if (Request.IsAjaxRequest())
|
|
|
|
|
return Content("Error Saving Settings, please fix any errors");
|
|
|
|
|
|
|
|
|
|
return Content("Error Saving Settings, please fix any errors");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.IsAjaxRequest())
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
return Content(_settingsFailed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult SaveIndexers(IndexerSettingsModel data)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
|
{
|
|
|
|
|
//Todo: Only allow indexers to be enabled if user information has been provided
|
|
|
|
|
foreach (var indexer in data.Indexers)
|
|
|
|
@ -208,38 +172,17 @@ namespace NzbDrone.Web.Controllers
|
|
|
|
|
_indexerProvider.Update(indexer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data.NzbMatrixUsername != null)
|
|
|
|
|
_configProvider.SetValue("NzbMatrixUsername", data.NzbMatrixUsername);
|
|
|
|
|
|
|
|
|
|
if (data.NzbMatrixApiKey != null)
|
|
|
|
|
_configProvider.SetValue("NzbMatrixApiKey", data.NzbMatrixApiKey);
|
|
|
|
|
|
|
|
|
|
if (data.NzbsOrgUId != null)
|
|
|
|
|
_configProvider.SetValue("NzbsOrgUId", data.NzbsOrgUId);
|
|
|
|
|
|
|
|
|
|
if (data.NzbsOrgHash != null)
|
|
|
|
|
_configProvider.SetValue("NzbsOrgHash", data.NzbsOrgHash);
|
|
|
|
|
|
|
|
|
|
if (data.NzbsrusUId != null)
|
|
|
|
|
_configProvider.SetValue("NzbsrusUId", data.NzbsrusUId);
|
|
|
|
|
|
|
|
|
|
if (data.NzbsrusHash != null)
|
|
|
|
|
_configProvider.SetValue("NzbsrusHash", data.NzbsrusHash);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException(e.Message, e);
|
|
|
|
|
if (Request.IsAjaxRequest())
|
|
|
|
|
return Content("Error Saving Settings, please fix any errors");
|
|
|
|
|
|
|
|
|
|
return Content("Error Saving Settings, please fix any errors");
|
|
|
|
|
return Content(_settingsSaved);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.IsAjaxRequest())
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
return Content(_settingsFailed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
@ -247,67 +190,34 @@ namespace NzbDrone.Web.Controllers
|
|
|
|
|
{
|
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (data.SyncFrequency > 15)
|
|
|
|
|
_configProvider.SetValue("SyncFrequency", data.SyncFrequency.ToString());
|
|
|
|
|
|
|
|
|
|
_configProvider.SetValue("DownloadPropers", data.DownloadPropers.ToString());
|
|
|
|
|
|
|
|
|
|
if (data.Retention > 0)
|
|
|
|
|
_configProvider.SetValue("Retention", data.Retention.ToString());
|
|
|
|
|
|
|
|
|
|
if (data.SabHost != null)
|
|
|
|
|
_configProvider.SetValue("SabHost", data.SabHost);
|
|
|
|
|
|
|
|
|
|
if (data.SabPort > 0)
|
|
|
|
|
_configProvider.SetValue("SabPort", data.SabPort.ToString());
|
|
|
|
|
|
|
|
|
|
if (data.SabApiKey != null)
|
|
|
|
|
_configProvider.SetValue("SabApiKey", data.SabApiKey);
|
|
|
|
|
|
|
|
|
|
if (data.SabUsername != null)
|
|
|
|
|
_configProvider.SetValue("SabUsername", data.SabUsername);
|
|
|
|
|
|
|
|
|
|
if (data.SabPassword != null)
|
|
|
|
|
_configProvider.SetValue("SabPassword", data.SabPassword);
|
|
|
|
|
|
|
|
|
|
if (data.SabCategory != null)
|
|
|
|
|
_configProvider.SetValue("SabCategory", data.SabCategory);
|
|
|
|
|
|
|
|
|
|
_configProvider.SetValue("SabPriority", data.SabPriority.ToString());
|
|
|
|
|
|
|
|
|
|
if (Request.IsAjaxRequest())
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
return Content(_settingsSaved);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException(e.Message, e);
|
|
|
|
|
if (Request.IsAjaxRequest())
|
|
|
|
|
return Content("Error Saving Settings, please fix any errors");
|
|
|
|
|
|
|
|
|
|
return Content("Error Saving Settings, please fix any errors");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.IsAjaxRequest())
|
|
|
|
|
return Content("Error Saving Settings, please fix any errors");
|
|
|
|
|
|
|
|
|
|
return Content("Error Saving Settings, please fix any errors");
|
|
|
|
|
return Content(_settingsFailed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult SaveQuality(QualityModel data)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
|
{
|
|
|
|
|
_configProvider.SetValue("DefaultQualityProfile", data.DefaultProfileId.ToString());
|
|
|
|
|
|
|
|
|
|
//Saves only the Default Quality, skips User Profiles since none exist
|
|
|
|
|
if (data.UserProfiles == null)
|
|
|
|
|
return Content(_settingsSaved);
|
|
|
|
|
|
|
|
|
|
foreach (var dbProfile in _qualityProvider.GetAllProfiles().Where(q => q.UserProfile))
|
|
|
|
|
{
|
|
|
|
|
if (!data.UserProfiles.Exists(p => p.ProfileId == dbProfile.ProfileId))
|
|
|
|
@ -321,13 +231,13 @@ namespace NzbDrone.Web.Controllers
|
|
|
|
|
profile.Allowed = new List<QualityTypes>();
|
|
|
|
|
foreach (var quality in profile.AllowedString.Split(','))
|
|
|
|
|
{
|
|
|
|
|
var qType = (QualityTypes) Enum.Parse(typeof (QualityTypes), quality);
|
|
|
|
|
var qType = (QualityTypes)Enum.Parse(typeof(QualityTypes), quality);
|
|
|
|
|
profile.Allowed.Add(qType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//If the Cutoff value selected is not in the allowed list then use the last allowed value, this should be validated on submit
|
|
|
|
|
if (!profile.Allowed.Contains(profile.Cutoff))
|
|
|
|
|
throw new InvalidOperationException("Invalid Cutoff Value");
|
|
|
|
|
return Content("Error Saving Settings, please fix any errors");
|
|
|
|
|
//profile.Cutoff = profile.Allowed.Last();
|
|
|
|
|
|
|
|
|
|
if (profile.ProfileId > 0)
|
|
|
|
@ -335,30 +245,12 @@ namespace NzbDrone.Web.Controllers
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
_qualityProvider.Add(profile);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException(e.Message, e);
|
|
|
|
|
|
|
|
|
|
if (Request.IsAjaxRequest())
|
|
|
|
|
return Content("Error Saving Settings, please fix any errors");
|
|
|
|
|
|
|
|
|
|
return Content("Error Saving Settings, please fix any errors");
|
|
|
|
|
return Content(_settingsSaved);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.IsAjaxRequest())
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult SortedList(List<object> items)
|
|
|
|
|
{
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
return Content(_settingsFailed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|