Fix graph initialization
We only want to initialize it when the graph is actually visible. For this we hook into tab changes, user changes and StartupComplete. That will hopefully ensure that once it DOES become visible it will get initialized, but not before.
This commit is contained in:
1 parent
fd6c7cd48f
commit
481faf8da1
1 file changed
+17
-26
@@ -148,6 +148,7 @@ $(function() {
|
||||
}
|
||||
self.updatePlot();
|
||||
};
|
||||
|
||||
self.settingsViewModel.printerProfiles.currentProfileData.subscribe(function() {
|
||||
self._printerProfileUpdated();
|
||||
self.settingsViewModel.printerProfiles.currentProfileData().extruder.count.subscribe(self._printerProfileUpdated);
|
||||
@@ -155,30 +156,6 @@ $(function() {
|
||||
self.settingsViewModel.printerProfiles.currentProfileData().heatedBed.subscribe(self._printerProfileUpdated);
|
||||
});
|
||||
|
||||
self.onUserLoggedIn = function () {
|
||||
self._initializePlot(true);
|
||||
|
||||
self.loginStateSubscription = self.loginState.hasPermissionKo(self.access.permissions.STATUS).subscribe(function(value) {
|
||||
var graph = $("#temp, #temp_link");
|
||||
if (graph.length) {
|
||||
if (value) {
|
||||
graph.removeAttr("style");
|
||||
}
|
||||
else {
|
||||
graph.hide();
|
||||
}
|
||||
}
|
||||
self.updatePlot();
|
||||
});
|
||||
};
|
||||
|
||||
self.onUserLoggedOut = function (){
|
||||
if (self.loginStateSubscription !== undefined) {
|
||||
self.loginStateSubscription.dispose();
|
||||
self.loginStateSubscription = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
self.temperatures = [];
|
||||
|
||||
self.plot = undefined;
|
||||
@@ -756,8 +733,9 @@ $(function() {
|
||||
}
|
||||
};
|
||||
|
||||
self.onAfterTabChange = function(current, previous) {
|
||||
if (current !== "#temp") {
|
||||
self.initOrUpdate = function() {
|
||||
if (OctoPrint.coreui.selectedTab !== "#temp" || !$("#temp").is(":visible")) {
|
||||
// do not try to initialize the graph when it's not visible or its sizing will be off
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -768,6 +746,10 @@ $(function() {
|
||||
}
|
||||
};
|
||||
|
||||
self.onAfterTabChange = function() {
|
||||
self.initOrUpdate();
|
||||
};
|
||||
|
||||
self.onStartup = function() {
|
||||
var graph = $("#temperature-graph");
|
||||
if (graph.length && !OctoPrint.coreui.browser.mobile) {
|
||||
@@ -785,9 +767,18 @@ $(function() {
|
||||
};
|
||||
|
||||
self.onStartupComplete = function() {
|
||||
self.initOrUpdate();
|
||||
self._printerProfileUpdated();
|
||||
};
|
||||
|
||||
self.onUserLoggedIn = function() {
|
||||
self.initOrUpdate();
|
||||
};
|
||||
|
||||
self.onUserLoggedOut = function() {
|
||||
self.initOrUpdate();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push([
|
||||
|
||||
Reference in new issue
Block a user