Skip to content

Commit

Permalink
feat(spoolman): store spool_id to save_variable, when enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Dej <[email protected]>
  • Loading branch information
meteyou committed Jul 16, 2024
1 parent f0987ad commit 90505aa
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/components/dialogs/SpoolmanChangeSpoolDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ export default class SpoolmanChangeSpoolDialog extends Mixins(BaseMixin) {
return this.$store.state.server.config.config?.spoolman?.server ?? null
}
get existsSaveVariables() {
const settings = this.$store.state.printer.configfile?.settings ?? {}
return 'save_variables' in settings
}
openSpoolManager() {
window.open(this.spoolManagerUrl, '_blank')
}
Expand Down Expand Up @@ -182,15 +188,27 @@ export default class SpoolmanChangeSpoolDialog extends Mixins(BaseMixin) {
}
setSpool(spool: ServerSpoolmanStateSpool) {
if (this.tool) {
const gcode = `SET_GCODE_VARIABLE MACRO=${this.tool} VARIABLE=spool_id VALUE=${spool.id}`
this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
this.$socket.emit('printer.gcode.script', { script: gcode })
this.$store.dispatch('server/spoolman/setActiveSpool', spool.id)
// Close the dialog if no tool is selected
if (!this.tool) {
this.close()
return
}
this.$store.dispatch('server/spoolman/setActiveSpool', spool.id)
// Set spool_id for tool
const gcode = `SET_GCODE_VARIABLE MACRO=${this.tool} VARIABLE=spool_id VALUE=${spool.id}`
this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
this.$socket.emit('printer.gcode.script', { script: gcode })
// Close dialog if save_variables is not enabled
if (this.existsSaveVariables) this.close()
// Set spool_id to save_variable
const gcode2 = `SAVE_VARIABLE VARIABLE=${this.tool.toUpperCase()}__SPOOL_ID VALUE=${spool.id}`
this.$store.dispatch('server/addEvent', { message: gcode2, type: 'command' })
this.$socket.emit('printer.gcode.script', { script: gcode2 })
this.close()
}
Expand Down

0 comments on commit 90505aa

Please sign in to comment.