Skip to content

feat: add show hidden option to outputs panel #1209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/settings/GeneralSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ export default class GeneralSettings extends Mixins(StateMixin) {
]
: []

const pins: OutputPin[] = this.$typedGetters['printer/getPins']
const pins: OutputPin[] = this.$typedGetters['printer/getPins']()
const pinEntries = pins.length
? [
{ header: 'Klipper' },
Expand Down
10 changes: 7 additions & 3 deletions src/components/widgets/outputs/Outputs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ 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.showHiddenOutputs
}

get all () {
const items: Array<Fan | Led | OutputPin> = [
...this.$typedGetters['printer/getAllFans'],
...this.$typedGetters['printer/getPins'],
...this.$typedGetters['printer/getAllLeds']
...this.$typedGetters['printer/getAllFans'](this.showHidden),
...this.$typedGetters['printer/getPins'](this.showHidden),
...this.$typedGetters['printer/getAllLeds'](this.showHidden)
]
let col1: Array<Fan | Led | OutputPin> = []
let col2: Array<Fan | Led | OutputPin> = []
Expand Down
48 changes: 48 additions & 0 deletions src/components/widgets/outputs/OutputsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,43 @@
layout-path="dashboard.outputs-card"
menu-breakpoint="lg"
>
<template #menu>
<v-menu
bottom
left
offset-y
transition="slide-y-transition"
:close-on-content-click="false"
>
<template #activator="{ on, attrs }">
<v-btn
icon
v-bind="attrs"
v-on="on"
>
<v-icon dense>
$cog
</v-icon>
</v-btn>
</template>

<v-list dense>
<v-list-item
:title="$t('app.setting.label.show_hidden')"
@click="showHidden = !showHidden"
>
<v-list-item-action class="my-0">
<v-checkbox :input-value="showHidden" />
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>
{{ $t('app.setting.label.show_hidden') }}
</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-menu>
</template>
<outputs />
</collapsable-card>
</template>
Expand All @@ -20,5 +57,16 @@ import Outputs from '@/components/widgets/outputs/Outputs.vue'
}
})
export default class OutputsCard extends Vue {
get showHidden () {
return this.$store.state.config.uiSettings.general.showHiddenOutputs
}

set showHidden (value: boolean) {
this.$store.dispatch('config/saveByPath', {
path: 'uiSettings.general.showHiddenOutputs',
value,
server: true
})
}
}
</script>
1 change: 1 addition & 0 deletions src/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ app:
show_chart: Show chart
show_code_lens: Show CodeLens
show_gas_resistance: Show gas resistance
show_hidden: Show hidden
show_legend: Show legend
show_logo_on_background: Show logo on background
show_rate_of_change: Show temperature rate of change
Expand Down
3 changes: 2 additions & 1 deletion src/store/config/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export const defaultState = (): ConfigState => {
printProgressCalculation: ['file'],
printEtaCalculation: ['file'],
enableDiagnostics: false,
colorPickerValueRange: 'absolute'
colorPickerValueRange: 'absolute',
showHiddenOutputs: false
},
theme: {
isDark: true,
Expand Down
1 change: 1 addition & 0 deletions src/store/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export interface GeneralConfig {
printEtaCalculation: PrintEtaCalculation[];
enableDiagnostics: boolean;
colorPickerValueRange: ColorPickerValueRange;
showHiddenOutputs: boolean;
}

export type ToolheadControlStyle = 'cross' | 'bars' | 'circle'
Expand Down
25 changes: 13 additions & 12 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,71 +569,72 @@ export const getters = {
.sort((a, b) => a.name.localeCompare(b.name))
},

getAllLeds: (_, getters) => {
getAllLeds: (_, getters) => (showHidden = false) => {
return getters.getOutputs([
'led',
'neopixel',
'dotstar',
'pca9533',
'pca9632'
])
], 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',
'pwm_tool',
'pwm_cycle_time'
])
], showHidden)
return outputs.sort((output: OutputPin) => output.pwm ? 1 : -1)
},

getPinByName: (state, getters) => (name: string) => {
const pins: OutputPin[] = getters.getPins
// const pins = getters.getPins() as OutputPin[]

return pins.find(pin => pin.name === name)
},

/**
* Return available fans and output pins
*/
getOutputs: (state, getters) => (filter?: string[]): Array<Fan | Led | OutputPin> => {
getOutputs: (state, getters) => (filter?: string[], showHidden = false): Array<Fan | Led | OutputPin> => {
// Fans..
const fans = [
'temperature_fan',
Expand Down Expand Up @@ -707,7 +708,7 @@ export const getters = {

if (
supportedTypes.includes(type) &&
(!filterByPrefix.includes(type) || !name.startsWith('_'))
(showHidden || !filterByPrefix.includes(type) || !name.startsWith('_'))
) {
const prettyName = name === 'fan'
? 'Part Fan' // If we know its the part fan.
Expand Down
6 changes: 3 additions & 3 deletions src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ export default class Dashboard extends Mixins(StateMixin) {

get hasOutputs (): boolean {
return (
this.$typedGetters['printer/getAllFans'].length > 0 ||
this.$typedGetters['printer/getPins'].length > 0 ||
this.$typedGetters['printer/getAllLeds'].length > 0
this.$typedGetters['printer/getAllFans']().length > 0 ||
this.$typedGetters['printer/getPins']().length > 0 ||
this.$typedGetters['printer/getAllLeds']().length > 0
)
}

Expand Down