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.
This commit is contained in:
ntoff 2018-03-10 02:41:37 +10:00
parent 3666aa5e8d
commit beff41780b

View File

@ -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
}
}