diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 3929f6469..35784ddde 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -391,6 +391,18 @@ $(function () { } }); + self.webcamCompat = { + webcam_streamUrl: "streamUrl", + webcam_streamRatio: "streamRatio", + webcam_streamTimeout: "streamTimeout", + webcam_streamWebrtcIceServers: "webrtcIceServers", + webcam_snapshotUrl: "snapshotUrl", + webcam_flipH: "flipH", + webcam_flipV: "flipV", + webcam_rotate90: "rotate90", + webcam_cacheBuster: "cacheBuster" + }; + self.addTemperatureProfile = function () { self.temperature_profiles.push({ name: "New", @@ -1140,6 +1152,31 @@ $(function () { } }; + // set up webcam compat layer if not yet done + _.each(self.webcamCompat, (mapped, key) => { + if (self.settings.hasOwnProperty(key)) return; + if (!self.settings.webcam.hasOwnProperty(mapped)) return; + const message = + "Please use the webcam system introduced with 1.9.0, the " + + key + + " config setting is deprecated and will be removed in a future release. Stacktrace:"; + self[key] = ko.pureComputed({ + read: () => { + const exc = new Error(); + log.warn(message, exc.stack || exc.stacktrace || ""); + + return self.settings.webcam[mapped](); + }, + write: (value) => { + const exc = new Error(); + log.warn(message, exc.stack || exc.stacktrace || ""); + + self.settings.webcam[mapped](value); + }, + owner: self + }); + }); + var mapToObservables = function (data, mapping, local, keyPrefix) { if (!_.isPlainObject(data)) { return; @@ -1157,6 +1194,11 @@ $(function () { return; } + if (self.webcamCompat.hasOwnProperty(observable)) { + // webcam compat layer, skip + return; + } + var haveLocalVersion = local && local.hasOwnProperty(key); if (