diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index ad6b46868..8e6c4d125 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -98,6 +98,8 @@ def getSettings(): "defaultExtrusionLength": s.getInt(["printerParameters", "defaultExtrusionLength"]) }, "webcam": { + "webcamEnabled": s.getBoolean(["webcam", "webcamEnabled"]), + "timelapseEnabled": s.getBoolean(["webcam", "timelapseEnabled"]), "streamUrl": s.get(["webcam", "stream"]), "streamRatio": s.get(["webcam", "streamRatio"]), "streamTimeout": s.getInt(["webcam", "streamTimeout"]), @@ -382,6 +384,8 @@ def _saveSettings(data): if "defaultExtrusionLength" in data["printer"]: s.setInt(["printerParameters", "defaultExtrusionLength"], data["printer"]["defaultExtrusionLength"]) if "webcam" in data.keys(): + if "webcamEnabled" in data["webcam"]: s.setBoolean(["webcam", "webcamEnabled"], data["webcam"]["webcamEnabled"]) + if "timelapseEnabled" in data["webcam"]: s.setBoolean(["webcam", "timelapseEnabled"], data["webcam"]["timelapseEnabled"]) if "streamUrl" in data["webcam"]: s.set(["webcam", "stream"], data["webcam"]["streamUrl"]) if "streamRatio" in data["webcam"] and data["webcam"]["streamRatio"] in ("16:9", "4:3"): s.set(["webcam", "streamRatio"], data["webcam"]["streamRatio"]) if "streamTimeout" in data["webcam"]: s.setInt(["webcam", "streamTimeout"], data["webcam"]["streamTimeout"]) diff --git a/src/octoprint/server/api/timelapse.py b/src/octoprint/server/api/timelapse.py index 98fa5dc43..c93e14e11 100644 --- a/src/octoprint/server/api/timelapse.py +++ b/src/octoprint/server/api/timelapse.py @@ -111,6 +111,7 @@ def getTimelapseData(): finished_list.append(output) result = dict(config=config, + enabled=settings().getBoolean(["webcam", "timelapseEnabled"]), files=finished_list) if unrendered: diff --git a/src/octoprint/server/views.py b/src/octoprint/server/views.py index 8006ad5b6..e189fb733 100644 --- a/src/octoprint/server/views.py +++ b/src/octoprint/server/views.py @@ -179,7 +179,7 @@ def index(): enable_accesscontrol = userManager.enabled enable_gcodeviewer = settings().getBoolean(["gcodeViewer", "enabled"]) - enable_timelapse = bool(settings().get(["webcam", "snapshot"]) and settings().get(["webcam", "ffmpeg"])) + enable_timelapse = settings().getBoolean(["webcam", "timelapseEnabled"]) def default_template_filter(template_type, template_key): if template_type == "navbar": @@ -355,7 +355,7 @@ def index(): now) render_kwargs.update(dict( - webcamStream=settings().get(["webcam", "stream"]), + enableWebcam=settings().getBoolean(["webcam", "enableWebcam"]) and bool(settings().get(["webcam", "stream"])), enableTemperatureGraph=settings().get(["feature", "temperatureGraph"]), enableAccessControl=enable_accesscontrol, accessControlActive=accesscontrol_active, diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index d97c6d171..db7492842 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -209,6 +209,8 @@ default_settings = { } }, "webcam": { + "webcamEnabled": True, + "timelapseEnabled": True, "stream": None, "streamRatio": "16:9", "streamTimeout": 5, diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 397c00a46..219ae41dd 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -117,6 +117,8 @@ $(function() { self.printer_defaultExtrusionLength = ko.observable(undefined); + self.webcam_webcamEnabled = ko.observable(undefined); + self.webcam_timelapseEnabled = ko.observable(undefined); self.webcam_streamUrl = ko.observable(undefined); self.webcam_streamRatio = ko.observable(undefined); self.webcam_streamTimeout = ko.observable(undefined); diff --git a/src/octoprint/static/js/app/viewmodels/timelapse.js b/src/octoprint/static/js/app/viewmodels/timelapse.js index 74c1bf22f..958fa2786 100644 --- a/src/octoprint/static/js/app/viewmodels/timelapse.js +++ b/src/octoprint/static/js/app/viewmodels/timelapse.js @@ -3,6 +3,7 @@ $(function() { var self = this; self.loginState = parameters[0]; + self.settings = parameters[1]; self.timelapsePopup = undefined; @@ -523,7 +524,7 @@ $(function() { OCTOPRINT_VIEWMODELS.push({ construct: TimelapseViewModel, - dependencies: ["loginStateViewModel"], + dependencies: ["loginStateViewModel", "settingsViewModel"], elements: ["#timelapse"] }); }); diff --git a/src/octoprint/templates/dialogs/settings/webcam.jinja2 b/src/octoprint/templates/dialogs/settings/webcam.jinja2 index f53894271..ebec6fad6 100644 --- a/src/octoprint/templates/dialogs/settings/webcam.jinja2 +++ b/src/octoprint/templates/dialogs/settings/webcam.jinja2 @@ -1,6 +1,7 @@

{{ _('Webcam') }}

+ {% include "snippets/settings/webcam/webcamEnabled.jinja2" %} {% include "snippets/settings/webcam/webcamStreamUrl.jinja2" %} {% include "snippets/settings/webcam/webcamStreamRatio.jinja2" %} {% include "snippets/settings/webcam/webcamOrientation.jinja2" %} @@ -16,6 +17,7 @@

{{ _('Timelapse Recordings') }}

+ {% include "snippets/settings/webcam/timelapseEnabled.jinja2" %} {% include "snippets/settings/webcam/webcamSnapshotUrl.jinja2" %} {% include "snippets/settings/webcam/ffmpegPath.jinja2" %} {% include "snippets/settings/webcam/watermark.jinja2" %} diff --git a/src/octoprint/templates/sidebar/state.jinja2 b/src/octoprint/templates/sidebar/state.jinja2 index 80e90da8b..71ab5f2b7 100644 --- a/src/octoprint/templates/sidebar/state.jinja2 +++ b/src/octoprint/templates/sidebar/state.jinja2 @@ -4,7 +4,9 @@ {{ _('User') }}:
+ {{ _('Timelapse') }}:
+
diff --git a/src/octoprint/templates/snippets/settings/webcam/timelapseEnabled.jinja2 b/src/octoprint/templates/snippets/settings/webcam/timelapseEnabled.jinja2 new file mode 100644 index 000000000..e11a1a8ac --- /dev/null +++ b/src/octoprint/templates/snippets/settings/webcam/timelapseEnabled.jinja2 @@ -0,0 +1,7 @@ +
+
+ +
+
diff --git a/src/octoprint/templates/snippets/settings/webcam/webcamEnabled.jinja2 b/src/octoprint/templates/snippets/settings/webcam/webcamEnabled.jinja2 new file mode 100644 index 000000000..e719d3d2f --- /dev/null +++ b/src/octoprint/templates/snippets/settings/webcam/webcamEnabled.jinja2 @@ -0,0 +1,7 @@ +
+
+ +
+
diff --git a/src/octoprint/templates/tabs/control.jinja2 b/src/octoprint/templates/tabs/control.jinja2 index 14b672508..c809f2b37 100644 --- a/src/octoprint/templates/tabs/control.jinja2 +++ b/src/octoprint/templates/tabs/control.jinja2 @@ -1,4 +1,4 @@ -{% if webcamStream %} +{% if enableWebcam %}
@@ -7,7 +7,7 @@

{{ _('Webcam stream not loaded') }}

{{ _('It might not be configured correctly or require authentication. To have this fixed, get in touch with an administrator of this OctoPrint instance.') }}

-

{{ _('It might not be configured correctly or require authentication. You can change the URL of the stream under "Settings" > "Webcam & Timelapse" > "Stream URL". If you don\'t have a webcam just set the URL to an empty value.') }}

+

{{ _('It might not be configured correctly or require authentication. You can change the URL of the stream under "Settings" > "Webcam & Timelapse" > "Webcam" > "Stream URL". If you don\'t have a webcam you can also just disable webcam support there.') }}

{{ _('Currently configured stream URL') }}:

diff --git a/src/octoprint/templates/tabs/timelapse.jinja2 b/src/octoprint/templates/tabs/timelapse.jinja2 index c47778de5..eefa7ff6b 100644 --- a/src/octoprint/templates/tabs/timelapse.jinja2 +++ b/src/octoprint/templates/tabs/timelapse.jinja2 @@ -1,93 +1,104 @@
-
- {{ _('Take note that timelapse configuration is disabled while your printer is printing.') }} +
+
+ {{ _('Take note that timelapse configuration is disabled while your printer is printing.') }} +
+ +

{{ _('Timelapse Configuration') }}

+ + +
+ +
+ + {{ _('Note') }} {% trans %}Does not work when printing from the printer's SD Card (no way to detect the change in Z reliably). Use "Timed" mode for those prints instead.{% endtrans %} +
+
+ +
+ +
+
+ + {{ _('sec') }} +
+ {{ _('OctoPrint will rate limit snapshots to this minimum interval. This it to prevent against performance issues with vase mode/continous z prints.') }} +
+
+ +
+ +
+
+ + {{ _('sec') }} +
+
+
+ +
+ +
+
+ + {{ _('fps') }} +
+
+
+ +
+ +
+
+ + {{ _('sec') }} +
+ {{ _('OctoPrint will use the final picture to add this many seconds to the end of your rendered timelapse.') }} +
+
+ +
+ +
+
+ + {{ _('mm') }} +
+ {{ _('Enter the retraction z-hop used in the firmware or the gcode file to trigger snapshots for the timelapse only if a real layer change happens. For this to work properly your retraction z-hop has to be different from your layerheight!') }} +
+
+ +
+
+ +
+
+ +
+
+ {{ _('You have unsaved changes. Don\'t forget to save them.') }} + + +
+
+ +
+ - -

{{ _('Timelapse Configuration') }}

- -
-
- -
- - {{ _('Note') }} {% trans %}Does not work when printing from the printer's SD Card (no way to detect the change in Z reliably). Use "Timed" mode for those prints instead.{% endtrans %} -
-
- -
- -
-
- - {{ _('sec') }} -
- {{ _('OctoPrint will rate limit snapshots to this minimum interval. This it to prevent against performance issues with vase mode/continous z prints.') }} -
-
- -
- -
-
- - {{ _('sec') }} -
-
-
- -
- -
-
- - {{ _('fps') }} -
-
-
- -
- -
-
- - {{ _('sec') }} -
- {{ _('OctoPrint will use the final picture to add this many seconds to the end of your rendered timelapse.') }} -
-
- -
- -
-
- - {{ _('mm') }} -
- {{ _('Enter the retraction z-hop used in the firmware or the gcode file to trigger snapshots for the timelapse only if a real layer change happens. For this to work properly your retraction z-hop has to be different from your layerheight!') }} -
-
- -
-
- -
-
- -
-
- {{ _('You have unsaved changes. Don\'t forget to save them.') }} - - -
-
-

{{ _('Finished Timelapses') }}

diff --git a/src/octoprint/timelapse.py b/src/octoprint/timelapse.py index 221c898f9..203934505 100644 --- a/src/octoprint/timelapse.py +++ b/src/octoprint/timelapse.py @@ -316,24 +316,16 @@ def configure_timelapse(config=None, persist=False): snapshot_url = settings().get(["webcam", "snapshot"]) ffmpeg_path = settings().get(["webcam", "ffmpeg"]) + timelapse_enabled = settings().getBoolean(["webcam", "timelapseEnabled"]) timelapse_precondition = snapshot_url is not None and snapshot_url.strip() != "" \ and ffmpeg_path is not None and ffmpeg_path.strip() != "" type = config["type"] - if not timelapse_precondition and type is not None and type != "off": + if not timelapse_precondition and timelapse_precondition: logging.getLogger(__name__).warn("Essential timelapse settings unconfigured (snapshot URL or FFMPEG path) " - "but timelapse enabled, forcing disabled timelapse and disabling it " - "in the config as well.") - type = "off" - config["type"] = "off" + "but timelapse enabled.") - if not persist: - # make sure we persist at least that timelapse is now disabled by default - we don't want the above - # warning to log - settings().set(["webcam", "timelapse", "type"], "off") - settings().save() - - if type is None or "off" == type: + if not timelapse_enabled or not timelapse_precondition or type is None or "off" == type: current = None else: