From 3767f83fe23b597650f7a3197068bb25f771ca44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 8 Oct 2015 15:23:19 +0200 Subject: [PATCH] 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. --- src/octoprint/static/js/app/dataupdater.js | 1 - .../static/js/app/viewmodels/settings.js | 2 +- .../static/js/app/viewmodels/wizard.js | 28 +++++++++++++++---- .../templates/overlays/reloadui.jinja2 | 9 ++++-- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/octoprint/static/js/app/dataupdater.js b/src/octoprint/static/js/app/dataupdater.js index 443f657d..c607016d 100644 --- a/src/octoprint/static/js/app/dataupdater.js +++ b/src/octoprint/static/js/app/dataupdater.js @@ -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}); diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index f3d0ed20..0e2a23d5 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -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); diff --git a/src/octoprint/static/js/app/viewmodels/wizard.js b/src/octoprint/static/js/app/viewmodels/wizard.js index 54ca62e4..de9db3d0 100644 --- a/src/octoprint/static/js/app/viewmodels/wizard.js +++ b/src/octoprint/static/js/app/viewmodels/wizard.js @@ -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() { diff --git a/src/octoprint/templates/overlays/reloadui.jinja2 b/src/octoprint/templates/overlays/reloadui.jinja2 index 8790002e..746c9129 100644 --- a/src/octoprint/templates/overlays/reloadui.jinja2 +++ b/src/octoprint/templates/overlays/reloadui.jinja2 @@ -4,9 +4,14 @@

{{ _('Please reload') }}

-

{{ _('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.') }}

+

{% 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 %}

- {{ _('Reload now') }} + {{ _('Reload now') }}