dialog to switch between rotary modes
This commit is contained in:
@@ -321,6 +321,13 @@ module.exports = new Vue({
|
|||||||
return semverLt(this.config.full_version, this.latestVersion);
|
return semverLt(this.config.full_version, this.latestVersion);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showSwitchRotaryModeDialog: function(){
|
||||||
|
SvelteComponents.showDialog("SwitchRotary", {
|
||||||
|
isActive: this.is_rotary_active,
|
||||||
|
switchMode: () => this.toggle_rotary()
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
toggle_rotary: async function() {
|
toggle_rotary: async function() {
|
||||||
let motor = this.config.motors[2];
|
let motor = this.config.motors[2];
|
||||||
if(motor['axis'] == 'A'){
|
if(motor['axis'] == 'A'){
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ html(lang="en")
|
|||||||
.whitespace
|
.whitespace
|
||||||
|
|
||||||
div
|
div
|
||||||
button.rotary-button(:disabled="!enable_rotary", :class="is_rotary_active && 'active'", @click="toggle_rotary")
|
button.rotary-button(:disabled="!enable_rotary", :class="is_rotary_active && 'active'", @click="showSwitchRotaryModeDialog")
|
||||||
img(src="/images/rotary.svg", alt="rotary", :style="is_rotary_active ? 'width:90%;' : 'width:85%;'")
|
img(src="/images/rotary.svg", alt="rotary", :style="is_rotary_active ? 'width:90%;' : 'width:85%;'")
|
||||||
|
|
||||||
.video(title="Plug camera into USB.\n" +
|
.video(title="Plug camera into USB.\n" +
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
import MoveToZeroDialog from "./MoveToZeroDialog.svelte";
|
import MoveToZeroDialog from "./MoveToZeroDialog.svelte";
|
||||||
import ShutdownDialog from "./ShutdownDialog.svelte";
|
import ShutdownDialog from "./ShutdownDialog.svelte";
|
||||||
import MessageDialog from "./MessageDialog.svelte";
|
import MessageDialog from "./MessageDialog.svelte";
|
||||||
|
import SwitchRotaryDialog from "./SwitchRotaryDialog.svelte";
|
||||||
|
|
||||||
const HomeMachineDialogProps = writable<HomeMachineDialogPropsType>();
|
const HomeMachineDialogProps = writable<HomeMachineDialogPropsType>();
|
||||||
type HomeMachineDialogPropsType = {
|
type HomeMachineDialogPropsType = {
|
||||||
@@ -72,6 +73,13 @@
|
|||||||
noaction: boolean;
|
noaction: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const SwitchRotaryDialogProps = writable<SwitchRotaryDialogPropsType>();
|
||||||
|
type SwitchRotaryDialogPropsType = {
|
||||||
|
open: boolean;
|
||||||
|
isActive: boolean;
|
||||||
|
switchMode: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
export function showDialog(
|
export function showDialog(
|
||||||
dialog: "HomeMachine",
|
dialog: "HomeMachine",
|
||||||
props: Omit<HomeMachineDialogPropsType, "open">
|
props: Omit<HomeMachineDialogPropsType, "open">
|
||||||
@@ -122,6 +130,11 @@
|
|||||||
props: Omit<MessageDialogPropsType, "open">
|
props: Omit<MessageDialogPropsType, "open">
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export function showDialog(
|
||||||
|
dialog: "SwitchRotary",
|
||||||
|
props: Omit<SwitchRotaryDialogPropsType, "open">
|
||||||
|
);
|
||||||
|
|
||||||
export function showDialog(dialog: string, props: any) {
|
export function showDialog(dialog: string, props: any) {
|
||||||
switch (dialog) {
|
switch (dialog) {
|
||||||
case "HomeMachine":
|
case "HomeMachine":
|
||||||
@@ -163,6 +176,10 @@
|
|||||||
case "Message":
|
case "Message":
|
||||||
MessageDialogProps.set({ ...props, open: true });
|
MessageDialogProps.set({ ...props, open: true });
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "SwitchRotary":
|
||||||
|
MessageDialogProps.set({ ...props, open: true });
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unknown dialog '${dialog}'`);
|
throw new Error(`Unknown dialog '${dialog}'`);
|
||||||
@@ -242,3 +259,4 @@
|
|||||||
<MoveToZeroDialog {...$MoveToZeroDialogProps} />
|
<MoveToZeroDialog {...$MoveToZeroDialogProps} />
|
||||||
<ShutdownDialog {...$ShutdownDialogProps} />
|
<ShutdownDialog {...$ShutdownDialogProps} />
|
||||||
<MessageDialog {...$MessageDialogProps} />
|
<MessageDialog {...$MessageDialogProps} />
|
||||||
|
<SwitchRotaryDialog {...$SwitchRotaryDialogProps} />
|
||||||
|
|||||||
36
src/svelte-components/src/dialogs/SwitchRotaryDialog.svelte
Normal file
36
src/svelte-components/src/dialogs/SwitchRotaryDialog.svelte
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import Dialog, {
|
||||||
|
Title,
|
||||||
|
Content,
|
||||||
|
Actions,
|
||||||
|
InitialFocus,
|
||||||
|
} from "@smui/dialog";
|
||||||
|
import Button, { Label } from "@smui/button";
|
||||||
|
|
||||||
|
export let open: boolean;
|
||||||
|
export let isActive: boolean;
|
||||||
|
export let switchMode: () => any;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Dialog
|
||||||
|
bind:open
|
||||||
|
scrimClickAction=""
|
||||||
|
aria-labelledby="switch-rotary-dialog-title"
|
||||||
|
aria-describedby="switch-rotary-dialog-content"
|
||||||
|
>
|
||||||
|
<Title id="switch-rotary-dialog-title">Switch Rotary Mode</Title>
|
||||||
|
|
||||||
|
<Content id="switch-rotary-dialog-content">
|
||||||
|
{isActive ? "Enable Rotary Mode?" : "Disable Rotary Mode?"}
|
||||||
|
</Content>
|
||||||
|
|
||||||
|
<Actions>
|
||||||
|
<Button>
|
||||||
|
<Label>No</Label>
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button defaultAction use={[InitialFocus]} on:click={switchMode}>
|
||||||
|
<Label>Yes</Label>
|
||||||
|
</Button>
|
||||||
|
</Actions>
|
||||||
|
</Dialog>
|
||||||
Reference in New Issue
Block a user