function to check if user and printer is operational

clean up the jinja a bit too
This commit is contained in:
ntoff 2017-03-23 08:54:26 +10:00
parent e268bf9e95
commit f12c3903c0
2 changed files with 11 additions and 5 deletions

View File

@ -7,10 +7,16 @@ $(function() {
var self = this;
//see if we're logged in and the printer is operational (for en/disable of button)
self.loginState = parameters[0];
self.terminal = parameters[1];
self.printerState = parameters[1];
self.enableEstop = ko.pureComputed(function() {
return self.printerState.isOperational() && self.loginState.isUser();
});
self.sendEstopCommand = function () {
OctoPrint.control.sendGcode("M112"); //should this ever be a variable? M112 universal?
if (self.enableEstop()) {
OctoPrint.control.sendGcode("M112");
};
};
}
@ -18,7 +24,7 @@ $(function() {
construct: EstopViewModel,
dependencies: [
"loginStateViewModel",
"terminalViewModel",
"printerStateViewModel",
],
elements: ["#sidebar_plugin_estop"]
});

View File

@ -1,4 +1,4 @@
<div class="estop_sidebar">
<button type="button" id="emergemcy_stop" title="send M112 estop gcode command" class="btn-estop" data-bind="enable: terminal.isOperational() && loginState.isAdmin(), click: function() { sendEstopCommand() }"><i class="fa fa-times" size="+2"></i>{{ _(' EMERGENCY STOP ') }}<i class="fa fa-times" size="+2"></i></button>
<button type="button" id="emergemcy_stop" title="send M112 estop gcode command" class="btn-estop" data-bind="enable: enableEstop, click: function() { sendEstopCommand() }"><i class="fa fa-times" size="+2"></i>{{ _(' EMERGENCY STOP ') }}<i class="fa fa-times" size="+2"></i></button>
</div>