2017-07-23 18:20:27 +02:00
|
|
|
/*
|
|
|
|
* View model for OctoPrint-Simpleemergencystop
|
|
|
|
*
|
|
|
|
* Author: Sebastien Clement
|
|
|
|
* License: AGPLv3
|
|
|
|
*/
|
|
|
|
$(function() {
|
|
|
|
function SimpleemergencystopViewModel(parameters) {
|
|
|
|
var self = this;
|
2017-07-25 23:58:19 +02:00
|
|
|
self.settings = undefined;
|
|
|
|
self.allSettings = parameters[0];
|
2017-07-23 18:20:27 +02:00
|
|
|
self.loginState = parameters[1];
|
|
|
|
self.printerState = parameters[2];
|
2017-07-25 23:58:19 +02:00
|
|
|
self.confirmation = undefined;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.onAfterBinding = function() {
|
|
|
|
self.confirmation = $("#confirmation");
|
|
|
|
self.settings = self.allSettings.settings.plugins.simpleemergencystop;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-07-23 18:20:27 +02:00
|
|
|
self.click = function () {
|
2017-07-25 23:58:19 +02:00
|
|
|
if(self.settings.confirmationDialog())
|
|
|
|
self.confirmation.modal("show");
|
|
|
|
else
|
|
|
|
self.sendCommand()
|
|
|
|
|
|
|
|
};
|
|
|
|
self.sendCommand = function () {
|
|
|
|
$.ajax({
|
2017-07-23 18:20:27 +02:00
|
|
|
url: API_BASEURL+"plugin/simpleemergencystop",
|
|
|
|
type: "POST",
|
|
|
|
dataType: "json",
|
|
|
|
data: JSON.stringify({
|
|
|
|
command: "emergencyStop"
|
|
|
|
}),
|
|
|
|
contentType: "application/json; charset=UTF-8",
|
|
|
|
success: function (data,status) {
|
2017-07-25 23:58:19 +02:00
|
|
|
self.confirmation.modal("hide");
|
2017-07-23 18:20:27 +02:00
|
|
|
}
|
2017-07-25 23:58:19 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-07-23 18:20:27 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// view model class, parameters for constructor, container to bind to
|
|
|
|
OCTOPRINT_VIEWMODELS.push([
|
|
|
|
SimpleemergencystopViewModel,
|
|
|
|
|
|
|
|
["settingsViewModel","loginStateViewModel","printerStateViewModel"],
|
|
|
|
|
|
|
|
["#navbar_plugin_simpleemergencystop"]
|
|
|
|
]);
|
|
|
|
});
|