diff --git a/backend/windmill-api/src/jobs.rs b/backend/windmill-api/src/jobs.rs index 1db5f17029..e61b5cc5a9 100644 --- a/backend/windmill-api/src/jobs.rs +++ b/backend/windmill-api/src/jobs.rs @@ -301,6 +301,7 @@ pub struct ListQueueQuery { pub parent_job: Option, pub order_desc: Option, pub job_kinds: Option, + pub suspended: Option, } fn list_queue_jobs_query(w_id: &str, lq: &ListQueueQuery, fields: &[&str]) -> SqlBuilder { @@ -335,6 +336,13 @@ fn list_queue_jobs_query(w_id: &str, lq: &ListQueueQuery, fields: &[&str]) -> Sq if let Some(dt) = &lq.created_after { sqlb.and_where_gt("created_at", format!("to_timestamp({})", dt.timestamp())); } + if let Some(s) = &lq.suspended { + if *s { + sqlb.and_where_is_not_null("suspend"); + } else { + sqlb.and_where_is_null("suspend"); + } + } if let Some(jk) = &lq.job_kinds { sqlb.and_where_in( "job_kind", @@ -378,6 +386,7 @@ async fn list_jobs( parent_job: lq.parent_job, order_desc: Some(true), job_kinds: lq.job_kinds, + suspended: lq.suspended, }, &[ "'QueuedJob' as typ", @@ -1475,6 +1484,7 @@ pub struct ListCompletedQuery { pub job_kinds: Option, pub is_skipped: Option, pub is_flow_step: Option, + pub suspended: Option, } async fn list_completed_jobs( diff --git a/frontend/src/lib/components/Editor.svelte b/frontend/src/lib/components/Editor.svelte index edefb21005..95485aba7c 100644 --- a/frontend/src/lib/components/Editor.svelte +++ b/frontend/src/lib/components/Editor.svelte @@ -421,7 +421,7 @@ timeoutModel && clearTimeout(timeoutModel) timeoutModel = setTimeout(() => { code = getCode() - dispatch('change') + dispatch('change', code) }, 500) }) diff --git a/frontend/src/lib/components/ScriptEditor.svelte b/frontend/src/lib/components/ScriptEditor.svelte index 346276cb9f..e4483b9568 100644 --- a/frontend/src/lib/components/ScriptEditor.svelte +++ b/frontend/src/lib/components/ScriptEditor.svelte @@ -70,7 +70,7 @@ }) } - async function inferSchema() { + async function inferSchema(code: string) { let isDefault: string[] = [] Object.entries(args).forEach(([k, v]) => { if (schema.properties[k].default == v) { @@ -99,7 +99,7 @@ } onMount(() => { - inferSchema() + inferSchema(code) }) @@ -145,20 +145,22 @@
{ - inferSchema() + inferSchema(code) }} > inferSchema()} + on:change={(e) => { + inferSchema(e.detail) + }} cmdEnterAction={async () => { - await inferSchema() + await inferSchema(code) runTest() }} formatAction={async () => { - await inferSchema() + await inferSchema(code) localStorage.setItem(path ?? 'last_save', code) lastSave = code }} diff --git a/frontend/src/lib/components/apps/components/helpers/RunnableComponent.svelte b/frontend/src/lib/components/apps/components/helpers/RunnableComponent.svelte index c23ed702f5..5b3efc6ef8 100644 --- a/frontend/src/lib/components/apps/components/helpers/RunnableComponent.svelte +++ b/frontend/src/lib/components/apps/components/helpers/RunnableComponent.svelte @@ -48,7 +48,9 @@ } }) - args = nargs + if (JSON.stringify(args) != JSON.stringify(nargs)) { + args = nargs + } } $: fields && setStaticInputsToArgs() @@ -102,7 +104,8 @@ return loadSchema(workspace, path, runType) ?? emptySchema() } - $: runnable && loadSchemaAndInputsByName() + $: runnable?.type === 'runnableByName' && loadSchemaAndInputsByName() + $: !schema && runnable?.type === 'runnableByPath' && loadSchemaAndInputsByPath() async function loadSchemaAndInputsByName() { if (runnable?.type === 'runnableByName') { @@ -112,7 +115,7 @@ const newSchema = inlineScript.schema schema = newSchema - const newFields = reloadInputs() + const newFields = reloadInputs(newSchema) if (JSON.stringify(newFields) !== JSON.stringify(fields)) { fields = newFields @@ -142,11 +145,9 @@ } } - $: !schema && runnable?.type === 'runnableByPath' && loadSchemaAndInputsByPath() - // When the schema is loaded, we need to update the inputs spec // in order to render the inputs the component panel - function reloadInputs() { + function reloadInputs(schema: Schema) { let schemaWithoutExtraQueries: Schema = JSON.parse(JSON.stringify(schema)) // Remove extra query params from the schema, which are not directly configurable by the user @@ -156,7 +157,6 @@ const result = {} const newInputs = schemaToInputsSpec(schemaWithoutExtraQueries) - if (!fields) { return newInputs } diff --git a/frontend/src/lib/components/apps/components/table/AppTable.svelte b/frontend/src/lib/components/apps/components/table/AppTable.svelte index e5a0bd497f..401cd0b4b2 100644 --- a/frontend/src/lib/components/apps/components/table/AppTable.svelte +++ b/frontend/src/lib/components/apps/components/table/AppTable.svelte @@ -83,6 +83,14 @@ ) } + function renderCell(x: any, props: any) { + try { + return flexRender(x, props) + } catch (e) { + return undefined + } + } + let filteredResult: Array> = [] $: filteredResult && setOptions(filteredResult) @@ -122,13 +130,17 @@ {#each $table.getHeaderGroups() as headerGroup} {#each headerGroup.headers as header} - - {#if !header.isPlaceholder} - + {#if header?.column?.columnDef?.header} + {@const context = header?.getContext()} + {#if context} + {@const component = renderCell(header.column.columnDef.header, context)} + + {#if !header.isPlaceholder && component} + + {/if} + {/if} - + {/if} {/each} {#if actionButtons.length > 0} Actions @@ -151,14 +163,20 @@ )} > {#each row.getVisibleCells() as cell, index (index)} - toggleRow(row, rowIndex)} - class="p-4 whitespace-nowrap text-xs text-gray-900" - > - - + {#if cell?.column?.columnDef?.header} + {@const context = cell?.getContext()} + {#if context} + {@const component = renderCell(cell.column.columnDef.cell, context)} + toggleRow(row, rowIndex)} + class="p-4 whitespace-nowrap text-xs text-gray-900" + > + {#if component != undefined} + + {/if} + + {/if} + {/if} {/each} {#if actionButtons.length > 0} diff --git a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte index bc49665256..7a66999412 100644 --- a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte +++ b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte @@ -18,6 +18,8 @@ export let inlineScript: InlineScript export let name: string | undefined = undefined + let editor: Editor + let validCode = false async function inferInlineScriptSchema( @@ -48,7 +50,7 @@ const dispatch = createEventDispatcher() - +
@@ -91,20 +93,18 @@
{ + on:change={async (e) => { if (inlineScript) { - let schema = await inferInlineScriptSchema( - inlineScript?.language, - inlineScript.content, - inlineScript.schema - ) - - inlineScript.schema = schema - inlineScript = inlineScript + const oldSchema = JSON.stringify(inlineScript.schema) + await inferInlineScriptSchema(inlineScript?.language, e.detail, inlineScript.schema) + if (JSON.stringify(inlineScript.schema) != oldSchema) { + inlineScript = inlineScript + } } }} /> diff --git a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditorDrawer.svelte b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditorDrawer.svelte index 4aef09aebe..40ed3b7e06 100644 --- a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditorDrawer.svelte +++ b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptEditorDrawer.svelte @@ -1,11 +1,13 @@