From 29a2eeb382b1d9359eb385fc21fc332c861ea2ff Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Thu, 22 Jun 2023 21:21:35 +0200 Subject: [PATCH] feat: add ability to copy job args --- frontend/src/lib/components/ArgInfo.svelte | 26 +-- .../src/lib/components/DisplayResult.svelte | 27 ++-- frontend/src/lib/components/JobArgs.svelte | 148 +++++++++++++++--- frontend/src/lib/components/Uptodate.svelte | 1 - .../(root)/(logged)/run/[...run]/+page.svelte | 47 +++--- 5 files changed, 177 insertions(+), 72 deletions(-) diff --git a/frontend/src/lib/components/ArgInfo.svelte b/frontend/src/lib/components/ArgInfo.svelte index c171c79d39..df047b7992 100644 --- a/frontend/src/lib/components/ArgInfo.svelte +++ b/frontend/src/lib/components/ArgInfo.svelte @@ -2,7 +2,7 @@ import { ResourceService } from '$lib/gen' import { workspaceStore } from '$lib/stores' import { copyToClipboard, truncate } from '$lib/utils' - import { ClipboardCopy } from 'lucide-svelte' + import { ClipboardCopy, Expand } from 'lucide-svelte' import { Button, DrawerContent } from './common' import Drawer from './common/drawer/Drawer.svelte' import ObjectViewer from './propertyPicker/ObjectViewer.svelte' @@ -68,16 +68,18 @@ > {/if} {:else} -
- +
+ {#if JSON.stringify(value).length > 120} + + {/if} +
+ +
- {#if JSON.stringify(value).length > 120} - - {/if} {/if} diff --git a/frontend/src/lib/components/DisplayResult.svelte b/frontend/src/lib/components/DisplayResult.svelte index f1e062b7aa..49329978f4 100644 --- a/frontend/src/lib/components/DisplayResult.svelte +++ b/frontend/src/lib/components/DisplayResult.svelte @@ -4,7 +4,7 @@ import TableCustom from './TableCustom.svelte' import { copyToClipboard, truncate } from '$lib/utils' import { Button, Drawer, DrawerContent } from './common' - import { ClipboardCopy } from 'lucide-svelte' + import { ClipboardCopy, Download, Expand } from 'lucide-svelte' import Portal from 'svelte-portal' import ObjectViewer from './propertyPicker/ObjectViewer.svelte' @@ -106,6 +106,7 @@ } let jsonViewer: Drawer + $: jsonStr = JSON.stringify(result, null, 4)
@@ -117,8 +118,8 @@ class="mb-2 w-full text-sm relative" >The result keys are: {truncate(Object.keys(result).join(', '), 50)} {#if !disableExpand} -
- +
+
{/if}
{/if}{#if !forceJson && resultKind == 'table-col'}
{:else} - {@const jsonStr = JSON.stringify(result, null, 4).replace(/\\n/g, '\n')} {#if jsonStr.length > 10000} +
No result: {jsonStr}
{/if}
@@ -261,25 +261,26 @@ - - {@const str = JSON.stringify(result, null, 4).replace(/\\n/g, '\n')} - {#if str.length > 100000} + {#if jsonStr.length > 100000}
DownloadDownload JSON is too large to be displayed in full.
{:else} - + {/if} diff --git a/frontend/src/lib/components/JobArgs.svelte b/frontend/src/lib/components/JobArgs.svelte index b95db179b5..9d7ece35fb 100644 --- a/frontend/src/lib/components/JobArgs.svelte +++ b/frontend/src/lib/components/JobArgs.svelte @@ -1,36 +1,132 @@ - - - Argument - Value - - - {#if args && Object.keys(args).length > 0} - {#each Object.entries(args) as [arg, value]} +
+
+ +
+ + + Argument + Value + + + {#if args && Object.keys(args).length > 0} + {#each Object.entries(args) as [arg, value]} + + {arg} + + + {/each} + {:else if args} +
No arguments
+ {:else} - {arg} - + + + + + + - {/each} - {:else if args} -
No arguments
- {:else} - - - - - - - - - {/if} - -
+ {/if} + + +
+ + + + + + Download + + + + {#if jsonStr.length > 100000} +
+ Download + JSON is too large to be displayed in full. +
+ {:else} + + {/if} +
+
+ + +

Envs

+ If using the wmill client in your code, set the following env variables: +
BASE_URL="{window.location.origin}"
+WM_TOKEN="{''}"
+

TypeScript

+
{typescriptCode()}
+

Python

+
{pythonCode()}
+
+
+
diff --git a/frontend/src/lib/components/Uptodate.svelte b/frontend/src/lib/components/Uptodate.svelte index 938149cfd5..fb7b9163a2 100644 --- a/frontend/src/lib/components/Uptodate.svelte +++ b/frontend/src/lib/components/Uptodate.svelte @@ -9,7 +9,6 @@ async function loadVersion() { try { const res = await SettingsService.backendUptodate() - console.log(res) if (res != 'yes') { uptodate = res } diff --git a/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte b/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte index 033f20e891..1964ae8c25 100644 --- a/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte @@ -233,8 +233,8 @@ -

-
+

+
{#if job} {#if 'success' in job && job.success} {#if job.is_skipped} @@ -282,22 +282,29 @@ /> {/if} {job.script_path ?? (job.job_kind == 'dependencies' ? 'lock dependencies' : 'No path')} - {#if job.script_hash} - {truncateHash(job.script_hash)} - {/if} - {#if job && 'job_kind' in job}{job.job_kind} - {/if} - {#if job.tag && !['deno', 'python3', 'flow', 'other', 'go', 'bash', 'other', 'dependency'].includes(job.tag)} - Worker group: {job.tag} - {/if} - {#if !job.visible_to_owner}only visible to you The option to hide this run from the owner of this script or flow was activated - {/if} +
+ {#if job.script_hash} + {truncateHash(job.script_hash)} + {/if} + {#if job && 'job_kind' in job} +
+ {job.job_kind} +
+ {/if} + {#if job.tag && !['deno', 'python3', 'flow', 'other', 'go', 'bash', 'other', 'dependency'].includes(job.tag)} +
+ Worker group: {job.tag} +
+ {/if} + {#if !job.visible_to_owner}only visible to you The option to hide this run from the owner of this script or flow was activated + {/if} +
{/if}

@@ -308,11 +315,11 @@ {/if} -
+
-
+
{#if job}{/if}