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.
This commit is contained in:
Mark McDowall 2011-08-04 21:38:18 -07:00
parent d85a8bc15d
commit 3507b97887
11 changed files with 65 additions and 60 deletions

View File

@ -6,7 +6,7 @@ namespace NzbDrone.Core.Model.Notification
{ {
public BasicNotification() public BasicNotification()
{ {
Id = Guid.Empty; Id = Guid.NewGuid();
} }
/// <summary> /// <summary>

View File

@ -107,4 +107,12 @@ p, h1, form, button{border:0; margin:0; padding:0;}
width: 20px; width: 20px;
height: 20px; height: 20px;
display: none; display: none;
}
#save_button[disabled="disabled"]
{
padding: 0px 6px 0px 6px;
border: 2px outset ButtonFace;
color: lightgrey;
cursor: progress;
} }

View File

@ -67,6 +67,8 @@ namespace NzbDrone.Web.Controllers
private string GetCurrentMessage() private string GetCurrentMessage()
{ {
var notes = _notifications.ProgressNotifications;
if (_notifications.ProgressNotifications.Count != 0) if (_notifications.ProgressNotifications.Count != 0)
return _notifications.ProgressNotifications[0].CurrentMessage; return _notifications.ProgressNotifications[0].CurrentMessage;

View File

@ -32,6 +32,7 @@ namespace NzbDrone.Web.Controllers
private readonly DiskProvider _diskProvider; private readonly DiskProvider _diskProvider;
private readonly SeriesProvider _seriesProvider; private readonly SeriesProvider _seriesProvider;
private readonly ExternalNotificationProvider _externalNotificationProvider; private readonly ExternalNotificationProvider _externalNotificationProvider;
private readonly ProgressNotification _progressNotification;
public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider, public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider,
QualityProvider qualityProvider, RootDirProvider rootDirProvider, QualityProvider qualityProvider, RootDirProvider rootDirProvider,
@ -48,6 +49,8 @@ namespace NzbDrone.Web.Controllers
_notificationProvider = notificationProvider; _notificationProvider = notificationProvider;
_diskProvider = diskProvider; _diskProvider = diskProvider;
_seriesProvider = seriesProvider; _seriesProvider = seriesProvider;
_progressNotification = new ProgressNotification("Settings");
} }
public ActionResult Test() public ActionResult Test()
@ -270,9 +273,7 @@ namespace NzbDrone.Web.Controllers
[HttpPost] [HttpPost]
public ActionResult SaveIndexers(IndexerSettingsModel data) public ActionResult SaveIndexers(IndexerSettingsModel data)
{ {
var basicNotification = new BasicNotification(); _notificationProvider.Register(_progressNotification);
basicNotification.Type = BasicNotificationType.Info;
basicNotification.AutoDismiss = true;
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
@ -304,22 +305,20 @@ namespace NzbDrone.Web.Controllers
_configProvider.NewzbinUsername = data.NewzbinUsername; _configProvider.NewzbinUsername = data.NewzbinUsername;
_configProvider.NewzbinPassword = data.NewzbinPassword; _configProvider.NewzbinPassword = data.NewzbinPassword;
basicNotification.Title = SETTINGS_SAVED; _progressNotification.CurrentMessage = SETTINGS_SAVED;
_notificationProvider.Register(basicNotification); _progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
basicNotification.Title = SETTINGS_FAILED; _progressNotification.CurrentMessage = SETTINGS_FAILED;
_notificationProvider.Register(basicNotification); _progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
[HttpPost] [HttpPost]
public ActionResult SaveSabnzbd(SabnzbdSettingsModel data) public ActionResult SaveSabnzbd(SabnzbdSettingsModel data)
{ {
var basicNotification = new BasicNotification(); _notificationProvider.Register(_progressNotification);
basicNotification.Type = BasicNotificationType.Info;
basicNotification.AutoDismiss = true;
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
@ -332,22 +331,20 @@ namespace NzbDrone.Web.Controllers
_configProvider.SabTvPriority = data.SabTvPriority; _configProvider.SabTvPriority = data.SabTvPriority;
_configProvider.SabDropDirectory = data.SabDropDirectory; _configProvider.SabDropDirectory = data.SabDropDirectory;
basicNotification.Title = SETTINGS_SAVED; _progressNotification.CurrentMessage = SETTINGS_SAVED;
_notificationProvider.Register(basicNotification); _progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
basicNotification.Title = SETTINGS_FAILED; _progressNotification.CurrentMessage = SETTINGS_FAILED;
_notificationProvider.Register(basicNotification); _progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
[HttpPost] [HttpPost]
public ActionResult SaveQuality(QualityModel data) public ActionResult SaveQuality(QualityModel data)
{ {
var basicNotification = new BasicNotification(); _notificationProvider.Register(_progressNotification);
basicNotification.Type = BasicNotificationType.Info;
basicNotification.AutoDismiss = true;
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
@ -379,22 +376,21 @@ namespace NzbDrone.Web.Controllers
_qualityProvider.Update(profile); _qualityProvider.Update(profile);
} }
basicNotification.Title = SETTINGS_SAVED;
_notificationProvider.Register(basicNotification); _progressNotification.CurrentMessage = SETTINGS_SAVED;
_progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
basicNotification.Title = SETTINGS_FAILED; _progressNotification.CurrentMessage = SETTINGS_FAILED;
_notificationProvider.Register(basicNotification); _progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
[HttpPost] [HttpPost]
public ActionResult SaveNotifications(NotificationSettingsModel data) public ActionResult SaveNotifications(NotificationSettingsModel data)
{ {
var basicNotification = new BasicNotification(); _notificationProvider.Register(_progressNotification);
basicNotification.Type = BasicNotificationType.Info;
basicNotification.AutoDismiss = true;
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
@ -411,22 +407,20 @@ namespace NzbDrone.Web.Controllers
_configProvider.XbmcUsername = data.XbmcUsername; _configProvider.XbmcUsername = data.XbmcUsername;
_configProvider.XbmcPassword = data.XbmcPassword; _configProvider.XbmcPassword = data.XbmcPassword;
basicNotification.Title = SETTINGS_SAVED; _progressNotification.CurrentMessage = SETTINGS_SAVED;
_notificationProvider.Register(basicNotification); _progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
basicNotification.Title = SETTINGS_FAILED; _progressNotification.CurrentMessage = SETTINGS_FAILED;
_notificationProvider.Register(basicNotification); _progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
[HttpPost] [HttpPost]
public ActionResult SaveEpisodeSorting(EpisodeSortingModel data) public ActionResult SaveEpisodeSorting(EpisodeSortingModel data)
{ {
var basicNotification = new BasicNotification(); _notificationProvider.Register(_progressNotification);
basicNotification.Type = BasicNotificationType.Info;
basicNotification.AutoDismiss = true;
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
@ -440,13 +434,13 @@ namespace NzbDrone.Web.Controllers
_configProvider.SortingNumberStyle = data.NumberStyle; _configProvider.SortingNumberStyle = data.NumberStyle;
_configProvider.SortingMultiEpisodeStyle = data.MultiEpisodeStyle; _configProvider.SortingMultiEpisodeStyle = data.MultiEpisodeStyle;
basicNotification.Title = SETTINGS_SAVED; _progressNotification.CurrentMessage = SETTINGS_SAVED;
_notificationProvider.Register(basicNotification); _progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
basicNotification.Title = SETTINGS_FAILED; _progressNotification.CurrentMessage = SETTINGS_FAILED;
_notificationProvider.Register(basicNotification); _progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
} }

View File

@ -7,6 +7,7 @@
resetForm: false resetForm: false
}; };
$('#form').ajaxForm(options); $('#form').ajaxForm(options);
$('#save_button').removeAttr('disabled');
}); });
function showRequest(formData, jqForm, options) { function showRequest(formData, jqForm, options) {

View File

@ -81,7 +81,7 @@
</div> </div>
</div> </div>
<button type="submit" id="save_button" >Save</button><img src="../../Content/Images/ajax-loader.gif" alt="Loader" id="saveAjax"/> <button type="submit" id="save_button" disabled="disabled">Save</button><img src="../../Content/Images/ajax-loader.gif" alt="Loader" id="saveAjax"/>
} }
</div> </div>
<div id="result" class="hiddenResult"></div> <div id="result" class="hiddenResult"></div>

View File

@ -9,8 +9,7 @@
{ {
padding-top: 20px; padding-top: 20px;
} }
</style>
</style>
} }
@section TitleContent{ @section TitleContent{
@ -126,10 +125,14 @@
} }
</div> </div>
<br/> <br/>
<button type="submit" id="save_button" >Save</button><img src="../../Content/Images/ajax-loader.gif" alt="Loader" id="saveAjax"/> <button type="submit" id="save_button" disabled="disabled">Save</button><img src="../../Content/Images/ajax-loader.gif" alt="Loader" id="saveAjax"/>
} }
</div> </div>
<div id="result" class="hiddenResult"></div> <div id="result" class="hiddenResult"></div>
}
@section Scripts{
<script src="/Scripts/settingsForm.js" type="text/javascript"></script>
} }

View File

@ -92,7 +92,7 @@
@Html.TextBoxFor(m => m.XbmcPassword, new { @class = "inputClass" }) @Html.TextBoxFor(m => m.XbmcPassword, new { @class = "inputClass" })
</div> </div>
<button type="submit" id="save_button" >Save</button><img src="../../Content/Images/ajax-loader.gif" alt="Loader" id="saveAjax"/> <button type="submit" id="save_button" disabled="disabled">Save</button><img src="../../Content/Images/ajax-loader.gif" alt="Loader" id="saveAjax"/>
} }
</div> </div>

View File

@ -40,7 +40,7 @@ Settings
</div> </div>
</div> </div>
<br /> <br />
<button type="submit" id="save_button" >Save</button><img src="../../Content/Images/ajax-loader.gif" alt="Loader" id="saveAjax"/> <button type="submit" id="save_button" disabled="disabled">Save</button><img src="../../Content/Images/ajax-loader.gif" alt="Loader" id="saveAjax"/>
</div> </div>
} }
</div> </div>

View File

@ -66,7 +66,7 @@
</label> </label>
@Html.TextBoxFor(m => m.SabDropDirectory, new { @class = "inputClass folderLookup" }) @Html.TextBoxFor(m => m.SabDropDirectory, new { @class = "inputClass folderLookup" })
<button type="submit" id="save_button" >Save</button><img src="../../Content/Images/ajax-loader.gif" alt="Loader" id="saveAjax"/> <button type="submit" id="save_button" disabled="disabled">Save</button><img src="../../Content/Images/ajax-loader.gif" alt="Loader" id="saveAjax"/>
} }
</div> </div>

View File

@ -1,20 +1,17 @@
<div id="image" value="5"> <script type="text/javascript">
<img src='../../Content/Images/watched.png' class='ignoreEpisode watched' value='5' /> $(document).ready(function () {
</div> //$('#save_button').attr('disabled', '');
<script type="text/javascript">
$(".ignoreEpisode").live("click", function () {
var toggle = $(this);
if (toggle.hasClass('watched')) {
toggle.removeClass('watched');
toggle.attr('src', '../../Content/Images/unwatched.png');
}
else {
toggle.addClass('watched');
toggle.attr('src', '../../Content/Images/watched.png');
}
}); });
</script> </script>
<style>
#save_button[disabled="disabled"]
{
padding: 0px 6px 0px 6px;
border: 2px outset ButtonFace;
color: GrayText;
cursor: inherit;
}
</style>
<button type="submit" id="save_button" disabled="disabled">Save</button>