f12c3903c0
clean up the jinja a bit too
32 lines
785 B
JavaScript
32 lines
785 B
JavaScript
/*
|
|
* Author: ntoff
|
|
* License: AGPLv3
|
|
*/
|
|
$(function() {
|
|
function EstopViewModel(parameters) {
|
|
var self = this;
|
|
//see if we're logged in and the printer is operational (for en/disable of button)
|
|
self.loginState = parameters[0];
|
|
self.printerState = parameters[1];
|
|
|
|
self.enableEstop = ko.pureComputed(function() {
|
|
return self.printerState.isOperational() && self.loginState.isUser();
|
|
});
|
|
|
|
self.sendEstopCommand = function () {
|
|
if (self.enableEstop()) {
|
|
OctoPrint.control.sendGcode("M112");
|
|
};
|
|
};
|
|
}
|
|
|
|
OCTOPRINT_VIEWMODELS.push({
|
|
construct: EstopViewModel,
|
|
dependencies: [
|
|
"loginStateViewModel",
|
|
"printerStateViewModel",
|
|
],
|
|
elements: ["#sidebar_plugin_estop"]
|
|
});
|
|
});
|