|
|
@ -19,6 +19,8 @@ namespace NzbDrone.Web.Controllers
|
|
|
|
private IIndexerProvider _indexerProvider;
|
|
|
|
private IIndexerProvider _indexerProvider;
|
|
|
|
private IQualityProvider _qualityProvider;
|
|
|
|
private IQualityProvider _qualityProvider;
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
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)
|
|
|
|
public SettingsController(IConfigProvider configProvider, IIndexerProvider indexerProvider, IQualityProvider qualityProvider)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -146,60 +148,22 @@ namespace NzbDrone.Web.Controllers
|
|
|
|
return new QualityModel {DefaultProfileId = defaultQualityProfileId, SelectList = selectList};
|
|
|
|
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]
|
|
|
|
[HttpPost]
|
|
|
|
public ActionResult SaveGeneral(SettingsModel data)
|
|
|
|
public ActionResult SaveGeneral(SettingsModel data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (data.TvFolder != null)
|
|
|
|
|
|
|
|
_configProvider.SeriesRoot = data.TvFolder;
|
|
|
|
_configProvider.SeriesRoot = data.TvFolder;
|
|
|
|
|
|
|
|
return Content(_settingsSaved);
|
|
|
|
//if (data.Quality != null)
|
|
|
|
|
|
|
|
// _configProvider.SetValue("Quality", data.Quality);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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(_settingsFailed);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Request.IsAjaxRequest())
|
|
|
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
[HttpPost]
|
|
|
|
public ActionResult SaveIndexers(IndexerSettingsModel data)
|
|
|
|
public ActionResult SaveIndexers(IndexerSettingsModel data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Todo: Only allow indexers to be enabled if user information has been provided
|
|
|
|
//Todo: Only allow indexers to be enabled if user information has been provided
|
|
|
|
foreach (var indexer in data.Indexers)
|
|
|
|
foreach (var indexer in data.Indexers)
|
|
|
@ -208,38 +172,17 @@ namespace NzbDrone.Web.Controllers
|
|
|
|
_indexerProvider.Update(indexer);
|
|
|
|
_indexerProvider.Update(indexer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (data.NzbMatrixUsername != null)
|
|
|
|
|
|
|
|
_configProvider.SetValue("NzbMatrixUsername", data.NzbMatrixUsername);
|
|
|
|
_configProvider.SetValue("NzbMatrixUsername", data.NzbMatrixUsername);
|
|
|
|
|
|
|
|
|
|
|
|
if (data.NzbMatrixApiKey != null)
|
|
|
|
|
|
|
|
_configProvider.SetValue("NzbMatrixApiKey", data.NzbMatrixApiKey);
|
|
|
|
_configProvider.SetValue("NzbMatrixApiKey", data.NzbMatrixApiKey);
|
|
|
|
|
|
|
|
|
|
|
|
if (data.NzbsOrgUId != null)
|
|
|
|
|
|
|
|
_configProvider.SetValue("NzbsOrgUId", data.NzbsOrgUId);
|
|
|
|
_configProvider.SetValue("NzbsOrgUId", data.NzbsOrgUId);
|
|
|
|
|
|
|
|
|
|
|
|
if (data.NzbsOrgHash != null)
|
|
|
|
|
|
|
|
_configProvider.SetValue("NzbsOrgHash", data.NzbsOrgHash);
|
|
|
|
_configProvider.SetValue("NzbsOrgHash", data.NzbsOrgHash);
|
|
|
|
|
|
|
|
|
|
|
|
if (data.NzbsrusUId != null)
|
|
|
|
|
|
|
|
_configProvider.SetValue("NzbsrusUId", data.NzbsrusUId);
|
|
|
|
_configProvider.SetValue("NzbsrusUId", data.NzbsrusUId);
|
|
|
|
|
|
|
|
|
|
|
|
if (data.NzbsrusHash != null)
|
|
|
|
|
|
|
|
_configProvider.SetValue("NzbsrusHash", data.NzbsrusHash);
|
|
|
|
_configProvider.SetValue("NzbsrusHash", data.NzbsrusHash);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
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(_settingsFailed);
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
[HttpPost]
|
|
|
@ -247,67 +190,34 @@ namespace NzbDrone.Web.Controllers
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (data.SyncFrequency > 15)
|
|
|
|
|
|
|
|
_configProvider.SetValue("SyncFrequency", data.SyncFrequency.ToString());
|
|
|
|
_configProvider.SetValue("SyncFrequency", data.SyncFrequency.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
_configProvider.SetValue("DownloadPropers", data.DownloadPropers.ToString());
|
|
|
|
_configProvider.SetValue("DownloadPropers", data.DownloadPropers.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
if (data.Retention > 0)
|
|
|
|
|
|
|
|
_configProvider.SetValue("Retention", data.Retention.ToString());
|
|
|
|
_configProvider.SetValue("Retention", data.Retention.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
if (data.SabHost != null)
|
|
|
|
|
|
|
|
_configProvider.SetValue("SabHost", data.SabHost);
|
|
|
|
_configProvider.SetValue("SabHost", data.SabHost);
|
|
|
|
|
|
|
|
|
|
|
|
if (data.SabPort > 0)
|
|
|
|
|
|
|
|
_configProvider.SetValue("SabPort", data.SabPort.ToString());
|
|
|
|
_configProvider.SetValue("SabPort", data.SabPort.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
if (data.SabApiKey != null)
|
|
|
|
|
|
|
|
_configProvider.SetValue("SabApiKey", data.SabApiKey);
|
|
|
|
_configProvider.SetValue("SabApiKey", data.SabApiKey);
|
|
|
|
|
|
|
|
|
|
|
|
if (data.SabUsername != null)
|
|
|
|
|
|
|
|
_configProvider.SetValue("SabUsername", data.SabUsername);
|
|
|
|
_configProvider.SetValue("SabUsername", data.SabUsername);
|
|
|
|
|
|
|
|
|
|
|
|
if (data.SabPassword != null)
|
|
|
|
|
|
|
|
_configProvider.SetValue("SabPassword", data.SabPassword);
|
|
|
|
_configProvider.SetValue("SabPassword", data.SabPassword);
|
|
|
|
|
|
|
|
|
|
|
|
if (data.SabCategory != null)
|
|
|
|
|
|
|
|
_configProvider.SetValue("SabCategory", data.SabCategory);
|
|
|
|
_configProvider.SetValue("SabCategory", data.SabCategory);
|
|
|
|
|
|
|
|
|
|
|
|
_configProvider.SetValue("SabPriority", data.SabPriority.ToString());
|
|
|
|
_configProvider.SetValue("SabPriority", data.SabPriority.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
if (Request.IsAjaxRequest())
|
|
|
|
return Content(_settingsSaved);
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
return Content(_settingsFailed);
|
|
|
|
{
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
[HttpPost]
|
|
|
|
public ActionResult SaveQuality(QualityModel data)
|
|
|
|
public ActionResult SaveQuality(QualityModel data)
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_configProvider.SetValue("DefaultQualityProfile", data.DefaultProfileId.ToString());
|
|
|
|
_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))
|
|
|
|
foreach (var dbProfile in _qualityProvider.GetAllProfiles().Where(q => q.UserProfile))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!data.UserProfiles.Exists(p => p.ProfileId == dbProfile.ProfileId))
|
|
|
|
if (!data.UserProfiles.Exists(p => p.ProfileId == dbProfile.ProfileId))
|
|
|
@ -327,7 +237,7 @@ namespace NzbDrone.Web.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
//If the Cutoff value selected is not in the allowed list then use the last allowed value, this should be validated on submit
|
|
|
|
//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))
|
|
|
|
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();
|
|
|
|
//profile.Cutoff = profile.Allowed.Last();
|
|
|
|
|
|
|
|
|
|
|
|
if (profile.ProfileId > 0)
|
|
|
|
if (profile.ProfileId > 0)
|
|
|
@ -335,30 +245,12 @@ namespace NzbDrone.Web.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
_qualityProvider.Add(profile);
|
|
|
|
_qualityProvider.Add(profile);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
return Content(_settingsSaved);
|
|
|
|
{
|
|
|
|
|
|
|
|
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.");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
return Content(_settingsFailed);
|
|
|
|
public ActionResult SortedList(List<object> items)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return Content("Settings Saved.");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|