Skip to content

Commit

Permalink
Merge pull request #43 from simonsobs/dev
Browse files Browse the repository at this point in the history
Add "Load Example Script" in the dev mode
  • Loading branch information
TaiSakuma authored May 9, 2024
2 parents 9f1a757 + 3ea395c commit 8462f4f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/components/main/trace-frame/script-editor/Actions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,30 @@
</template>
Load From Scheduler
</v-list-item>
<v-list-item v-if="devMode" @click="emit('loadExample')">
<template v-slot:prepend>
<v-icon> mdi-code-tags </v-icon>
</template>
Load Example Script
</v-list-item>
</v-list>
</v-menu>
</v-card-actions>
</template>

<script setup lang="ts">
import { useDevTool } from "@/utils/dev/enabled";
interface Props {
editing: boolean;
}
const { isDevToolEnabled: devMode } = useDevTool();
type Emits = {
reset: [];
save: [];
load: [];
loadExample: [];
};
defineProps<Props>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@reset="reset"
@save="save"
@load="load"
@load-example="loadExample"
>
</actions>
</v-card>
Expand All @@ -22,7 +23,7 @@ import { useMonacoEditor } from "@/utils/monaco-editor";
import { useSource } from "./source";
import Actions from "./Actions.vue";
const editor = ref<HTMLElement>();
const { source, modified, save, reset, load } = await useSource();
const { source, modified, save, reset, load, loadExample } = await useSource();
useMonacoEditor({ element: editor, source, mode: "editor" });
</script>

Expand Down
11 changes: 10 additions & 1 deletion src/components/main/trace-frame/script-editor/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
useSourceQuery,
useResetMutation,
useLoadScriptMutation,
useLoadExampleScriptMutation,
} from "@/graphql/codegen/generated";
import { useStore } from "@/plugins/pinia/stores/main";

Expand Down Expand Up @@ -43,7 +44,15 @@ export async function useSource() {
query.executeQuery();
}

const { executeMutation: executeMutationLoadExample } =
useLoadExampleScriptMutation();

async function loadExample() {
await executeMutationLoadExample({});
query.executeQuery();
}

await query;

return { source, modified, save, reset, load };
return { source, modified, save, reset, load, loadExample };
}
15 changes: 15 additions & 0 deletions src/graphql/codegen/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type Mutation = {
exec: Scalars['Boolean']['output'];
interrupt: Scalars['Boolean']['output'];
kill: Scalars['Boolean']['output'];
loadExampleScript: Scalars['Boolean']['output'];
rdb: MutationRdb;
reset: Scalars['Boolean']['output'];
runAndContinue: Scalars['Boolean']['output'];
Expand Down Expand Up @@ -442,6 +443,11 @@ export type KillMutationVariables = Exact<{ [key: string]: never; }>;

export type KillMutation = { __typename?: 'Mutation', kill: boolean };

export type LoadExampleScriptMutationVariables = Exact<{ [key: string]: never; }>;


export type LoadExampleScriptMutation = { __typename?: 'Mutation', loadExampleScript: boolean };

export type LoadScriptMutationVariables = Exact<{ [key: string]: never; }>;


Expand Down Expand Up @@ -669,6 +675,15 @@ export const KillDocument = gql`
export function useKillMutation() {
return Urql.useMutation<KillMutation, KillMutationVariables>(KillDocument);
};
export const LoadExampleScriptDocument = gql`
mutation LoadExampleScript {
loadExampleScript
}
`;

export function useLoadExampleScriptMutation() {
return Urql.useMutation<LoadExampleScriptMutation, LoadExampleScriptMutationVariables>(LoadExampleScriptDocument);
};
export const LoadScriptDocument = gql`
mutation LoadScript {
schedule {
Expand Down
3 changes: 3 additions & 0 deletions src/graphql/gql/mutations/LoadExampleScript.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mutation LoadExampleScript {
loadExampleScript
}

0 comments on commit 8462f4f

Please sign in to comment.