From de58b08e907e81850612962d887b037e393356d5 Mon Sep 17 00:00:00 2001 From: Teja Date: Sun, 4 Jan 2015 18:24:52 +0100 Subject: [PATCH] zaxis setting, settings not a popup anymore --- .../svgtogcode/static/js/working_area.js | 5 +- .../templates/override_index.jinja2 | 49 +- src/octoprint/printer.py | 1 + src/octoprint/server/__init__.py | 1 + src/octoprint/server/api/settings.py | 4 +- src/octoprint/server/util/sockjs.py | 2 - src/octoprint/settings.py | 3 +- src/octoprint/static/css/mrbeam.css | 1 - src/octoprint/static/js/app/main.js | 25 +- .../static/js/app/viewmodels/connection.js | 4 +- .../static/js/app/viewmodels/printerstate.js | 1 - .../static/js/app/viewmodels/settings.js | 11 +- src/octoprint/templates/dialogs.jinja2 | 22 + .../templates/settings_mrbeam.jinja2 | 501 ++++++++++++++++++ 14 files changed, 580 insertions(+), 50 deletions(-) create mode 100644 src/octoprint/templates/settings_mrbeam.jinja2 diff --git a/src/octoprint/plugins/svgtogcode/static/js/working_area.js b/src/octoprint/plugins/svgtogcode/static/js/working_area.js index 226a79ad..cff770b7 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/working_area.js +++ b/src/octoprint/plugins/svgtogcode/static/js/working_area.js @@ -36,8 +36,9 @@ function WorkingAreaViewModel(loginStateViewModel, settingsViewModel, printerSta }; self._fromData = function(data) { - workPosition = data.workPosition; - self._processPos(workPosition); + if(data.workPosition){ + self._processPos(data.workPosition); + } }; self.fromCurrentData = function(data) { diff --git a/src/octoprint/plugins/svgtogcode/templates/override_index.jinja2 b/src/octoprint/plugins/svgtogcode/templates/override_index.jinja2 index e558ed45..5caa37b9 100644 --- a/src/octoprint/plugins/svgtogcode/templates/override_index.jinja2 +++ b/src/octoprint/plugins/svgtogcode/templates/override_index.jinja2 @@ -79,7 +79,7 @@
  • working area
  • design library
  • focus
  • -
  • +
  • {{ _('settings') }}
  • @@ -127,11 +127,19 @@
    -
    + + + +
    + + +
    @@ -146,12 +154,7 @@
    -
    -
    - -
    +
    {{ _('Machine State') }}:
    {{ _('File') }}:  (SD)
    @@ -269,12 +272,9 @@
    +
    x,y
    - +
    + + {% if hasZAxis %}
    @@ -305,6 +307,8 @@
    + {% endif %} +
    @@ -376,12 +380,11 @@
    -
    - setting menu -
    -
    -
    settings
    -
    + +
    + {% include 'settings_mrbeam.jinja2' %} +
    +
    @@ -393,7 +396,7 @@
    - +
    - {% include 'settings.jinja2' %} + {% include 'dialogs.jinja2' %} diff --git a/src/octoprint/printer.py b/src/octoprint/printer.py index 3229a189..50c7c440 100644 --- a/src/octoprint/printer.py +++ b/src/octoprint/printer.py @@ -760,6 +760,7 @@ class StateMonitor(object): self._changeEvent.set() def setState(self, state): + print("state", state) with self._stateMutex: self._state = state self._changeEvent.set() diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index f4b0c1e7..4840f501 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -120,6 +120,7 @@ def index(): return render_template( root_template, webcamStream=settings().get(["webcam", "stream"]), + hasZAxis=settings().get(["feature", "zaxis"]), enableTimelapse=(settings().get(["webcam", "snapshot"]) is not None and settings().get(["webcam", "ffmpeg"]) is not None), enableGCodeVisualizer=settings().get(["gcodeViewer", "enabled"]), enableTemperatureGraph=settings().get(["feature", "temperatureGraph"]), diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index 6026a69d..dc5dbe53 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -70,7 +70,8 @@ def getSettings(): "sdAlwaysAvailable": s.getBoolean(["feature", "sdAlwaysAvailable"]), "swallowOkAfterResend": s.getBoolean(["feature", "swallowOkAfterResend"]), "repetierTargetTemp": s.getBoolean(["feature", "repetierTargetTemp"]), - "grbl": s.getBoolean(["feature", "grbl"]) + "grbl": s.getBoolean(["feature", "grbl"]), + "zaxis": s.getBoolean(["feature", "zaxis"]) }, "serial": { "port": connectionOptions["portPreference"], @@ -169,6 +170,7 @@ def setSettings(): if "swallowOkAfterResend" in data["feature"].keys(): s.setBoolean(["feature", "swallowOkAfterResend"], data["feature"]["swallowOkAfterResend"]) if "repetierTargetTemp" in data["feature"].keys(): s.setBoolean(["feature", "repetierTargetTemp"], data["feature"]["repetierTargetTemp"]) if "grbl" in data["feature"].keys(): s.setBoolean(["feature", "grbl"], data["feature"]["grbl"]) + if "zaxis" in data["feature"].keys(): s.setBoolean(["feature", "zaxis"], data["feature"]["zaxis"]) if "serial" in data.keys(): if "autoconnect" in data["serial"].keys(): s.setBoolean(["serial", "autoconnect"], data["serial"]["autoconnect"]) diff --git a/src/octoprint/server/util/sockjs.py b/src/octoprint/server/util/sockjs.py index 99be19b3..22374eac 100644 --- a/src/octoprint/server/util/sockjs.py +++ b/src/octoprint/server/util/sockjs.py @@ -70,7 +70,6 @@ class PrinterStateConnection(sockjs.tornado.SockJSConnection): pass def sendCurrentData(self, data): - print("send_current_data", data) # add current temperature, log and message backlogs to sent data with self._temperatureBacklogMutex: temperatures = self._temperatureBacklog @@ -132,5 +131,4 @@ class PrinterStateConnection(sockjs.tornado.SockJSConnection): self.sendEvent(event, payload) def _emit(self, type, payload): - print("emit", type, payload) self.send({type: payload}) diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index c3a3aa90..dc5fddc0 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -85,7 +85,8 @@ default_settings = { "sdAlwaysAvailable": False, "swallowOkAfterResend": True, "repetierTargetTemp": False, - "grbl": True + "grbl": True, + "zaxis": False }, "folder": { "uploads": None, diff --git a/src/octoprint/static/css/mrbeam.css b/src/octoprint/static/css/mrbeam.css index 1f552e85..7e61715b 100644 --- a/src/octoprint/static/css/mrbeam.css +++ b/src/octoprint/static/css/mrbeam.css @@ -1504,7 +1504,6 @@ ul.dropdown-menu li a { #control #btn_motors_off, #tab_temp, #temp, -#control_zaxis, #gcode_command_slider, #gcode_layer_slider, #renderer_options, #control_extruder {display:none;} diff --git a/src/octoprint/static/js/app/main.js b/src/octoprint/static/js/app/main.js index b58d862c..e1b1edea 100644 --- a/src/octoprint/static/js/app/main.js +++ b/src/octoprint/static/js/app/main.js @@ -55,15 +55,15 @@ $(function() { } }); }); - $('#navbar_show_settings').click(function() { - settingsDialog.modal() - .css({ - width: 'auto', - 'margin-left': function() { return -($(this).width() /2); } - }); - - return false; - }); +// $('#navbar_show_settings').click(function() { +// settingsDialog.modal() +// .css({ +// width: 'auto', +// 'margin-left': function() { return -($(this).width() /2); } +// }); +// +// return false; +// }); //~~ Initialize view models var loginStateViewModel = new LoginStateViewModel(); @@ -391,14 +391,12 @@ $(function() { }) } }; - console.log("wavm", workingAreaViewModel); settingsViewModel.requestData(function() { - console.log("settingsViewModel.requestData"); ko.applyBindings(settingsViewModel, document.getElementById("settings_dialog")); - ko.applyBindings(connectionViewModel, document.getElementById("connection_accordion")); - ko.applyBindings(printerStateViewModel, document.getElementById("state_accordion")); + ko.applyBindings(connectionViewModel, document.getElementById("connection")); + ko.applyBindings(printerStateViewModel, document.getElementById("state")); ko.applyBindings(gcodeFilesViewModel, document.getElementById("files_accordion")); //ko.applyBindings(temperatureViewModel, document.getElementById("temp")); ko.applyBindings(controlViewModel, document.getElementById("control")); @@ -421,7 +419,6 @@ $(function() { // // ko.applyBindings(slicingViewModel, document.getElementById("slicing_configuration_dialog")); // ko.applyBindings(vectorConversionViewModel, document.getElementById("dialog_vector_graphics_conversion")); -// console.log("settingsViewModel.requestData wavm", document.getElementById("working_area")); ko.applyBindings(workingAreaViewModel, document.getElementById("area_preview")); // apply bindings and signal startup diff --git a/src/octoprint/static/js/app/viewmodels/connection.js b/src/octoprint/static/js/app/viewmodels/connection.js index 42450128..1b4505c2 100644 --- a/src/octoprint/static/js/app/viewmodels/connection.js +++ b/src/octoprint/static/js/app/viewmodels/connection.js @@ -79,10 +79,10 @@ function ConnectionViewModel(loginStateViewModel, settingsViewModel) { if (self.previousIsOperational != self.isOperational()) { if (self.isOperational() && connectionTab.hasClass("in")) { // connection just got established, close connection tab for now - connectionTab.collapse("hide"); +// connectionTab.collapse("hide"); } else if (!connectionTab.hasClass("in")) { // connection just dropped, make sure connection tab is open - connectionTab.collapse("show"); +// connectionTab.collapse("show"); } } } diff --git a/src/octoprint/static/js/app/viewmodels/printerstate.js b/src/octoprint/static/js/app/viewmodels/printerstate.js index 6dfbb0cf..53f42407 100644 --- a/src/octoprint/static/js/app/viewmodels/printerstate.js +++ b/src/octoprint/static/js/app/viewmodels/printerstate.js @@ -116,7 +116,6 @@ function PrinterStateViewModel(loginStateViewModel) { self._processStateData = function(data) { var prevPaused = self.isPaused(); - self.stateString(gettext(data.text)); self.isErrorOrClosed(data.flags.closedOrError); self.isOperational(data.flags.operational); diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 909be619..e2ad6bc4 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -138,6 +138,7 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) { self.feature_sdAlwaysAvailable = ko.observable(undefined); self.feature_swallowOkAfterResend = ko.observable(undefined); self.feature_repetierTargetTemp = ko.observable(undefined); + self.feature_zaxis = ko.observable(undefined); self.serial_port = ko.observable(); self.serial_baudrate = ko.observable(); @@ -223,6 +224,7 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) { }; self.fromResponse = function(response) { + console.log("settings resp", response) if (self.settings === undefined) { self.settings = ko.mapping.fromJS(response); } else { @@ -262,6 +264,7 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) { self.feature_sdAlwaysAvailable(response.feature.sdAlwaysAvailable); self.feature_swallowOkAfterResend(response.feature.swallowOkAfterResend); self.feature_repetierTargetTemp(response.feature.repetierTargetTemp); + self.feature_zaxis(response.feature.zaxis); self.serial_port(response.serial.port); self.serial_baudrate(response.serial.baudrate); @@ -294,7 +297,7 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) { self.saveData = function() { var data = ko.mapping.toJS(self.settings); - + console.log("settings save", data) data = _.extend(data, { "api" : { "enabled": self.api_enabled(), @@ -333,7 +336,8 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) { "sdSupport": self.feature_sdSupport(), "sdAlwaysAvailable": self.feature_sdAlwaysAvailable(), "swallowOkAfterResend": self.feature_swallowOkAfterResend(), - "repetierTargetTemp": self.feature_repetierTargetTemp() + "repetierTargetTemp": self.feature_repetierTargetTemp(), + "zaxis": self.feature_zaxis() }, "serial": { "port": self.serial_port(), @@ -375,7 +379,8 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) { data: JSON.stringify(data), success: function(response) { self.fromResponse(response); - $("#settings_dialog").modal("hide"); +// $("#settings_dialog").modal("hide"); + $("#settings_save_btn").attr("disabled", "disabled"); } }); }; diff --git a/src/octoprint/templates/dialogs.jinja2 b/src/octoprint/templates/dialogs.jinja2 index fa7a322a..d6b069a4 100644 --- a/src/octoprint/templates/dialogs.jinja2 +++ b/src/octoprint/templates/dialogs.jinja2 @@ -134,3 +134,25 @@ {{ _('Keep Access Control Enabled') }}
    + diff --git a/src/octoprint/templates/settings_mrbeam.jinja2 b/src/octoprint/templates/settings_mrbeam.jinja2 new file mode 100644 index 00000000..54840d54 --- /dev/null +++ b/src/octoprint/templates/settings_mrbeam.jinja2 @@ -0,0 +1,501 @@ +