diff options
Diffstat (limited to 'makima/src/daemon/tui/views')
| -rw-r--r-- | makima/src/daemon/tui/views/contracts.rs | 32 | ||||
| -rw-r--r-- | makima/src/daemon/tui/views/files.rs | 90 | ||||
| -rw-r--r-- | makima/src/daemon/tui/views/mod.rs | 3 | ||||
| -rw-r--r-- | makima/src/daemon/tui/views/tasks.rs | 71 |
4 files changed, 0 insertions, 196 deletions
diff --git a/makima/src/daemon/tui/views/contracts.rs b/makima/src/daemon/tui/views/contracts.rs deleted file mode 100644 index 73b7c33..0000000 --- a/makima/src/daemon/tui/views/contracts.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! Contracts view implementation. - -use uuid::Uuid; - -use crate::daemon::api::ApiClient; -use crate::daemon::tui::app::ListItem; - -/// Load contracts from API -pub async fn load_contracts( - client: &ApiClient, -) -> Result<Vec<ListItem>, Box<dyn std::error::Error>> { - let result = client.list_contracts().await?; - - // Response is { "contracts": [...], "total": N } - let contracts = result - .0 - .get("contracts") - .and_then(|v| v.as_array()) - .map(|arr| arr.iter().filter_map(ListItem::from_contract).collect()) - .unwrap_or_default(); - - Ok(contracts) -} - -/// Get full contract details for preview -pub async fn get_contract_preview( - _client: &ApiClient, - _contract_id: Uuid, -) -> Result<String, Box<dyn std::error::Error>> { - // TODO: Implement contract preview - Ok("Contract preview not yet implemented".to_string()) -} diff --git a/makima/src/daemon/tui/views/files.rs b/makima/src/daemon/tui/views/files.rs deleted file mode 100644 index e21a989..0000000 --- a/makima/src/daemon/tui/views/files.rs +++ /dev/null @@ -1,90 +0,0 @@ -//! Files view implementation. - -use uuid::Uuid; - -use crate::daemon::api::ApiClient; -use crate::daemon::tui::app::ListItem; - -/// Load files from API -pub async fn load_files( - client: &ApiClient, - contract_id: Uuid, -) -> Result<Vec<ListItem>, Box<dyn std::error::Error>> { - let result = client.contract_files(contract_id).await?; - - // Parse JSON response into ListItem - let files: Vec<serde_json::Value> = serde_json::from_value(result.0)?; - - let items = files - .into_iter() - .filter_map(|f| { - let id_str = f.get("id")?.as_str()?; - let id = Uuid::parse_str(id_str).ok()?; - - Some(ListItem { - id, - name: f - .get("name") - .and_then(|v| v.as_str()) - .unwrap_or("Unnamed") - .to_string(), - status: None, - description: f - .get("description") - .and_then(|v| v.as_str()) - .map(String::from), - updated_at: f - .get("updatedAt") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - extra: f, - }) - }) - .collect(); - - Ok(items) -} - -/// Get full file details for preview -pub async fn get_file_preview( - client: &ApiClient, - contract_id: Uuid, - file_id: Uuid, -) -> Result<String, Box<dyn std::error::Error>> { - let result = client.contract_file(contract_id, file_id).await?; - let file: serde_json::Value = result.0; - - let name = file - .get("name") - .and_then(|v| v.as_str()) - .unwrap_or("Unknown"); - let description = file - .get("description") - .and_then(|v| v.as_str()) - .unwrap_or("-"); - - // Try to get body content - let body_preview = if let Some(body) = file.get("body") { - if let Some(body_array) = body.as_array() { - body_array - .iter() - .filter_map(|item| { - let text = item.get("text").and_then(|v| v.as_str())?; - Some(text.to_string()) - }) - .take(5) - .collect::<Vec<_>>() - .join("\n") - } else { - "-".to_string() - } - } else { - "-".to_string() - }; - - Ok(format!( - "Name: {}\nDescription: {}\n\nContent:\n{}", - name, description, body_preview - )) -} diff --git a/makima/src/daemon/tui/views/mod.rs b/makima/src/daemon/tui/views/mod.rs deleted file mode 100644 index 699b6df..0000000 --- a/makima/src/daemon/tui/views/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod contracts; -pub mod files; -pub mod tasks; diff --git a/makima/src/daemon/tui/views/tasks.rs b/makima/src/daemon/tui/views/tasks.rs deleted file mode 100644 index fd52b11..0000000 --- a/makima/src/daemon/tui/views/tasks.rs +++ /dev/null @@ -1,71 +0,0 @@ -//! Tasks view implementation. - -use uuid::Uuid; - -use crate::daemon::api::ApiClient; -use crate::daemon::tui::app::ListItem; - -/// Load tasks from API -pub async fn load_tasks( - client: &ApiClient, - contract_id: Option<Uuid>, -) -> Result<Vec<ListItem>, Box<dyn std::error::Error>> { - let Some(contract_id) = contract_id else { - // TODO: Implement listing all tasks across contracts - return Ok(Vec::new()); - }; - - let result = client.supervisor_tasks(contract_id).await?; - - // Parse JSON response into ListItem - let tasks: Vec<serde_json::Value> = serde_json::from_value(result.0)?; - - let items = tasks - .into_iter() - .filter_map(|t| { - let id_str = t.get("id")?.as_str()?; - let id = Uuid::parse_str(id_str).ok()?; - - Some(ListItem { - id, - name: t - .get("name") - .and_then(|v| v.as_str()) - .unwrap_or("Unnamed") - .to_string(), - status: t.get("status").and_then(|v| v.as_str()).map(String::from), - description: t - .get("progressSummary") - .and_then(|v| v.as_str()) - .map(String::from), - updated_at: t - .get("updatedAt") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - extra: t, - }) - }) - .collect(); - - Ok(items) -} - -/// Get full task details for preview -pub async fn get_task_preview( - client: &ApiClient, - task_id: Uuid, -) -> Result<String, Box<dyn std::error::Error>> { - let result = client.supervisor_get_task(task_id).await?; - let task: serde_json::Value = result.0; - - Ok(format!( - "Name: {}\nStatus: {}\nPlan: {}\n\nProgress:\n{}", - task.get("name").and_then(|v| v.as_str()).unwrap_or("-"), - task.get("status").and_then(|v| v.as_str()).unwrap_or("-"), - task.get("plan").and_then(|v| v.as_str()).unwrap_or("-"), - task.get("progressSummary") - .and_then(|v| v.as_str()) - .unwrap_or("-"), - )) -} |
