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 f061723365..225dc97a78 100644 --- a/NzbDrone.Core/Model/Notification/BasicNotification.cs +++ b/NzbDrone.Core/Model/Notification/BasicNotification.cs @@ -6,7 +6,7 @@ public class BasicNotification { public BasicNotification() { - Id = Guid.Empty; + Id = Guid.NewGuid(); } /// diff --git a/NzbDrone.Web/Content/Settings.css b/NzbDrone.Web/Content/Settings.css index 2169714bf5..fc8d817e77 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 c1796cac04..43a02b5c0c 100644 --- a/NzbDrone.Web/Controllers/NotificationController.cs +++ b/NzbDrone.Web/Controllers/NotificationController.cs @@ -67,6 +67,8 @@ public JsonResult Comet(string message) 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 5c2a364361..f263828bfa 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -32,6 +32,7 @@ public class SettingsController : Controller 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 @@ public SettingsController(ConfigProvider configProvider, IndexerProvider indexer _notificationProvider = notificationProvider; _diskProvider = diskProvider; _seriesProvider = seriesProvider; + + _progressNotification = new ProgressNotification("Settings"); } public ActionResult Test() @@ -270,9 +273,7 @@ public JsonResult AutoConfigureSab() [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 @@ public ActionResult SaveIndexers(IndexerSettingsModel data) _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 @@ public ActionResult SaveSabnzbd(SabnzbdSettingsModel data) _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 @@ public ActionResult SaveQuality(QualityModel data) _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 @@ public ActionResult SaveNotifications(NotificationSettingsModel data) _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 @@ public ActionResult SaveEpisodeSorting(EpisodeSortingModel data) _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 d4b0515999..dfb7b86092 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 dd96cf0823..1bc05aa366 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 1f0e104f7b..44094b9fb6 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 0a040bdaee..e5e859d632 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 b27bed24c3..7be8f82edf 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 a731bc2d72..03696c16cc 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 03660916e9..18d52b0b07 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