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