feat: improve load/unload filament button logic in Extruder panel (#989)
This commit is contained in:
1 parent
afb041a5fa
commit
fa2f07fc22
2 files changed
+132
-119
No files matched your search
@@ -1,15 +1,3 @@
|
||||
<style scoped>
|
||||
.btnMacroMenu {
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
.macroWithParameters {
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<v-item-group class="d-inline-block">
|
||||
<v-btn
|
||||
@@ -17,13 +5,20 @@
|
||||
:color="color"
|
||||
:class="paramArray.length ? 'macroWithParameters' : ''"
|
||||
:loading="loadings.includes('macro_' + macro.name)"
|
||||
:disabled="disabled"
|
||||
@click="doSendMacro(macro.name)">
|
||||
{{ macro.name.replace(/_/g, ' ') }}
|
||||
{{ alias ? alias : macro.name.replace(/_/g, ' ') }}
|
||||
</v-btn>
|
||||
<template v-if="paramArray.length">
|
||||
<v-menu offset-y :close-on-content-click="false">
|
||||
<template #activator="{ on, attrs }">
|
||||
<v-btn small :color="color" v-bind="attrs" class="minwidth-0 px-1 btnMacroMenu" v-on="on">
|
||||
<v-btn
|
||||
:disabled="disabled"
|
||||
:color="color"
|
||||
v-bind="attrs"
|
||||
class="minwidth-0 px-1 btnMacroMenu"
|
||||
small
|
||||
v-on="on">
|
||||
<v-icon>{{ mdiMenuDown }}</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
@@ -88,7 +83,15 @@ export default class MacroButton extends Mixins(BaseMixin) {
|
||||
|
||||
@Prop({ required: true })
|
||||
declare readonly macro: GuiMacrosStateMacrogroupMacro
|
||||
@Prop({ default: 'primary' }) declare readonly color: string
|
||||
|
||||
@Prop({ default: 'primary' })
|
||||
declare readonly color: string
|
||||
|
||||
@Prop({ default: null })
|
||||
declare readonly alias: string
|
||||
|
||||
@Prop({ default: false })
|
||||
declare readonly disabled: boolean
|
||||
|
||||
get klipperMacro() {
|
||||
return this.$store.getters['printer/getMacro'](this.macro.name)
|
||||
@@ -149,3 +152,15 @@ export default class MacroButton extends Mixins(BaseMixin) {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.btnMacroMenu {
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
.macroWithParameters {
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -1,48 +1,3 @@
|
||||
<style lang="scss" scoped>
|
||||
._btn-group {
|
||||
border-radius: 4px;
|
||||
display: inline-flex;
|
||||
flex-wrap: nowrap;
|
||||
max-width: 100%;
|
||||
min-width: 100%;
|
||||
width: 100%;
|
||||
|
||||
.v-btn {
|
||||
border-radius: 0;
|
||||
border-color: rgba(255, 255, 255, 0.12);
|
||||
border-style: solid;
|
||||
border-width: thin;
|
||||
box-shadow: none;
|
||||
height: 28px;
|
||||
opacity: 0.8;
|
||||
min-width: auto !important;
|
||||
}
|
||||
|
||||
.v-btn:first-child {
|
||||
border-top-left-radius: inherit;
|
||||
border-bottom-left-radius: inherit;
|
||||
}
|
||||
|
||||
.v-btn:last-child {
|
||||
border-top-right-radius: inherit;
|
||||
border-bottom-right-radius: inherit;
|
||||
}
|
||||
|
||||
.v-btn:not(:first-child) {
|
||||
border-left-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
._btn-qs {
|
||||
font-size: 0.8rem !important;
|
||||
max-height: 24px;
|
||||
}
|
||||
|
||||
._btn-extruder-cmd {
|
||||
min-width: 135px !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<panel
|
||||
v-if="klipperReadyForGui && extruders.length"
|
||||
@@ -52,31 +7,23 @@
|
||||
card-class="extruder-control-panel">
|
||||
<!-- PANEL-HEADER 3-DOT-MENU -->
|
||||
<template #buttons>
|
||||
<v-menu v-if="filamentChangeMacros" left :offset-y="true" :close-on-content-click="false" class="pa-0">
|
||||
<v-menu v-if="showFilamentMacros" :offset-y="true" :close-on-content-click="false" left>
|
||||
<template #activator="{ on, attrs }">
|
||||
<v-btn icon tile v-bind="attrs" v-on="on">
|
||||
<v-icon>{{ mdiDotsVertical }}</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
<v-list dense>
|
||||
<v-list-item>
|
||||
<!-- FILAMENT UNLOAD -->
|
||||
<v-tooltip top :disabled="extrudePossible" color="secondary">
|
||||
<!-- FILAMENT UNLOAD -->
|
||||
<v-list-item v-if="unloadFilamentMacro">
|
||||
<v-tooltip top :disabled="canExecuteUnloadMacro" color="secondary">
|
||||
<template #activator="{ on }">
|
||||
<div style="width: 100%" v-on="on">
|
||||
<v-btn
|
||||
:loading="loadings.includes('btnUnloadFilament')"
|
||||
:disabled="!extrudePossible || isPrinting"
|
||||
small
|
||||
style="width: 100%"
|
||||
@click="sendUnloadFilament()">
|
||||
<span class="d-flex align-center">
|
||||
<v-icon left small style="transform: rotate(270deg)" class="mr-1">
|
||||
{{ mdiLocationExit }}
|
||||
</v-icon>
|
||||
{{ $t('Panels.ExtruderControlPanel.UnloadFilament') }}
|
||||
</span>
|
||||
</v-btn>
|
||||
<div v-on="on">
|
||||
<macro-button
|
||||
:macro="unloadFilamentMacro"
|
||||
:alias="$t('Panels.ExtruderControlPanel.UnloadFilament').toString()"
|
||||
:disabled="!canExecuteUnloadMacro || isPrinting"
|
||||
color="#272727" />
|
||||
</div>
|
||||
</template>
|
||||
<span>
|
||||
@@ -85,24 +32,16 @@
|
||||
</span>
|
||||
</v-tooltip>
|
||||
</v-list-item>
|
||||
<v-list-item>
|
||||
<!-- FILAMENT LOAD -->
|
||||
<v-tooltip top :disabled="extrudePossible" color="secondary">
|
||||
<!-- FILAMENT LOAD -->
|
||||
<v-list-item v-if="loadFilamentMacro">
|
||||
<v-tooltip top :disabled="canExecuteLoadMacro" color="secondary">
|
||||
<template #activator="{ on }">
|
||||
<div style="width: 100%" v-on="on">
|
||||
<v-btn
|
||||
:loading="loadings.includes('btnLoadFilament')"
|
||||
:disabled="!extrudePossible || isPrinting"
|
||||
small
|
||||
style="width: 100%"
|
||||
@click="sendLoadFilament()">
|
||||
<span class="d-flex align-center">
|
||||
<v-icon left small style="transform: rotate(90deg)" class="mr-1">
|
||||
{{ mdiLocationEnter }}
|
||||
</v-icon>
|
||||
{{ $t('Panels.ExtruderControlPanel.LoadFilament') }}
|
||||
</span>
|
||||
</v-btn>
|
||||
<div v-on="on">
|
||||
<macro-button
|
||||
:macro="loadFilamentMacro"
|
||||
:alias="$t('Panels.ExtruderControlPanel.LoadFilament').toString()"
|
||||
:disabled="!canExecuteLoadMacro || isPrinting"
|
||||
color="#272727" />
|
||||
</div>
|
||||
</template>
|
||||
<span>
|
||||
@@ -359,12 +298,15 @@ import {
|
||||
mdiArrowUpBold,
|
||||
mdiPrinter3dNozzle,
|
||||
mdiPrinter3dNozzleOutline,
|
||||
mdiLocationEnter,
|
||||
mdiLocationExit,
|
||||
mdiDotsVertical,
|
||||
} from '@mdi/js'
|
||||
import { Component, Mixins, Watch } from 'vue-property-decorator'
|
||||
import { PrinterStateExtruder, PrinterStateExtruderStepper, PrinterStateToolchangeMacro } from '@/store/printer/types'
|
||||
import {
|
||||
PrinterStateExtruder,
|
||||
PrinterStateExtruderStepper,
|
||||
PrinterStateMacro,
|
||||
PrinterStateToolchangeMacro,
|
||||
} from '@/store/printer/types'
|
||||
import BaseMixin from '../mixins/base'
|
||||
import ControlMixin from '../mixins/control'
|
||||
import NumberInput from '@/components/inputs/NumberInput.vue'
|
||||
@@ -387,25 +329,48 @@ export default class ExtruderControlPanel extends Mixins(BaseMixin, ControlMixin
|
||||
mdiArrowDownBold = mdiArrowDownBold
|
||||
mdiPrinter3dNozzle = mdiPrinter3dNozzle
|
||||
mdiPrinter3dNozzleOutline = mdiPrinter3dNozzleOutline
|
||||
mdiLocationEnter = mdiLocationEnter
|
||||
mdiLocationExit = mdiLocationExit
|
||||
mdiDotsVertical = mdiDotsVertical
|
||||
|
||||
private heatWaitGcodes = ['printer.extruder.can_extrude', 'TEMPERATURE_WAIT', 'M109']
|
||||
|
||||
get isPrinting(): boolean {
|
||||
return ['printing'].includes(this.printer_state)
|
||||
}
|
||||
|
||||
get macros() {
|
||||
return this.$store.getters['printer/getMacros']
|
||||
}
|
||||
|
||||
get toolchangeMacros(): PrinterStateToolchangeMacro[] {
|
||||
return this.$store.getters['printer/getToolchangeMacros']
|
||||
}
|
||||
|
||||
get filamentChangeMacros(): boolean {
|
||||
let macros: string[] = []
|
||||
this.$store.getters['printer/getMacros'].forEach((m: any) => {
|
||||
if (m.name.toUpperCase().startsWith('LOAD_FILAMENT')) macros.push(m.name)
|
||||
if (m.name.toUpperCase().startsWith('UNLOAD_FILAMENT')) macros.push(m.name)
|
||||
})
|
||||
return macros.length === 2
|
||||
get loadFilamentMacro() {
|
||||
return this.macros.find((macro: PrinterStateMacro) => macro.name === 'LOAD_FILAMENT')
|
||||
}
|
||||
|
||||
get unloadFilamentMacro() {
|
||||
return this.macros.find((macro: PrinterStateMacro) => macro.name === 'UNLOAD_FILAMENT')
|
||||
}
|
||||
|
||||
/**
|
||||
* test if the load and unload macro include specific keywords. if true, we allow
|
||||
* execution of that macro even if at the current time extrudePossible === false
|
||||
*/
|
||||
get canExecuteLoadMacro(): boolean {
|
||||
if (this.extrudePossible) return true
|
||||
|
||||
return this.heatWaitGcodes.some((gcode) => this.loadFilamentMacro.prop.gcode.includes(gcode))
|
||||
}
|
||||
|
||||
get canExecuteUnloadMacro(): boolean {
|
||||
if (this.extrudePossible) return true
|
||||
|
||||
return this.heatWaitGcodes.some((gcode) => this.unloadFilamentMacro.prop.gcode.includes(gcode))
|
||||
}
|
||||
|
||||
get showFilamentMacros(): boolean {
|
||||
return this.loadFilamentMacro !== undefined || this.unloadFilamentMacro !== undefined
|
||||
}
|
||||
|
||||
get extruders(): PrinterStateExtruder[] {
|
||||
@@ -519,17 +484,50 @@ export default class ExtruderControlPanel extends Mixins(BaseMixin, ControlMixin
|
||||
this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
|
||||
this.$socket.emit('printer.gcode.script', { script: gcode }, { loading: 'btnDetract' })
|
||||
}
|
||||
|
||||
sendUnloadFilament(): void {
|
||||
const gcode = 'UNLOAD_FILAMENT'
|
||||
this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
|
||||
this.$socket.emit('printer.gcode.script', { script: gcode }, { loading: 'btnUnloadFilament' })
|
||||
}
|
||||
|
||||
sendLoadFilament(): void {
|
||||
const gcode = 'LOAD_FILAMENT'
|
||||
this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
|
||||
this.$socket.emit('printer.gcode.script', { script: gcode }, { loading: 'btnLoadFilament' })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
._btn-group {
|
||||
border-radius: 4px;
|
||||
display: inline-flex;
|
||||
flex-wrap: nowrap;
|
||||
max-width: 100%;
|
||||
min-width: 100%;
|
||||
width: 100%;
|
||||
|
||||
.v-btn {
|
||||
border-radius: 0;
|
||||
border-color: rgba(255, 255, 255, 0.12);
|
||||
border-style: solid;
|
||||
border-width: thin;
|
||||
box-shadow: none;
|
||||
height: 28px;
|
||||
opacity: 0.8;
|
||||
min-width: auto !important;
|
||||
}
|
||||
|
||||
.v-btn:first-child {
|
||||
border-top-left-radius: inherit;
|
||||
border-bottom-left-radius: inherit;
|
||||
}
|
||||
|
||||
.v-btn:last-child {
|
||||
border-top-right-radius: inherit;
|
||||
border-bottom-right-radius: inherit;
|
||||
}
|
||||
|
||||
.v-btn:not(:first-child) {
|
||||
border-left-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
._btn-qs {
|
||||
font-size: 0.8rem !important;
|
||||
max-height: 24px;
|
||||
}
|
||||
|
||||
._btn-extruder-cmd {
|
||||
min-width: 135px !important;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user