diff --git a/octoprint_klipper/__init__.py b/octoprint_klipper/__init__.py index 7790957..a7ef0da 100644 --- a/octoprint_klipper/__init__.py +++ b/octoprint_klipper/__init__.py @@ -136,6 +136,7 @@ class KlipperPlugin( logpath="/tmp/klippy.log", reload_command="RESTART", restart_onsave=False, + confirm_reload=True, shortStatus_navbar=True, shortStatus_sidebar=True, parse_check=False, @@ -597,7 +598,7 @@ class KlipperPlugin( # Restart klippy to reload config self._printer.commands(reload_command) logger.log_info(self, "Restarting Klipper.") - return NO_CONTENT + return flask.jsonify(command = reload_command) # APIs end diff --git a/octoprint_klipper/static/js/klipper.js b/octoprint_klipper/static/js/klipper.js index cb8dc43..a129ad9 100644 --- a/octoprint_klipper/static/js/klipper.js +++ b/octoprint_klipper/static/js/klipper.js @@ -254,20 +254,43 @@ $(function () { self.requestRestart = function () { if (!self.loginState.hasPermission(self.access.permissions.PLUGIN_KLIPPER_CONFIG)) return; - var request = function () { - OctoPrint.plugins.klipper.restartKlipper().done(function () { - self.consoleMessage("debug", "requestRestart"); + var request = function (index) { + OctoPrint.plugins.klipper.restartKlipper().done(function (response) { + self.consoleMessage("debug", "restartingKlipper"); + self.showPopUp("success", gettext("Reloaded Klipper"), "command: " + response.command); }); + if (index == 1) { + self.settings + .saveData({ + plugins: { + klipper: { + configuration: { + confirm_reload: false + } + } + } + }); + } }; - var html = "

" + gettext("All ongoing Prints will be stopped!") + "

"; + var html = "

" + + gettext("All ongoing Prints will be stopped!") + + "

"; - showConfirmationDialog({ - title: gettext("Klipper restart?"), - html: html, - proceed: gettext("Proceed"), - onproceed: request, - }); + if (self.settings.settings.plugins.klipper.configuration.confirm_reload() == true) { + showConfirmationDialog({ + title: gettext("Reload Klipper?"), + html: html, + proceed: [gettext("Reload"), gettext("Reload and don't show again.")], + onproceed: function (idx) { + if (idx > -1) { + request(idx); + } + }, + }); + } else { + request(0); + } }; // OctoKlipper settings link diff --git a/octoprint_klipper/templates/klipper_settings.jinja2 b/octoprint_klipper/templates/klipper_settings.jinja2 index 1d11005..cd1a8f9 100644 --- a/octoprint_klipper/templates/klipper_settings.jinja2 +++ b/octoprint_klipper/templates/klipper_settings.jinja2 @@ -78,7 +78,10 @@ {{ _('The command that is executed if you want to restart klipper.') }} +