Slight timing changes in wizard finishing process

We now wait until the settings have been saved before we close the dialog.
That should hopefully reduce chances of an asynchronous "Oh no, the settings
were updated" message showing up just when finishing the dialog.
This commit is contained in:
Gina Häußge 2015-10-08 15:23:19 +02:00
parent dd4bec3329
commit 3767f83fe2
4 changed files with 30 additions and 10 deletions

View file

@ -7,7 +7,6 @@ function DataUpdater(allViewModels) {
self._configHash = undefined;
self.reloadOverlay = $("#reloadui_overlay");
$("#reloadui_overlay_reload").click(function() { location.reload(true); });
self.connect = function() {
OctoPrint.socket.connect({debug: !!SOCKJS_DEBUG});

View file

@ -705,7 +705,7 @@ $(function() {
data = getOnlyChangedData(self.getLocalData(), self.lastReceivedSettings);
}
OctoPrint.settings.save(data)
return OctoPrint.settings.save(data)
.done(function(data, status, xhr) {
self.receiving(true);
self.sending(false);

View file

@ -6,6 +6,7 @@ $(function() {
self.settingsViewModel = parameters[1];
self.wizardDialog = undefined;
self.reloadOverlay = undefined;
self.allViewModels = undefined;
@ -40,6 +41,7 @@ $(function() {
self.onStartup = function() {
self.wizardDialog = $("#wizard_dialog");
self.reloadOverlay = $("#reloadui_overlay");
};
self.onUserLoggedIn = function() {
@ -126,8 +128,7 @@ $(function() {
.done(function() {
self.closeDialog();
if (reload) {
log.info("Wizard requested reloading");
location.reload(true);
self.reloadOverlay.show();
}
});
}
@ -144,12 +145,27 @@ $(function() {
};
self.finishWizard = function() {
var deferred = $.Deferred();
self.finishing = true;
self.settingsViewModel.saveData();
return OctoPrint.wizard.finish(self.wizards)
.always(function() {
self.finishing = false;
self.settingsViewModel.saveData()
.done(function() {
OctoPrint.wizard.finish(self.wizards)
.done(function() {
deferred.resolve(arguments);
})
.fail(function() {
deferred.reject(arguments);
})
.always(function() {
self.finishing = false;
});
})
.fail(function() {
deferred.reject(arguments);
});
return deferred;
};
self.onSettingsPreventRefresh = function() {

View file

@ -4,9 +4,14 @@
<div class="container">
<div class="hero-unit">
<h1>{{ _('Please reload') }}</h1>
<p>{{ _('There is a new version of the server active now, a reload of the user interface is needed. This will not interrupt any print jobs you might have ongoing. Please reload the web interface now by clicking the button below.') }}</p>
<p>{% trans %}
There is a new version of the server active now, a reload
of the user interface is needed. This will not interrupt
any print jobs you might have ongoing. Please reload the
web interface now by clicking the button below.
{% endtrans %}</p>
<p>
<a class="btn btn-primary btn-large" id="reloadui_overlay_reload">{{ _('Reload now') }}</a>
<a class="btn btn-primary btn-large" title="{{ _('Reload now') }}" href="javascript:void(0)" onclick="location.reload(true); return false;">{{ _('Reload now') }}</a>
</p>
</div>
</div>