From 3604c677bc6c53eba613fd7f51d84bb167f0496c Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Tue, 22 Oct 2024 00:51:32 +0200 Subject: [PATCH] refactor: refactor Console & MiniConsole (#2031) --- src/components/inputs/ConsoleTextarea.vue | 138 ++++++++++++ src/components/mixins/console.ts | 63 ++++++ src/components/panels/MiniconsolePanel.vue | 234 ++------------------- src/pages/Console.vue | 221 ++----------------- src/store/gui/console/mutations.ts | 16 +- 5 files changed, 244 insertions(+), 428 deletions(-) create mode 100644 src/components/inputs/ConsoleTextarea.vue create mode 100644 src/components/mixins/console.ts diff --git a/src/components/inputs/ConsoleTextarea.vue b/src/components/inputs/ConsoleTextarea.vue new file mode 100644 index 000000000..8663a9286 --- /dev/null +++ b/src/components/inputs/ConsoleTextarea.vue @@ -0,0 +1,138 @@ + + + + diff --git a/src/components/mixins/console.ts b/src/components/mixins/console.ts new file mode 100644 index 000000000..1709f6e89 --- /dev/null +++ b/src/components/mixins/console.ts @@ -0,0 +1,63 @@ +import Vue from 'vue' +import Component from 'vue-class-component' +import { CommandHelp } from '@/store/printer/types' +import { GuiConsoleStateFilter } from '@/store/gui/console/types' + +@Component +export default class ConsoleMixin extends Vue { + get helplist(): CommandHelp[] { + return this.$store.state.printer.helplist ?? [] + } + + get consoleDirection() { + return this.$store.state.gui.console.direction ?? 'table' + } + + get hideWaitTemperatures(): boolean { + return this.$store.state.gui.console.hideWaitTemperatures + } + + set hideWaitTemperatures(newVal) { + this.$store.dispatch('gui/saveSetting', { name: 'console.hideWaitTemperatures', value: newVal }) + } + + get hideTlCommands(): boolean { + return this.$store.state.gui.console.hideTlCommands + } + + set hideTlCommands(newVal) { + this.$store.dispatch('gui/saveSetting', { name: 'console.hideTlCommands', value: newVal }) + } + + get customFilters() { + return this.$store.state.gui.console.consolefilters ?? {} + } + + get autoscroll(): boolean { + return this.$store.state.gui.console.autoscroll ?? true + } + + set autoscroll(newVal) { + this.$store.dispatch('gui/saveSetting', { name: 'console.autoscroll', value: newVal }) + } + + get rawOutput(): boolean { + return this.$store.state.gui.console.rawOutput ?? false + } + + set rawOutput(newVal) { + this.$store.dispatch('gui/saveSetting', { name: 'console.rawOutput', value: newVal }) + } + + get lastCommands(): string[] { + return this.$store.state.gui.gcodehistory.entries ?? [] + } + + toggleFilter(id: string | number, filter: GuiConsoleStateFilter): void { + this.$store.dispatch('gui/console/filterUpdate', { id, values: filter }) + } + + clearConsole() { + this.$store.dispatch('gui/console/clear') + } +} diff --git a/src/components/panels/MiniconsolePanel.vue b/src/components/panels/MiniconsolePanel.vue index 8a5168dc6..98c6499d7 100644 --- a/src/components/panels/MiniconsolePanel.vue +++ b/src/components/panels/MiniconsolePanel.vue @@ -10,7 +10,7 @@ {{ mdiTrashCan }} - + + @change="toggleFilter(index, filter)" />
- + @@ -107,14 +86,14 @@ @@ -359,8 +169,4 @@ export default class MiniconsolePanel extends Mixins(BaseMixin) { html.theme--light .consoleTable { border-top: 1px solid rgba(0, 0, 0, 0.12); } - -.gcode-command-field { - font-family: 'Roboto Mono', monospace; -} diff --git a/src/pages/Console.vue b/src/pages/Console.vue index 39a5da20b..a9ca31d6d 100644 --- a/src/pages/Console.vue +++ b/src/pages/Console.vue @@ -2,35 +2,14 @@
- + {{ mdiTrashCan }} - + + @change="toggleFilter(index, filter)" />