From d5a083b0b5965181faa05d166b75b57029d4741b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 18 Aug 2015 17:04:27 +0200 Subject: [PATCH] Extracted FFMPEG path config into reusable snippet & added test button --- .../static/js/app/viewmodels/settings.js | 55 ++++++++++++++++++- .../dialogs/_snippets/configureffmpeg.jinja2 | 10 ++++ .../templates/dialogs/settings/webcam.jinja2 | 9 +-- 3 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 src/octoprint/templates/dialogs/_snippets/configureffmpeg.jinja2 diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index fdf930ac..0db0aa71 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -169,6 +169,10 @@ $(function() { self.settings = undefined; self.lastReceivedSettings = undefined; + self.webcam_ffmpegPathText = ko.observable(); + self.webcam_ffmpegPathOk = ko.observable(false); + self.webcam_ffmpegPathBroken = ko.observable(false); + self.addTemperatureProfile = function() { self.temperature_profiles.push({name: "New", extruder:0, bed:0}); }; @@ -253,6 +257,43 @@ $(function() { }); }; + self.testWebcamFfmpegPath = function() { + if (!self.webcam_ffmpegPath()) { + return; + } + + var successCallback = function(response) { + if (!response.result) { + if (!response.exists) { + self.webcam_ffmpegPathText(gettext("The path doesn't exist")); + } else if (!response.typeok) { + self.webcam_ffmpegPathText(gettext("The path is not a file")); + } else if (!response.access) { + self.webcam_ffmpegPathText(gettext("The path is not an executable")); + } + } else { + self.webcam_ffmpegPathText(gettext("The path is valid")); + } + self.webcam_ffmpegPathOk(response.result); + self.webcam_ffmpegPathBroken(!response.result); + }; + + var path = self.webcam_ffmpegPath(); + $.ajax({ + url: API_BASEURL + "util/test", + type: "POST", + dataType: "json", + data: JSON.stringify({ + command: "path", + path: path, + check_type: "file", + check_access: "x" + }), + contentType: "application/json; charset=UTF-8", + success: successCallback + }) + }; + self.onSettingsShown = function() { self.requestData(); }; @@ -698,15 +739,23 @@ $(function() { }; self.saveEnqueued = function(callback) { - var data = self.enqueuedForSaving; - self.enqueuedForSaving = undefined; + var data = self.getEnqueued(); + self.resetEnqueued(); if (data == undefined) { return; } self.saveData(data, callback); - } + }; + + self.getEnqueued = function() { + return self.enqueuedForSaving; + }; + + self.resetEnqueued = function() { + self.enqueueForSaving = undefined; + }; } OCTOPRINT_VIEWMODELS.push([ diff --git a/src/octoprint/templates/dialogs/_snippets/configureffmpeg.jinja2 b/src/octoprint/templates/dialogs/_snippets/configureffmpeg.jinja2 new file mode 100644 index 00000000..b2eb4136 --- /dev/null +++ b/src/octoprint/templates/dialogs/_snippets/configureffmpeg.jinja2 @@ -0,0 +1,10 @@ +
+ +
+
+ + +
+ +
+
diff --git a/src/octoprint/templates/dialogs/settings/webcam.jinja2 b/src/octoprint/templates/dialogs/settings/webcam.jinja2 index d39b69f0..40c062ed 100644 --- a/src/octoprint/templates/dialogs/settings/webcam.jinja2 +++ b/src/octoprint/templates/dialogs/settings/webcam.jinja2 @@ -1,11 +1,8 @@
{% include "dialogs/_snippets/configurewebcamurls.jinja2" %} -
- -
- -
-
+ + {% include "dialogs/_snippets/configureffmpeg.jinja2" %} +