refactor(ExtruderPanel): add _ prefix to gcode_state name (#1989)

This commit is contained in:
Stefan Dej 2024-09-04 23:07:43 +02:00 committed by GitHub
parent 21dab3913c
commit 5cb308064c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -93,7 +93,7 @@
<template #activator="{ on }"> <template #activator="{ on }">
<div v-on="on"> <div v-on="on">
<v-btn <v-btn
:loading="loadings.includes('btnDetract')" :loading="loadings.includes('btnExtrude')"
:disabled="!extrudePossible || tooLargeExtrusion || printerIsPrintingOnly" :disabled="!extrudePossible || tooLargeExtrusion || printerIsPrintingOnly"
small small
class="_btn-extruder-cmd" class="_btn-extruder-cmd"
@ -157,7 +157,7 @@
<template #activator="{ on }"> <template #activator="{ on }">
<div class="pt-1 pb-2 px-3" v-on="on"> <div class="pt-1 pb-2 px-3" v-on="on">
<v-btn <v-btn
:loading="loadings.includes('btnDetract')" :loading="loadings.includes('btnExtrude')"
:disabled=" :disabled="
!extrudePossible || tooLargeExtrusion || printerIsPrintingOnly !extrudePossible || tooLargeExtrusion || printerIsPrintingOnly
" "
@ -263,23 +263,22 @@ export default class ExtruderControlPanel extends Mixins(BaseMixin, ExtruderMixi
} }
sendRetract(): void { sendRetract(): void {
const gcode = this.sendCommand(this.feedamount * -1, 'btnRetract')
`SAVE_GCODE_STATE NAME=ui_retract\n` +
`M83\n` +
`G1 E-${this.feedamount} F${this.feedrate * 60}\n` +
`RESTORE_GCODE_STATE NAME=ui_retract`
this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
this.$socket.emit('printer.gcode.script', { script: gcode }, { loading: 'btnRetract' })
} }
sendExtrude(): void { sendExtrude(): void {
this.sendCommand(this.feedamount, 'btnExtrude')
}
sendCommand(length: number, loading: string): void {
const gcode = const gcode =
`SAVE_GCODE_STATE NAME=ui_extrude\n` + `SAVE_GCODE_STATE NAME=_ui_extrude\n` +
`M83\n` + `M83\n` +
`G1 E${this.feedamount} F${this.feedrate * 60}\n` + `G1 E${length} F${this.feedrate * 60}\n` +
`RESTORE_GCODE_STATE NAME=ui_extrude` `RESTORE_GCODE_STATE NAME=_ui_extrude`
this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' }) this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
this.$socket.emit('printer.gcode.script', { script: gcode }, { loading: 'btnDetract' }) this.$socket.emit('printer.gcode.script', { script: gcode }, { loading })
} }
} }
</script> </script>