Added set sail button and much nicer artist enrichment

This commit is contained in:
Connor Johnstone
2026-03-18 14:54:52 -04:00
parent 8b16859526
commit ff41233a96
8 changed files with 251 additions and 13 deletions

View File

@@ -171,6 +171,11 @@ pub async fn cancel_download(id: i32) -> Result<(), ApiError> {
delete(&format!("{BASE}/downloads/{id}")).await
}
// --- Pipeline ---
pub async fn trigger_pipeline() -> Result<PipelineRef, ApiError> {
post_empty(&format!("{BASE}/pipeline")).await
}
// --- System ---
pub async fn trigger_index() -> Result<TaskRef, ApiError> {
post_empty(&format!("{BASE}/index")).await

View File

@@ -15,6 +15,7 @@ pub fn status_badge(props: &Props) -> Html {
"pending" => "badge badge-pending",
"failed" => "badge badge-failed",
"completed" => "badge badge-completed",
"running" => "badge badge-available",
"downloading" => "badge badge-available",
"cancelled" => "badge badge-pending",
_ => "badge",

View File

@@ -142,6 +142,26 @@ pub fn dashboard() -> Html {
})
};
let on_pipeline = {
let message = message.clone();
let error = error.clone();
let fetch = fetch_status.clone();
Callback::from(move |_: MouseEvent| {
let message = message.clone();
let error = error.clone();
let fetch = fetch.clone();
wasm_bindgen_futures::spawn_local(async move {
match api::trigger_pipeline().await {
Ok(p) => {
message.set(Some(format!("Pipeline started — {} tasks queued", p.task_ids.len())));
fetch.emit(());
}
Err(e) => error.set(Some(e.0)),
}
});
})
};
if let Some(ref err) = *error {
return html! { <div class="error">{ format!("Error: {err}") }</div> };
}
@@ -150,6 +170,8 @@ pub fn dashboard() -> Html {
return html! { <p class="loading">{ "Loading..." }</p> };
};
let pipeline_active = s.tasks.iter().any(|t| t.status == "Pending" || t.status == "Running");
html! {
<div>
<div class="page-header">
@@ -182,12 +204,25 @@ pub fn dashboard() -> Html {
</div>
</div>
// Actions
// Pipeline
<div class="card">
<h3>{ "Actions" }</h3>
<div class="flex items-center justify-between">
<h3>{ "Pipeline" }</h3>
<button class="btn btn-primary" onclick={on_pipeline} disabled={pipeline_active}>
{ "Set Sail" }
</button>
</div>
<p class="text-sm text-muted mt-1">
{ "Sync \u{2192} Download \u{2192} Index \u{2192} Tag \u{2192} Organize \u{2192} Enrich" }
</p>
</div>
// Individual Actions
<div class="card">
<h3>{ "Individual Actions" }</h3>
<div class="actions mt-1">
<button class="btn btn-primary" onclick={on_sync}>{ "Sync Watchlist" }</button>
<button class="btn btn-success" onclick={on_process}>{ "Process Downloads" }</button>
<button class="btn btn-secondary" onclick={on_sync}>{ "Sync Watchlist" }</button>
<button class="btn btn-secondary" onclick={on_process}>{ "Process Downloads" }</button>
<button class="btn btn-secondary" onclick={on_index}>{ "Re-index" }</button>
<button class="btn btn-secondary" onclick={on_tag}>{ "Auto-tag" }</button>
<button class="btn btn-secondary" onclick={on_organize}>{ "Organize" }</button>

View File

@@ -180,6 +180,11 @@ pub struct TaskRef {
pub task_id: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct PipelineRef {
pub task_ids: Vec<String>,
}
// --- Status ---
#[derive(Debug, Clone, PartialEq, Deserialize)]