From beff41780b69cd43d64217fee21f868b4aa89bc2 Mon Sep 17 00:00:00 2001 From: ntoff Date: Sat, 10 Mar 2018 02:41:37 +1000 Subject: [PATCH] fix bizarre set of circumstances that could lead to malfunction of reconnect If the setting to reconnect is unticked, and a user hits the e-stop button, and then ticks the box to reconnect, and then manually disconnects, the printer would automatically reconnect. This fixes that. Also added an "unknown status" to the button, since the status should always be known, if it's not then it's not, you know? Yeah, me either. --- octoprint_estop/static/js/estop.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/octoprint_estop/static/js/estop.js b/octoprint_estop/static/js/estop.js index b2b876f..8d6cee8 100644 --- a/octoprint_estop/static/js/estop.js +++ b/octoprint_estop/static/js/estop.js @@ -30,12 +30,16 @@ $(function() { self.buttonText = ko.pureComputed(function() { if (self.enableEstop()) { return gettext("EMERGENCY STOP"); - } else if (self.reconnect()) { + } + else if (self.reconnect()) { return gettext("Reconnecting...") } - else { + else if (!self.enableEstop()) { return gettext("Offline"); } + else { + return gettext("Unknown Status"); + } }); self.buttonTitle = ko.pureComputed(function() { @@ -67,11 +71,11 @@ $(function() { self.sendEstopCommand = function () { if (self.enableEstop()) { - self.emergencyCalled(true); self.estopCommand(self.settings.settings.plugins.estop.estopCommand()); OctoPrint.control.sendGcode(self.estopCommand()); if (self.estopReconnect()) { + self.emergencyCalled(true); OctoPrint.connection.disconnect(); //normally octoprint would probably disconnect anyway, just calling this here in case the printer is in a blocking loop } }