dynamic class, invisible to anon users
dynamic class based on state, completely invisible to non logged in users
This commit is contained in:
@ -5,14 +5,26 @@
|
||||
$(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.estopState = ko.pureComputed(function() {
|
||||
return self.loginState.isUser() > 0 ? "estop_sidebar" : "estop_sidebar_disabled";
|
||||
});
|
||||
|
||||
self.buttonText = ko.pureComputed(function() {
|
||||
if (self.enableEstop()) {
|
||||
return gettext("EMERGENCY STOP");
|
||||
} else {
|
||||
return gettext("Offline");
|
||||
}
|
||||
});
|
||||
|
||||
self.sendEstopCommand = function () {
|
||||
if (self.enableEstop()) {
|
||||
OctoPrint.control.sendGcode("M112");
|
||||
@ -26,6 +38,6 @@ $(function() {
|
||||
"loginStateViewModel",
|
||||
"printerStateViewModel",
|
||||
],
|
||||
elements: ["#sidebar_plugin_estop"]
|
||||
elements: ["#sidebar_plugin_estop_wrapper"]
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user