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:
1 parent
a5a7d05460
commit
d85a072a39
4 files changed
+58
-3
No files matched your search
@@ -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')
|
||||
|
||||
+16
-1
@@ -115,13 +115,28 @@ import kebabCase from 'lodash.kebabcase'
|
||||
})
|
||||
export default class PageDashboard extends Mixins(DashboardMixin) {
|
||||
get allComponents() {
|
||||
const output: string[] = []
|
||||
let output: string[] = []
|
||||
const components = Object.keys(this.$options.components ?? {})
|
||||
|
||||
components?.forEach((component) => {
|
||||
if (component.endsWith('Panel')) output.push(kebabCase(component))
|
||||
})
|
||||
|
||||
// remove toolhead panel, if kinematics === none
|
||||
if (this.printerKinematics === 'none') {
|
||||
output = output.filter((name) => name !== 'toolhead-control-panel')
|
||||
}
|
||||
|
||||
// remove extruder panel, if printerExtruderCount < 1
|
||||
if (this.printerExtruderCount < 1) {
|
||||
output = output.filter((name) => name !== 'extruder-control-panel')
|
||||
}
|
||||
|
||||
// remove temperature panel, if heaters & sensors < 1
|
||||
if (this.printerAvailableHeatersCount + this.printerAvailableSensorsCount < 1) {
|
||||
output = output.filter((name) => name !== 'temperature-panel')
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { GetterTree } from 'vuex'
|
||||
import { GuiState } from '@/store/gui/types'
|
||||
import { GuiMacrosStateMacrogroup } from '@/store/gui/macros/types'
|
||||
import Vue from 'vue'
|
||||
|
||||
// eslint-disable-next-line
|
||||
export const getters: GetterTree<GuiState, any> = {
|
||||
@@ -47,7 +46,7 @@ export const getters: GetterTree<GuiState, any> = {
|
||||
panels = panels.filter((element: any) => {
|
||||
if (!element.name.startsWith('macrogroup_')) return true
|
||||
|
||||
const macrogroupId = element.name.substr(11)
|
||||
const macrogroupId = element.name.slice(11)
|
||||
return (
|
||||
macrogroups.findIndex(
|
||||
(macrogroup: GuiMacrosStateMacrogroup) => macrogroup.id === macrogroupId
|
||||
|
||||
@@ -452,6 +452,10 @@ export const getters: GetterTree<PrinterState, RootState> = {
|
||||
return additionValues
|
||||
},
|
||||
|
||||
getAvailableHeaters: (state) => {
|
||||
return state.heaters?.available_heaters ?? []
|
||||
},
|
||||
|
||||
getAvailableSensors: (state) => {
|
||||
return state.heaters?.available_sensors ?? []
|
||||
},
|
||||
@@ -870,6 +874,12 @@ export const getters: GetterTree<PrinterState, RootState> = {
|
||||
return tools
|
||||
},
|
||||
|
||||
getKinematics: (state) => {
|
||||
if (!state.configfile?.settings?.printer) return false
|
||||
|
||||
return state.configfile?.settings?.printer.kinematics ?? 'none'
|
||||
},
|
||||
|
||||
existsQGL: (state) => {
|
||||
if (!state.configfile?.settings) return false
|
||||
|
||||
|
||||
Reference in new issue
Block a user