From 3507b97887fbd0d16378ef8ded610e8ed6fe214f Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 4 Aug 2011 21:38:18 -0700 Subject: [PATCH] Settings save buttons are disabled until jQuery loads and attribute is removed (prevents saving without ajax if saving too quickly). Notifications are set when saving now (progress) until basic is redone. --- .../Model/Notification/BasicNotification.cs | 2 +- NzbDrone.Web/Content/Settings.css | 8 +++ .../Controllers/NotificationController.cs | 2 + .../Controllers/SettingsController.cs | 64 +++++++++---------- NzbDrone.Web/Scripts/settingsForm.js | 1 + .../Views/Settings/EpisodeSorting.cshtml | 2 +- NzbDrone.Web/Views/Settings/Indexers.cshtml | 9 ++- .../Views/Settings/Notifications.cshtml | 2 +- NzbDrone.Web/Views/Settings/Quality.cshtml | 2 +- NzbDrone.Web/Views/Settings/Sabnzbd.cshtml | 2 +- NzbDrone.Web/Views/Settings/Test.cshtml | 31 ++++----- 11 files changed, 65 insertions(+), 60 deletions(-) diff --git a/NzbDrone.Core/Model/Notification/BasicNotification.cs b/NzbDrone.Core/Model/Notification/BasicNotification.cs index f06172336..225dc97a7 100644 --- a/NzbDrone.Core/Model/Notification/BasicNotification.cs +++ b/NzbDrone.Core/Model/Notification/BasicNotification.cs @@ -6,7 +6,7 @@ namespace NzbDrone.Core.Model.Notification { public BasicNotification() { - Id = Guid.Empty; + Id = Guid.NewGuid(); } /// diff --git a/NzbDrone.Web/Content/Settings.css b/NzbDrone.Web/Content/Settings.css index 2169714bf..fc8d817e7 100644 --- a/NzbDrone.Web/Content/Settings.css +++ b/NzbDrone.Web/Content/Settings.css @@ -107,4 +107,12 @@ p, h1, form, button{border:0; margin:0; padding:0;} width: 20px; height: 20px; display: none; +} + +#save_button[disabled="disabled"] +{ + padding: 0px 6px 0px 6px; + border: 2px outset ButtonFace; + color: lightgrey; + cursor: progress; } \ No newline at end of file diff --git a/NzbDrone.Web/Controllers/NotificationController.cs b/NzbDrone.Web/Controllers/NotificationController.cs index c1796cac0..43a02b5c0 100644 --- a/NzbDrone.Web/Controllers/NotificationController.cs +++ b/NzbDrone.Web/Controllers/NotificationController.cs @@ -67,6 +67,8 @@ namespace NzbDrone.Web.Controllers private string GetCurrentMessage() { + var notes = _notifications.ProgressNotifications; + if (_notifications.ProgressNotifications.Count != 0) return _notifications.ProgressNotifications[0].CurrentMessage; diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 5c2a36436..f263828bf 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -32,6 +32,7 @@ namespace NzbDrone.Web.Controllers private readonly DiskProvider _diskProvider; private readonly SeriesProvider _seriesProvider; private readonly ExternalNotificationProvider _externalNotificationProvider; + private readonly ProgressNotification _progressNotification; public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider, QualityProvider qualityProvider, RootDirProvider rootDirProvider, @@ -48,6 +49,8 @@ namespace NzbDrone.Web.Controllers _notificationProvider = notificationProvider; _diskProvider = diskProvider; _seriesProvider = seriesProvider; + + _progressNotification = new ProgressNotification("Settings"); } public ActionResult Test() @@ -270,9 +273,7 @@ namespace NzbDrone.Web.Controllers [HttpPost] public ActionResult SaveIndexers(IndexerSettingsModel data) { - var basicNotification = new BasicNotification(); - basicNotification.Type = BasicNotificationType.Info; - basicNotification.AutoDismiss = true; + _notificationProvider.Register(_progressNotification); if (ModelState.IsValid) { @@ -304,22 +305,20 @@ namespace NzbDrone.Web.Controllers _configProvider.NewzbinUsername = data.NewzbinUsername; _configProvider.NewzbinPassword = data.NewzbinPassword; - basicNotification.Title = SETTINGS_SAVED; - _notificationProvider.Register(basicNotification); + _progressNotification.CurrentMessage = SETTINGS_SAVED; + _progressNotification.Status = ProgressNotificationStatus.Completed; return Content(SETTINGS_SAVED); } - basicNotification.Title = SETTINGS_FAILED; - _notificationProvider.Register(basicNotification); + _progressNotification.CurrentMessage = SETTINGS_FAILED; + _progressNotification.Status = ProgressNotificationStatus.Completed; return Content(SETTINGS_FAILED); } [HttpPost] public ActionResult SaveSabnzbd(SabnzbdSettingsModel data) { - var basicNotification = new BasicNotification(); - basicNotification.Type = BasicNotificationType.Info; - basicNotification.AutoDismiss = true; + _notificationProvider.Register(_progressNotification); if (ModelState.IsValid) { @@ -332,22 +331,20 @@ namespace NzbDrone.Web.Controllers _configProvider.SabTvPriority = data.SabTvPriority; _configProvider.SabDropDirectory = data.SabDropDirectory; - basicNotification.Title = SETTINGS_SAVED; - _notificationProvider.Register(basicNotification); + _progressNotification.CurrentMessage = SETTINGS_SAVED; + _progressNotification.Status = ProgressNotificationStatus.Completed; return Content(SETTINGS_SAVED); } - basicNotification.Title = SETTINGS_FAILED; - _notificationProvider.Register(basicNotification); + _progressNotification.CurrentMessage = SETTINGS_FAILED; + _progressNotification.Status = ProgressNotificationStatus.Completed; return Content(SETTINGS_FAILED); } [HttpPost] public ActionResult SaveQuality(QualityModel data) { - var basicNotification = new BasicNotification(); - basicNotification.Type = BasicNotificationType.Info; - basicNotification.AutoDismiss = true; + _notificationProvider.Register(_progressNotification); if (ModelState.IsValid) { @@ -379,22 +376,21 @@ namespace NzbDrone.Web.Controllers _qualityProvider.Update(profile); } - basicNotification.Title = SETTINGS_SAVED; - _notificationProvider.Register(basicNotification); + + _progressNotification.CurrentMessage = SETTINGS_SAVED; + _progressNotification.Status = ProgressNotificationStatus.Completed; return Content(SETTINGS_SAVED); } - basicNotification.Title = SETTINGS_FAILED; - _notificationProvider.Register(basicNotification); + _progressNotification.CurrentMessage = SETTINGS_FAILED; + _progressNotification.Status = ProgressNotificationStatus.Completed; return Content(SETTINGS_FAILED); } [HttpPost] public ActionResult SaveNotifications(NotificationSettingsModel data) { - var basicNotification = new BasicNotification(); - basicNotification.Type = BasicNotificationType.Info; - basicNotification.AutoDismiss = true; + _notificationProvider.Register(_progressNotification); if (ModelState.IsValid) { @@ -411,22 +407,20 @@ namespace NzbDrone.Web.Controllers _configProvider.XbmcUsername = data.XbmcUsername; _configProvider.XbmcPassword = data.XbmcPassword; - basicNotification.Title = SETTINGS_SAVED; - _notificationProvider.Register(basicNotification); + _progressNotification.CurrentMessage = SETTINGS_SAVED; + _progressNotification.Status = ProgressNotificationStatus.Completed; return Content(SETTINGS_SAVED); } - basicNotification.Title = SETTINGS_FAILED; - _notificationProvider.Register(basicNotification); + _progressNotification.CurrentMessage = SETTINGS_FAILED; + _progressNotification.Status = ProgressNotificationStatus.Completed; return Content(SETTINGS_FAILED); } [HttpPost] public ActionResult SaveEpisodeSorting(EpisodeSortingModel data) { - var basicNotification = new BasicNotification(); - basicNotification.Type = BasicNotificationType.Info; - basicNotification.AutoDismiss = true; + _notificationProvider.Register(_progressNotification); if (ModelState.IsValid) { @@ -440,13 +434,13 @@ namespace NzbDrone.Web.Controllers _configProvider.SortingNumberStyle = data.NumberStyle; _configProvider.SortingMultiEpisodeStyle = data.MultiEpisodeStyle; - basicNotification.Title = SETTINGS_SAVED; - _notificationProvider.Register(basicNotification); + _progressNotification.CurrentMessage = SETTINGS_SAVED; + _progressNotification.Status = ProgressNotificationStatus.Completed; return Content(SETTINGS_SAVED); } - basicNotification.Title = SETTINGS_FAILED; - _notificationProvider.Register(basicNotification); + _progressNotification.CurrentMessage = SETTINGS_FAILED; + _progressNotification.Status = ProgressNotificationStatus.Completed; return Content(SETTINGS_FAILED); } } diff --git a/NzbDrone.Web/Scripts/settingsForm.js b/NzbDrone.Web/Scripts/settingsForm.js index d4b051599..dfb7b8609 100644 --- a/NzbDrone.Web/Scripts/settingsForm.js +++ b/NzbDrone.Web/Scripts/settingsForm.js @@ -7,6 +7,7 @@ resetForm: false }; $('#form').ajaxForm(options); + $('#save_button').removeAttr('disabled'); }); function showRequest(formData, jqForm, options) { diff --git a/NzbDrone.Web/Views/Settings/EpisodeSorting.cshtml b/NzbDrone.Web/Views/Settings/EpisodeSorting.cshtml index dd96cf082..1bc05aa36 100644 --- a/NzbDrone.Web/Views/Settings/EpisodeSorting.cshtml +++ b/NzbDrone.Web/Views/Settings/EpisodeSorting.cshtml @@ -81,7 +81,7 @@ - Loader + Loader }
diff --git a/NzbDrone.Web/Views/Settings/Indexers.cshtml b/NzbDrone.Web/Views/Settings/Indexers.cshtml index 1f0e104f7..44094b9fb 100644 --- a/NzbDrone.Web/Views/Settings/Indexers.cshtml +++ b/NzbDrone.Web/Views/Settings/Indexers.cshtml @@ -9,8 +9,7 @@ { padding-top: 20px; } - - + } @section TitleContent{ @@ -126,10 +125,14 @@ }
- Loader + Loader }
+} + +@section Scripts{ + } \ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/Notifications.cshtml b/NzbDrone.Web/Views/Settings/Notifications.cshtml index 0a040bdae..e5e859d63 100644 --- a/NzbDrone.Web/Views/Settings/Notifications.cshtml +++ b/NzbDrone.Web/Views/Settings/Notifications.cshtml @@ -92,7 +92,7 @@ @Html.TextBoxFor(m => m.XbmcPassword, new { @class = "inputClass" }) - Loader + Loader } diff --git a/NzbDrone.Web/Views/Settings/Quality.cshtml b/NzbDrone.Web/Views/Settings/Quality.cshtml index b27bed24c..7be8f82ed 100644 --- a/NzbDrone.Web/Views/Settings/Quality.cshtml +++ b/NzbDrone.Web/Views/Settings/Quality.cshtml @@ -40,7 +40,7 @@ Settings
- Loader + Loader } diff --git a/NzbDrone.Web/Views/Settings/Sabnzbd.cshtml b/NzbDrone.Web/Views/Settings/Sabnzbd.cshtml index a731bc2d7..03696c16c 100644 --- a/NzbDrone.Web/Views/Settings/Sabnzbd.cshtml +++ b/NzbDrone.Web/Views/Settings/Sabnzbd.cshtml @@ -66,7 +66,7 @@ @Html.TextBoxFor(m => m.SabDropDirectory, new { @class = "inputClass folderLookup" }) - Loader + Loader } diff --git a/NzbDrone.Web/Views/Settings/Test.cshtml b/NzbDrone.Web/Views/Settings/Test.cshtml index 03660916e..18d52b0b0 100644 --- a/NzbDrone.Web/Views/Settings/Test.cshtml +++ b/NzbDrone.Web/Views/Settings/Test.cshtml @@ -1,20 +1,17 @@ -
- -
- - + + + \ No newline at end of file