From 3bc7cfafb404badf76ae3b4f82ba0889e73bb64f Mon Sep 17 00:00:00 2001 From: AleenaThomas_gh Date: Fri, 14 Jul 2023 10:11:35 +0200 Subject: [PATCH 1/3] Displaying alert on create dry run modal and stop dry run --- .../[project_id]/[dry_run]/+page.svelte | 25 ++++++---- .../[dry_run]/modal-submit-new-dry-run.svelte | 50 +++++++++++-------- .../[dry_run]/symbol-for-action.svelte | 17 ++++++- 3 files changed, 59 insertions(+), 33 deletions(-) diff --git a/frontend-dev/src/routes/projects/[project_id]/[dry_run]/+page.svelte b/frontend-dev/src/routes/projects/[project_id]/[dry_run]/+page.svelte index 85309c5c..aae59209 100644 --- a/frontend-dev/src/routes/projects/[project_id]/[dry_run]/+page.svelte +++ b/frontend-dev/src/routes/projects/[project_id]/[dry_run]/+page.svelte @@ -15,7 +15,6 @@ // let { project_id } = params; // } - const getProjectDetails = async (): Promise => { const variables = {projectId: get(clickedProjectId)}; const response: { project: Project } = await get(graphQLClient).request(allDryRunsQuery, variables); @@ -34,14 +33,7 @@ reactiveProjectDetails = undefined; }); - const modal: ModalSettings = { - type: 'component', - component: { ref: ModalSubmitNewDryRun }, - title: 'Add new dry run', - body: 'Enter details of dry run', - }; - - let checkboxes: Record = {}; + let checkboxes: Record = {}; function transformSecondsToHoursMinutesSeconds(seconds_string: string) { let seconds = Number(seconds_string); @@ -71,6 +63,15 @@ let responseProjectDetails: { project: Project } = await get(graphQLClient).request(allDryRunsQuery, { projectId: $clickedProjectId }); $selectedProject = responseProjectDetails.project; } + async function onCreateSelected() { + const modal: ModalSettings = { + type: 'component', + component: { ref: ModalSubmitNewDryRun }, + title: 'Add new dry run', + body: 'Enter details of dry run', + }; + modalStore.trigger(modal); + } // TODO: fill all possible phase values function getDryRunAction(status:string):string { @@ -100,7 +101,7 @@

dry runs: {reactiveProjectDetails?.dryRuns.length}

-
- +{#if $modalStore[0]} + +{/if} diff --git a/frontend-dev/src/routes/projects/[project_id]/[dry_run]/modal-submit-new-dry-run.svelte b/frontend-dev/src/routes/projects/[project_id]/[dry_run]/modal-submit-new-dry-run.svelte index 7d2d1821..674fb373 100644 --- a/frontend-dev/src/routes/projects/[project_id]/[dry_run]/modal-submit-new-dry-run.svelte +++ b/frontend-dev/src/routes/projects/[project_id]/[dry_run]/modal-submit-new-dry-run.svelte @@ -1,6 +1,6 @@ -{#if $modalStore[0]} +{#if !hideModal} {/if} - \ No newline at end of file +{#if alertModal} + +{/if} \ No newline at end of file diff --git a/frontend-dev/src/routes/projects/[project_id]/[dry_run]/symbol-for-action.svelte b/frontend-dev/src/routes/projects/[project_id]/[dry_run]/symbol-for-action.svelte index 75dfc2ab..ea69df6f 100644 --- a/frontend-dev/src/routes/projects/[project_id]/[dry_run]/symbol-for-action.svelte +++ b/frontend-dev/src/routes/projects/[project_id]/[dry_run]/symbol-for-action.svelte @@ -2,11 +2,26 @@ import { HelpCircleIcon, PlayCircleIcon, StopCircleIcon, PlusIcon } from 'svelte-feather-icons'; import stopDryRunMutation from '../../../../queries/stop_dry_run.js'; import { graphQLClient } from '../../../../stores/stores.js'; + import { modalStore, type ModalSettings } from '@skeletonlabs/skeleton'; export let action: string, dryRunId: string; async function stopRun() { - const response = await $graphQLClient.request(stopDryRunMutation, { dryRunId: dryRunId, terminate: false }); + try { + await $graphQLClient.request(stopDryRunMutation, { dryRunId: dryRunId, terminate: false }); + const createDryRunErrorModal: ModalSettings = { + type: 'alert', + title: 'Stopping dry run..', + body: `ID: ${dryRunId}`, + }; + modalStore.trigger(createDryRunErrorModal); + await new Promise((resolve) => setTimeout(resolve, 1000)); + modalStore.close(); + modalStore.clear(); + } catch { + // TODO: handle error + console.log('Error! to be handled') + } } From 73c51b39c6d8f0b82be9a365aade16565310a5e7 Mon Sep 17 00:00:00 2001 From: AleenaThomas_gh Date: Fri, 14 Jul 2023 10:57:56 +0200 Subject: [PATCH 2/3] Create project with YAML or JSON --- .../projects/modal-submit-new-project.svelte | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend-dev/src/routes/projects/modal-submit-new-project.svelte b/frontend-dev/src/routes/projects/modal-submit-new-project.svelte index 1f85a417..811ae3ef 100644 --- a/frontend-dev/src/routes/projects/modal-submit-new-project.svelte +++ b/frontend-dev/src/routes/projects/modal-submit-new-project.svelte @@ -7,6 +7,7 @@ import createWorkflowTemplateMutation from '../../queries/create_workflow_template.js' import type { Project } from '../../types.js'; import { modalStore } from '@skeletonlabs/skeleton'; + import yaml from 'js-yaml'; export let parent: any; @@ -22,9 +23,16 @@ const responseCreateProject : {createProject: Project}= await get(graphQLClient).request(createProjectMutation, variables1); if (formData.template != '') { + let template:JSON ; + // check if template is in JSON/YAML format, if YAML convert to JSON + try { + template = JSON.parse(formData.template); + } catch { + template = yaml.load(formData.template); + } const variables2 = { input: { - argoWorkflowTemplate: JSON.parse(formData.template), + argoWorkflowTemplate: template, name: formData.name, projectId: responseCreateProject.createProject.id, } @@ -49,10 +57,10 @@ -