fix: hide toolhead, extruder & temperature panel if they have no content (#852)

* refactor: fix deprecated substr function

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* refactor: remove unused import

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* fix: hide toolhead, extruder and temperature panel if it is not available

Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
Stefan Dej authored and GitHub committed 2022-05-28 15:47:48 +02:00
1 parent a5a7d05460
commit d85a072a39
4 files changed
+58 -3

No files matched your search

+31
View File
@@ -8,6 +8,22 @@ import Vue from 'vue'
@Component
export default class DashboardMixin extends BaseMixin {
get printerKinematics() {
return this.$store.getters['printer/getKinematics']
}
get printerExtruderCount() {
return this.$store.getters['printer/getExtruders'].length
}
get printerAvailableHeatersCount() {
return this.$store.getters['printer/getAvailableHeaters'].length
}
get printerAvailableSensorsCount() {
return this.$store.getters['printer/getAvailableSensors'].length
}
get macroMode() {
return this.$store.state.gui.macros.mode ?? 'simple'
}
@@ -66,6 +82,21 @@ export default class DashboardMixin extends BaseMixin {
allPanels = allPanels.filter((name) => name !== 'macros')
}
// remove toolhead panel, if kinematics === none
if (this.printerKinematics === 'none') {
allPanels = allPanels.filter((name) => name !== 'toolhead-control')
}
// remove extruder panel, if printerExtruderCount < 1
if (this.printerExtruderCount < 1) {
allPanels = allPanels.filter((name) => name !== 'extruder-control')
}
// remove temperature panel, if heaters & sensors < 1
if (this.printerAvailableHeatersCount + this.printerAvailableSensorsCount < 1) {
allPanels = allPanels.filter((name) => name !== 'temperature')
}
// remove webcam panel, if no webcam exists
if (this.webcams.length === 0) {
allPanels = allPanels.filter((name) => name !== 'webcam')