Rebuild the "toolpath message" dialog in Svelte.

This commit is contained in:
David Carley
2022-08-23 09:11:57 +00:00
parent dded59535f
commit ff7e99acf8
4 changed files with 43 additions and 22 deletions

View File

@@ -39,14 +39,6 @@ module.exports = {
jog_adjust: parseInt(cookie.get('jog-adjust', 2)), jog_adjust: parseInt(cookie.get('jog-adjust', 2)),
deleteGCode: false, deleteGCode: false,
tab: 'auto', tab: 'auto',
toolpath_msg: {
x: false,
y: false,
z: false,
a: false,
b: false,
c: false
},
ask_home: true, ask_home: true,
showGcodeMessage: false showGcodeMessage: false
} }
@@ -425,8 +417,8 @@ module.exports = {
SvelteComponents.showDialog("MoveToZero", { axes }); SvelteComponents.showDialog("MoveToZero", { axes });
}, },
show_toolpath_msg: function (axis) { showToolpathMessageDialog: function (axis) {
this.toolpath_msg[axis] = true; SvelteComponents.showDialog("ToolpathMessage", { msg: this[axis].toolmsg });
}, },
set_position: function (axis, position) { set_position: function (axis, position) {

View File

@@ -107,20 +107,10 @@ script#control-view-template(type="text/x-template")
td.state td.state
.fa(:class=`'fa-' + ${axis}.icon`) .fa(:class=`'fa-' + ${axis}.icon`)
| {{#{axis}.state}} | {{#{axis}.state}}
td.tstate(:class=`${axis}.tklass`, :title=`${axis}.toolmsg`, @click=`show_toolpath_msg('${axis}')`) td.tstate(:class=`${axis}.tklass`, :title=`${axis}.toolmsg`, @click=`showToolpathMessageDialog('${axis}')`)
.fa(:class=`'fa-' + ${axis}.ticon`) .fa(:class=`'fa-' + ${axis}.ticon`)
| {{#{axis}.tstate}} | {{#{axis}.tstate}}
message(:show.sync=`toolpath_msg['${axis}']`)
h3(slot="header") Tool path info {{'#{axis}' | upper}} axis
div(slot="body")
p {{#{axis}.toolmsg}}
div(slot="footer")
button.pure-button(@click=`toolpath_msg['${axis}'] = false`)
| OK
th.actions th.actions
button.pure-button(:disabled="!can_set_axis", button.pure-button(:disabled="!can_set_axis",
title=`Set {{'${axis}' | upper}} axis position.`, title=`Set {{'${axis}' | upper}} axis position.`,

View File

@@ -9,6 +9,7 @@
import SetAxisPositionDialog from "./SetAxisPositionDialog.svelte"; import SetAxisPositionDialog from "./SetAxisPositionDialog.svelte";
import MoveToZeroDialog from "./MoveToZeroDialog.svelte"; import MoveToZeroDialog from "./MoveToZeroDialog.svelte";
import ShutdownDialog from "./ShutdownDialog.svelte"; import ShutdownDialog from "./ShutdownDialog.svelte";
import ToolpathMessageDialog from "./ToolpathMessageDialog.svelte";
const HomeMachineDialogProps = writable<HomeMachineDialogPropsType>(); const HomeMachineDialogProps = writable<HomeMachineDialogPropsType>();
type HomeMachineDialogPropsType = { type HomeMachineDialogPropsType = {
@@ -62,6 +63,12 @@
open: boolean; open: boolean;
}; };
const ToolpathMessageDialogProps = writable<ToolpathMessageDialogPropsType>();
type ToolpathMessageDialogPropsType = {
open: boolean;
msg: string;
};
export function showDialog( export function showDialog(
dialog: "HomeMachine", dialog: "HomeMachine",
props: Omit<HomeMachineDialogPropsType, "open"> props: Omit<HomeMachineDialogPropsType, "open">
@@ -107,6 +114,11 @@
props: Omit<ShutdownDialogPropsType, "open"> props: Omit<ShutdownDialogPropsType, "open">
); );
export function showDialog(
dialog: "ToolpathMessage",
props: Omit<ToolpathMessageDialogPropsType, "open">
);
export function showDialog(dialog: string, props: any) { export function showDialog(dialog: string, props: any) {
switch (dialog) { switch (dialog) {
case "HomeMachine": case "HomeMachine":
@@ -145,6 +157,10 @@
ShutdownDialogProps.set({ ...props, open: true }); ShutdownDialogProps.set({ ...props, open: true });
break; break;
case "ToolpathMessage":
ToolpathMessageDialogProps.set({ ...props, open: true });
break;
default: default:
throw new Error(`Unknown dialog '${dialog}'`); throw new Error(`Unknown dialog '${dialog}'`);
} }
@@ -220,3 +236,4 @@
<SetAxisPositionDialog {...$SetAxisPositionDialogProps} /> <SetAxisPositionDialog {...$SetAxisPositionDialogProps} />
<MoveToZeroDialog {...$MoveToZeroDialogProps} /> <MoveToZeroDialog {...$MoveToZeroDialogProps} />
<ShutdownDialog {...$ShutdownDialogProps} /> <ShutdownDialog {...$ShutdownDialogProps} />
<ToolpathMessageDialog {...$ToolpathMessageDialogProps} />

View File

@@ -0,0 +1,22 @@
<script lang="ts">
import Dialog, { Title, Content, Actions, InitialFocus } from "@smui/dialog";
import Button, { Label } from "@smui/button";
export let open: boolean;
export let msg: string;
</script>
<Dialog
bind:open
scrimClickAction=""
aria-labelledby="toolpath-message-dialog-title"
aria-describedby="toolpath-message-dialog-content"
>
<Title id="toolpath-message-dialog-title">{msg || ""}</Title>
<Actions>
<Button defaultAction use={[InitialFocus]}>
<Label>OK</Label>
</Button>
</Actions>
</Dialog>