Fix update of webcam streamURL not being recognized
We used to track our webcam stream URL by the global variable CONFIG_WEBCAMURL. That's still a left over from the architecture about four years ago and completely obsolete these days. Additionally it causes issues now that anything rendered into the page (as this variable value is through initscript.jinja2) will not be changed unless the page cache is refreshed. Taking the stream URL from the settings view model instead solves that problem and is way cleaner anyhow.
This commit is contained in:
parent
1b9bfc6d04
commit
4a0d91315c
4 changed files with 12 additions and 8 deletions
|
|
@ -136,10 +136,6 @@ function DataUpdater(allViewModels) {
|
|||
hideOfflineOverlay();
|
||||
callViewModels(self.allViewModels, "onServerReconnect");
|
||||
callViewModels(self.allViewModels, "onDataUpdaterReconnect");
|
||||
|
||||
if ($('#tabs li[class="active"] a').attr("href") == "#control") {
|
||||
$("#webcam_image").attr("src", CONFIG_WEBCAM_STREAM + "?" + new Date().getTime());
|
||||
}
|
||||
} else {
|
||||
callViewModels(self.allViewModels, "onServerConnect");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,6 +91,8 @@ $(function() {
|
|||
};
|
||||
|
||||
self.onEventSettingsUpdated = function (payload) {
|
||||
// the webcam url might have changed, make sure we replace it now if the tab is focused
|
||||
self._enableWebcam();
|
||||
self.requestData();
|
||||
};
|
||||
|
||||
|
|
@ -378,9 +380,9 @@ $(function() {
|
|||
}
|
||||
var webcamImage = $("#webcam_image");
|
||||
var currentSrc = webcamImage.attr("src");
|
||||
if (currentSrc === undefined || currentSrc.trim() == "") {
|
||||
var newSrc = CONFIG_WEBCAM_STREAM;
|
||||
if (CONFIG_WEBCAM_STREAM.lastIndexOf("?") > -1) {
|
||||
var newSrc = self.settings.webcam_streamUrl();
|
||||
if (currentSrc != newSrc) {
|
||||
if (newSrc.lastIndexOf("?") > -1) {
|
||||
newSrc += "&";
|
||||
} else {
|
||||
newSrc += "?";
|
||||
|
|
|
|||
|
|
@ -807,6 +807,12 @@ $(function() {
|
|||
$('ul.nav-list a:first', self.settingsDialog).tab("show");
|
||||
}
|
||||
};
|
||||
|
||||
self.onServerReconnect = function() {
|
||||
// the settings might have changed if the server was just restarted,
|
||||
// better refresh them now
|
||||
self.requestData();
|
||||
};
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push([
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
var CONFIG_TIMELAPSEFILESPERPAGE = 10;
|
||||
var CONFIG_LOGFILESPERPAGE = 10;
|
||||
var CONFIG_USERSPERPAGE = 10;
|
||||
var CONFIG_WEBCAM_STREAM = "{{ webcamStream|e }}";
|
||||
var CONFIG_WEBCAM_STREAM = "{{ webcamStream|e }}"; // deprecated, only left for compatibility reasons
|
||||
var CONFIG_ACCESS_CONTROL = {% if enableAccessControl -%} true; {% else %} false; {%- endif %}
|
||||
var CONFIG_ACCESS_CONTROL_ACTIVE = {% if accessControlActive -%} true; {% else %} false; {%- endif %}
|
||||
var CONFIG_SD_SUPPORT = {% if enableSdSupport -%} true; {% else %} false; {%- endif %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue