From 0e374f24c831a468ea69313938cf597ec02b3020 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 18 Oct 2023 17:08:13 +0800 Subject: [PATCH 1/2] add show hidden option to outputs panel --- src/components/settings/GeneralSettings.vue | 2 +- src/components/widgets/outputs/Outputs.vue | 9 ++-- .../widgets/outputs/OutputsCard.vue | 49 +++++++++++++++++++ src/store/config/state.ts | 3 +- src/store/config/types.ts | 1 + src/store/printer/getters.ts | 26 +++++----- 6 files changed, 72 insertions(+), 18 deletions(-) diff --git a/src/components/settings/GeneralSettings.vue b/src/components/settings/GeneralSettings.vue index fb15e64b53..6f30dab6a5 100644 --- a/src/components/settings/GeneralSettings.vue +++ b/src/components/settings/GeneralSettings.vue @@ -340,7 +340,7 @@ export default class GeneralSettings extends Mixins(StateMixin) { ] : [] - const pins = this.$store.getters['printer/getPins'] as OutputPin[] + const pins = this.$store.getters['printer/getPins']() as OutputPin[] const pinEntries = pins.length ? [ { header: 'Klipper' }, diff --git a/src/components/widgets/outputs/Outputs.vue b/src/components/widgets/outputs/Outputs.vue index ab1dc32a2c..01f59a573b 100644 --- a/src/components/widgets/outputs/Outputs.vue +++ b/src/components/widgets/outputs/Outputs.vue @@ -55,11 +55,14 @@ import type { Fan, Led, OutputPin } from '@/store/printer/types' } }) export default class Outputs extends Mixins(StateMixin) { + get showHidden () { + return this.$store.state.config.uiSettings.general.showHidden + } get all () { const items: Array = [ - ...this.$store.getters['printer/getAllFans'], - ...this.$store.getters['printer/getPins'], - ...this.$store.getters['printer/getAllLeds'] + ...this.$store.getters['printer/getAllFans'](this.showHidden), + ...this.$store.getters['printer/getPins'](this.showHidden), + ...this.$store.getters['printer/getAllLeds'](this.showHidden) ] let col1: Array = [] let col2: Array = [] diff --git a/src/components/widgets/outputs/OutputsCard.vue b/src/components/widgets/outputs/OutputsCard.vue index c7ae70a71e..b88b0e4dc3 100644 --- a/src/components/widgets/outputs/OutputsCard.vue +++ b/src/components/widgets/outputs/OutputsCard.vue @@ -6,6 +6,44 @@ layout-path="dashboard.outputs-card" menu-breakpoint="lg" > + @@ -20,5 +58,16 @@ import Outputs from '@/components/widgets/outputs/Outputs.vue' } }) export default class OutputsCard extends Vue { + get showHidden () { + return this.$store.state.config.uiSettings.general.showHidden + } + + set showHidden (value: boolean) { + this.$store.dispatch('config/saveByPath', { + path: 'uiSettings.general.showHidden', + value, + server: true + }) + } } diff --git a/src/store/config/state.ts b/src/store/config/state.ts index 4fd8f35c3d..aa4f65037e 100644 --- a/src/store/config/state.ts +++ b/src/store/config/state.ts @@ -57,7 +57,8 @@ export const defaultState = (): ConfigState => { showBedScrewsAdjustDialogAutomatically: true, forceMoveToggleWarning: true, enableDiagnostics: false, - thumbnailSize: 32 + thumbnailSize: 32, + showHidden: false }, theme: { isDark: true, diff --git a/src/store/config/types.ts b/src/store/config/types.ts index 229a7a25a9..ff4bc6c2fb 100644 --- a/src/store/config/types.ts +++ b/src/store/config/types.ts @@ -91,6 +91,7 @@ export interface GeneralConfig { forceMoveToggleWarning: boolean; enableDiagnostics: boolean; thumbnailSize: number; + showHidden: boolean; } export type ToolheadControlStyle = 'cross' | 'bars' diff --git a/src/store/printer/getters.ts b/src/store/printer/getters.ts index da39807007..5ea0e7bea7 100644 --- a/src/store/printer/getters.ts +++ b/src/store/printer/getters.ts @@ -440,59 +440,59 @@ export const getters: GetterTree = { return [] }, - getAllLeds: (_, getters) => { + getAllLeds: (_, getters) => (showHidden=false) => { return getters.getOutputs([ 'led', 'neopixel', 'dotstar' - ]) + ], showHidden) }, - getAllFans: (_, getters) => { + getAllFans: (_, getters) => (showHidden=false) => { return getters.getOutputs([ 'temperature_fan', 'controller_fan', 'heater_fan', 'fan_generic', 'fan' - ]) + ], showHidden) }, /** * Return toolhead fans */ - getToolHeadFans: (_, getters) => { + getToolHeadFans: (_, getters) => (showHidden=false) => { return getters.getOutputs([ // 'temperature_fan', // 'controller_fan', 'heater_fan', // 'fan_generic', 'fan' - ]) + ], showHidden) }, - getOtherFans: (_, getters) => { + getOtherFans: (_, getters) => (showHidden=false) => { return getters.getOutputs([ 'temperature_fan', 'controller_fan', // 'heater_fan', 'fan_generic' // 'fan' - ]) + ], showHidden) }, /** * Return output pins */ - getPins: (_, getters) => { + getPins: (_, getters) => (showHidden=false) => { const outputs = getters.getOutputs([ 'output_pin' - ]) + ], showHidden) return outputs.sort((output: OutputPin) => output.pwm ? 1 : -1) }, getPinByName: (state, getters) => (name: string) => { - const pins = getters.getPins as OutputPin[] + const pins = getters.getPins() as OutputPin[] return pins.find(pin => pin.name === name) }, @@ -500,7 +500,7 @@ export const getters: GetterTree = { /** * Return available fans and output pins */ - getOutputs: (state, getters) => (filter?: string[]): Array => { + getOutputs: (state, getters) => (filter?: string[], showHidden=false): Array => { // Fans.. const fans = [ 'temperature_fan', @@ -561,7 +561,7 @@ export const getters: GetterTree = { if ( supportedTypes.includes(type) && - (!filterByPrefix.includes(type) || !name.startsWith('_')) + ((!filterByPrefix.includes(type) || !name.startsWith('_')) || showHidden) ) { const prettyName = name === 'fan' ? 'Part Fan' // If we know its the part fan. From 182fa425796e879c26c17b801736163e5f75fd25 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 18 Oct 2023 17:17:45 +0800 Subject: [PATCH 2/2] fix formatting --- src/components/widgets/outputs/Outputs.vue | 1 + src/store/printer/getters.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/widgets/outputs/Outputs.vue b/src/components/widgets/outputs/Outputs.vue index 01f59a573b..51bef0a17e 100644 --- a/src/components/widgets/outputs/Outputs.vue +++ b/src/components/widgets/outputs/Outputs.vue @@ -58,6 +58,7 @@ export default class Outputs extends Mixins(StateMixin) { get showHidden () { return this.$store.state.config.uiSettings.general.showHidden } + get all () { const items: Array = [ ...this.$store.getters['printer/getAllFans'](this.showHidden), diff --git a/src/store/printer/getters.ts b/src/store/printer/getters.ts index 5ea0e7bea7..19ca09d165 100644 --- a/src/store/printer/getters.ts +++ b/src/store/printer/getters.ts @@ -440,7 +440,7 @@ export const getters: GetterTree = { return [] }, - getAllLeds: (_, getters) => (showHidden=false) => { + getAllLeds: (_, getters) => (showHidden = false) => { return getters.getOutputs([ 'led', 'neopixel', @@ -448,7 +448,7 @@ export const getters: GetterTree = { ], showHidden) }, - getAllFans: (_, getters) => (showHidden=false) => { + getAllFans: (_, getters) => (showHidden = false) => { return getters.getOutputs([ 'temperature_fan', 'controller_fan', @@ -461,7 +461,7 @@ export const getters: GetterTree = { /** * Return toolhead fans */ - getToolHeadFans: (_, getters) => (showHidden=false) => { + getToolHeadFans: (_, getters) => (showHidden = false) => { return getters.getOutputs([ // 'temperature_fan', // 'controller_fan', @@ -471,7 +471,7 @@ export const getters: GetterTree = { ], showHidden) }, - getOtherFans: (_, getters) => (showHidden=false) => { + getOtherFans: (_, getters) => (showHidden = false) => { return getters.getOutputs([ 'temperature_fan', 'controller_fan', @@ -484,7 +484,7 @@ export const getters: GetterTree = { /** * Return output pins */ - getPins: (_, getters) => (showHidden=false) => { + getPins: (_, getters) => (showHidden = false) => { const outputs = getters.getOutputs([ 'output_pin' ], showHidden) @@ -500,7 +500,7 @@ export const getters: GetterTree = { /** * Return available fans and output pins */ - getOutputs: (state, getters) => (filter?: string[], showHidden=false): Array => { + getOutputs: (state, getters) => (filter?: string[], showHidden = false): Array => { // Fans.. const fans = [ 'temperature_fan',