Skip to content

Commit

Permalink
feat: adjust layout of fans
Browse files Browse the repository at this point in the history
  • Loading branch information
cadriel committed Jan 14, 2021
1 parent 7a1c63d commit 10e9c3c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 23 deletions.
8 changes: 7 additions & 1 deletion src/components/cards/dashboard/OutputsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@
<v-card-text>
<v-row justify="space-between">
<v-col cols="6">
<fans-widget></fans-widget>
<fans-widget
getter="getToolHeadFans">
</fans-widget>
</v-col>

<v-col cols="6">
<fans-widget
getter="getOtherFans"
force-divider>
</fans-widget>
<output-pins-widget></output-pins-widget>
</v-col>
</v-row>
Expand Down
38 changes: 20 additions & 18 deletions src/components/widgets/FansWidget.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
<template>
<!-- Fans -->
<div>
<v-row>
<v-col class="">
<div v-for="(fan, i) in fans" :key="i">
<input-slider
value-suffix="%"
:label="fan.prettyName"
:value="fan.speed * 100"
:rules="rules"
:disabled="!klippyConnected"
:readonly="!fan.controllable"
@input="setFanSpeed(fan, $event)">
</input-slider>
<v-divider class="my-2" v-if="i < fans.length - 1"></v-divider>
</div>
</v-col>
</v-row>
<div v-for="(fan, i) in fans" :key="i">
<input-slider
value-suffix="%"
:label="fan.prettyName"
:value="fan.speed * 100"
:rules="rules"
:disabled="!klippyConnected"
:readonly="!fan.controllable"
@input="setFanSpeed(fan, $event)">
</input-slider>
<v-divider class="my-2" v-if="(i < fans.length - 1) || forceDivider"></v-divider>
</div>
</div>
</template>

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator'
import { Component, Mixins, Prop } from 'vue-property-decorator'
import InputSlider from '@/components/inputs/InputSlider.vue'
import UtilsMixin from '@/mixins/utils'
import { Waits } from '@/globals'
Expand All @@ -33,8 +29,14 @@ import { Fan } from '@/store/socket/types'
}
})
export default class FansWidget extends Mixins(UtilsMixin) {
@Prop({ type: String, default: 'getToolHeadFans' })
getter!: string
@Prop({ type: Boolean, default: false })
forceDivider!: boolean
get fans () {
return this.$store.getters['socket/getToolHeadFans']
return this.$store.getters[`socket/${this.getter}`]
}
get partFanSpeed () {
Expand Down
9 changes: 5 additions & 4 deletions src/store/socket/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,10 @@ export const getters: GetterTree<SocketState, RootState> = {
*/
getToolHeadFans: (_, getters) => {
return getters.getOutputs([
'temperature_fan',
'controller_fan',
// 'temperature_fan',
// 'controller_fan',
'heater_fan',
'fan_generic',
// 'fan_generic',
'fan'
])
},
Expand All @@ -379,9 +379,10 @@ export const getters: GetterTree<SocketState, RootState> = {
* Return output pins
*/
getPins: (_, getters) => {
return getters.getOutputs([
const outputs = getters.getOutputs([
'output_pin'
])
return outputs.sort((output: OutputPin) => output.pwm ? 1 : 1)
},

/**
Expand Down

0 comments on commit 10e9c3c

Please sign in to comment.