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.
pull/4/head
Mark McDowall 13 years ago
parent d85a8bc15d
commit 3507b97887

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

@ -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;
}

@ -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;

@ -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);
}
}

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

@ -81,7 +81,7 @@
</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 id="result" class="hiddenResult"></div>

@ -9,8 +9,7 @@
{
padding-top: 20px;
}
</style>
</style>
}
@section TitleContent{
@ -126,10 +125,14 @@
}
</div>
<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 id="result" class="hiddenResult"></div>
}
@section Scripts{
<script src="/Scripts/settingsForm.js" type="text/javascript"></script>
}

@ -92,7 +92,7 @@
@Html.TextBoxFor(m => m.XbmcPassword, new { @class = "inputClass" })
</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>

@ -40,7 +40,7 @@ Settings
</div>
</div>
<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>

@ -66,7 +66,7 @@
</label>
@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>

@ -1,20 +1,17 @@
<div id="image" value="5">
<img src='../../Content/Images/watched.png' class='ignoreEpisode watched' value='5' />
</div>
<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 type="text/javascript">
$(document).ready(function () {
//$('#save_button').attr('disabled', '');
});
</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>
Loading…
Cancel
Save