feat: macro management (#396)

* feature: add multiple macro management settings (simple/expert)

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* feature: create and remove Macrogroups

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* refactor: edit function for macro groups

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* feature: create/edit/delete macrogroups

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* fix: init data in heightmap dont exist without bed_mesh

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* chore: extract macro params (#392)

Signed-off-by: Eike Ahmels <eike.ahmels@tu-dortmund.de>

* feat: finish macro management settings

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* feat: macro management in dashboard settings and display panels

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* fix: align of icons and text in settings dashboard

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* refactor: move gcode macros in seperate component

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* feat: combine "show status lines" in edit macro groups

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* fix: display macrogroups and macros in paused state

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* fix: macro group rights and display errors

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* refactor: remove create macrogroup and just add new group without name

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* fix: hide macrogroups when macromanagement is simple

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* feat: change to Roboto-Mono font in console

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* chore: add robotoMono font

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* refactor: remove debug outputs

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* refactor: update regex for extract params from macros

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* fix: macro params regex update

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* feat: hide params with '_' as first char

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* refactor: switch simple macros panel to macro-button component

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* refactor: fix padding of macro params dialog

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* refactor: add tooltips to macro management icon buttons

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* fix: filter not existing macrogroups in panellist

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* fix: delete layout position when deleting macrogroup

Signed-off-by: Stefan Dej <meteyou@gmail.com>

Co-authored-by: Eike Ahmels <hui_buh-@gmx.net>
This commit is contained in:
Stefan DejandEike Ahmels authored and GitHub committed 2021-10-27 22:37:15 +02:00
1 parent 3984a40fd9
commit 4ece97a535
35 files changed
+1474 -241

No files matched your search

+75 -10
View File
@@ -27,6 +27,7 @@
"object-assign-deep": "^0.4.0",
"sass-loader": "^10.2.0",
"semver": "^7.3.5",
"uuid": "^8.3.2",
"vue": "^2.6.14",
"vue-class-component": "^7.2.6",
"vue-context": "^6.0.0",
@@ -47,6 +48,7 @@
"devDependencies": {
"@mdi/font": "^6.2.95",
"@types/semver": "^7.3.8",
"@types/uuid": "^8.3.1",
"@typescript-eslint/eslint-plugin": "^4.28.5",
"@typescript-eslint/parser": "^4.29.3",
"@vue/cli-plugin-babel": "^4.5.13",
@@ -2238,6 +2240,12 @@
"node": ">=0.10.0"
}
},
"node_modules/@types/uuid": {
"version": "8.3.1",
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.1.tgz",
"integrity": "sha512-Y2mHTRAbqfFkpjldbkHGY8JIzRN6XqYRliG8/24FcHm2D2PwW24fl5xMRTVGdrb7iMrwCaIEbLWerGIkXuFWVg==",
"dev": true
},
"node_modules/@types/webpack": {
"version": "4.41.29",
"resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.29.tgz",
@@ -15133,6 +15141,16 @@
"node": ">= 6"
}
},
"node_modules/request/node_modules/uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
"devOptional": true,
"bin": {
"uuid": "bin/uuid"
}
},
"node_modules/require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
@@ -16149,6 +16167,16 @@
"ms": "^2.1.1"
}
},
"node_modules/sockjs/node_modules/uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
"dev": true,
"bin": {
"uuid": "bin/uuid"
}
},
"node_modules/sort-keys": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz",
@@ -18037,13 +18065,11 @@
}
},
"node_modules/uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
"devOptional": true,
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"bin": {
"uuid": "bin/uuid"
"uuid": "dist/bin/uuid"
}
},
"node_modules/v8-compile-cache": {
@@ -19471,6 +19497,16 @@
"node": ">= 6"
}
},
"node_modules/webpack-log/node_modules/uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
"dev": true,
"bin": {
"uuid": "bin/uuid"
}
},
"node_modules/webpack-merge": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-4.2.2.tgz",
@@ -22045,6 +22081,12 @@
}
}
},
"@types/uuid": {
"version": "8.3.1",
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.1.tgz",
"integrity": "sha512-Y2mHTRAbqfFkpjldbkHGY8JIzRN6XqYRliG8/24FcHm2D2PwW24fl5xMRTVGdrb7iMrwCaIEbLWerGIkXuFWVg==",
"dev": true
},
"@types/webpack": {
"version": "4.41.29",
"resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.29.tgz",
@@ -32185,6 +32227,14 @@
"tough-cookie": "~2.5.0",
"tunnel-agent": "^0.6.0",
"uuid": "^3.3.2"
},
"dependencies": {
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"devOptional": true
}
}
},
"require-directory": {
@@ -32988,6 +33038,14 @@
"faye-websocket": "^0.11.3",
"uuid": "^3.4.0",
"websocket-driver": "^0.7.4"
},
"dependencies": {
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"dev": true
}
}
},
"sockjs-client": {
@@ -34522,10 +34580,9 @@
"dev": true
},
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"devOptional": true
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
},
"v8-compile-cache": {
"version": "2.3.0",
@@ -35677,6 +35734,14 @@
"requires": {
"ansi-colors": "^3.0.0",
"uuid": "^3.3.2"
},
"dependencies": {
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"dev": true
}
}
},
"webpack-merge": {
+2
View File
@@ -33,6 +33,7 @@
"object-assign-deep": "^0.4.0",
"sass-loader": "^10.2.0",
"semver": "^7.3.5",
"uuid": "^8.3.2",
"vue": "^2.6.14",
"vue-class-component": "^7.2.6",
"vue-context": "^6.0.0",
@@ -53,6 +54,7 @@
"devDependencies": {
"@mdi/font": "^6.2.95",
"@types/semver": "^7.3.8",
"@types/uuid": "^8.3.1",
"@typescript-eslint/eslint-plugin": "^4.28.5",
"@typescript-eslint/parser": "^4.29.3",
"@vue/cli-plugin-babel": "^4.5.13",
Binary file not shown.
+8
View File
@@ -45,4 +45,12 @@
font-weight: 900;
src: local('Roboto Black'), local('Roboto-Black'), url(/fonts/roboto-black.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin */
@font-face {
font-family: 'Roboto Mono';
font-style: normal;
font-weight: 400;
src: local('Roboto Mono'), local('Roboto-Mono'), url(/fonts/robotoMono-regular.woff) format('woff');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
+5 -1
View File
@@ -35,7 +35,7 @@
</v-col>
<v-col :class="isMobile ? '' : 'pl-0'">
<perfect-scrollbar :class="'settings-tabs '+(isMobile ? '' : 'height500')" ref="settingsScroll">
<component :is="'settings-'+activeTab+'-tab'"></component>
<component :is="'settings-'+activeTab+'-tab'" @scrollToTop="scrollToTop"></component>
</perfect-scrollbar>
</v-col>
</v-row>
@@ -140,6 +140,10 @@ export default class TheSettingsMenu extends Mixins(BaseMixin) {
@Watch('activeTab')
activeTabWatch() {
this.scrollToTop()
}
scrollToTop() {
if (this.$refs.settingsScroll) this.$refs.settingsScroll.$el.scrollTop = 0
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
<style scoped lang="scss">
.consoleTableRow {
font-family: monospace;
font-family: 'Roboto Mono', monospace;
&+.consoleTableRow .col {
border-top: 1px solid rgba(255, 255, 255, 0.12);
+144
View File
@@ -0,0 +1,144 @@
<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
small
:color="color"
:class="paramArray.length ? 'macroWithParameters' : ''"
:loading="loadings.includes('macro_'+macro.name)"
@click="doSendMacro(macro.name)">
{{ macro.name.replace(/_/g, " ") }}
</v-btn>
<template v-if="paramArray.length">
<v-menu offset-y :close-on-content-click="false">
<template v-slot:activator="{ on, attrs }">
<v-btn
small
:color="color"
v-bind="attrs"
v-on="on"
class="minwidth-0 px-1 btnMacroMenu"
>
<v-icon>mdi-menu-down</v-icon>
</v-btn>
</template>
<v-card max-width="200">
<v-card-text class="py-2">
<v-row v-for="(name, key) in paramArray" :key="'param_'+key" class="my-2">
<v-col class="py-0">
<v-text-field
:label="name"
v-model="params[name].value"
hide-details
outlined
dense
>
<template v-slot:append>
<v-btn
v-if="params[name].value !== params[name].default"
@click="params[name].value = params[name].default"
icon
small>
<v-icon>mdi-refresh</v-icon>
</v-btn>
</template>
</v-text-field>
</v-col>
</v-row>
<v-row class="my-2">
<v-col class="py-0">
<v-btn color="primary" class="text-uppercase" block @click="sendWithParams">
{{ $t('Panels.MacrosPanel.Send') }}
</v-btn>
</v-col>
</v-row>
</v-card-text>
</v-card>
</v-menu>
</template>
</v-item-group>
</template>
<script lang="ts">
import Component from 'vue-class-component'
import {Mixins, Prop, Watch} from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import {GuiStateMacrogroupMacros} from '@/store/gui/types'
interface param {
type: 'int' | 'double' | 'string' | null,
default: string | null
value: string | null
}
interface params {
[key: string]: param
}
@Component
export default class MacroButton extends Mixins(BaseMixin) {
private paramArray: string[] = []
private params: params = {}
@Prop({ required: true }) readonly macro!: GuiStateMacrogroupMacros
@Prop({ default: 'primary' }) readonly color!: string
get klipperMacro() {
return this.$store.getters['printer/getMacro'](this.macro.name)
}
@Watch('klipperMacro')
klipperMacroChange() {
this.refreshParams()
}
refreshParams() {
this.paramArray.splice(0, this.paramArray.length)
this.params = {}
if (this.klipperMacro.params !== null) {
Object.keys(this.klipperMacro.params).forEach((name: string) => {
if (!name.startsWith('_')) {
this.paramArray.push(name)
this.params[name] = {
type: this.klipperMacro.params[name].type,
default: this.klipperMacro.params[name].default,
value: this.klipperMacro.params[name].default
}
}
})
}
}
doSendMacro(gcode: string) {
this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
this.$socket.emit('printer.gcode.script', { script: gcode }, { loading: 'macro_'+gcode })
}
sendWithParams() {
let params: string[] = []
this.paramArray.forEach((paramname: string) => {
if (this.params[paramname].value !== null && this.params[paramname].value !== '')
params.push(paramname+'='+this.params[paramname].value)
})
const gcode = this.macro.name + ' ' +params.join(' ')
this.doSendMacro(gcode)
}
mounted(){
this.refreshParams()
}
}
</script>
@@ -99,8 +99,6 @@ export default class MiscellaneousSlider extends Mixins(BaseMixin) {
}
increment() {
window.console.log(this.value)
this.value = this.value < 1.0 ? Math.round((this.value + 0.01) * 100) / 100 : 1.0
if (this.value < this.off_below) this.value = this.off_below
this.sendCmd()
+87
View File
@@ -0,0 +1,87 @@
import Component from 'vue-class-component'
import BaseMixin from '@/components/mixins/base'
import {allDashboardPanels} from '@/store/variables'
import {GuiStateMacrogroup} from '@/store/gui/types'
import {capitalize} from '@/plugins/helpers'
@Component
export default class DashboardMixin extends BaseMixin {
get macroMode() {
return this.$store.state.gui.dashboard.macroManagement ?? 'simple'
}
get macrogroups() {
return this.$store.state.gui.dashboard.macrogroups ?? []
}
get missingPanelsMobile() {
const panels = [
...this.$store.state.gui.dashboard.mobileLayout,
]
return this.checkMissingPanels(panels)
}
get missingPanelsTablet() {
const panels = [
...this.$store.state.gui.dashboard.tabletLayout1,
...this.$store.state.gui.dashboard.tabletLayout2,
]
return this.checkMissingPanels(panels)
}
get missingPanelsDesktop() {
const panels = [
...this.$store.state.gui.dashboard.desktopLayout1,
...this.$store.state.gui.dashboard.desktopLayout2,
]
return this.checkMissingPanels(panels)
}
get missingPanelsWidescreen() {
const panels = [
...this.$store.state.gui.dashboard.widescreenLayout1,
...this.$store.state.gui.dashboard.widescreenLayout2,
...this.$store.state.gui.dashboard.widescreenLayout3,
]
return this.checkMissingPanels(panels)
}
checkMissingPanels(panels: any[]) {
let allPanels = [...allDashboardPanels]
const missingPanels: any[] = []
if (this.macroMode === 'expert') {
this.macrogroups.forEach((group: GuiStateMacrogroup) => {
allPanels.push('macrogroup_'+group.id)
})
allPanels = allPanels.filter((name) => name !== 'macros')
}
allPanels.forEach((panelname) => {
if (!panels.find((panel) => panel.name === panelname))
missingPanels.push({
name: panelname,
visable: true
})
})
return missingPanels
}
getPanelName(name: string) {
if (name.startsWith('macrogroup_')) {
const groupId = name.split('_')[1] ?? ''
const group = this.macrogroups.find((group: GuiStateMacrogroup) => group.id === groupId)
return (group) ? group.name : 'Macrogroup'
}
return this.$t('Panels.'+capitalize(name)+'Panel.Headline')
}
}
@@ -79,7 +79,6 @@ export default class EndstopPanel extends Mixins(BaseMixin) {
syncEndstops() {
this.$socket.emit('printer.query_endstops.status', { }, { action: 'printer/getEndstopStatus', loading: 'queryEndstops' })
if (this.existProbe) {
window.console.log('exist probe')
this.$store.dispatch('server/addEvent', { message: 'QUERY_PROBE', type: 'command' })
this.$socket.emit('printer.gcode.script', { script: 'QUERY_PROBE' })
}
@@ -475,8 +475,6 @@ export default class UpdatePanel extends Mixins(BaseMixin) {
}
this.commitsOverlay.bool = true
window.console.log(this.commitsOverlay.groupedCommits)
}
}
+75
View File
@@ -0,0 +1,75 @@
<style lang="scss" scoped>
</style>
<template>
<panel
v-if="klipperReadyForGui && macros.length > 0 && macrogroupStatus"
icon="mdi-code-tags"
:title="macrogroup.name"
:collapsible="true"
:card-class="'macrogroup_'+panelId+'_panel'"
>
<v-card-text class="py-2">
<v-row>
<v-col class="text-center">
<macro-button v-for="(macro, index) in macros"
:key="'macroparam_'+index"
:macro="macro"
:color="getColor(macro)"
class="mx-1 my-1"
/>
</v-col>
</v-row>
</v-card-text>
</panel>
</template>
<script lang="ts">
import {Component, Mixins, Prop} from 'vue-property-decorator'
import BaseMixin from '../mixins/base'
import Panel from '@/components/ui/Panel.vue'
import {GuiStateMacrogroupMacros} from '@/store/gui/types'
import MacroButton from '@/components/inputs/MacroButton.vue'
@Component({
components: {MacroButton, Panel}
})
export default class MacrogroupPanel extends Mixins(BaseMixin) {
@Prop({ required: true }) panelId!: string
get macrogroup() {
return this.$store.getters['gui/getMacroGroup'](this.panelId)
}
get macros() {
let macros = this.macrogroup?.macros ?? []
macros = macros.filter((macro: GuiStateMacrogroupMacros) => {
return (
(macro.showInStandby && ['standby', 'complete', 'error'].includes(this.printer_state)) ||
(macro.showInPause && this.printer_state === 'paused') ||
(macro.showInPrinting && this.printer_state === 'printing')
)
})
return macros.sort((a: GuiStateMacrogroupMacros, b: GuiStateMacrogroupMacros) => a.pos - b.pos)
}
get macrogroupStatus() {
return (
(this.macrogroup.showInStandby && ['standby', 'complete', 'error'].includes(this.printer_state)) ||
(this.macrogroup.showInPause && this.printer_state === 'paused') ||
(this.macrogroup.showInPrinting && this.printer_state === 'printing')
)
}
getColor(macro: GuiStateMacrogroupMacros) {
if (macro.color === 'group') {
if (this.macrogroup.color === 'custom') return this.macrogroup.colorCustom
else return this.macrogroup.color
}
return macro.color
}
}
</script>
+8 -18
View File
@@ -1,7 +1,3 @@
<style lang="scss" scoped>
</style>
<template>
<panel
v-if="klipperReadyForGui && macros.length > 0"
@@ -13,13 +9,12 @@
<v-container>
<v-row no-gutters v-if="macros.length">
<v-col class="text-center mr-fix-2 mb-fix-2">
<v-btn v-for="(macro, index) in macros"
:key="index+99"
small
color="primary"
class="mr-2 mb-2"
:loading="loadings.includes('macro_'+macro.name)"
@click="doSendMacro(macro.name)">{{ macro.name.replace(/_/g, " ") }}</v-btn>
<macro-button v-for="(macro, index) in macros"
:key="'macro_'+index"
:macro="macro"
color="primary"
class="mx-1 my-1"
/>
</v-col>
</v-row>
</v-container>
@@ -30,18 +25,13 @@
import {Component, Mixins} from 'vue-property-decorator'
import BaseMixin from '../mixins/base'
import Panel from '@/components/ui/Panel.vue'
import MacroButton from '@/components/inputs/MacroButton.vue'
@Component({
components: {Panel}
components: {MacroButton, Panel}
})
export default class MacrosPanel extends Mixins(BaseMixin) {
get macros() {
return this.$store.getters['printer/getMacros']
}
doSendMacro(gcode: string) {
this.$store.dispatch('server/addEvent', { message: gcode, type: 'command' })
this.$socket.emit('printer.gcode.script', { script: gcode }, { loading: 'macro_'+gcode })
}
}
</script>
+1 -1
View File
@@ -5,7 +5,7 @@
}
.gcode-command-field {
font-family: monospace;
font-family: 'Roboto Mono', monospace;
}
</style>
@@ -150,7 +150,6 @@ export default class SettingsConsoleTab extends Mixins(BaseMixin) {
@Debounce(500)
updateConsoleHeight(newVal: number) {
window.console.log('updateConsoleHeight', newVal)
this.consoleHeight = newVal
}
@@ -13,30 +13,34 @@
<v-card class="mx-auto" max-width="300" tile >
<v-list dense>
<v-list-item>
<v-list-item-icon>
<v-icon>mdi-information</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('Panels.StatusPanel.Headline') }}</v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-icon color="grey lighten-1">mdi-lock</v-icon>
</v-list-item-action>
<v-row>
<v-col class="col-auto pr-0">
<v-icon>mdi-information</v-icon>
</v-col>
<v-col>
{{ $t('Panels.StatusPanel.Headline') }}
</v-col>
<v-col class="col-auto">
<v-icon color="grey lighten-1">mdi-lock</v-icon>
</v-col>
</v-row>
</v-list-item>
<draggable v-model="desktopLayout1" :handle="isMobile ? '.handle' : ''" class="v-list-item-group" ghost-class="ghost" group="desktopViewport">
<template v-for="(element) in desktopLayout1">
<v-list-item :key="'item-desktop-'+element.name" link>
<v-list-item-icon>
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('Panels.'+capitalize(element.name)+'Panel.Headline') }}</v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-icon v-if="!element.visable" color="grey lighten-1" @click.stop="changeState1(element.name,true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click.stop="changeState1(element.name,false)">mdi-checkbox-marked</v-icon>
</v-list-item-action>
<v-row>
<v-col class="col-auto pr-0">
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-col>
<v-col class="pr-0">
{{ getPanelName(element.name) }}
</v-col>
<v-col class="col-auto pl-0">
<v-icon v-if="!element.visable" color="grey lighten-1" @click.stop="changeState1(element.name,true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click.stop="changeState1(element.name,false)">mdi-checkbox-marked</v-icon>
</v-col>
</v-row>
</v-list-item>
</template>
</draggable>
@@ -49,17 +53,19 @@
<draggable v-model="desktopLayout2" :handle="isMobile ? '.handle' : ''" class="v-list-item-group" ghost-class="ghost" group="desktopViewport">
<template v-for="(element) in desktopLayout2">
<v-list-item :key="'item-desktop-'+element.name" link>
<v-list-item-icon>
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('Panels.'+capitalize(element.name)+'Panel.Headline') }}</v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-icon v-if="!element.visable" color="grey lighten-1" @click.stop="changeState2(element.name,true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click.stop="changeState2(element.name,false)">mdi-checkbox-marked</v-icon>
</v-list-item-action>
<v-row>
<v-col class="col-auto pr-0">
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-col>
<v-col class="pr-0">
{{ getPanelName(element.name) }}
</v-col>
<v-col class="col-auto pl-0">
<v-icon v-if="!element.visable" color="grey lighten-1" @click.stop="changeState2(element.name,true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click.stop="changeState2(element.name,false)">mdi-checkbox-marked</v-icon>
</v-col>
</v-row>
</v-list-item>
</template>
</draggable>
@@ -79,21 +85,24 @@
<script lang="ts">
import Component from 'vue-class-component'
import { Mixins } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import draggable from 'vuedraggable'
import {capitalize, convertPanelnameToIcon} from '@/plugins/helpers'
import DashboardMixin from '@/components/mixins/dashboard'
@Component( {
components: {
draggable
}
}
)
export default class SettingsDashboardTabDesktop extends Mixins(BaseMixin) {
export default class SettingsDashboardTabDesktop extends Mixins(DashboardMixin) {
capitalize = capitalize
convertPanelnameToIcon = convertPanelnameToIcon
get desktopLayout1() {
return this.$store.state.gui?.dashboard?.desktopLayout1?.filter((element: any) => element !== null) ?? []
let panels = this.$store.getters['gui/getPanels']('desktopLayout1')
panels = panels.concat(this.missingPanelsDesktop)
return panels
}
set desktopLayout1(newVal) {
@@ -103,7 +112,7 @@ export default class SettingsDashboardTabDesktop extends Mixins(BaseMixin) {
}
get desktopLayout2() {
return this.$store.state.gui?.dashboard?.desktopLayout2?.filter((element: any) => element !== null) ?? []
return this.$store.getters['gui/getPanels']('desktopLayout2')
}
set desktopLayout2(newVal) {
@@ -13,32 +13,34 @@
<v-card class="mx-auto" max-width="300" tile >
<v-list dense>
<v-list-item>
<v-list-item-icon>
<v-icon>mdi-information</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('Panels.StatusPanel.Headline') }}</v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-icon color="grey lighten-1">mdi-lock</v-icon>
</v-list-item-action>
<v-row>
<v-col class="col-auto pr-0">
<v-icon>mdi-information</v-icon>
</v-col>
<v-col>
{{ $t('Panels.StatusPanel.Headline') }}
</v-col>
<v-col class="col-auto">
<v-icon color="grey lighten-1">mdi-lock</v-icon>
</v-col>
</v-row>
</v-list-item>
<draggable v-model="mobileLayout" :handle="isMobile ? '.handle' : ''" class="v-list-item-group" ghost-class="ghost" group="mobileViewport">
<template v-for="(element) in mobileLayout">
<v-list-item :key="'item-mobile-'+element.name" link>
<v-list-item-icon>
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>
{{ $t('Panels.'+capitalize(element.name)+'Panel.Headline') }}
</v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-icon v-if="!element.visable" color="grey lighten-1" @click="changeState(element.name, true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click="changeState(element.name, false)">mdi-checkbox-marked</v-icon>
</v-list-item-action>
<v-row>
<v-col class="col-auto pr-0">
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-col>
<v-col class="pr-0">
{{ getPanelName(element.name) }}
</v-col>
<v-col class="col-auto pl-0">
<v-icon v-if="!element.visable" color="grey lighten-1" @click.stop="changeState(element.name,true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click.stop="changeState(element.name,false)">mdi-checkbox-marked</v-icon>
</v-col>
</v-row>
</v-list-item>
</template>
</draggable>
@@ -58,7 +60,7 @@
<script lang="ts">
import Component from 'vue-class-component'
import { Mixins } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import DashboardMixin from '@/components/mixins/dashboard'
import draggable from 'vuedraggable'
import {capitalize, convertPanelnameToIcon} from '@/plugins/helpers'
@Component( {
@@ -67,12 +69,15 @@ import {capitalize, convertPanelnameToIcon} from '@/plugins/helpers'
}
}
)
export default class SettingsDashboardTabMobile extends Mixins(BaseMixin) {
export default class SettingsDashboardTabMobile extends Mixins(DashboardMixin) {
capitalize = capitalize
convertPanelnameToIcon = convertPanelnameToIcon
get mobileLayout() {
return this.$store.state.gui?.dashboard?.mobileLayout?.filter((element: any) => element !== null) ?? []
let panels = this.$store.getters['gui/getPanels']('mobileLayout')
panels = panels.concat(this.missingPanelsMobile)
return panels
}
set mobileLayout(newVal) {
@@ -13,30 +13,34 @@
<v-card class="mx-auto" max-width="300" tile >
<v-list dense>
<v-list-item>
<v-list-item-icon>
<v-icon>mdi-information</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('Panels.StatusPanel.Headline') }}</v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-icon color="grey lighten-1">mdi-lock</v-icon>
</v-list-item-action>
<v-row>
<v-col class="col-auto pr-0">
<v-icon>mdi-information</v-icon>
</v-col>
<v-col>
{{ $t('Panels.StatusPanel.Headline') }}
</v-col>
<v-col class="col-auto">
<v-icon color="grey lighten-1">mdi-lock</v-icon>
</v-col>
</v-row>
</v-list-item>
<draggable v-model="tabletLayout1" :handle="isMobile ? '.handle' : ''" class="v-list-item-group" ghost-class="ghost" group="tabletViewport">
<template v-for="(element) in tabletLayout1">
<v-list-item :key="'item-tablet-'+element.name" link>
<v-list-item-icon>
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('Panels.'+capitalize(element.name)+'Panel.Headline') }}</v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-icon v-if="!element.visable" color="grey lighten-1" @click.stop="changeState1(element.name,true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click.stop="changeState1(element.name,false)">mdi-checkbox-marked</v-icon>
</v-list-item-action>
<v-row>
<v-col class="col-auto pr-0">
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-col>
<v-col class="pr-0">
{{ getPanelName(element.name) }}
</v-col>
<v-col class="col-auto pl-0">
<v-icon v-if="!element.visable" color="grey lighten-1" @click.stop="changeState1(element.name,true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click.stop="changeState1(element.name,false)">mdi-checkbox-marked</v-icon>
</v-col>
</v-row>
</v-list-item>
</template>
</draggable>
@@ -49,17 +53,19 @@
<draggable v-model="tabletLayout2" :handle="isMobile ? '.handle' : ''" class="v-list-item-group" ghost-class="ghost" group="tabletViewport">
<template v-for="(element) in tabletLayout2">
<v-list-item :key="'item-tablet-'+element.name" link>
<v-list-item-icon>
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('Panels.'+capitalize(element.name)+'Panel.Headline') }}</v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-icon v-if="!element.visable" color="grey lighten-1" @click.stop="changeState2(element.name,true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click.stop="changeState2(element.name,false)">mdi-checkbox-marked</v-icon>
</v-list-item-action>
<v-row>
<v-col class="col-auto pr-0">
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-col>
<v-col class="pr-0">
{{ getPanelName(element.name) }}
</v-col>
<v-col class="col-auto pl-0">
<v-icon v-if="!element.visable" color="grey lighten-1" @click.stop="changeState2(element.name,true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click.stop="changeState2(element.name,false)">mdi-checkbox-marked</v-icon>
</v-col>
</v-row>
</v-list-item>
</template>
</draggable>
@@ -79,7 +85,7 @@
<script lang="ts">
import Component from 'vue-class-component'
import { Mixins } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import DashboardMixin from '@/components/mixins/dashboard'
import draggable from 'vuedraggable'
import {capitalize, convertPanelnameToIcon} from '@/plugins/helpers'
@Component( {
@@ -88,12 +94,15 @@ import {capitalize, convertPanelnameToIcon} from '@/plugins/helpers'
}
}
)
export default class SettingsDashboardTabTablet extends Mixins(BaseMixin) {
export default class SettingsDashboardTabTablet extends Mixins(DashboardMixin) {
capitalize = capitalize
convertPanelnameToIcon = convertPanelnameToIcon
get tabletLayout1() {
return this.$store.state.gui?.dashboard?.tabletLayout1?.filter((element: any) => element !== null) ?? []
let panels = this.$store.getters['gui/getPanels']('tabletLayout1')
panels = panels.concat(this.missingPanelsTablet)
return panels
}
set tabletLayout1(newVal) {
@@ -103,7 +112,7 @@ export default class SettingsDashboardTabTablet extends Mixins(BaseMixin) {
}
get tabletLayout2() {
return this.$store.state.gui?.dashboard?.tabletLayout2?.filter((element: any) => element !== null) ?? []
return this.$store.getters['gui/getPanels']('tabletLayout2')
}
set tabletLayout2(newVal) {
@@ -13,30 +13,34 @@
<v-card class="mx-auto" max-width="300" tile >
<v-list dense>
<v-list-item>
<v-list-item-icon>
<v-icon>mdi-information</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('Panels.StatusPanel.Headline') }}</v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-icon color="grey lighten-1">mdi-lock</v-icon>
</v-list-item-action>
<v-row>
<v-col class="col-auto pr-0">
<v-icon>mdi-information</v-icon>
</v-col>
<v-col>
{{ $t('Panels.StatusPanel.Headline') }}
</v-col>
<v-col class="col-auto">
<v-icon color="grey lighten-1">mdi-lock</v-icon>
</v-col>
</v-row>
</v-list-item>
<draggable v-model="widescreenLayout1" :handle="isMobile ? '.handle' : ''" class="v-list-item-group" ghost-class="ghost" group="widescreenViewport">
<template v-for="(element) in widescreenLayout1">
<v-list-item :key="'item-widescreen-'+element.name" link>
<v-list-item-icon>
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('Panels.'+capitalize(element.name)+'Panel.Headline') }}</v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-icon v-if="!element.visable" color="grey lighten-1" @click.stop="changeState1(element.name,true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click.stop="changeState1(element.name,false)">mdi-checkbox-marked</v-icon>
</v-list-item-action>
<v-row>
<v-col class="col-auto pr-0">
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-col>
<v-col class="pr-0">
{{ getPanelName(element.name) }}
</v-col>
<v-col class="col-auto pl-0">
<v-icon v-if="!element.visable" color="grey lighten-1" @click.stop="changeState1(element.name,true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click.stop="changeState1(element.name,false)">mdi-checkbox-marked</v-icon>
</v-col>
</v-row>
</v-list-item>
</template>
</draggable>
@@ -49,17 +53,19 @@
<draggable v-model="widescreenLayout2" :handle="isMobile ? '.handle' : ''" class="v-list-item-group" ghost-class="ghost" group="widescreenViewport">
<template v-for="(element) in widescreenLayout2">
<v-list-item :key="'item-widescreen-'+element.name" link>
<v-list-item-icon>
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('Panels.'+capitalize(element.name)+'Panel.Headline') }}</v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-icon v-if="!element.visable" color="grey lighten-1" @click.stop="changeState2(element.name,true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click.stop="changeState2(element.name,false)">mdi-checkbox-marked</v-icon>
</v-list-item-action>
<v-row>
<v-col class="col-auto pr-0">
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-col>
<v-col class="pr-0">
{{ getPanelName(element.name) }}
</v-col>
<v-col class="col-auto pl-0">
<v-icon v-if="!element.visable" color="grey lighten-1" @click.stop="changeState2(element.name,true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click.stop="changeState2(element.name,false)">mdi-checkbox-marked</v-icon>
</v-col>
</v-row>
</v-list-item>
</template>
</draggable>
@@ -72,17 +78,19 @@
<draggable v-model="widescreenLayout3" :handle="isMobile ? '.handle' : ''" class="v-list-item-group" ghost-class="ghost" group="widescreenViewport">
<template v-for="(element) in widescreenLayout3">
<v-list-item :key="'item-widescreen-'+element.name" link>
<v-list-item-icon>
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('Panels.'+capitalize(element.name)+'Panel.Headline') }}</v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-icon v-if="!element.visable" color="grey lighten-1" @click.stop="changeState3(element.name,true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click.stop="changeState3(element.name,false)">mdi-checkbox-marked</v-icon>
</v-list-item-action>
<v-row>
<v-col class="col-auto pr-0">
<v-icon v-if="isMobile" class="handle">mdi-arrow-up-down</v-icon>
<v-icon v-else v-text="convertPanelnameToIcon(element.name)"></v-icon>
</v-col>
<v-col class="pr-0">
{{ getPanelName(element.name) }}
</v-col>
<v-col class="col-auto pl-0">
<v-icon v-if="!element.visable" color="grey lighten-1" @click.stop="changeState3(element.name,true)">mdi-checkbox-blank-outline</v-icon>
<v-icon v-else color="primary" @click.stop="changeState3(element.name,false)">mdi-checkbox-marked</v-icon>
</v-col>
</v-row>
</v-list-item>
</template>
</draggable>
@@ -102,21 +110,24 @@
<script lang="ts">
import Component from 'vue-class-component'
import { Mixins } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import draggable from 'vuedraggable'
import {capitalize, convertPanelnameToIcon} from '@/plugins/helpers'
import DashboardMixin from '@/components/mixins/dashboard'
@Component( {
components: {
draggable
}
}
)
export default class SettingsDashboardTabWidescreen extends Mixins(BaseMixin) {
export default class SettingsDashboardTabWidescreen extends Mixins(DashboardMixin) {
capitalize = capitalize
convertPanelnameToIcon = convertPanelnameToIcon
get widescreenLayout1() {
return this.$store.state.gui?.dashboard?.widescreenLayout1?.filter((element: any) => element !== null) ?? []
let panels = this.$store.getters['gui/getPanels']('widescreenLayout1')
panels = panels.concat(this.missingPanelsWidescreen)
return panels
}
set widescreenLayout1(newVal) {
@@ -126,7 +137,7 @@ export default class SettingsDashboardTabWidescreen extends Mixins(BaseMixin) {
}
get widescreenLayout2() {
return this.$store.state.gui?.dashboard?.widescreenLayout2?.filter((element: any) => element !== null) ?? []
return this.$store.getters['gui/getPanels']('widescreenLayout2')
}
set widescreenLayout2(newVal) {
@@ -136,7 +147,7 @@ export default class SettingsDashboardTabWidescreen extends Mixins(BaseMixin) {
}
get widescreenLayout3() {
return this.$store.state.gui?.dashboard?.widescreenLayout3?.filter((element: any) => element !== null) ?? []
return this.$store.getters['gui/getPanels']('widescreenLayout3')
}
set widescreenLayout3(newVal) {
+36 -31
View File
@@ -1,23 +1,19 @@
<template>
<v-card flat>
<v-card-text>
<template v-if="macros.length">
<div v-for="(macro, index) in macros" v-bind:key="index">
<v-divider class="my-2" v-if="index"></v-divider>
<settings-row :title="macro.name" :sub-title="macro.description" :dynamicSlotWidth="true">
<v-switch :input-value="getMacroStatus(macro.name)" @change="changeMacroStatus(macro.name)" hide-details class="mt-0"></v-switch>
</settings-row>
</div>
</template>
<template v-else>
<v-row>
<v-col>
<p class="mb-0 text-center font-italic">{{ $t('Settings.MacrosTab.NOMacros') }}</p>
</v-col>
</v-row>
</template>
<v-card-text v-if="showGeneral">
<h3 class="text-h5 mb-3">{{ $t('Settings.MacrosTab.General') }}</h3>
<settings-row :title="$t('Settings.MacrosTab.Management')">
<v-select v-model="macroManagement" :items="macroManagements" outlined dense hide-details></v-select>
</settings-row>
<v-divider class="my-2"></v-divider>
</v-card-text>
<template v-if="macroManagement === 'expert'">
<settings-macros-tab-expert @update:showGeneral="updateShowGeneral" @scrollToTop="scrollToTop"></settings-macros-tab-expert>
</template>
<template v-else>
<settings-macros-tab-simple></settings-macros-tab-simple>
</template>
</v-card>
</template>
@@ -26,32 +22,41 @@
import {Component, Mixins} from 'vue-property-decorator'
import BaseMixin from '../mixins/base'
import SettingsRow from '@/components/settings/SettingsRow.vue'
import SettingsMacrosTabSimple from '@/components/settings/SettingsMacrosTabSimple.vue'
import SettingsMacrosTabExpert from '@/components/settings/SettingsMacrosTabExpert.vue'
@Component({
components: {SettingsRow}
components: {SettingsMacrosTabExpert, SettingsMacrosTabSimple, SettingsRow}
})
export default class SettingsMacrosTab extends Mixins(BaseMixin) {
private showGeneral = true
get macros() {
return this.$store.getters['printer/getAllMacros'] ?? []
get macroManagements() {
return [
{
text: this.$t('Settings.MacrosTab.Simple'),
value: 'simple',
},
{
text: this.$t('Settings.MacrosTab.Expert'),
value: 'expert',
},
]
}
get hiddenMacros() {
return this.$store.state.gui.dashboard.hiddenMacros ?? []
get macroManagement() {
return this.$store.state.gui?.dashboard?.macroManagement ?? 'simple'
}
getMacroStatus(name: string) {
return !this.hiddenMacros.includes(name.toUpperCase())
set macroManagement(newVal) {
this.$store.dispatch('gui/saveSetting', { name: 'dashboard.macroManagement', value: newVal })
}
changeMacroStatus(name: string) {
const hiddenMacros = [...this.hiddenMacros]
updateShowGeneral(newVal: boolean) {
this.showGeneral = newVal
}
if (this.hiddenMacros.includes(name.toUpperCase()))
hiddenMacros.splice(hiddenMacros.indexOf(name.toUpperCase()), 1)
else
hiddenMacros.push(name.toUpperCase())
this.$store.dispatch('gui/saveSetting', { name: 'dashboard.hiddenMacros', value: hiddenMacros })
scrollToTop() {
this.$emit('scrollToTop')
}
}
</script>
@@ -0,0 +1,410 @@
<template>
<div>
<template v-if="boolFormEdit === false">
<v-card-text>
<h3 class="text-h5 mb-3">{{ $t('Settings.MacrosTab.Macrogroups') }}</h3>
<template v-if="groups.length">
<div v-for="(group, index) in groups" v-bind:key="index">
<v-divider class="my-2" v-if="index"></v-divider>
<settings-row :title="group.name !== '' ? group.name : '<'+$t('Settings.MacrosTab.UnknownGroup')+'>'" :sub-title="$tc('Settings.MacrosTab.CountMacros', ('macros' in group ? group.macros.length : 0), { count: ('macros' in group ? group.macros.length : 0) })" :dynamicSlotWidth="true">
<v-btn small outlined class="ml-3" @click="editMacrogroup(group)">
<v-icon left small>mdi-pencil</v-icon>{{ $t('Settings.Edit') }}
</v-btn>
<v-btn small outlined @click="deleteMacrogroup(group.id)" class="ml-3 minwidth-0 px-2" color="error">
<v-icon small>mdi-delete</v-icon>
</v-btn>
</settings-row>
</div>
</template>
<template v-else>
<v-row>
<v-col>
<p class="mb-0 text-center font-italic">{{ $t('Settings.MacrosTab.NoGroups') }}</p>
</v-col>
</v-row>
</template>
</v-card-text>
<v-card-actions class="d-flex justify-end">
<v-btn text color="primary" @click="addGroup">{{ $t("Settings.MacrosTab.AddGroup")}}</v-btn>
</v-card-actions>
</template>
<template v-else-if="boolFormEdit">
<v-card-text>
<h3 class="text-h5 mb-3">{{ $t('Settings.MacrosTab.EditGroup') }}</h3>
<settings-row :title="$t('Settings.MacrosTab.Name')">
<v-text-field
v-model="editGroup.name"
hide-details="auto"
:rules="[rules.required, rules.groupUnique]"
dense
outlined
@change="updateGroupOptionName"
></v-text-field>
</settings-row>
<v-divider class="my-2"></v-divider>
<settings-row :title="$t('Settings.MacrosTab.Color')">
<v-select v-model="editGroup.color" :items="groupColors" @change="updateGroupOptionColor" outlined dense hide-details></v-select>
</settings-row>
<template v-if="editGroup.color === 'custom'">
<v-divider class="my-2"></v-divider>
<settings-row :title="$t('Settings.MacrosTab.CustomColor')">
<v-menu bottom left offset-y :close-on-content-click="false">
<template v-slot:activator="{ on, attrs }">
<v-btn v-bind="attrs" v-on="on" :color="editGroup.colorCustom" class="minwidth-0 px-5" small></v-btn>
</template>
<v-color-picker
:value="editGroup.colorCustom"
hide-mode-switch
mode="rgba"
@update:color="updateGroupOptionColorCustom"
></v-color-picker>
</v-menu>
</settings-row>
</template>
<v-divider class="my-2"></v-divider>
<settings-row :title="$t('Settings.MacrosTab.Status')">
<v-tooltip top>
<template v-slot:activator="{ on, attrs }">
<v-btn small outlined v-bind="attrs" v-on="on" @click="updateGroupOptionShowInStandby(!editGroup.showInStandby)" class="ml-3 minwidth-0 px-2" :color="editGroup.showInStandby ? '' : 'secondary'">
<v-icon small>mdi-sleep</v-icon>
</v-btn>
</template>
<span>{{ $t('Settings.MacrosTab.ShowInStateStandby') }}</span>
</v-tooltip>
<v-tooltip top>
<template v-slot:activator="{ on, attrs }">
<v-btn small outlined v-bind="attrs" v-on="on" @click="updateGroupOptionShowInPause(!editGroup.showInPause)" class="ml-3 minwidth-0 px-2" :color="editGroup.showInPause ? '' : 'secondary'">
<v-icon small>mdi-pause</v-icon>
</v-btn>
</template>
<span>{{ $t('Settings.MacrosTab.ShowInStatePaused') }}</span>
</v-tooltip>
<v-tooltip top>
<template v-slot:activator="{ on, attrs }">
<v-btn small outlined v-bind="attrs" v-on="on" @click="updateGroupOptionShowInPrinting(!editGroup.showInPrinting)" class="ml-3 minwidth-0 px-2" :color="editGroup.showInPrinting ? '' : 'secondary'">
<v-icon small>mdi-printer-3d-nozzle</v-icon>
</v-btn>
</template>
<span>{{ $t('Settings.MacrosTab.ShowInStatePrinting') }}</span>
</v-tooltip>
</settings-row>
<v-divider class="my-2"></v-divider>
<h3 class="text-h5 mt-6 mb-3">{{ $t('Settings.MacrosTab.GroupMacros') }}</h3>
<template v-if="editGroup.macros && editGroup.macros.length">
<draggable v-model="editGroupMacros" handle=".handle" ghost-class="ghost" group="macros" @change="updateMacroOrder">
<template v-for="(macro, index) in editGroupMacros">
<div v-bind:key="macro.name">
<v-row>
<v-col class="col-auto pr-0 d-flex">
<v-icon class="handle">mdi-arrow-up-down</v-icon>
</v-col>
<v-col>
<settings-row :title="macro.name" :sub-title="getMacroDescription(macro.name)" v-bind:key="'groupMacro_macro_'+index" :dynamicSlotWidth="true">
<v-tooltip top>
<template v-slot:activator="{ on, attrs }">
<v-btn small outlined v-bind="attrs" v-on="on" @click="changeColorMacroFromGroup(macro)" class="ml-3 minwidth-0 px-2" :color="macro.color ">
<v-icon small left>mdi-palette</v-icon> {{ macro.color }}
</v-btn>
</template>
<span>{{ $t('Settings.MacrosTab.ChangeMacroColor') }}</span>
</v-tooltip>
<v-tooltip top>
<template v-slot:activator="{ on, attrs }">
<v-btn small outlined v-bind="attrs" v-on="on" @click="updateMacroFromGroup(macro, 'showInStandby', !macro.showInStandby)" class="ml-3 minwidth-0 px-2" :color="macro.showInStandby ? '' : 'secondary'">
<v-icon small>mdi-sleep</v-icon>
</v-btn>
</template>
<span>{{ $t('Settings.MacrosTab.ShowInStateStandby') }}</span>
</v-tooltip>
<v-tooltip top>
<template v-slot:activator="{ on, attrs }">
<v-btn small outlined v-bind="attrs" v-on="on" @click="updateMacroFromGroup(macro, 'showInPause', !macro.showInPause)" class="ml-3 minwidth-0 px-2" :color="macro.showInPause ? '' : 'secondary'">
<v-icon small>mdi-pause</v-icon>
</v-btn>
</template>
<span>{{ $t('Settings.MacrosTab.ShowInStatePaused') }}</span>
</v-tooltip>
<v-tooltip top>
<template v-slot:activator="{ on, attrs }">
<v-btn small outlined v-bind="attrs" v-on="on" @click="updateMacroFromGroup(macro, 'showInPrinting', !macro.showInPrinting)" class="ml-3 minwidth-0 px-2" :color="macro.showInPrinting ? '' : 'secondary'">
<v-icon small>mdi-printer-3d-nozzle</v-icon>
</v-btn>
</template>
<span>{{ $t('Settings.MacrosTab.ShowInStatePrinting') }}</span>
</v-tooltip>
<v-tooltip top>
<template v-slot:activator="{ on, attrs }">
<v-btn small outlined v-bind="attrs" v-on="on" @click="removeMacroFromGroup(macro)" class="ml-3 minwidth-0 px-2" color="error">
<v-icon small>mdi-delete</v-icon>
</v-btn>
</template>
<span>{{ $t('Settings.MacrosTab.DeleteMacroFromGroup') }}</span>
</v-tooltip>
</settings-row>
</v-col>
</v-row>
<v-divider class="my-2" ></v-divider>
</div>
</template>
</draggable>
</template>
<template v-else>
<v-row>
<v-col>
<p class="mb-0 text-center font-italic">{{ $t('Settings.MacrosTab.NoMacrosInGroup') }}</p>
</v-col>
</v-row>
</template>
<h3 class="text-h5 mt-6 mb-3">{{ $t('Settings.MacrosTab.AvailableMacros') }}</h3>
<template v-if="availableMacros.length">
<template v-for="(macro, index) in availableMacros">
<v-divider class="my-2" v-if="index" v-bind:key="'availableMacro_deliver_'+index"></v-divider>
<settings-row :title="macro.name" :sub-title="macro.description" v-bind:key="'availableMacro_macro_'+index" :dynamicSlotWidth="true">
<v-btn small outlined class="ml-3" @click="addMacroToGroup(macro)">
<v-icon left small>mdi-plus</v-icon> {{ $t('Settings.MacrosTab.Add') }}
</v-btn>
</settings-row>
</template>
</template>
<template v-else>
<v-row>
<v-col>
<p class="mb-0 text-center font-italic">{{ $t('Settings.MacrosTab.NoAvailableMacros') }}</p>
</v-col>
</v-row>
</template>
</v-card-text>
<v-card-actions class="d-flex justify-end">
<v-btn text @click="cancelEditMacrogroup">{{ $t('Settings.Cancel')}}</v-btn>
</v-card-actions>
</template>
</div>
</template>
<script lang="ts">
import {Component, Mixins, Watch} from 'vue-property-decorator'
import BaseMixin from '../mixins/base'
import draggable from 'vuedraggable'
import SettingsRow from '@/components/settings/SettingsRow.vue'
import {GuiStateMacrogroup, GuiStateMacrogroupMacros} from '@/store/gui/types'
import {Debounce} from 'vue-debounce-decorator'
import {PrinterStateMacro} from '@/store/printer/types'
@Component({
components: {SettingsRow, draggable}
})
export default class SettingsMacrosTabExpert extends Mixins(BaseMixin) {
private rules = {
required: (value: string) => value !== '' || 'required',
groupUnique: (value: string) => !this.existsGroupName(value) || 'Name already exists',
}
private boolFormEdit = false
private editGroupId: string | null = ''
get groupColors() {
return [
{
text: this.$t('Settings.MacrosTab.Primary'),
value: 'primary',
},
{
text: this.$t('Settings.MacrosTab.Secondary'),
value: 'secondary',
},
{
text: this.$t('Settings.MacrosTab.Success'),
value: 'success',
},
{
text: this.$t('Settings.MacrosTab.Warning'),
value: 'warning',
},
{
text: this.$t('Settings.MacrosTab.Error'),
value: 'error',
},
{
text: this.$t('Settings.MacrosTab.Custom'),
value: 'custom',
},
]
}
get macroColors() {
const colors = [...this.groupColors]
const indexCustom = colors.findIndex((color) => color.value === 'custom')
if (indexCustom !== -1) colors.splice(indexCustom, 1)
colors.push({
text: this.$t('Settings.MacrosTab.Group'),
value: 'group'
})
return colors
}
get allMacros() {
return this.$store.getters['printer/getAllMacros'] ?? []
}
get availableMacros() {
return this.allMacros.filter((m: GuiStateMacrogroupMacros) => !this.editGroupUsedMacros.includes(m.name))
}
get groups() {
return this.$store.getters['gui/getAllMacroGroups'] ?? []
}
get editGroupUsedMacros() {
return this.editGroup?.macros?.map((m: GuiStateMacrogroupMacros) => m.name) ?? []
}
get editGroup(): GuiStateMacrogroup | null {
return this.$store.getters['gui/getMacroGroup'](this.editGroupId)
}
get editGroupMacros() {
const macros = this.editGroup?.macros ?? []
macros.sort((a, b) => a.pos - b.pos)
return macros
}
set editGroupMacros(newVal) {
}
existsGroupName(name: string) {
return (this.groups.findIndex((group: GuiStateMacrogroup) => group.name === name && group.id != this.editGroupId) >= 0)
}
clearColorObject(color: any): string {
if (typeof color === 'object' && 'hex' in color)
color = color.hex
if (color.length > 7)
color = color.substr(0, 7)
return color
}
updateShowGeneral(newVal: boolean) {
this.$emit('update:showGeneral', newVal )
}
async addGroup() {
this.editGroupId = await this.$store.dispatch('gui/storeMarcogroup', {
name: '',
color: 'primary',
colorCustom: '#fff',
showInStandby: true,
showInPause: true,
showInPrinting: true,
})
this.boolFormEdit = true
}
editMacrogroup(group: GuiStateMacrogroup) {
this.boolFormEdit = true
this.editGroupId = group.id
}
deleteMacrogroup(id: string) {
this.$store.dispatch('gui/destroyMacrogroup', id)
}
addMacroToGroup(macro: PrinterStateMacro) {
this.$store.dispatch('gui/addMacroToMacrogroup', {
group: this.editGroupId,
macro: macro.name
})
}
updateMacroFromGroup(macro: GuiStateMacrogroupMacros, option: string, value: boolean | string | number) {
this.$store.dispatch('gui/updateMacroFromMacrogroup', {
group: this.editGroupId,
macro: macro.name,
option: option,
value: value
})
}
updateMacroOrder(output: any) {
const oldIndex = output.moved.oldIndex ?? 0
const newIndex = output.moved.newIndex ?? 0
const oldPos = this.editGroupMacros[oldIndex].pos
const newPos = this.editGroupMacros[newIndex].pos
this.updateMacroFromGroup(this.editGroupMacros[oldIndex], 'pos', newPos)
this.updateMacroFromGroup(this.editGroupMacros[newIndex], 'pos', oldPos)
}
changeColorMacroFromGroup(macro: GuiStateMacrogroupMacros) {
let index = this.macroColors.findIndex((color) => color.value === macro.color) + 1
const maxIndex = this.macroColors.length - 1
if (index > maxIndex) index = 0
const newColor = this.macroColors[index].value
this.updateMacroFromGroup(macro, 'color', newColor)
}
removeMacroFromGroup(macro: GuiStateMacrogroupMacros) {
this.$store.dispatch('gui/removeMacroFromMacrogroup', {
group: this.editGroupId,
macro: macro.name
})
}
getMacroDescription(macroname: string) {
const macro = this.allMacros.find((m: PrinterStateMacro) => m.name.toLowerCase() === macroname.toLowerCase())
return macro?.description ?? null
}
updateMacrogroupOption(option: string, newVal: boolean | string) {
this.$store.dispatch('gui/updateMacrogroup', {
group: this.editGroupId,
option: option,
value: newVal
})
}
@Debounce(250)
updateGroupOptionName(newVal: string) {
this.updateMacrogroupOption('name', newVal)
}
updateGroupOptionColor(newVal: string) {
this.updateMacrogroupOption('color', newVal)
}
@Debounce(250)
updateGroupOptionColorCustom(newVal: string) {
this.updateMacrogroupOption('colorCustom', this.clearColorObject(newVal))
}
updateGroupOptionShowInStandby(newVal: boolean) {
this.updateMacrogroupOption('showInStandby', newVal)
}
updateGroupOptionShowInPause(newVal: boolean) {
this.updateMacrogroupOption('showInPause', newVal)
}
updateGroupOptionShowInPrinting(newVal: boolean) {
this.updateMacrogroupOption('showInPrinting', newVal)
}
@Watch('boolFormEdit')
updatedBoolFormEdit(newVal: boolean) {
this.updateShowGeneral(!newVal)
}
cancelEditMacrogroup() {
this.boolFormEdit = false
this.$emit('scrollToTop')
}
}
</script>
@@ -0,0 +1,55 @@
<template>
<v-card-text>
<h3 class="text-h5 mt-6 mb-3">{{ $t('Settings.MacrosTab.Macros') }}</h3>
<template v-if="macros.length">
<div v-for="(macro, index) in macros" v-bind:key="index">
<v-divider class="my-2" v-if="index"></v-divider>
<settings-row :title="macro.name" :sub-title="macro.description" :dynamicSlotWidth="true">
<v-switch :input-value="getMacroStatus(macro.name)" @change="changeMacroStatus(macro.name)" hide-details class="mt-0"></v-switch>
</settings-row>
</div>
</template>
<template v-else>
<v-row>
<v-col>
<p class="mb-0 text-center font-italic">{{ $t('Settings.MacrosTab.NOMacros') }}</p>
</v-col>
</v-row>
</template>
</v-card-text>
</template>
<script lang="ts">
import {Component, Mixins} from 'vue-property-decorator'
import BaseMixin from '../mixins/base'
import SettingsRow from '@/components/settings/SettingsRow.vue'
@Component({
components: {SettingsRow}
})
export default class SettingsMacrosTabSimple extends Mixins(BaseMixin) {
get macros() {
return this.$store.getters['printer/getAllMacros'] ?? []
}
get hiddenMacros() {
return this.$store.state.gui.dashboard.hiddenMacros ?? []
}
getMacroStatus(name: string) {
return !this.hiddenMacros.includes(name.toUpperCase())
}
changeMacroStatus(name: string) {
const hiddenMacros = [...this.hiddenMacros]
if (this.hiddenMacros.includes(name.toUpperCase()))
hiddenMacros.splice(hiddenMacros.indexOf(name.toUpperCase()), 1)
else
hiddenMacros.push(name.toUpperCase())
this.$store.dispatch('gui/saveSetting', { name: 'dashboard.hiddenMacros', value: hiddenMacros })
}
}
</script>
+34 -2
View File
@@ -266,7 +266,8 @@
"Extrude": "Extrude"
},
"MacrosPanel": {
"Headline": "Macros"
"Headline": "Macros",
"Send": "send"
},
"FarmPrinterPanel": {
"WebcamOff": "Off",
@@ -560,7 +561,38 @@
},
"MacrosTab": {
"Macros": "Macros",
"NOMacros": "No macros found..."
"NOMacros": "No macros found...",
"General": "General",
"Management": "Management",
"Simple": "Simple",
"Expert": "Expert",
"NoGroups": "No group found...",
"Macrogroups": "Groups",
"CreateGroup": "Create Group",
"EditGroup": "Edit Group",
"CountMacros": "no Macros added | {count} Macro | {count} Macros",
"Name": "Name",
"Color": "Color",
"CustomColor": "Custom Color",
"Status": "Status",
"Primary": "primary",
"Secondary": "secondary",
"Success": "success",
"Warning": "warning",
"Error": "error",
"Custom": "custom",
"AddGroup": "add Group",
"GroupMacros": "Group Macros",
"AvailableMacros": "Available Macros",
"Add": "add",
"NoMacrosInGroup": "No macros in this group.",
"NoAvailableMacros": "No available macros.",
"UnknownGroup": "Unknown Group",
"ChangeMacroColor": "Change the color of the button.",
"ShowInStateStandby": "Show/hide if printer is standby.",
"ShowInStatePaused": "Show/hide if printer is paused.",
"ShowInStatePrinting": "Show/hide if printer is printing.",
"DeleteMacroFromGroup": "Delete macro from group."
},
"ControlTab": {
"Control": "Control",
+1 -1
View File
@@ -6,7 +6,7 @@
}
.gcode-command-field {
font-family: monospace;
font-family: 'Roboto Mono', monospace;
}
</style>
+56 -18
View File
@@ -4,7 +4,7 @@
<v-col>
<status-panel></status-panel>
<template v-for="component in mobileLayout">
<component v-bind:is="component.name+'-panel'" :key="'dashboard-mobileLayout-'+component.name"></component>
<component v-bind:is="extractPanelName(component.name)" :panel-id="extractPanelId(component.name)" :key="'dashboard-mobileLayout-'+component.name"></component>
</template>
</v-col>
</v-row>
@@ -12,12 +12,12 @@
<v-col class="col-6">
<status-panel></status-panel>
<template v-for="component in tabletLayout1">
<component v-bind:is="component.name+'-panel'" :key="'dashboard-tabletLayout1-'+component.name"></component>
<component v-bind:is="extractPanelName(component.name)" :panel-id="extractPanelId(component.name)" :key="'dashboard-tabletLayout1-'+component.name"></component>
</template>
</v-col>
<v-col class="col-6">
<template v-for="component in tabletLayout2">
<component v-bind:is="component.name+'-panel'" :key="'dashboard-tabletLayout2-'+component.name"></component>
<component v-bind:is="extractPanelName(component.name)" :panel-id="extractPanelId(component.name)" :key="'dashboard-tabletLayout2-'+component.name"></component>
</template>
</v-col>
</v-row>
@@ -25,12 +25,12 @@
<v-col class="col-5">
<status-panel></status-panel>
<template v-for="component in desktopLayout1">
<component v-bind:is="component.name+'-panel'" :key="'dashboard-desktopLayout1-'+component.name"></component>
<component v-bind:is="extractPanelName(component.name)" :panel-id="extractPanelId(component.name)" :key="'dashboard-desktopLayout1-'+component.name"></component>
</template>
</v-col>
<v-col class="col-7">
<template v-for="component in desktopLayout2">
<component v-bind:is="component.name+'-panel'" :key="'dashboard-desktopLayout2-'+component.name"></component>
<component v-bind:is="extractPanelName(component.name)" :panel-id="extractPanelId(component.name)" :key="'dashboard-desktopLayout2-'+component.name"></component>
</template>
</v-col>
</v-row>
@@ -38,17 +38,17 @@
<v-col class="col-3">
<status-panel></status-panel>
<template v-for="component in widescreenLayout1">
<component v-bind:is="component.name+'-panel'" :key="'dashboard-desktopLayout1-'+component.name"></component>
<component v-bind:is="extractPanelName(component.name)" :panel-id="extractPanelId(component.name)" :key="'dashboard-desktopLayout1-'+component.name"></component>
</template>
</v-col>
<v-col class="col-5">
<template v-for="component in widescreenLayout2">
<component v-bind:is="component.name+'-panel'" :key="'dashboard-desktopLayout2-'+component.name"></component>
<component v-bind:is="extractPanelName(component.name)" :panel-id="extractPanelId(component.name)" :key="'dashboard-desktopLayout2-'+component.name"></component>
</template>
</v-col>
<v-col class="col-4">
<template v-for="component in widescreenLayout3">
<component v-bind:is="component.name+'-panel'" :key="'dashboard-desktopLayout3-'+component.name"></component>
<component v-bind:is="extractPanelName(component.name)" :panel-id="extractPanelId(component.name)" :key="'dashboard-desktopLayout3-'+component.name"></component>
</template>
</v-col>
</v-row>
@@ -59,7 +59,6 @@
import Component from 'vue-class-component'
import {Mixins} from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import MinSettingsPanel from '@/components/panels/MinSettingsPanel.vue'
import KlippyStatePanel from '@/components/panels/KlippyStatePanel.vue'
import MoonrakerStatePanel from '@/components/panels/MoonrakerStatePanel.vue'
@@ -69,9 +68,11 @@ import WebcamPanel from '@/components/panels/WebcamPanel.vue'
import ZoffsetPanel from '@/components/panels/ZoffsetPanel.vue'
import ControlPanel from '@/components/panels/ControlPanel.vue'
import MacrosPanel from '@/components/panels/MacrosPanel.vue'
import MacrogroupPanel from '@/components/panels/MacrogroupPanel.vue'
import MiscellaneousPanel from '@/components/panels/MiscellaneousPanel.vue'
import MiniconsolePanel from '@/components/panels/MiniconsolePanel.vue'
import PrintsettingsPanel from '@/components/panels/PrintsettingsPanel.vue'
import DashboardMixin from '@/components/mixins/dashboard'
@Component({
components: {
@@ -80,6 +81,7 @@ import PrintsettingsPanel from '@/components/panels/PrintsettingsPanel.vue'
MiscellaneousPanel,
ControlPanel,
MacrosPanel,
MacrogroupPanel,
ZoffsetPanel,
WebcamPanel,
ToolsPanel,
@@ -89,37 +91,73 @@ import PrintsettingsPanel from '@/components/panels/PrintsettingsPanel.vue'
MinSettingsPanel
}
})
export default class PageDashboard extends Mixins(BaseMixin) {
export default class PageDashboard extends Mixins(DashboardMixin) {
get mobileLayout() {
return this.$store.state.gui.dashboard.mobileLayout.filter((element: any) => element.visable) ?? []
let panels = this.$store.getters['gui/getPanels']('mobileLayout')
panels = panels.concat(this.missingPanelsMobile)
panels = panels.filter((element: any) => element.visable)
return panels
}
get tabletLayout1() {
return this.$store.state.gui.dashboard.tabletLayout1.filter((element: any) => element.visable) ?? []
let panels = this.$store.getters['gui/getPanels']('tabletLayout1')
panels = panels.concat(this.missingPanelsTablet)
panels = panels.filter((element: any) => element.visable)
return panels
}
get tabletLayout2() {
return this.$store.state.gui.dashboard.tabletLayout2.filter((element: any) => element.visable) ?? []
let panels = this.$store.getters['gui/getPanels']('tabletLayout2')
panels = panels.filter((element: any) => element.visable)
return panels
}
get desktopLayout1() {
return this.$store.state.gui.dashboard.desktopLayout1.filter((element: any) => element.visable) ?? []
let panels = this.$store.getters['gui/getPanels']('desktopLayout1')
panels = panels.concat(this.missingPanelsDesktop)
panels = panels.filter((element: any) => element.visable)
return panels
}
get desktopLayout2() {
return this.$store.state.gui.dashboard.desktopLayout2.filter((element: any) => element.visable) ?? []
let panels = this.$store.getters['gui/getPanels']('desktopLayout2')
panels = panels.filter((element: any) => element.visable)
return panels
}
get widescreenLayout1() {
return this.$store.state.gui.dashboard.widescreenLayout1.filter((element: any) => element.visable) ?? []
let panels = this.$store.getters['gui/getPanels']('widescreenLayout1')
panels = panels.concat(this.missingPanelsWidescreen)
panels = panels.filter((element: any) => element.visable)
return panels
}
get widescreenLayout2() {
return this.$store.state.gui.dashboard.widescreenLayout2.filter((element: any) => element.visable) ?? []
let panels = this.$store.getters['gui/getPanels']('widescreenLayout2')
panels = panels.filter((element: any) => element.visable)
return panels
}
get widescreenLayout3() {
return this.$store.state.gui.dashboard.widescreenLayout3.filter((element: any) => element.visable) ?? []
let panels = this.$store.getters['gui/getPanels']('widescreenLayout3')
panels = panels.filter((element: any) => element.visable)
return panels
}
extractPanelName(name: string) {
return name.split('_')[0]+'-panel'
}
extractPanelId(name: string) {
return name.split('_')[1] ?? null
}
}
</script>
+2 -2
View File
@@ -386,8 +386,8 @@ export default class PageHeightmap extends Mixins(BaseMixin) {
}
get rangeY(): number[] {
const axis_minimum = this.$store.state.printer.toolhead?.axis_minimum
const axis_maximum = this.$store.state.printer.toolhead?.axis_maximum
const axis_minimum = this.$store.state.printer.toolhead?.axis_minimum ?? [0,0]
const axis_maximum = this.$store.state.printer.toolhead?.axis_maximum ?? [0,0]
return [axis_minimum[1] ?? 0, axis_maximum[1] ?? 0]
}
+46
View File
@@ -1,5 +1,6 @@
import { ServerStateEvent } from '@/store/server/types'
import {FileStateFile} from '@/store/files/types'
import {PrinterStateMacroParams} from '@/store/printer/types'
export const findDirectory = (folder: FileStateFile[], dirArray: string[]): FileStateFile[] | null => {
if (folder !== undefined && folder !== null && dirArray.length) {
@@ -35,6 +36,8 @@ export const capitalize = (str: string): string => {
}
export const convertPanelnameToIcon = (name: string): string => {
if (name.startsWith('macrogroup_')) return 'mdi-code-tags'
switch (name) {
case 'webcam': return 'mdi-webcam'
case 'zoffset': return 'mdi-arrow-collapse-vertical'
@@ -164,3 +167,46 @@ export function formatTime(date: Date): string {
return hours+':'+minutes+':'+seconds
}
export function getMacroParams(macro: { gcode: string }): PrinterStateMacroParams {
const paramRegex = /{%?.*?params\.([A-Za-z_0-9]+)(?:\|(int|string|double))?(?:\|default\('?(.*?)'?\))?(?:\|(int|string))?.*?%?}/
let params = paramRegex.exec(macro.gcode)
let currentMatch = macro.gcode
let ret: PrinterStateMacroParams = null
while(params) {
if (ret === null) {
ret = {}
}
const name = params[1]
const t: 'int' | 'string' | 'double' | null = (params[2] ?? params[4] ?? null) as 'int' | 'string' | 'double' | null
const def = params[3] ?? null
ret[`${name}`] = {
type: t,
default: def
}
currentMatch = currentMatch.replace(params[0], '')
params = paramRegex.exec(currentMatch)
}
const paramInRegex = /{%?.*?if.*?'([A-Za-z_0-9]+)' (?:not )?in params.*?%?}/
params = paramInRegex.exec(macro.gcode)
currentMatch = macro.gcode
while(params) {
if (ret === null) {
ret = {}
}
const name = params[1]
if (!(`${name}` in ret)) {
ret[`${name}`] = {
type: null,
default: null
}
}
currentMatch = currentMatch.replace(params[0], '')
params = paramInRegex.exec(currentMatch)
}
return ret
}
+82
View File
@@ -3,6 +3,7 @@ import {ActionTree} from 'vuex'
import {GuiState} from '@/store/gui/types'
import {RootState} from '@/store/types'
import { getDefaultState } from './index'
import {v4 as uuid} from 'uuid'
export const actions: ActionTree<GuiState, RootState> = {
reset({ commit }) {
@@ -225,5 +226,86 @@ export const actions: ActionTree<GuiState, RootState> = {
name: 'dashboard.'+name,
value: newVal
})
},
async storeMarcogroup({ commit, dispatch, state }, payload) {
payload.id = uuid()
await commit('storeMacrogroup', payload)
dispatch('updateSettings', {
keyName: 'dashboard.macrogroups',
newVal: state.dashboard.macrogroups
})
return payload.id
},
updateMacrogroup({ commit, dispatch, state }, payload) {
if (payload.group) {
commit('updateMacrogroup', payload)
dispatch('updateSettings', {
keyName: 'dashboard.macrogroups',
newVal: state.dashboard.macrogroups
})
}
},
destroyMacrogroup({ commit, dispatch, state }, payload) {
commit('destroyMacrogroup', payload)
dispatch('updateSettings', {
keyName: 'dashboard.macrogroups',
newVal: state.dashboard.macrogroups
})
const layouts = ['mobileLayout', 'tabletLayout1', 'tabletLayout2', 'desktopLayout1', 'desktopLayout2',
'widescreenLayout1', 'widescreenLayout2', 'widescreenLayout3']
layouts.forEach((layoutname: string) => {
const layoutArray = [...state.dashboard[layoutname]]
const index = layoutArray.findIndex((layoutPos: any) => layoutPos.name === 'macrogroup_'+payload)
if (index !== -1) {
commit('deleteFromDashboardLayout', { layoutname, index })
dispatch('updateSettings', {
keyName: 'dashboard.'+layoutname,
newVal: state.dashboard[layoutname]
})
}
})
},
addMacroToMacrogroup({ commit, dispatch, state }, payload) {
if (payload.group) {
commit('addMacroToMacrogroup', payload)
dispatch('updateSettings', {
keyName: 'dashboard.macrogroups',
newVal: state.dashboard.macrogroups
})
}
},
updateMacroFromMacrogroup({ commit, dispatch, state }, payload) {
if (payload.group) {
commit('updateMacroFromMacrogroup', payload)
dispatch('updateSettings', {
keyName: 'dashboard.macrogroups',
newVal: state.dashboard.macrogroups
})
}
},
removeMacroFromMacrogroup({ commit, dispatch, state }, payload) {
if (payload.group) {
commit('removeMacroFromMacrogroup', payload)
dispatch('updateSettings', {
keyName: 'dashboard.macrogroups',
newVal: state.dashboard.macrogroups
})
}
}
}
+29 -1
View File
@@ -1,6 +1,6 @@
import {caseInsensitiveSort} from '@/plugins/helpers'
import {GetterTree} from 'vuex'
import {GuiState, GuiStateConsoleFilter, GuiStatePreset} from '@/store/gui/types'
import {GuiState, GuiStateConsoleFilter, GuiStateMacrogroup, GuiStatePreset} from '@/store/gui/types'
// eslint-disable-next-line
export const getters: GetterTree<GuiState, any> = {
@@ -106,5 +106,33 @@ export const getters: GetterTree<GuiState, any> = {
getPanelExpand: (state) => (name: string) => {
return !state.dashboard.nonExpandPanels?.includes(name) ?? true
},
getAllMacroGroups: (state) => {
return caseInsensitiveSort(state.dashboard.macrogroups ?? [], 'name')
},
getMacroGroup: (state) => (id: string) => {
return state.dashboard.macrogroups.find((group: GuiStateMacrogroup) => group.id === id)
},
getPanels: (state, getters) => (viewport: string) => {
let panels = state.dashboard[viewport]?.filter((element: any) => element !== null) ?? []
if (state.dashboard.macroManagement === 'simple') panels = panels.filter((element: any) => !element.name.startsWith('macrogroup_'))
else {
panels = panels.filter((element: any) => element.name !== 'macros')
const macrogroups = getters['getAllMacroGroups']
if (macrogroups.length) {
panels = panels.filter((element: any) => {
if (!element.name.startsWith('macrogroup_')) return true
const macrogroupId = element.name.substr(11)
return (macrogroups.findIndex((macrogroup: GuiStateMacrogroup) => macrogroup.id === macrogroupId) !== -1)
})
}
}
return panels
}
}
+2
View File
@@ -24,7 +24,9 @@ export const getDefaultState = (): GuiState => {
dashboard: {
boolTempchart: true,
boolBigThumbnail: true,
macroManagement: 'simple',
hiddenMacros: [],
macrogroups: [],
hiddenTempChart: [],
control: {
style: 'bars',
+75 -1
View File
@@ -1,7 +1,8 @@
import Vue from 'vue'
import { getDefaultState } from './index'
import {MutationTree} from 'vuex'
import {GuiState} from '@/store/gui/types'
import {GuiState, GuiStateMacrogroup, GuiStateMacrogroupMacros} from '@/store/gui/types'
import { v4 as uuid } from 'uuid'
export const mutations: MutationTree<GuiState> = {
reset(state) {
@@ -162,5 +163,78 @@ export const mutations: MutationTree<GuiState> = {
removeClosePanel(state, payload) {
const index = state.dashboard.nonExpandPanels.indexOf(payload.name)
if (index > -1) state.dashboard.nonExpandPanels.splice(index, 1)
},
storeMacrogroup(state, payload) {
state.dashboard.macrogroups.push(payload)
},
destroyMacrogroup(state, payload) {
const index = state.dashboard.macrogroups.findIndex((group: GuiStateMacrogroup) => group.id === payload)
if (index !== -1) state.dashboard.macrogroups.splice(index, 1)
},
addMacroToMacrogroup(state, payload) {
const index = state.dashboard.macrogroups.findIndex((group: GuiStateMacrogroup) => group.id === payload.group)
if (index !== -1) {
const macros = [...state.dashboard.macrogroups[index]?.macros ?? []]
const newMacro: GuiStateMacrogroupMacros = {
pos: 1,
name: payload.macro,
color: 'group',
showInStandby: true,
showInPrinting: true,
showInPause: true
}
if (macros.length) newMacro.pos = Math.max(...macros.map((m: GuiStateMacrogroupMacros) => m.pos)) + 1
macros.push(newMacro)
Vue.set(state.dashboard.macrogroups[index], 'macros', macros)
}
},
updateMacroFromMacrogroup(state, payload) {
const index = state.dashboard.macrogroups.findIndex((group: GuiStateMacrogroup) => group.id === payload.group)
if (index !== -1) {
const macros = [...state.dashboard.macrogroups[index]?.macros ?? []]
const updateMacroIndex = macros.findIndex((m: GuiStateMacrogroupMacros) => m.name === payload.macro)
if (updateMacroIndex !== -1) {
macros[updateMacroIndex][payload.option] = payload.value
Vue.set(state.dashboard.macrogroups[index], 'macros', macros)
}
}
},
removeMacroFromMacrogroup(state, payload) {
const index = state.dashboard.macrogroups.findIndex((group: GuiStateMacrogroup) => group.id === payload.group)
if (index !== -1) {
const macros = [...state.dashboard.macrogroups[index]?.macros ?? []]
const deletedMacroIndex = macros.findIndex((m: GuiStateMacrogroupMacros) => m.name === payload.macro)
if (deletedMacroIndex !== -1) {
const oldPos = macros[deletedMacroIndex].pos
macros.splice(deletedMacroIndex, 1)
macros.filter((macro: GuiStateMacrogroupMacros) => macro.pos > oldPos).forEach((macro: GuiStateMacrogroupMacros) => {
macro.pos = macro.pos - 1
})
}
Vue.set(state.dashboard.macrogroups[index], 'macros', macros)
}
},
updateMacrogroup(state, payload) {
const index = state.dashboard.macrogroups.findIndex((group: GuiStateMacrogroup) => group.id === payload.group)
if (index !== -1 && payload.option in state.dashboard.macrogroups[index]) {
Vue.set(state.dashboard.macrogroups[index], payload.option, payload.value)
}
},
deleteFromDashboardLayout(state, payload) {
const layoutArray = [...state.dashboard[payload.layoutname]]
layoutArray.splice(payload.index, 1)
Vue.set(state.dashboard, payload.layoutname, layoutArray)
}
}
+20
View File
@@ -38,4 +38,24 @@ export interface GuiStateConsoleFilter {
index?: string
name: string
regex: string
}
export interface GuiStateMacrogroup {
id: string | null
name: string
color: 'primary' | 'secondary' | 'success' | 'warning' | 'error' | 'custom'
colorCustom?: string
showInStandby: boolean
showInPrinting: boolean
showInPause: boolean
macros?: GuiStateMacrogroupMacros[]
}
export interface GuiStateMacrogroupMacros {
pos: number
name: string
color: 'group' | 'primary' | 'secondary' | 'success' | 'warning' | 'error'
showInStandby: boolean
showInPrinting: boolean
showInPause: boolean
}
+21 -4
View File
@@ -5,9 +5,9 @@ import {
PrinterStateFan, PrinterStateFilamentSensors,
PrinterStateHeater, PrinterStateTemperatureFan,
PrinterStateMiscellaneous,
PrinterStateSensor, PrinterStateMacro
PrinterStateSensor, PrinterStateMacro,
} from '@/store/printer/types'
import {caseInsensitiveSort, formatFrequency} from '@/plugins/helpers'
import {caseInsensitiveSort, formatFrequency, getMacroParams} from '@/plugins/helpers'
import {RootState} from '@/store/types'
export const getters: GetterTree<PrinterState, RootState> = {
@@ -64,7 +64,8 @@ export const getters: GetterTree<PrinterState, RootState> = {
array.push({
'name': prop.replace('gcode_macro ', ''),
'description': state.configfile.config[prop].description ?? null,
'prop': state.configfile.config[prop]
'prop': state.configfile.config[prop],
'params': getMacroParams(state.configfile.config[prop])
})
}
})
@@ -371,7 +372,8 @@ export const getters: GetterTree<PrinterState, RootState> = {
array.push({
'name': prop.replace('gcode_macro ', ''),
'description': state.configfile.config[prop].description ?? null,
'prop': state.configfile.config[prop]
'prop': state.configfile.config[prop],
'params': getMacroParams(state.configfile.config[prop])
})
}
})
@@ -379,6 +381,21 @@ export const getters: GetterTree<PrinterState, RootState> = {
return caseInsensitiveSort(array, 'name')
},
getMacro: (state) => (name: string) => {
if ('gcode_macro '+name in state.configfile.config) {
const config = state.configfile.config['gcode_macro '+name]
return {
name,
description: config.description ?? null,
prop: config,
params: getMacroParams(config)
}
}
return null
},
getFilamentSensors: state => {
const sensorObjectNames = ['filament_switch_sensor', 'filament_motion_sensor']
const sensors: PrinterStateFilamentSensors[] = []
+11 -1
View File
@@ -129,13 +129,23 @@ export interface PrinterStateBedMesh {
is_active: boolean
}
export interface PrinterStateMacroParam {
type: 'int' | 'double' | 'string' | null,
default: string | null
}
export type PrinterStateMacroParams = {
[key: string]: PrinterStateMacroParam
} | null
export interface PrinterStateMacro {
name: string
description: string | null
prop: {
// eslint-disable-next-line
[key: string]: any
}
},
params: PrinterStateMacroParams
}
export interface PrinterStateKlipperConfig {
+12 -1
View File
@@ -79,4 +79,15 @@ export const allowedMetadata = [
'thumbnails',
]
export const maxEventHistory = 500
export const maxEventHistory = 500
export const allDashboardPanels = [
'control',
'macros',
'miniconsole',
'miscellaneous',
'printsettings',
'tools',
'webcam',
'zoffset',
]