From f402cc67c12f1a67fcdb26d296cd3bc7e6b4f486 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sun, 24 Jul 2022 11:27:36 +0200 Subject: [PATCH] also allow editable flow --- backend/src/flow.rs | 2 +- backend/src/scripts.rs | 52 +++++++++++++++++-- frontend/src/lib/components/FlowViewer.svelte | 28 +++++----- frontend/src/routes/flows.svelte | 1 + frontend/src/routes/scripts.svelte | 16 ++++-- 5 files changed, 77 insertions(+), 22 deletions(-) diff --git a/backend/src/flow.rs b/backend/src/flow.rs index f5a32625ed..e1571f0caf 100644 --- a/backend/src/flow.rs +++ b/backend/src/flow.rs @@ -133,7 +133,7 @@ async fn list_flows( "edited_by", "edited_at", "archived", - "schema", + "null schema", "extra_perms", ]) .order_by("edited_at", lq.order_desc.unwrap_or(true)) diff --git a/backend/src/scripts.rs b/backend/src/scripts.rs index 6b2cfa08ee..6c4d51afab 100644 --- a/backend/src/scripts.rs +++ b/backend/src/scripts.rs @@ -195,7 +195,7 @@ async fn list_scripts( "created_by", "created_at", "archived", - "schema", + "null as schema", "deleted", "is_template", "extra_perms", @@ -252,16 +252,20 @@ async fn list_scripts( } #[derive(Deserialize, Serialize)] -struct SearchData { +struct SearchScriptData { asks: Vec, } + #[derive(Deserialize, Serialize)] struct ScriptSearch { id: i32, + ask_id: i32, summary: String, app: String, approved: bool, is_trigger: bool, + views: i32, + votes: i32, } async fn list_hub_scripts( @@ -282,7 +286,49 @@ async fn list_hub_scripts( .send() .await .map_err(to_anyhow)? - .json::() + .json::() + .await + .map_err(to_anyhow)? + .asks; + Ok(Json(rows)) +} + +#[derive(Deserialize, Serialize)] +struct SearchFlowData { + asks: Vec, +} + +#[derive(Deserialize, Serialize)] +struct FlowSearch { + id: i32, + ask_id: i32, + summary: String, + app: String, + approved: bool, + is_trigger: bool, + views: i32, + votes: i32, +} + +async fn list_hub_flows( + Authed { + email, username, .. + }: Authed, + Host(host): Host, +) -> JsonResult> { + let http_client = reqwest::ClientBuilder::new() + .user_agent("windmill/beta") + .build() + .map_err(to_anyhow)?; + let rows = http_client + .get("https://hub.windmill.dev/searchFlowData?approved=true") + .header("X-email", email.unwrap_or_else(|| "".to_string())) + .header("X-username", username) + .header("X-hostname", host) + .send() + .await + .map_err(to_anyhow)? + .json::() .await .map_err(to_anyhow)? .asks; diff --git a/frontend/src/lib/components/FlowViewer.svelte b/frontend/src/lib/components/FlowViewer.svelte index ef0abc56c2..2664a9cce1 100644 --- a/frontend/src/lib/components/FlowViewer.svelte +++ b/frontend/src/lib/components/FlowViewer.svelte @@ -47,14 +47,14 @@ {#if tab == 'ui'}

- {flow.value.modules.length} Steps + {flow?.value?.modules?.length} Steps

    - {#each flow.value.modules ?? [] as mod, i} + {#each flow?.value?.modules ?? [] as mod, i}
  • - {#if i < (flow.value.modules ?? []).length - 1} + {#if i < (flow?.value?.modules ?? []).length - 1}