OctoPrint-Estop/octoprint_estop/static/js/estop.js

32 lines
785 B
JavaScript
Raw Normal View History

2017-03-22 22:17:16 +01:00
/*
* 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();
});
2017-03-22 22:17:16 +01:00
self.sendEstopCommand = function () {
if (self.enableEstop()) {
OctoPrint.control.sendGcode("M112");
};
2017-03-22 22:17:16 +01:00
};
}
OCTOPRINT_VIEWMODELS.push({
construct: EstopViewModel,
dependencies: [
"loginStateViewModel",
"printerStateViewModel",
2017-03-22 22:17:16 +01:00
],
elements: ["#sidebar_plugin_estop"]
});
});