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

+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
}