OctoPrint-Estop/octoprint_estop/static/js/estop.js
2017-03-23 08:54:26 +10:00

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"]
});
});