mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-23 08:00:45 +00:00
fix forking hub deno scripts in apps
This commit is contained in:
@@ -19,7 +19,7 @@ use hmac::Mac;
|
||||
use hyper::{HeaderMap, StatusCode};
|
||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||
use sql_builder::{prelude::*, quote, SqlBuilder};
|
||||
use sqlx::{query_scalar, types::Uuid, Postgres, Transaction};
|
||||
use sqlx::{query_scalar, types::Uuid, FromRow, Postgres, Transaction};
|
||||
use urlencoding::encode;
|
||||
use windmill_audit::{audit_log, ActionKind};
|
||||
use windmill_common::{
|
||||
@@ -338,9 +338,9 @@ fn list_queue_jobs_query(w_id: &str, lq: &ListQueueQuery, fields: &[&str]) -> Sq
|
||||
}
|
||||
if let Some(s) = &lq.suspended {
|
||||
if *s {
|
||||
sqlb.and_where_is_not_null("suspend");
|
||||
sqlb.and_where_gt("suspend", 0);
|
||||
} else {
|
||||
sqlb.and_where_is_null("suspend");
|
||||
sqlb.and_where_eq("suspend", 0);
|
||||
}
|
||||
}
|
||||
if let Some(jk) = &lq.job_kinds {
|
||||
@@ -353,13 +353,55 @@ fn list_queue_jobs_query(w_id: &str, lq: &ListQueueQuery, fields: &[&str]) -> Sq
|
||||
sqlb
|
||||
}
|
||||
|
||||
#[derive(Serialize, FromRow)]
|
||||
struct ListableQueuedJob {
|
||||
pub id: Uuid,
|
||||
pub created_by: String,
|
||||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||||
pub started_at: Option<chrono::DateTime<chrono::Utc>>,
|
||||
pub scheduled_for: chrono::DateTime<chrono::Utc>,
|
||||
pub script_hash: Option<ScriptHash>,
|
||||
pub script_path: Option<String>,
|
||||
pub args: Option<serde_json::Value>,
|
||||
pub job_kind: JobKind,
|
||||
pub schedule_path: Option<String>,
|
||||
pub is_flow_step: bool,
|
||||
pub language: Option<ScriptLang>,
|
||||
pub email: String,
|
||||
pub suspend: Option<i32>,
|
||||
}
|
||||
|
||||
async fn list_queue_jobs(
|
||||
Extension(db): Extension<DB>,
|
||||
Path(w_id): Path<String>,
|
||||
Query(lq): Query<ListQueueQuery>,
|
||||
) -> error::JsonResult<Vec<QueuedJob>> {
|
||||
let sql = list_queue_jobs_query(&w_id, &lq, &["*"]).sql()?;
|
||||
let jobs = sqlx::query_as::<_, QueuedJob>(&sql).fetch_all(&db).await?;
|
||||
) -> error::JsonResult<Vec<ListableQueuedJob>> {
|
||||
let sql = list_queue_jobs_query(
|
||||
&w_id,
|
||||
&lq,
|
||||
&[
|
||||
"id",
|
||||
"created_by",
|
||||
"created_at",
|
||||
"started_at",
|
||||
"scheduled_for",
|
||||
"script_hash",
|
||||
"script_path",
|
||||
"args",
|
||||
"job_kind",
|
||||
"schedule_path",
|
||||
"permissioned_as",
|
||||
"is_flow_step",
|
||||
"language",
|
||||
"same_worker",
|
||||
"email",
|
||||
"suspend",
|
||||
],
|
||||
)
|
||||
.sql()?;
|
||||
let jobs = sqlx::query_as::<_, ListableQueuedJob>(&sql)
|
||||
.fetch_all(&db)
|
||||
.await?;
|
||||
Ok(Json(jobs))
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
function cellIsObject(x: (any) => any, props: any): boolean {
|
||||
return typeof x != 'string' && typeof x(props) == 'object'
|
||||
}
|
||||
|
||||
let filteredResult: Array<Record<string, any>> = []
|
||||
|
||||
$: filteredResult && setOptions(filteredResult)
|
||||
@@ -167,7 +171,7 @@
|
||||
)}
|
||||
>
|
||||
{#each row.getVisibleCells() as cell, index (index)}
|
||||
{#if cell?.column?.columnDef?.header}
|
||||
{#if cell?.column?.columnDef?.cell}
|
||||
{@const context = cell?.getContext()}
|
||||
{#if context}
|
||||
{@const component = renderCell(cell.column.columnDef.cell, context)}
|
||||
@@ -175,7 +179,9 @@
|
||||
on:click={() => toggleRow(row, rowIndex)}
|
||||
class="p-4 whitespace-nowrap text-xs text-gray-900"
|
||||
>
|
||||
{#if component != undefined}
|
||||
{#if typeof cell.column.columnDef.cell != 'string' && cellIsObject(cell.column.columnDef.cell, context)}
|
||||
{JSON.stringify(cell.column.columnDef.cell(context), null, 4)}
|
||||
{:else if component != undefined}
|
||||
<svelte:component this={component} />
|
||||
{/if}
|
||||
</td>
|
||||
|
||||
+10
-2
@@ -3,7 +3,9 @@
|
||||
import Button from '$lib/components/common/button/Button.svelte'
|
||||
import FlowModuleScript from '$lib/components/flows/content/FlowModuleScript.svelte'
|
||||
import FlowPathViewer from '$lib/components/flows/content/FlowPathViewer.svelte'
|
||||
import { getScriptByPath } from '$lib/utils'
|
||||
import { inferArgs } from '$lib/infer'
|
||||
import { loadSchema } from '$lib/scripts'
|
||||
import { emptySchema, getScriptByPath } from '$lib/utils'
|
||||
import { faCodeBranch, faExternalLinkAlt, faEye, faPen } from '@fortawesome/free-solid-svg-icons'
|
||||
import type { AppInput, ResultAppInput } from '../../inputType'
|
||||
import { clearResultAppInput } from '../../utils'
|
||||
@@ -13,8 +15,13 @@
|
||||
export let componentInput: AppInput | undefined
|
||||
|
||||
async function fork(path: string) {
|
||||
const { content, language, schema } = await getScriptByPath(path)
|
||||
let { content, language, schema } = await getScriptByPath(path)
|
||||
if (componentInput && componentInput.type == 'runnable') {
|
||||
if (!schema || Object.keys(schema).length == 0) {
|
||||
schema = emptySchema()
|
||||
await inferArgs(language, content, schema)
|
||||
}
|
||||
console.log(schema)
|
||||
componentInput.runnable = {
|
||||
type: 'runnableByName',
|
||||
name: path,
|
||||
@@ -25,6 +32,7 @@
|
||||
path
|
||||
}
|
||||
}
|
||||
console.log(content, language, schema)
|
||||
} else {
|
||||
console.error('componentInput is undefined')
|
||||
}
|
||||
|
||||
@@ -53,6 +53,9 @@ export async function loadSchema(
|
||||
}
|
||||
|
||||
export function schemaToInputsSpec(schema: Schema): Record<string, StaticAppInput> {
|
||||
if (schema?.properties == undefined) {
|
||||
return {}
|
||||
}
|
||||
return Object.keys(schema.properties).reduce((accu, key) => {
|
||||
const property = schema.properties[key]
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import { Badge } from '../common'
|
||||
import { NEVER_TESTED_THIS_FAR } from '../flows/utils'
|
||||
import { getTypeAsString } from '../flows/utils'
|
||||
import Popover from '../Popover.svelte'
|
||||
import { computeKey } from './utils'
|
||||
import WarningMessage from './WarningMessage.svelte'
|
||||
|
||||
@@ -90,9 +91,13 @@
|
||||
{#if json[key] === NEVER_TESTED_THIS_FAR}
|
||||
<WarningMessage />
|
||||
{:else if json[key] == undefined}
|
||||
<span>undefined</span>
|
||||
<span class="text-2xs">undefined</span>
|
||||
{:else if typeof json[key] == 'string'}
|
||||
<span title={json[key]} class="text-2xs">"{truncate(json[key], 200)}"</span>
|
||||
{:else}
|
||||
<span>{truncate(JSON.stringify(json[key]), 40)}</span>
|
||||
<span title={JSON.stringify(json[key])} class="text-2xs"
|
||||
>{truncate(JSON.stringify(json[key]), 200)}</span
|
||||
>
|
||||
{/if}
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user