Hides temperature tab if the machine has no heated bed nor extruders.
This commit is contained in:
1 parent
3e16f0901a
commit
f0ee7f343e
4 files changed
+44
-14
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: tempTabVisible")),
|
||||
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")),
|
||||
|
||||
@@ -123,6 +123,33 @@ $(function() {
|
||||
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;
|
||||
})();
|
||||
|
||||
@@ -544,16 +571,6 @@ $(function() {
|
||||
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();
|
||||
@@ -676,6 +693,10 @@ $(function() {
|
||||
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();
|
||||
|
||||
// make sure we can track the browser tab visibility
|
||||
OctoPrint.coreui.onBrowserVisibilityChange(function(status) {
|
||||
log.debug("Browser tab is now " + (status ? "visible" : "hidden"));
|
||||
@@ -683,11 +704,11 @@ $(function() {
|
||||
});
|
||||
|
||||
$(window).on("hashchange", function() {
|
||||
changeTab();
|
||||
OctoPrint.coreui.updateTab();
|
||||
});
|
||||
|
||||
if (window.location.hash !== "") {
|
||||
changeTab();
|
||||
OctoPrint.coreui.updateTab();
|
||||
}
|
||||
|
||||
log.info("Application startup complete");
|
||||
|
||||
@@ -71,6 +71,8 @@ $(function() {
|
||||
|
||||
self.hasBed = ko.observable(true);
|
||||
|
||||
self.tempTabVisible = ko.observable(true);
|
||||
|
||||
self.bedTemp = self._createToolEntry();
|
||||
self.bedTemp["name"](gettext("Bed"));
|
||||
self.bedTemp["key"]("bed");
|
||||
@@ -138,6 +140,12 @@ $(function() {
|
||||
// write back
|
||||
self.heaterOptions(heaterOptions);
|
||||
self.tools(tools);
|
||||
var tempTabVisible = self.hasBed() || numExtruders > 0;
|
||||
|
||||
if (tempTabVisible !== self.tempTabVisible()) {
|
||||
self.tempTabVisible(tempTabVisible);
|
||||
OctoPrint.coreui.updateTab();
|
||||
}
|
||||
|
||||
if (!self._printerProfileInitialized) {
|
||||
self._triggerBacklog();
|
||||
@@ -789,6 +797,6 @@ $(function() {
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: TemperatureViewModel,
|
||||
dependencies: ["loginStateViewModel", "settingsViewModel"],
|
||||
elements: ["#temp", "#change_offset_dialog"]
|
||||
elements: ["#temp", "#change_offset_dialog", "#temp_link"]
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user