Skip to content
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

add show hidden option to outputs panel #1209

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -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' },
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.showHidden
}

get all () {
const items: Array<Fan | Led | OutputPin> = [
...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<Fan | Led | OutputPin> = []
let col2: Array<Fan | Led | OutputPin> = []
Expand Down
49 changes: 49 additions & 0 deletions src/components/widgets/outputs/OutputsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,44 @@
layout-path="dashboard.outputs-card"
menu-breakpoint="lg"
>
<template #menu>

Check warning on line 9 in src/components/widgets/outputs/OutputsCard.vue

View workflow job for this annotation

GitHub Actions / Build

Expected indentation of 4 spaces but found 2 spaces

Check warning on line 9 in src/components/widgets/outputs/OutputsCard.vue

View workflow job for this annotation

GitHub Actions / Build

Expected 1 line break after opening tag (`<template>`), but 2 line breaks found

<v-menu
bottom
left
offset-y
transition="slide-y-transition"
:close-on-content-click="false"
>
<template #activator="{ on, attrs }">
<v-btn
fab
x-small
text
v-bind="attrs"
class="ms-1 my-1"
v-on="on"
>
<v-icon>
$cog
</v-icon>
</v-btn>
</template>

<v-list dense>
<v-list-item @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>
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 +58,16 @@
}
})
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
})
}
}
</script>
3 changes: 2 additions & 1 deletion src/store/config/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export const defaultState = (): ConfigState => {
showBedScrewsAdjustDialogAutomatically: true,
forceMoveToggleWarning: true,
enableDiagnostics: false,
thumbnailSize: 32
thumbnailSize: 32,
showHidden: 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 @@ -91,6 +91,7 @@ export interface GeneralConfig {
forceMoveToggleWarning: boolean;
enableDiagnostics: boolean;
thumbnailSize: number;
showHidden: boolean;
}

export type ToolheadControlStyle = 'cross' | 'bars'
Expand Down
26 changes: 13 additions & 13 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,67 +440,67 @@ export const getters: GetterTree<PrinterState, RootState> = {
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)
},

/**
* 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 @@ -561,7 +561,7 @@ export const getters: GetterTree<PrinterState, RootState> = {

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.
Expand Down