function to check if user and printer is operational
clean up the jinja a bit too
This commit is contained in:
parent
e268bf9e95
commit
f12c3903c0
@ -7,10 +7,16 @@ $(function() {
|
|||||||
var self = this;
|
var self = this;
|
||||||
//see if we're logged in and the printer is operational (for en/disable of button)
|
//see if we're logged in and the printer is operational (for en/disable of button)
|
||||||
self.loginState = parameters[0];
|
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 () {
|
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,
|
construct: EstopViewModel,
|
||||||
dependencies: [
|
dependencies: [
|
||||||
"loginStateViewModel",
|
"loginStateViewModel",
|
||||||
"terminalViewModel",
|
"printerStateViewModel",
|
||||||
],
|
],
|
||||||
elements: ["#sidebar_plugin_estop"]
|
elements: ["#sidebar_plugin_estop"]
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<div class="estop_sidebar">
|
<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>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user