Merge pull request #3072 from Fabi0San/maint/temperature
Hides temperature tab if the machine has no heated bed nor extruders.
This commit is contained in:
4 files changed
+63
-32
No files matched your search
@@ -98,6 +98,7 @@ date of first contribution):
|
||||
* [Jubaleth](https://github.com/jubaleth)
|
||||
* [Daniel Joyce](https://github.com/DanielJoyce)
|
||||
* [Andy Qua](https://github.com/AndyQ)
|
||||
* [Fabio Santos](https://github.com/Fabi0San)
|
||||
|
||||
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
|
||||
[Daid Braam](https://github.com/daid). Parts of its communication layer and
|
||||
|
||||
@@ -560,7 +560,7 @@ def fetch_template_data(refresh=False):
|
||||
# tabs
|
||||
|
||||
templates["tab"]["entries"] = dict(
|
||||
temperature=(gettext("Temperature"), dict(template="tabs/temperature.jinja2", _div="temp")),
|
||||
temperature=(gettext("Temperature"), dict(template="tabs/temperature.jinja2", _div="temp", data_bind="visible: visible")),
|
||||
control=(gettext("Control"), dict(template="tabs/control.jinja2", _div="control")),
|
||||
gcodeviewer=(gettext("GCode Viewer"), dict(template="tabs/gcodeviewer.jinja2", _div="gcode")),
|
||||
terminal=(gettext("Terminal"), dict(template="tabs/terminal.jinja2", _div="term")),
|
||||
|
||||
@@ -122,6 +122,34 @@ $(function() {
|
||||
exports.onBrowserVisibilityChange = function(callback) {
|
||||
browserVisibilityCallbacks.push(callback);
|
||||
};
|
||||
exports.hashFromTabChange = false;
|
||||
exports.updateTab = function() {
|
||||
if (exports.hashFromTabChange) {
|
||||
exports.hashFromTabChange = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var tabs = $('#tabs');
|
||||
|
||||
var hashtag = window.location.hash;
|
||||
if (hashtag) {
|
||||
var selectedTab = tabs.find('a[href="' + hashtag + '"]:visible');
|
||||
if (selectedTab.length) {
|
||||
selectedTab.tab("show");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var firstTab = tabs.find('a[data-toggle=tab]:visible').eq(0);
|
||||
if (firstTab.length) {
|
||||
var firstHash = firstTab[0].hash;
|
||||
if (firstHash !== exports.selectedTab) {
|
||||
firstTab.tab("show");
|
||||
} else {
|
||||
window.location.hash = firstHash;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return exports;
|
||||
})();
|
||||
@@ -509,9 +537,6 @@ $(function() {
|
||||
});
|
||||
};
|
||||
|
||||
// Use bootstrap tabdrop for tabs and pills
|
||||
$('.nav-pills, .nav-tabs').tabdrop();
|
||||
|
||||
// Allow components to react to tab change
|
||||
var onTabChange = function(current, previous) {
|
||||
log.debug("Selected OctoPrint tab changed: previous = " + previous + ", current = " + current);
|
||||
@@ -526,34 +551,22 @@ $(function() {
|
||||
var tabs = $('#tabs').find('a[data-toggle="tab"]');
|
||||
tabs.on('show', function (e) {
|
||||
var current = e.target.hash;
|
||||
var previous = e.relatedTarget.hash;
|
||||
var previous = e.relatedTarget ? e.relatedTarget.hash : undefined;
|
||||
onTabChange(current, previous);
|
||||
});
|
||||
|
||||
tabs.on('shown', function (e) {
|
||||
var current = e.target.hash;
|
||||
var previous = e.relatedTarget.hash;
|
||||
var previous = e.relatedTarget ? e.relatedTarget.hash : undefined;
|
||||
onAfterTabChange(current, previous);
|
||||
|
||||
// make sure we also update the hash but stick to the current scroll position
|
||||
var scrollmem = $('body').scrollTop() || $('html').scrollTop();
|
||||
OctoPrint.coreui.hashFromTabChange = true;
|
||||
window.location.hash = current;
|
||||
$('html,body').scrollTop(scrollmem);
|
||||
});
|
||||
|
||||
onTabChange(OCTOPRINT_INITIAL_TAB);
|
||||
onAfterTabChange(OCTOPRINT_INITIAL_TAB, undefined);
|
||||
|
||||
var changeTab = function() {
|
||||
var hashtag = window.location.hash;
|
||||
if (!hashtag) return;
|
||||
|
||||
var tab = $('#tabs').find('a[href="' + hashtag + '"]');
|
||||
if (tab) {
|
||||
tab.tab("show");
|
||||
}
|
||||
};
|
||||
|
||||
// Fix input element click problems on dropdowns
|
||||
$(".dropdown input, .dropdown label").click(function(e) {
|
||||
e.stopPropagation();
|
||||
@@ -672,10 +685,6 @@ $(function() {
|
||||
callViewModels(allViewModels, "onAllBound", [allViewModels]);
|
||||
log.info("... binding done");
|
||||
|
||||
// startup complete
|
||||
callViewModels(allViewModels, "onStartupComplete");
|
||||
setOnViewModels(allViewModels, "_startupComplete", true);
|
||||
|
||||
// make sure we can track the browser tab visibility
|
||||
OctoPrint.coreui.onBrowserVisibilityChange(function(status) {
|
||||
log.debug("Browser tab is now " + (status ? "visible" : "hidden"));
|
||||
@@ -683,14 +692,21 @@ $(function() {
|
||||
});
|
||||
|
||||
$(window).on("hashchange", function() {
|
||||
changeTab();
|
||||
OctoPrint.coreui.updateTab();
|
||||
});
|
||||
|
||||
if (window.location.hash !== "") {
|
||||
changeTab();
|
||||
}
|
||||
|
||||
log.info("Application startup complete");
|
||||
|
||||
// startup complete
|
||||
callViewModels(allViewModels, "onStartupComplete");
|
||||
setOnViewModels(allViewModels, "_startupComplete", true);
|
||||
|
||||
// this will also allow selecting any tabs that will be hidden later due to overflowing since our
|
||||
// overflow plugin tabdrop hasn't run yet
|
||||
OctoPrint.coreui.updateTab();
|
||||
|
||||
// Use bootstrap tabdrop for tabs and pills
|
||||
$('.nav-pills, .nav-tabs').tabdrop();
|
||||
};
|
||||
|
||||
var fetchSettings = function() {
|
||||
|
||||
@@ -68,9 +68,15 @@ $(function() {
|
||||
self.changeOffsetDialog = undefined;
|
||||
|
||||
self.tools = ko.observableArray([]);
|
||||
|
||||
self.hasTools = ko.pureComputed(function() {
|
||||
return self.tools().length > 0;
|
||||
});
|
||||
self.hasBed = ko.observable(true);
|
||||
|
||||
self.visible = ko.pureComputed(function() {
|
||||
return self.hasTools() || self.hasBed();
|
||||
});
|
||||
|
||||
self.bedTemp = self._createToolEntry();
|
||||
self.bedTemp["name"](gettext("Bed"));
|
||||
self.bedTemp["key"]("bed");
|
||||
@@ -139,6 +145,8 @@ $(function() {
|
||||
self.heaterOptions(heaterOptions);
|
||||
self.tools(tools);
|
||||
|
||||
OctoPrint.coreui.updateTab();
|
||||
|
||||
if (!self._printerProfileInitialized) {
|
||||
self._triggerBacklog();
|
||||
}
|
||||
@@ -752,8 +760,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;
|
||||
}
|
||||
|
||||
@@ -764,6 +773,10 @@ $(function() {
|
||||
}
|
||||
};
|
||||
|
||||
self.onAfterTabChange = function() {
|
||||
self.initOrUpdate();
|
||||
};
|
||||
|
||||
self.onStartup = function() {
|
||||
var graph = $("#temperature-graph");
|
||||
if (graph.length && !OctoPrint.coreui.browser.mobile) {
|
||||
@@ -781,6 +794,7 @@ $(function() {
|
||||
};
|
||||
|
||||
self.onStartupComplete = function() {
|
||||
self.initOrUpdate();
|
||||
self._printerProfileUpdated();
|
||||
};
|
||||
|
||||
@@ -789,6 +803,6 @@ $(function() {
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: TemperatureViewModel,
|
||||
dependencies: ["loginStateViewModel", "settingsViewModel"],
|
||||
elements: ["#temp", "#change_offset_dialog"]
|
||||
elements: ["#temp", "#temp_link", "#change_offset_dialog"]
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user