diff --git a/README.md b/README.md index d567213..62f304b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # OctoPrint-WebcamTab -This OctoPrint plugin relocates the webcam stream into a separate tab. +This OctoPrint plugin moves the webcam stream from the controls into its own tab. Keyboard control is still possible and it is compatible with the [FullScreen Plugin](https://github.com/BillyBlaze/OctoPrint-FullScreen). ## Setup diff --git a/octoprint_webcamtab/__init__.py b/octoprint_webcamtab/__init__.py index e87230d..8f6934d 100644 --- a/octoprint_webcamtab/__init__.py +++ b/octoprint_webcamtab/__init__.py @@ -22,7 +22,7 @@ class WebcamTabPlugin(octoprint.plugin.AssetPlugin, def get_template_configs(self): return [ - dict(type="tab", name="Webcam") + dict(type="tab", name="Webcam", template=None) ] # Softwareupdate hook diff --git a/octoprint_webcamtab/static/js/webcamtab.js b/octoprint_webcamtab/static/js/webcamtab.js index 0c060a7..c85be92 100644 --- a/octoprint_webcamtab/static/js/webcamtab.js +++ b/octoprint_webcamtab/static/js/webcamtab.js @@ -51,14 +51,15 @@ $(function() { } }; - self.onStartup = function() { - var container = $("#control #webcam_container"); - if (container.length) { - var hint = container.next(); - if (hint.attr("data-bind") === "visible: keycontrolPossible") { - hint.remove(); + self.onAfterBinding = function() { + var tab = $("#tab_plugin_webcamtab"); + var webcam = $("#webcam_container"); + if (webcam) { + var hint = webcam.next(); + tab.append(webcam.detach()); + if (hint && hint.attr("data-bind") === "visible: keycontrolPossible") { + tab.append(hint.detach()); } - container.remove(); } }; }; diff --git a/octoprint_webcamtab/templates/webcamtab_tab.jinja2 b/octoprint_webcamtab/templates/webcamtab_tab.jinja2 deleted file mode 100644 index a1c04f4..0000000 --- a/octoprint_webcamtab/templates/webcamtab_tab.jinja2 +++ /dev/null @@ -1,36 +0,0 @@ -
{{ _('Webcam stream loading...') }}
-{{ _('Webcam stream not loaded') }}
-{{ _('It might not be correctly configured. 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.') }}
-