From d8dc8131a24e651b35c55449d237d3e8041c0fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 26 Jan 2023 10:06:26 +0100 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=90=9B=20Trigger=20FILE=5FDESELECTED?= =?UTF-8?q?=20on=20disconnect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #4623 --- src/octoprint/printer/standard.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 2acf848c9..72e9a2e6f 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -1491,12 +1491,17 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): if self._comm is not None: self._comm = None + with self._selectedFileMutex: + if self._selectedFile is not None: + eventManager().fire(Events.FILE_DESELECTED) + self._setJobData(None, None, None) + self._updateProgressData() self._setCurrentZ(None) - self._setJobData(None, None, None) self._setOffsets(None) self._addTemperatureData() self._printerProfileManager.deselect() + eventManager().fire(Events.DISCONNECTED) self._setState(state, state_string=state_string, error_string=error_string) From eb89369c6f96f855fc468d686cc54ffa7b251190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 26 Jan 2023 10:54:56 +0100 Subject: [PATCH 2/4] =?UTF-8?q?=E2=9C=A8=20New=20gettext=20knockout=20bind?= =?UTF-8?q?ing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allows to wrap a value into a gettext call to translate dynamic values (if a translation is available). --- src/octoprint/server/util/flask.py | 1 + src/octoprint/static/js/app/bindings/gettext.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/octoprint/static/js/app/bindings/gettext.js diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py index bb1b52c58..799a0f9d9 100644 --- a/src/octoprint/server/util/flask.py +++ b/src/octoprint/server/util/flask.py @@ -1759,6 +1759,7 @@ def collect_core_assets(preferred_stylesheet="css"): assets["js"] = [ "js/app/bindings/allowbindings.js", "js/app/bindings/contextmenu.js", + "js/app/bindings/gettext.js", "js/app/bindings/invisible.js", "js/app/bindings/popover.js", "js/app/bindings/qrcode.js", diff --git a/src/octoprint/static/js/app/bindings/gettext.js b/src/octoprint/static/js/app/bindings/gettext.js new file mode 100644 index 000000000..5a897a138 --- /dev/null +++ b/src/octoprint/static/js/app/bindings/gettext.js @@ -0,0 +1,16 @@ +ko.bindingHandlers.gettext = { + init: function () { + // Prevent binding on the dynamically-injected text node (as developers are unlikely to expect that, and it has security implications). + // It should also make things faster, as we no longer have to consider whether the text node might be bindable. + return {controlsDescendantBindings: true}; + }, + update: function (element, valueAccessor) { + var gt = + gettext || + function (text) { + return text; + }; + ko.utils.setTextContent(element, gt(valueAccessor())); + } +}; +ko.virtualElements.allowedBindings["gettext"] = true; From 61195f067650cb9812a6955f46163544e4755443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 26 Jan 2023 10:55:56 +0100 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=90=9B=20Translate=20Permission=20des?= =?UTF-8?q?criptions=20in=20UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use new gettext binding. Closes #4626 --- .../snippets/settings/accesscontrol/permission_list.jinja2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/templates/snippets/settings/accesscontrol/permission_list.jinja2 b/src/octoprint/templates/snippets/settings/accesscontrol/permission_list.jinja2 index d90d6ef41..aa3bf1db3 100644 --- a/src/octoprint/templates/snippets/settings/accesscontrol/permission_list.jinja2 +++ b/src/octoprint/templates/snippets/settings/accesscontrol/permission_list.jinja2 @@ -6,7 +6,7 @@ {{ _('Plugin') }} {{ _('Dangerous') }}
- + From 1d0a2287f82fd32b7ee3431c192c27cb20fe06f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 26 Jan 2023 11:07:13 +0100 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=90=9B=20Fix=20a=20broken=20identifie?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/classicwebcam/templates/classicwebcam_webcam.jinja2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/plugins/classicwebcam/templates/classicwebcam_webcam.jinja2 b/src/octoprint/plugins/classicwebcam/templates/classicwebcam_webcam.jinja2 index b90c7ecf6..1e6246124 100644 --- a/src/octoprint/plugins/classicwebcam/templates/classicwebcam_webcam.jinja2 +++ b/src/octoprint/plugins/classicwebcam/templates/classicwebcam_webcam.jinja2 @@ -1,6 +1,6 @@
-
+