Add a confirmation to disconnect while printing

Fullfills a feature request:
https://github.com/foosel/OctoPrint/issues/2287

Add a confirmation dialog if a user attempts to disconnect while a print
is in progress
This commit is contained in:
ntoff committed 2018-03-07 22:21:54 +10:00
1 parent 6a3f1d28fb
commit fb6ff04013
1 file changed
+18 -2
@@ -125,8 +125,24 @@ $(function() {
self.settings.printerProfiles.requestData();
});
} else {
self.requestData();
OctoPrint.connection.disconnect();
if (!self.isPrinting() && !self.isPaused()) {
self.requestData();
OctoPrint.connection.disconnect();
} else {
showConfirmationDialog({
title: gettext("Are you sure?"),
message: gettext("<p><strong>You are about to disconnect from the printer while a print is in progress.</strong></p> \
<p>Disconnecting while a print is in progress will prevent OctoPrint from completing the print. If you're printing from an SD card attached directly to the printer, any attempt to restart OctoPrint or reconnect to the printer could interrupt the print.<p>"),
question: gettext("Are you sure you want to disconnect from the printer?"),
cancel: gettext("Stay Connected"),
proceed: gettext("Disconnect"),
onproceed: function() {
self.requestData();
OctoPrint.connection.disconnect();
}
})
}
}
};