From bf7ebbd26126440510f53028130dc24a6926eee1 Mon Sep 17 00:00:00 2001 From: thelastWallE <12502210+thelastWallE@users.noreply.github.com> Date: Tue, 19 Oct 2021 10:21:08 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20setting=20for=20hiding=20co?= =?UTF-8?q?nfirmation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add setting to hide confirmation before reloading klipper --- octoprint_klipper/__init__.py | 3 +- octoprint_klipper/static/js/klipper.js | 43 ++++++++++++++----- .../templates/klipper_settings.jinja2 | 5 ++- 3 files changed, 39 insertions(+), 12 deletions(-) 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 = "