diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 785abf97..e8751dcd 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -224,37 +224,48 @@ $(function() { self.terminalFilters.remove(filter); }; + self.testWebcamStreamUrlBusy = ko.observable(false); self.testWebcamStreamUrl = function() { if (!self.webcam_streamUrl()) { return; } + if (self.testWebcamStreamUrlBusy()) { + return; + } + var text = gettext("If you see your webcam stream below, the entered stream URL is ok."); var image = $(''); var message = $("

") .append(text) .append(image); + + self.testWebcamStreamUrlBusy(true); showMessageDialog({ title: gettext("Stream test"), - message: message + message: message, + onclose: function() { + self.testWebcamStreamUrlBusy(false); + } }); }; + self.testWebcamSnapshotUrlBusy = ko.observable(false); self.testWebcamSnapshotUrl = function(viewModel, event) { if (!self.webcam_snapshotUrl()) { return; } - var target = $(event.target); - target.prepend(' '); + if (self.testWebcamSnapshotUrlBusy()) { + return; + } var errorText = gettext("Could not retrieve snapshot URL, please double check the URL"); var errorTitle = gettext("Snapshot test failed"); + self.testWebcamSnapshotUrlBusy(true); OctoPrint.util.testUrl(self.webcam_snapshotUrl(), {method: "GET", response: "bytes"}) .done(function(response) { - $("i.icon-spinner", target).remove(); - if (!response.result) { showMessageDialog({ title: errorTitle, @@ -274,23 +285,34 @@ $(function() { var text = gettext("If you see your webcam snapshot picture below, the entered snapshot URL is ok."); showMessageDialog({ title: gettext("Snapshot test"), - message: $('

' + text + '

') + message: $('

' + text + '

'), + onclose: function() { + self.testWebcamSnapshotUrlBusy(false); + } }); }) .fail(function() { - $("i.icon-spinner", target).remove(); showMessageDialog({ title: errorTitle, - message: errorText + message: errorText, + onclose: function() { + self.testWebcamSnapshotUrlBusy(false); + } }); }); }; + self.testWebcamFfmpegPathBusy = ko.observable(false); self.testWebcamFfmpegPath = function() { if (!self.webcam_ffmpegPath()) { return; } + if (self.testWebcamFfmpegPathBusy()) { + return; + } + + self.testWebcamFfmpegPathBusy(true); OctoPrint.util.testExecutable(self.webcam_ffmpegPath()) .done(function(response) { if (!response.result) { @@ -306,6 +328,9 @@ $(function() { } self.webcam_ffmpegPathOk(response.result); self.webcam_ffmpegPathBroken(!response.result); + }) + .always(function() { + self.testWebcamFfmpegPathBusy(false); }); }; diff --git a/src/octoprint/templates/snippets/settings/webcam/ffmpegPath.jinja2 b/src/octoprint/templates/snippets/settings/webcam/ffmpegPath.jinja2 index 14375942..478e6166 100644 --- a/src/octoprint/templates/snippets/settings/webcam/ffmpegPath.jinja2 +++ b/src/octoprint/templates/snippets/settings/webcam/ffmpegPath.jinja2 @@ -3,7 +3,7 @@
- +
diff --git a/src/octoprint/templates/snippets/settings/webcam/webcamSnapshotUrl.jinja2 b/src/octoprint/templates/snippets/settings/webcam/webcamSnapshotUrl.jinja2 index da33fc48..cf149540 100644 --- a/src/octoprint/templates/snippets/settings/webcam/webcamSnapshotUrl.jinja2 +++ b/src/octoprint/templates/snippets/settings/webcam/webcamSnapshotUrl.jinja2 @@ -3,7 +3,7 @@
- +
{% trans %}Fully qualified URL, needs to be reachable by OctoPrint's server{% endtrans %}
diff --git a/src/octoprint/templates/snippets/settings/webcam/webcamStreamUrl.jinja2 b/src/octoprint/templates/snippets/settings/webcam/webcamStreamUrl.jinja2 index a26337fa..42aaa529 100644 --- a/src/octoprint/templates/snippets/settings/webcam/webcamStreamUrl.jinja2 +++ b/src/octoprint/templates/snippets/settings/webcam/webcamStreamUrl.jinja2 @@ -3,7 +3,7 @@
- +
{% trans %}Needs to be reachable from the browser displaying the OctoPrint UI, used to embed the webcam stream into the page.{% endtrans %}