Skip to content

Commit

Permalink
Add laser cutter mode switch
Browse files Browse the repository at this point in the history
  • Loading branch information
irlaec committed Sep 22, 2023
1 parent 133e76e commit ade0522
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
9 changes: 9 additions & 0 deletions octoprint_mrbeam/static/css/mrbeam.css
Original file line number Diff line number Diff line change
Expand Up @@ -3982,3 +3982,12 @@ div.hopscotch-bubble .hopscotch-bubble-number {
color: #638ba0;
}
/* Better together - end */

/* Laser cutter mode - start */
#laser_cutter_mode_select {
width: auto;
max-width: 100%;
margin-bottom: 0;
margin-left: 20px;
}
/* Laser cutter mode - end */
34 changes: 34 additions & 0 deletions octoprint_mrbeam/static/js/app/view-models/working-area.js
Original file line number Diff line number Diff line change
Expand Up @@ -3103,6 +3103,9 @@ $(function () {
"change",
throttle((event) => self._qt_currentQuickTextUpdate(event), 200)
);

// todo change to using LASER_CUTTER_MODE_NAME
$("laser_cutter_mode_select").val("default");
};

self.onAllBound = function (allViewModels) {
Expand Down Expand Up @@ -4611,6 +4614,37 @@ $(function () {
self._sendAnalytics = function (event, payload) {
self.analytics.send_frontend_event(event, payload);
};

self.changeLaserCutterMode = function (selectObject) {
console.log('Changing laser cutter mode to', selectObject.value)

showConfirmationDialog({
title: gettext("Do you want to switch the mode?"),
message: gettext(
"Keep in mind that the device will restart after switching the laser cutter mode."
),
question: gettext(`Do you want to switch to ${selectObject.value} mode?`),
proceed: gettext("Continue"),
proceedClass: "primary",
cancel: gettext("Cancel"),
onproceed: function () {
OctoPrint.simpleApiCommand("mrbeam", "lasercutter_mode_change", {"mode": selectObject.value})
.done(function (response) {
console.log("Laser cutter mode changed ", response);
})
.fail(function () {
console.log("Laser cutter mode change failed!");
new PNotify({
title: gettext("Could not change laser cutter mode"),
text: gettext(`Could not change the laser cutter mode to ${selectObject.value}.`),
type: "error",
hide: true,
});

});
},
});
};
}

// view model class, parameters for constructor, container to bind to
Expand Down
4 changes: 4 additions & 0 deletions octoprint_mrbeam/templates/mrbeam_ui_index.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
{% if navbar_label %}
<span style="margin: 6px; vertical-align: -5px; font-size: 14px; font-weight: 400; color: #e25303; text-decoration: none;">{{ navbar_label }}</span>
{% endif %}
<select id="laser_cutter_mode_select" data-test="laser-cutter-mode-select" onchange="window.mrbeam.viewModels.workingAreaViewModel.changeLaserCutterMode(this)">
<option value="default">{{ _('Default') }}</option>
<option value="rotary">{{ _('Rotary') }}</option>
</select>
</div>
<!-- Navbar -->
<ul id="mrbeam-main-tabs" class="nav nav-pills pull-right">
Expand Down

0 comments on commit ade0522

Please sign in to comment.