-
-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add action command prompt dialog and panel buttons
Signed-off-by: Stefan Dej <[email protected]>
- Loading branch information
Showing
2 changed files
with
109 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/components/dialogs/TheActionCommandPromptActionButton.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<template> | ||
<v-btn :color="color" text @click="clickButton"> | ||
{{ text }} | ||
</v-btn> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Mixins, Prop } from 'vue-property-decorator' | ||
import BaseMixin from '@/components/mixins/base' | ||
import { ServerStateEvent } from '@/store/server/types' | ||
@Component({}) | ||
export default class TheActionCommandPromptActionButton extends Mixins(BaseMixin) { | ||
@Prop({ type: Object, required: true }) readonly event!: ServerStateEvent | ||
@Prop({ type: String, required: true }) readonly type!: 'primary' | 'secondary' | ||
get filtertedMessageSplits() { | ||
return (this.event.message ?? '') | ||
.replace(`// action:prompt_button_${this.type}`, '') | ||
.replace(/"/g, '') | ||
.trim() | ||
.split('|') | ||
} | ||
get text() { | ||
return this.filtertedMessageSplits[0] | ||
} | ||
get command() { | ||
return this.filtertedMessageSplits[1] ?? this.text | ||
} | ||
get color() { | ||
return this.type === 'primary' ? 'primary' : '' | ||
} | ||
clickButton() { | ||
this.$store.dispatch('server/addEvent', { message: this.command, type: 'command' }) | ||
this.$socket.emit('printer.gcode.script', { script: this.command }) | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped></style> |