From 93a18b2c4d7df5efd9f5e4c94b5e1e8fa52f07ca Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sat, 30 Jul 2022 00:02:03 +0200 Subject: [PATCH] autoscroll + status viewer auto update --- .../src/lib/components/DisplayResult.svelte | 7 +- frontend/src/lib/components/FlowEditor.svelte | 4 +- .../src/lib/components/FlowJobResult.svelte | 2 +- .../lib/components/FlowStatusViewer.svelte | 66 ++++++++++++++----- .../lib/components/ObjectResourceInput.svelte | 27 ++++++-- .../src/lib/components/ResourcePicker.svelte | 10 ++- .../src/lib/components/ScriptEditor.svelte | 5 +- .../src/routes/flows/get/[...path].svelte | 8 ++- frontend/src/routes/run/[...run].svelte | 4 +- 9 files changed, 97 insertions(+), 36 deletions(-) diff --git a/frontend/src/lib/components/DisplayResult.svelte b/frontend/src/lib/components/DisplayResult.svelte index 97ce6d6e60..9725584543 100644 --- a/frontend/src/lib/components/DisplayResult.svelte +++ b/frontend/src/lib/components/DisplayResult.svelte @@ -3,6 +3,7 @@ import github from 'svelte-highlight/styles/github' import { json } from 'svelte-highlight/languages' import TableCustom from './TableCustom.svelte' + import { truncate } from '$lib/utils' export let result: any @@ -65,13 +66,13 @@ {#if resultKind == 'table-col'}
{#each Object.keys(result) as col} -
+
{col}
{#if Array.isArray(result[col])} {#each result[col] as item} -
+
{typeof item === 'string' ? item : JSON.stringify(item)}
{/each} @@ -87,7 +88,7 @@ {#each asListOfList(Object.values(result)[0]) as row} {#each row as v} - {v ?? ''} + {truncate(v, 200) ?? ''} {/each} {/each} diff --git a/frontend/src/lib/components/FlowEditor.svelte b/frontend/src/lib/components/FlowEditor.svelte index f21b147b5d..7f2fc26b25 100644 --- a/frontend/src/lib/components/FlowEditor.svelte +++ b/frontend/src/lib/components/FlowEditor.svelte @@ -48,8 +48,8 @@ }) scheduleEnabled = schedule.enabled scheduleCron = schedule.schedule - scheduleArgs = scheduleArgs - console.log(schedule.enabled, schedule.schedule) + scheduleArgs = schedule.args ?? {} + console.log(scheduleArgs) } } diff --git a/frontend/src/lib/components/FlowJobResult.svelte b/frontend/src/lib/components/FlowJobResult.svelte index 6a13f860f7..d9d376c569 100644 --- a/frontend/src/lib/components/FlowJobResult.svelte +++ b/frontend/src/lib/components/FlowJobResult.svelte @@ -18,7 +18,7 @@
-
+
{job.logs}
diff --git a/frontend/src/lib/components/FlowStatusViewer.svelte b/frontend/src/lib/components/FlowStatusViewer.svelte index 654a5f426b..39f58fbaa6 100644 --- a/frontend/src/lib/components/FlowStatusViewer.svelte +++ b/frontend/src/lib/components/FlowStatusViewer.svelte @@ -15,7 +15,27 @@ let forloop_selected = '' - function loadResults() { + let logs: { [key: number]: string } = {} + let pres: { [key: number]: HTMLElement } = {} + + async function loadResults() { + if (!('success' in job)) { + const mods = job?.flow_status?.modules + if (mods) { + let i = mods?.findIndex((x) => x.type == FlowStatusModule.type.IN_PROGRESS) + if (i != -1) { + let last = mods[i] + if (last?.type == FlowStatusModule.type.IN_PROGRESS) { + logs[i] = + (await JobService.getJob({ workspace: $workspaceStore ?? '', id: last.job ?? '' })) + .logs ?? '' + console.log(logs[i]) + logs = logs + pres[i].scroll({ top: pres[i]?.scrollHeight, behavior: 'smooth' }) + } + } + } + } job?.flow_status?.modules?.forEach(async (x, i) => { if ( (i >= jobs.length && x.type == FlowStatusModule.type.SUCCESS) || @@ -49,7 +69,7 @@ $: $workspaceStore && job && loadResults() -
+
{#if job}
@@ -133,28 +153,33 @@
{job.flow_status?.modules[i].type} - {#if job.flow_status?.modules[i].forloop_jobs} - {#each job.flow_status?.modules[i].forloop_jobs ?? [] as job} - - {/each} - {:else if job.flow_status?.modules[i].job} - {truncateRev(job.flow_status?.modules[i].job ?? '', 10)} - {/if} +
+ {#if job.flow_status?.modules[i].forloop_jobs} + {#each job.flow_status?.modules[i].forloop_jobs ?? [] as job} + + {/each} + {:else if job.flow_status?.modules[i].job} + {truncateRev(job.flow_status?.modules[i].job ?? '', 10)} + {/if} +
{#if jobs[i]} {#if Array.isArray(jobs[i])} -
+
{#each toCompletedJobs(jobs[i]) as job, i}
diff --git a/frontend/src/lib/components/ObjectResourceInput.svelte b/frontend/src/lib/components/ObjectResourceInput.svelte index cd5f37eaed..9f31082e7d 100644 --- a/frontend/src/lib/components/ObjectResourceInput.svelte +++ b/frontend/src/lib/components/ObjectResourceInput.svelte @@ -9,22 +9,28 @@ export let format: string export let value: any + console.log(value) function isString(value: any) { return typeof value === 'string' || value instanceof String } - let path: string = - isString(value) && value.length >= '$res:'.length ? value.substr('$res:'.length) : undefined + let path: string = '' let args: Record = {} if (!isString(value) && value) { args = value } + valueToPath() + let schema: any | undefined = undefined let isValid = true let resourceTypeName: string = '' + let option: 'resource' | 'raw' = isString(value) || value == undefined ? 'resource' : 'raw' + + $: format.startsWith('resource-') && loadSchema(format) + async function loadSchema(format: string) { resourceTypeName = format.substring('resource-'.length) schema = ( @@ -32,16 +38,19 @@ ).schema } - let option: 'resource' | 'raw' = isString(value) || value == undefined ? 'resource' : 'raw' - - $: { + function argToValue() { if (option == 'resource') { value = `$res:${path}` } else { value = args } } - $: format.startsWith('resource-') && loadSchema(format) + function valueToPath() { + path = + isString(value) && value.length >= '$res:'.length ? value.substr('$res:'.length) : undefined + } + + $: value && valueToPath()
@@ -51,12 +60,18 @@ [`Resource (${resourceTypeName})`, 'resource'], [`Raw object value`, 'raw'] ]} + on:change={argToValue} bind:value={option} />
{#if option == 'resource'} loadSchema(format)} + on:change={(e) => { + path = e.detail + argToValue() + }} bind:value={path} resourceType={format.split('-').length > 1 ? format.substring('resource-'.length) diff --git a/frontend/src/lib/components/ResourcePicker.svelte b/frontend/src/lib/components/ResourcePicker.svelte index fb692cf6ba..2d7cff3f65 100644 --- a/frontend/src/lib/components/ResourcePicker.svelte +++ b/frontend/src/lib/components/ResourcePicker.svelte @@ -1,28 +1,32 @@ loadResources(resourceType)} /> -