diff options
| author | soryu <soryu@soryu.co> | 2026-02-07 16:58:38 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-02-07 16:58:38 +0000 |
| commit | 8f757f561eeb397aaea70d7c10d41445cc5e50b5 (patch) | |
| tree | db64ab219594f069a9f0e11ff0cba10eeb80f862 /makima/src | |
| parent | 1b72449496ce3a057a43d002c8042d5e7a1d6576 (diff) | |
| download | soryu-8f757f561eeb397aaea70d7c10d41445cc5e50b5.tar.gz soryu-8f757f561eeb397aaea70d7c10d41445cc5e50b5.zip | |
Show directive init on frontend
Diffstat (limited to 'makima/src')
| -rw-r--r-- | makima/src/db/models.rs | 4 | ||||
| -rw-r--r-- | makima/src/server/handlers/directives.rs | 21 |
2 files changed, 21 insertions, 4 deletions
diff --git a/makima/src/db/models.rs b/makima/src/db/models.rs index ec4ee15..bc90942 100644 --- a/makima/src/db/models.rs +++ b/makima/src/db/models.rs @@ -2849,13 +2849,13 @@ pub struct UpdateDirectiveRequest { pub version: Option<i32>, } -/// Directive with its chains for detail view. +/// Directive with its chains and steps for detail view. #[derive(Debug, Serialize, ToSchema)] #[serde(rename_all = "camelCase")] pub struct DirectiveWithChains { #[serde(flatten)] pub directive: Directive, - pub chains: Vec<DirectiveChain>, + pub chains: Vec<ChainWithSteps>, } /// Full row from directive_chains table. diff --git a/makima/src/server/handlers/directives.rs b/makima/src/server/handlers/directives.rs index 560151b..a877c6b 100644 --- a/makima/src/server/handlers/directives.rs +++ b/makima/src/server/handlers/directives.rs @@ -9,7 +9,7 @@ use axum::{ use uuid::Uuid; use crate::db::models::{ - ChainWithSteps, CreateDirectiveRequest, Directive, DirectiveChain, + ChainStep, ChainWithSteps, CreateDirectiveRequest, Directive, DirectiveChain, DirectiveListResponse, DirectiveWithChains, UpdateDirectiveRequest, }; use crate::db::repository::{self, RepositoryError}; @@ -122,7 +122,24 @@ pub async fn get_directive( } }; - Json(DirectiveWithChains { directive, chains }).into_response() + // Build chains with steps + let mut chains_with_steps = Vec::new(); + for chain in chains { + let steps = match repository::list_steps_for_chain(pool, chain.id).await { + Ok(s) => s, + Err(e) => { + tracing::warn!("Failed to get steps for chain {}: {}", chain.id, e); + Vec::new() + } + }; + chains_with_steps.push(ChainWithSteps { chain, steps }); + } + + Json(DirectiveWithChains { + directive, + chains: chains_with_steps, + }) + .into_response() } /// Create a new directive. |
