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

feat: improve fan and outputs panel layout #1470

Draft
wants to merge 1 commit 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 components.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}

/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
ActionCommandPromptDialog: typeof import('./src/components/common/ActionCommandPromptDialog.vue')['default']
Expand Down
221 changes: 165 additions & 56 deletions src/components/widgets/outputs/Outputs.vue
Original file line number Diff line number Diff line change
@@ -1,46 +1,155 @@
<template>
<v-card-text>
<v-row>
<v-col
cols="12"
sm="6"
md="12"
lg="6"
>
<template v-for="(item, i) in all.col1">
<OutputItem
:key="item.key"
:item="item"
/>

<v-divider
v-if="i < all.col1.length - 1 || $vuetify.breakpoint.mdAndDown"
:key="`divider-0${i}`"
class="my-2"
/>
</template>
</v-col>
<v-col
cols="12"
sm="6"
md="12"
lg="6"
>
<template v-for="(item, i) in all.col2">
<OutputItem
:key="item.key"
:item="item"
/>

<v-divider
v-if="i < all.col2.length - 1"
:key="`divider-1${i}`"
class="my-2"
/>
</template>
</v-col>
</v-row>
</v-card-text>
<div>
<v-expansion-panels
accordion
multiple
>
<v-expansion-panel>
<v-expansion-panel-header
v-if="all.controllableFans.length > 0"
>
<template #actions>
<v-icon
small
class="mr-2"
>
$expand
</v-icon>
</template>
<div>
{{ $t('app.general.title.controllable_fans') }}
<v-chip
small
class="ml-2"
>
{{ all.controllableFans.length }}
</v-chip>
</div>
</v-expansion-panel-header>
<v-expansion-panel-content>
<template v-for="(item, i) in all.controllableFans">
<OutputItem
:key="item.key"
:item="item"
/>
<v-divider
v-if="i < all.controllableFans.length - 1"
:key="`divider-controllableFans${i}`"
class="my-2"
/>
</template>
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header
v-if="all.unControllableFans.length > 0"
>
<template #actions>
<v-icon
small
class="mr-2"
>
$expand
</v-icon>
</template>
<div>
{{ $t('app.general.title.other_fans') }}
<v-chip
small
class="ml-2"
>
{{ all.unControllableFans.length }}
</v-chip>
</div>
</v-expansion-panel-header>
<v-expansion-panel-content>
<template v-for="(item, i) in all.unControllableFans">
<OutputItem
:key="item.key"
:item="item"
/>
<v-divider
v-if="i < all.unControllableFans.length - 1"
:key="`divider-unControllableFans${i}`"
class="my-2"
/>
</template>
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header
v-if="all.pins.length > 0"
>
<template #actions>
<v-icon
small
class="mr-2"
>
$expand
</v-icon>
</template>
<div>
{{ $t('app.general.title.output_pins') }}
<v-chip
small
class="ml-2"
>
{{ all.pins.length }}
</v-chip>
</div>
</v-expansion-panel-header>
<v-expansion-panel-content>
<template v-for="(item, i) in all.pins">
<OutputItem
:key="item.key"
:item="item"
/>
<v-divider
v-if="i < all.pins.length - 1"
:key="`divider-pins${i}`"
class="my-2"
/>
</template>
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header
v-if="all.leds.length > 0"
>
<template #actions>
<v-icon
small
class="mr-2"
>
$expand
</v-icon>
</template>
<div>
{{ $t('app.general.title.leds') }}
<v-chip
small
class="ml-2"
>
{{ all.leds.length }}
</v-chip>
</div>
</v-expansion-panel-header>
<v-expansion-panel-content>
<template v-for="(item, i) in all.leds">
<OutputItem
:key="item.key"
:item="item"
/>
<v-divider
v-if="i < all.leds.length - 1"
:key="`divider-leds${i}`"
class="my-2"
/>
</template>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
</div>
</template>

<script lang="ts">
Expand All @@ -56,23 +165,23 @@ import type { Fan, Led, OutputPin } from '@/store/printer/types'
})
export default class Outputs extends Mixins(StateMixin) {
get all () {
const items: Array<Fan | Led | OutputPin> = [
...this.$store.getters['printer/getAllFans'],
...this.$store.getters['printer/getPins'],
const controllableFans: Array<Fan> = [
...this.$store.getters['printer/getControllableFans']
]
const unControllableFans: Array<Fan> = [
...this.$store.getters['printer/getUnctrollableFans']
]
const pins: Array<OutputPin> = [
...this.$store.getters['printer/getPins']
]
const leds: Array<Led> = [
...this.$store.getters['printer/getAllLeds']
]
let col1: Array<Fan | Led | OutputPin> = []
let col2: Array<Fan | Led | OutputPin> = []
if (items.length > 1) {
const half = Math.ceil(items.length / 2)
col1 = items.splice(0, half)
col2 = items
} else {
col1 = items
}
return {
col1,
col2
controllableFans,
unControllableFans,
pins,
leds
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,18 @@ export const getters: GetterTree<PrinterState, RootState> = {
])
},

getAllFans: (_, getters) => {
getControllableFans: (_, getters) => {
return getters.getOutputs([
'fan',
'fan_generic'
])
},

getUnctrollableFans: (_, getters) => {
return getters.getOutputs([
'temperature_fan',
'controller_fan',
'heater_fan',
'fan_generic',
'fan'
'temperature_fan',
'heater_fan'
])
},

Expand Down
3 changes: 2 additions & 1 deletion src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ export default class Dashboard extends Mixins(StateMixin) {

get hasOutputs () {
return (
this.$store.getters['printer/getAllFans'].length > 0 ||
this.$store.getters['printer/getControllableFans'].length > 0 ||
this.$store.getters['printer/getUnctrollableFans'].length > 0 ||
this.$store.getters['printer/getPins'].length > 0 ||
this.$store.getters['printer/getAllLeds'].length > 0
)
Expand Down
Loading