From f88bae066c354e2389a05719769a7ab8873a4cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 23 Mar 2023 18:14:00 +0100 Subject: [PATCH 01/17] =?UTF-8?q?=F0=9F=90=9B=20gcv:=20get=20rid=20of=20do?= =?UTF-8?q?uble=20load?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Could happen if not switched to tab yet after reload, then switching over. Mentioned in #4772 --- .../plugins/gcodeviewer/static/js/gcodeviewer.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js index 5b49120f8..0b9e71df9 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js @@ -345,8 +345,6 @@ $(function () { self.currentlyPrinting = false; - self.errorCount = 0; - self.layerSlider = undefined; self.layerCommandSlider = undefined; @@ -510,7 +508,12 @@ $(function () { self.loadFile = function (path, date, size) { self.enableReload(false); self.needsLoad = false; - if (self.status === "idle" && self.errorCount < 3) { + if ( + self.status === "idle" && + self.cachedPath !== path && + self.cachedDate !== date && + self.cachedSize !== size + ) { self.status = "request"; self.cachedPath = path; @@ -609,7 +612,6 @@ $(function () { ) { self._renderPercentage(data.progress.completion); } - self.errorCount = 0; } else { if (self.status === "idle") self.clear(); if ( From c1c1cccc5602d452cfb6c04f36fa2301d21f575b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 23 Mar 2023 18:15:06 +0100 Subject: [PATCH 02/17] =?UTF-8?q?=F0=9F=A5=85=20gcv:=20make=20sure=20cmds?= =?UTF-8?q?=20are=20available?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes a symptom of whatever causes #4772, might at least render the viewer functional again. --- src/octoprint/plugins/gcodeviewer/static/js/viewer/reader.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/octoprint/plugins/gcodeviewer/static/js/viewer/reader.js b/src/octoprint/plugins/gcodeviewer/static/js/viewer/reader.js index 5fca079b1..18c0f8b70 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/viewer/reader.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/viewer/reader.js @@ -127,7 +127,10 @@ GCODE.gCodeReader = (function () { if (key == null) return {layer: cachedLayer, cmd: cachedCmd}; var layer = searchInLayers(0, rendererModel.length - 1, key); - var cmd = searchInCmds(layer, 0, GCODE.renderer.getLayer(layer).length - 1, key); + var cmds = GCODE.renderer.getLayer(layer); + if (cmds === undefined) return undefined; + + var cmd = searchInCmds(layer, 0, cmds.length - 1, key); // remember last position cachedLayer = layer; From a4b0d340a773aad61488f2d522cc3474a3f9fc47 Mon Sep 17 00:00:00 2001 From: JoveToo Date: Mon, 27 Mar 2023 12:18:00 +0200 Subject: [PATCH 03/17] =?UTF-8?q?=F0=9F=90=9B=20Add=20X-Original-Content-L?= =?UTF-8?q?ength=20to=20file=20downloads=20(#4775)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoids issues with chunked transfers that remove the "Content-Length" header, which the GCODE viewer requires for calculating percentages for progress monitoring. Closes #4772 --- src/octoprint/plugins/gcodeviewer/static/js/viewer/worker.js | 2 +- src/octoprint/server/util/tornado.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/octoprint/plugins/gcodeviewer/static/js/viewer/worker.js b/src/octoprint/plugins/gcodeviewer/static/js/viewer/worker.js index c1be5700c..5ab1e537e 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/viewer/worker.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/viewer/worker.js @@ -353,7 +353,7 @@ var gCodeLineGenerator = async function* (fileURL) { const reader = response.body.getReader(); // we use these two variables to calculate the percentage. - var totalDownloadLength = response.headers.get("content-length"); + var totalDownloadLength = response.headers.get("X-Original-Content-Length"); var currentDownloadLength = 0; // lets read a first data chunk diff --git a/src/octoprint/server/util/tornado.py b/src/octoprint/server/util/tornado.py index b4be6a6d9..89e41e9c6 100644 --- a/src/octoprint/server/util/tornado.py +++ b/src/octoprint/server/util/tornado.py @@ -1192,6 +1192,8 @@ class LargeResponseHandler( self.set_header("Cache-Control", "max-age=0, must-revalidate, private") self.set_header("Expires", "-1") + self.set_header("X-Original-Content-Length", str(self.get_content_size())) + @property def original_absolute_path(self): """The path of the uncompressed file corresponding to the compressed file""" From 1ae36c9aff20995445d9339608a63197fab11cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 27 Mar 2023 12:24:12 +0200 Subject: [PATCH 04/17] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20onWebcamVisbility?= =?UTF-8?q?Change=20->=20onWebcamVisibilityChange?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #4776 --- .../plugins/classicwebcam/static/js/classicwebcam.js | 2 +- src/octoprint/static/js/app/viewmodels/control.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/octoprint/plugins/classicwebcam/static/js/classicwebcam.js b/src/octoprint/plugins/classicwebcam/static/js/classicwebcam.js index f1b99522a..70d610fcf 100644 --- a/src/octoprint/plugins/classicwebcam/static/js/classicwebcam.js +++ b/src/octoprint/plugins/classicwebcam/static/js/classicwebcam.js @@ -54,7 +54,7 @@ $(function () { }); }; - self.onWebcamVisbilityChange = function (visible) { + self.onWebcamVisibilityChange = function (visible) { self.webcamStreamVisible = visible; if (self.webcamStreamVisible) { self._enableWebcam(); diff --git a/src/octoprint/static/js/app/viewmodels/control.js b/src/octoprint/static/js/app/viewmodels/control.js index 84e7c3615..554dab821 100644 --- a/src/octoprint/static/js/app/viewmodels/control.js +++ b/src/octoprint/static/js/app/viewmodels/control.js @@ -66,11 +66,11 @@ $(function () { console.debug( `VM for webcam #${target.id} not found, skipping visibility update` ); - } else if (typeof vm.onWebcamVisbilityChange === "function") { - vm.onWebcamVisbilityChange(visible); + } else if (typeof vm.onWebcamVisibilityChange === "function") { + vm.onWebcamVisibilityChange(visible); } else { console.debug( - `VM for webcam #${target.id} does not declare 'onWebcamVisbilityChange(visible)', skipping visibility update (vm=${vm.constructor.name})` + `VM for webcam #${target.id} does not declare 'onWebcamVisibilityChange(visible)', skipping visibility update (vm=${vm.constructor.name})` ); } }; @@ -84,7 +84,7 @@ $(function () { // A webcam will not intersect with the control tab if the control tab is invisible because another tab // is selected or if the webcam isn't shown because another webcam is active. // - // Whenever the webacam changes visibility we will call onWebcamVisbilityChange() which the webcam's + // Whenever the webacam changes visibility we will call onWebcamVisibilityChange() which the webcam's // VM can use to start or stop the stream. self.intersectionObservers.forEach(function (observer) { observer.disconnect(); From cf7f72e2405ade3da6129acb6061c89bf0dcc553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 27 Mar 2023 18:33:23 +0200 Subject: [PATCH 05/17] =?UTF-8?q?=F0=9F=9A=B8=20Remember=20last=20shown=20?= =?UTF-8?q?webcam=20on=20the=20client?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See #4778 --- .../static/js/app/viewmodels/control.js | 19 +++++++++++++++++++ src/octoprint/templates/tabs/control.jinja2 | 7 ++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/octoprint/static/js/app/viewmodels/control.js b/src/octoprint/static/js/app/viewmodels/control.js index 554dab821..107d28c6d 100644 --- a/src/octoprint/static/js/app/viewmodels/control.js +++ b/src/octoprint/static/js/app/viewmodels/control.js @@ -75,7 +75,26 @@ $(function () { } }; + const selectedCameraStorageKey = "core.control.selectedCamera"; + self.selectDefaultWebcam = function () { + let div = localStorage[selectedCameraStorageKey]; + + if (!div || document.getElementById(div.slice(1)) === null) { + div = undefined; + } + + if (div !== undefined) { + $(`${div}_link a`).tab("show"); + } else { + $("#webcam_plugins_container .nav li:first a").tab("show"); + } + }; + self.onStartupComplete = function () { + $("#webcam_plugins_container .nav a[data-toggle='tab']").on("shown", (e) => { + localStorage[selectedCameraStorageKey] = e.target.hash; + }); + self.selectDefaultWebcam(); self.recreateIntersectionObservers(); }; diff --git a/src/octoprint/templates/tabs/control.jinja2 b/src/octoprint/templates/tabs/control.jinja2 index 7ee865855..222a37896 100644 --- a/src/octoprint/templates/tabs/control.jinja2 +++ b/src/octoprint/templates/tabs/control.jinja2 @@ -1,9 +1,6 @@ {% if enableWebcam %}
- {% set nsContent = namespace(mark_active = True) %} - {% set nsTab = namespace(mark_active = True) %} -
{% for key in templates.webcam.order %} {% set entry, data = templates.webcam.entries[key] %} @@ -11,7 +8,7 @@ {% if "custom_bindings" not in data or data["custom_bindings"] %}{% endif %}
{% try "There was an error with the template {filename} at line number {lineno}: {exception}" %}{% include data.template ignore missing %}{% endtry %} @@ -29,7 +26,7 @@ {% set entry, data = templates.webcam.entries[key] %} {% endfor %} From 0d733b8c2e6b7ac0f6754723a6a22b101bc25428 Mon Sep 17 00:00:00 2001 From: Charlie Powell <31997505+cp2004@users.noreply.github.com> Date: Tue, 11 Apr 2023 08:32:13 +0100 Subject: [PATCH 06/17] :bug: Fix typo in classicwebcam snapshot (#4785) Closes OctoPrint/OctoPrint#4782 --- src/octoprint/plugins/classicwebcam/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/plugins/classicwebcam/__init__.py b/src/octoprint/plugins/classicwebcam/__init__.py index 048fde57b..f45aed491 100644 --- a/src/octoprint/plugins/classicwebcam/__init__.py +++ b/src/octoprint/plugins/classicwebcam/__init__.py @@ -134,7 +134,7 @@ class ClassicWebcamPlugin( snapshot_url, stream=True, timeout=self._settings.get_int(["snapshotTimeout"]), - verify=self._settings.get_boolean(["rosnapshotSslValidationtate90"]), + verify=self._settings.get_boolean(["snapshotSslValidation"]), ) r.raise_for_status() return r.iter_content(chunk_size=1024) From a6de25e8645ce6a387890ae3bc7b8d3162f34c46 Mon Sep 17 00:00:00 2001 From: Charlie Powell <31997505+cp2004@users.noreply.github.com> Date: Tue, 11 Apr 2023 09:34:00 +0100 Subject: [PATCH 07/17] :bug: Fix `webcam.snapshotWebcam` not saving to config (#4784) It had no default so OctoPrint didn't want to save it Closes #4783 --- src/octoprint/schema/config/webcam.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/octoprint/schema/config/webcam.py b/src/octoprint/schema/config/webcam.py index 1f3c87338..8f6bd7567 100644 --- a/src/octoprint/schema/config/webcam.py +++ b/src/octoprint/schema/config/webcam.py @@ -78,3 +78,6 @@ class WebcamConfig(BaseModel): defaultWebcam: str = "classic" """The name of the default webcam""" + + snapshotWebcam: str = "classic" + """The name of the default webcam to use for snapshots""" From 0f922283f88cc6b76e846c7aa548757592fead77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 11 Apr 2023 14:18:26 +0200 Subject: [PATCH 08/17] =?UTF-8?q?=F0=9F=9A=B8=20Improve=20documentation=20?= =?UTF-8?q?of=20use=20of=20Default=20Webcam?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make clear it's only used on the webcam compat layer on the settings API Also fix some HTML semantics. Closes #4778 --- .../settings/webcam/defaultWebcam.jinja2 | 35 ++++++++++++------- .../settings/webcam/snapshotWebcam.jinja2 | 10 +++--- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/octoprint/templates/snippets/settings/webcam/defaultWebcam.jinja2 b/src/octoprint/templates/snippets/settings/webcam/defaultWebcam.jinja2 index b1ebc496d..2d03acf5b 100644 --- a/src/octoprint/templates/snippets/settings/webcam/defaultWebcam.jinja2 +++ b/src/octoprint/templates/snippets/settings/webcam/defaultWebcam.jinja2 @@ -1,5 +1,5 @@ -
- +
+
- {{ _('Snapshot stream')}}  +
+ {{ _('Snapshot stream')}}    @@ -23,11 +23,11 @@ {{ _('Not supported')}} - +
- {{ _('You can make changes to this webcam in the plugin\'s settings.') }} +
{{ _('You can make changes to this webcam in the plugin\'s settings.') }}
From 16c8647e218ede054f1144d2d16d21790bd7a49d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 11 Apr 2023 18:49:28 +0200 Subject: [PATCH 09/17] =?UTF-8?q?=F0=9F=90=9B=20Make=20sure=20to=20reconfi?= =?UTF-8?q?gure=20timelapse=20on=20snapshot=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #4789 --- src/octoprint/server/api/settings.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index 4139a3de7..5bb611bb5 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -15,6 +15,7 @@ from octoprint.server import pluginManager, printer, userManager from octoprint.server.api import NO_CONTENT, api from octoprint.server.util.flask import no_firstrun_access, with_revalidation_checking from octoprint.settings import settings, valid_boolean_trues +from octoprint.timelapse import configure_timelapse from octoprint.webcams import ( get_default_webcam, get_snapshot_webcam, @@ -656,6 +657,9 @@ def _saveSettings(data): if "snapshotWebcam" in data["webcam"]: s.set(["webcam", "snapshotWebcam"], data["webcam"]["snapshotWebcam"]) + # timelapse needs to be reconfigured now since it depends on the current snapshot webcam + configure_timelapse() + if "feature" in data: if "temperatureGraph" in data["feature"]: s.setBoolean( From add76c821cfa2281ee85f38b9462d45899476332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 11 Apr 2023 18:50:17 +0200 Subject: [PATCH 10/17] =?UTF-8?q?=F0=9F=9A=B8=20Some=20rephrasing=20for=20?= =?UTF-8?q?better=20understanding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../snippets/settings/webcam/defaultWebcam.jinja2 | 2 +- .../snippets/settings/webcam/snapshotWebcam.jinja2 | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/octoprint/templates/snippets/settings/webcam/defaultWebcam.jinja2 b/src/octoprint/templates/snippets/settings/webcam/defaultWebcam.jinja2 index 2d03acf5b..db2dcc128 100644 --- a/src/octoprint/templates/snippets/settings/webcam/defaultWebcam.jinja2 +++ b/src/octoprint/templates/snippets/settings/webcam/defaultWebcam.jinja2 @@ -35,7 +35,7 @@ layer provided on the settings API.

- You can make changes to this webcam in the plugin's settings. + You can make changes to this webcam's configuration in its plugin settings if it provides any.

{% endtrans %}
diff --git a/src/octoprint/templates/snippets/settings/webcam/snapshotWebcam.jinja2 b/src/octoprint/templates/snippets/settings/webcam/snapshotWebcam.jinja2 index dc095d8e6..0737bbb96 100644 --- a/src/octoprint/templates/snippets/settings/webcam/snapshotWebcam.jinja2 +++ b/src/octoprint/templates/snippets/settings/webcam/snapshotWebcam.jinja2 @@ -27,7 +27,14 @@ -
{{ _('You can make changes to this webcam in the plugin\'s settings.') }}
+
{% trans %} +

+ Selects the webcam to use to take snapshots for the timelapse. +

+

+ You can make changes to this webcam's configuration in its plugin settings, if it provides any. +

+ {% endtrans %}
From 4f3937de091218b769afd9e94c3b4fb7f8dfb947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 11 Apr 2023 19:31:03 +0200 Subject: [PATCH 11/17] =?UTF-8?q?=F0=9F=9A=B8=20Even=20more=20clarificatio?= =?UTF-8?q?n=20of=20the=20role=20of=20the=20"default=20webcam"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now renamed to fallback webcam, since that is what it is. Also moved to the end of the configuration dialog. See #4778 --- .../templates/dialogs/settings/webcam.jinja2 | 22 +++++++++++++++++-- .../settings/webcam/defaultWebcam.jinja2 | 15 ++----------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/octoprint/templates/dialogs/settings/webcam.jinja2 b/src/octoprint/templates/dialogs/settings/webcam.jinja2 index b81710708..dfe2f2d75 100644 --- a/src/octoprint/templates/dialogs/settings/webcam.jinja2 +++ b/src/octoprint/templates/dialogs/settings/webcam.jinja2 @@ -2,11 +2,10 @@ {{ _('Note: ') }}{{ _('Please note that OctoPrint merely embeds a webcam stream & access a snapshot URL. It does not actually run its own webcam server or interact directly with your camera. It thus can\'t impose access restrictions on it or enable/disable the stream for you. Please see this FAQ entry for more explanation.', url="http://faq.octoprint.org/external-webcam-server") }}
-

{{ _('Webcam') }}

+

{{ _('Webcam Streaming') }}

{% include "snippets/settings/webcam/webcamEnabled.jinja2" %} - {% include "snippets/settings/webcam/defaultWebcam.jinja2" %}

{{ _('Timelapse Recordings') }}

@@ -29,3 +28,22 @@ + +

{{ _('Fallback Webcam') }}

+ +{% trans %}

+ Select the webcam to fall back to to populate the stream and snapshot URLs on the settings + API used by old clients that do not yet utilize the webcam plugin + system introduced in OctoPrint 1.9.0. If the selected webcam does not + provide a snapshot or stream URL, it won't be available on the settings API and thus + to older clients. +

+

+ Note that this does not affect the webcam stream options available + in OctoPrint's core UI, nor the snapshot camera used for timelapse recordings. + It is exclusively relevant for the compatibility layer provided on the settings API. +

{% endtrans %} + +
+ {% include "snippets/settings/webcam/defaultWebcam.jinja2" %} +
diff --git a/src/octoprint/templates/snippets/settings/webcam/defaultWebcam.jinja2 b/src/octoprint/templates/snippets/settings/webcam/defaultWebcam.jinja2 index db2dcc128..f406d6736 100644 --- a/src/octoprint/templates/snippets/settings/webcam/defaultWebcam.jinja2 +++ b/src/octoprint/templates/snippets/settings/webcam/defaultWebcam.jinja2 @@ -1,5 +1,5 @@ -
- +
+