1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Replaced save notifications for settings on page with AJAX Notifications.

This commit is contained in:
Mark McDowall 2011-05-12 21:46:26 -07:00
parent 3cc052e9b6
commit d65d79a5c9
10 changed files with 81 additions and 10 deletions

View File

@ -155,7 +155,7 @@ private void Execute(Type jobType, int targetId = 0)
var timerClass = _jobs.Where(t => t.GetType() == jobType).FirstOrDefault(); var timerClass = _jobs.Where(t => t.GetType() == jobType).FirstOrDefault();
if (timerClass == null) if (timerClass == null)
{ {
Logger.Error("Unable to locate implantation for '{0}'. Make sure its properly registered.", jobType.ToString()); Logger.Error("Unable to locate implementation for '{0}'. Make sure its properly registered.", jobType.ToString());
return; return;
} }

View File

@ -278,6 +278,11 @@ button, input[type="button"], input[type="submit"], input[type="reset"]
border-bottom-color: #3C3C3C; border-bottom-color: #3C3C3C;
} }
.hiddenResult
{
display: none;
}
/* Add Series */ /* Add Series */
.tvDbSearchResults .tvDbSearchResults

View File

@ -18,9 +18,21 @@ public NotificationController(NotificationProvider notificationProvider)
public JsonResult Index() public JsonResult Index()
{ {
string message = string.Empty; string message = string.Empty;
if (_notifications.GetProgressNotifications.Count != 0)
var basic = _notifications.BasicNotifications;
if (basic.Count != 0)
{ {
message = _notifications.GetProgressNotifications[0].CurrentMessage; message = basic[0].Title;
if (basic[0].AutoDismiss)
_notifications.Dismiss(basic[0].Id);
}
else
{
if (_notifications.GetProgressNotifications.Count != 0)
message = _notifications.GetProgressNotifications[0].CurrentMessage;
} }
return Json(message, JsonRequestBehavior.AllowGet); return Json(message, JsonRequestBehavior.AllowGet);

View File

@ -5,6 +5,7 @@
using NLog; using NLog;
using NzbDrone.Core.Helpers; using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.Indexer; using NzbDrone.Core.Providers.Indexer;
@ -25,16 +26,18 @@ public class SettingsController : Controller
private readonly QualityProvider _qualityProvider; private readonly QualityProvider _qualityProvider;
private readonly RootDirProvider _rootDirProvider; private readonly RootDirProvider _rootDirProvider;
private readonly AutoConfigureProvider _autoConfigureProvider; private readonly AutoConfigureProvider _autoConfigureProvider;
private readonly NotificationProvider _notificationProvider;
public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider, public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider,
QualityProvider qualityProvider, RootDirProvider rootDirProvider, QualityProvider qualityProvider, RootDirProvider rootDirProvider,
AutoConfigureProvider autoConfigureProvider) AutoConfigureProvider autoConfigureProvider, NotificationProvider notificationProvider)
{ {
_configProvider = configProvider; _configProvider = configProvider;
_indexerProvider = indexerProvider; _indexerProvider = indexerProvider;
_qualityProvider = qualityProvider; _qualityProvider = qualityProvider;
_rootDirProvider = rootDirProvider; _rootDirProvider = rootDirProvider;
_autoConfigureProvider = autoConfigureProvider; _autoConfigureProvider = autoConfigureProvider;
_notificationProvider = notificationProvider;
} }
public ActionResult Index(string viewName) public ActionResult Index(string viewName)
@ -313,6 +316,10 @@ public JsonResult AutoConfigureSab()
[HttpPost] [HttpPost]
public ActionResult SaveGeneral(SettingsModel data) public ActionResult SaveGeneral(SettingsModel data)
{ {
var basicNotification = new BasicNotification();
basicNotification.Type = BasicNotificationType.Info;
basicNotification.AutoDismiss = true;
try try
{ {
foreach (var dir in data.Directories) foreach (var dir in data.Directories)
@ -324,15 +331,26 @@ public ActionResult SaveGeneral(SettingsModel data)
{ {
Logger.Debug("Failed to save Root Dirs"); Logger.Debug("Failed to save Root Dirs");
Logger.DebugException(ex.Message, ex); Logger.DebugException(ex.Message, ex);
basicNotification.Title = SETTINGS_FAILED;
_notificationProvider.Register(basicNotification);
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
basicNotification.Title = SETTINGS_SAVED;
_notificationProvider.Register(basicNotification);
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
[HttpPost] [HttpPost]
public ActionResult SaveIndexers(IndexerSettingsModel data) public ActionResult SaveIndexers(IndexerSettingsModel data)
{ {
var basicNotification = new BasicNotification();
basicNotification.Type = BasicNotificationType.Info;
basicNotification.AutoDismiss = true;
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
var nzbsOrgSettings = _indexerProvider.GetSettings(typeof(NzbsOrgProvider)); var nzbsOrgSettings = _indexerProvider.GetSettings(typeof(NzbsOrgProvider));
@ -363,15 +381,23 @@ public ActionResult SaveIndexers(IndexerSettingsModel data)
_configProvider.NewzbinUsername = data.NewzbinUsername; _configProvider.NewzbinUsername = data.NewzbinUsername;
_configProvider.NewzbinPassword = data.NewzbinPassword; _configProvider.NewzbinPassword = data.NewzbinPassword;
basicNotification.Title = SETTINGS_SAVED;
_notificationProvider.Register(basicNotification);
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
basicNotification.Title = SETTINGS_FAILED;
_notificationProvider.Register(basicNotification);
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
[HttpPost] [HttpPost]
public ActionResult SaveDownloads(DownloadSettingsModel data) public ActionResult SaveDownloads(DownloadSettingsModel data)
{ {
var basicNotification = new BasicNotification();
basicNotification.Type = BasicNotificationType.Info;
basicNotification.AutoDismiss = true;
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_configProvider.SyncFrequency = data.SyncFrequency.ToString(); _configProvider.SyncFrequency = data.SyncFrequency.ToString();
@ -387,15 +413,23 @@ public ActionResult SaveDownloads(DownloadSettingsModel data)
_configProvider.UseBlackhole = data.UseBlackHole; _configProvider.UseBlackhole = data.UseBlackHole;
_configProvider.BlackholeDirectory = data.BlackholeDirectory; _configProvider.BlackholeDirectory = data.BlackholeDirectory;
basicNotification.Title = SETTINGS_SAVED;
_notificationProvider.Register(basicNotification);
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
basicNotification.Title = SETTINGS_FAILED;
_notificationProvider.Register(basicNotification);
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
[HttpPost] [HttpPost]
public ActionResult SaveQuality(QualityModel data) public ActionResult SaveQuality(QualityModel data)
{ {
var basicNotification = new BasicNotification();
basicNotification.Type = BasicNotificationType.Info;
basicNotification.AutoDismiss = true;
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_configProvider.SetValue("DefaultQualityProfile", data.DefaultQualityProfileId.ToString()); _configProvider.SetValue("DefaultQualityProfile", data.DefaultQualityProfileId.ToString());
@ -422,15 +456,23 @@ public ActionResult SaveQuality(QualityModel data)
_qualityProvider.Update(profile); _qualityProvider.Update(profile);
} }
basicNotification.Title = SETTINGS_SAVED;
_notificationProvider.Register(basicNotification);
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
basicNotification.Title = SETTINGS_FAILED;
_notificationProvider.Register(basicNotification);
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
[HttpPost] [HttpPost]
public ActionResult SaveNotifications(NotificationSettingsModel data) public ActionResult SaveNotifications(NotificationSettingsModel data)
{ {
var basicNotification = new BasicNotification();
basicNotification.Type = BasicNotificationType.Info;
basicNotification.AutoDismiss = true;
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_configProvider.SetValue("XbmcEnabled", data.XbmcEnabled.ToString()); _configProvider.SetValue("XbmcEnabled", data.XbmcEnabled.ToString());
@ -448,15 +490,23 @@ public ActionResult SaveNotifications(NotificationSettingsModel data)
_configProvider.SetValue("XbmcUsername", data.XbmcUsername); _configProvider.SetValue("XbmcUsername", data.XbmcUsername);
_configProvider.SetValue("XbmcPassword", data.XbmcPassword); _configProvider.SetValue("XbmcPassword", data.XbmcPassword);
basicNotification.Title = SETTINGS_SAVED;
_notificationProvider.Register(basicNotification);
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
basicNotification.Title = SETTINGS_FAILED;
_notificationProvider.Register(basicNotification);
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
[HttpPost] [HttpPost]
public ActionResult SaveEpisodeSorting(EpisodeSortingModel data) public ActionResult SaveEpisodeSorting(EpisodeSortingModel data)
{ {
var basicNotification = new BasicNotification();
basicNotification.Type = BasicNotificationType.Info;
basicNotification.AutoDismiss = true;
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
_configProvider.SetValue("Sorting_ShowName", data.ShowName.ToString()); _configProvider.SetValue("Sorting_ShowName", data.ShowName.ToString());
@ -470,9 +520,13 @@ public ActionResult SaveEpisodeSorting(EpisodeSortingModel data)
_configProvider.SetValue("Sorting_NumberStyle", data.NumberStyle.ToString()); _configProvider.SetValue("Sorting_NumberStyle", data.NumberStyle.ToString());
_configProvider.SetValue("Sorting_MultiEpisodeStyle", data.MultiEpisodeStyle.ToString()); _configProvider.SetValue("Sorting_MultiEpisodeStyle", data.MultiEpisodeStyle.ToString());
basicNotification.Title = SETTINGS_SAVED;
_notificationProvider.Register(basicNotification);
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
basicNotification.Title = SETTINGS_FAILED;
_notificationProvider.Register(basicNotification);
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
} }

View File

@ -216,7 +216,7 @@
</fieldset> </fieldset>
} }
<div id="result"></div> <div id="result" class="hiddenResult"></div>
<script type="text/javascript"> <script type="text/javascript">
var autoConfigureSabUrl = '@Url.Action("AutoConfigureSab", "Settings")'; var autoConfigureSabUrl = '@Url.Action("AutoConfigureSab", "Settings")';

View File

@ -121,4 +121,4 @@
</fieldset> </fieldset>
} }
<div id="result"></div> <div id="result" class="hiddenResult"></div>

View File

@ -50,7 +50,7 @@
</p> </p>
</fieldset> </fieldset>
} }
<div id="result"></div> <div id="result" class="hiddenResult"></div>
<script type="text/javascript"> <script type="text/javascript">

View File

@ -206,4 +206,4 @@
</div> </div>
</fieldset> </fieldset>
} }
<div id="result"></div> <div id="result" class="hiddenResult"></div>

View File

@ -158,4 +158,4 @@
</fieldset> </fieldset>
} }
<div id="result"></div> <div id="result" class="hiddenResult"></div>

View File

@ -63,7 +63,7 @@
</fieldset> </fieldset>
} }
<div id="result"></div> <div id="result" class="hiddenResult"></div>
<script type="text/javascript"> <script type="text/javascript">