From 0cc55c6c3cf313ce097b1f61886b6ee94a2eac7f Mon Sep 17 00:00:00 2001 From: Tai Sakuma Date: Thu, 9 May 2024 13:05:10 -0400 Subject: [PATCH 1/2] Add GraphQL query LoadExampleScript --- src/graphql/codegen/generated.ts | 15 +++++++++++++++ src/graphql/gql/mutations/LoadExampleScript.gql | 3 +++ 2 files changed, 18 insertions(+) create mode 100644 src/graphql/gql/mutations/LoadExampleScript.gql diff --git a/src/graphql/codegen/generated.ts b/src/graphql/codegen/generated.ts index c787241..0bb8b7c 100644 --- a/src/graphql/codegen/generated.ts +++ b/src/graphql/codegen/generated.ts @@ -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']; @@ -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; }>; @@ -669,6 +675,15 @@ export const KillDocument = gql` export function useKillMutation() { return Urql.useMutation(KillDocument); }; +export const LoadExampleScriptDocument = gql` + mutation LoadExampleScript { + loadExampleScript +} + `; + +export function useLoadExampleScriptMutation() { + return Urql.useMutation(LoadExampleScriptDocument); +}; export const LoadScriptDocument = gql` mutation LoadScript { schedule { diff --git a/src/graphql/gql/mutations/LoadExampleScript.gql b/src/graphql/gql/mutations/LoadExampleScript.gql new file mode 100644 index 0000000..89ae454 --- /dev/null +++ b/src/graphql/gql/mutations/LoadExampleScript.gql @@ -0,0 +1,3 @@ +mutation LoadExampleScript { + loadExampleScript +} From 3ea395cbe004ef8abcecc4bc8c997b9f2989b21a Mon Sep 17 00:00:00 2001 From: Tai Sakuma Date: Thu, 9 May 2024 13:18:04 -0400 Subject: [PATCH 2/2] Add "Load Example Script" in the dev mode --- .../main/trace-frame/script-editor/Actions.vue | 10 ++++++++++ .../main/trace-frame/script-editor/ScriptEditorE.vue | 3 ++- .../main/trace-frame/script-editor/source.ts | 11 ++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/components/main/trace-frame/script-editor/Actions.vue b/src/components/main/trace-frame/script-editor/Actions.vue index 563e741..4d0acdb 100644 --- a/src/components/main/trace-frame/script-editor/Actions.vue +++ b/src/components/main/trace-frame/script-editor/Actions.vue @@ -27,20 +27,30 @@ Load From Scheduler + + + Load Example Script + diff --git a/src/components/main/trace-frame/script-editor/source.ts b/src/components/main/trace-frame/script-editor/source.ts index 0a034f3..83aa970 100644 --- a/src/components/main/trace-frame/script-editor/source.ts +++ b/src/components/main/trace-frame/script-editor/source.ts @@ -4,6 +4,7 @@ import { useSourceQuery, useResetMutation, useLoadScriptMutation, + useLoadExampleScriptMutation, } from "@/graphql/codegen/generated"; import { useStore } from "@/plugins/pinia/stores/main"; @@ -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 }; }