fixed some unwatch cleanup stuff

This commit is contained in:
Connor Johnstone
2026-03-24 20:41:13 -04:00
parent 45a7dcd8cd
commit 7b14ed593f
6 changed files with 142 additions and 84 deletions

View File

@@ -34,6 +34,8 @@ pub fn dashboard() -> Html {
let status = use_state(|| None::<Status>);
let error = use_state(|| None::<String>);
let message = use_state(|| None::<String>);
let pipeline_was_active = use_state(|| false);
let pipeline_complete = use_state(|| false);
// Fetch status function
let fetch_status = {
@@ -280,6 +282,72 @@ pub fn dashboard() -> Html {
})
};
let pipeline_progress_html = if let Some(ref wq) = s.work_queue {
let active = wq.download.pending
+ wq.download.running
+ wq.index.pending
+ wq.index.running
+ wq.tag.pending
+ wq.tag.running
+ wq.organize.pending
+ wq.organize.running
+ wq.enrich.pending
+ wq.enrich.running;
// Track pipeline active→inactive transition
if active > 0 {
if !*pipeline_was_active {
pipeline_was_active.set(true);
pipeline_complete.set(false);
}
} else if *pipeline_was_active {
pipeline_was_active.set(false);
pipeline_complete.set(true);
}
if active > 0 {
html! {
<div class="card">
<h3>{ "Pipeline Progress" }</h3>
<table>
<thead>
<tr><th>{ "Step" }</th><th>{ "Pending" }</th><th>{ "Running" }</th><th>{ "Done" }</th><th>{ "Failed" }</th></tr>
</thead>
<tbody>
{ for [("Download", &wq.download), ("Index", &wq.index), ("Tag", &wq.tag), ("Organize", &wq.organize), ("Enrich", &wq.enrich)].iter().map(|(name, c)| {
html! {
<tr>
<td>{ name }</td>
<td>{ c.pending }</td>
<td>{ if c.running > 0 { html! { <span class="badge badge-accent">{ c.running }</span> } } else { html! { { "0" } } } }</td>
<td>{ c.completed }</td>
<td>{ if c.failed > 0 { html! { <span class="badge badge-danger">{ c.failed }</span> } } else { html! { { "0" } } } }</td>
</tr>
}
})}
</tbody>
</table>
</div>
}
} else if *pipeline_complete {
html! {
<div class="card" style="border-color: var(--success);">
<p style="color: var(--success);">{ "Pipeline run complete!" }</p>
</div>
}
} else {
html! {}
}
} else if *pipeline_complete {
html! {
<div class="card" style="border-color: var(--success);">
<p style="color: var(--success);">{ "Pipeline run complete!" }</p>
</div>
}
} else {
html! {}
};
let scheduled_jobs_html = {
let next_pipeline = s
.scheduled
@@ -410,33 +478,7 @@ pub fn dashboard() -> Html {
</div>
// Work Queue Progress
if let Some(ref wq) = s.work_queue {
if wq.download.pending + wq.download.running + wq.tag.pending + wq.tag.running + wq.organize.pending + wq.organize.running > 0
|| wq.download.completed + wq.tag.completed + wq.organize.completed > 0
{
<div class="card">
<h3>{ "Pipeline Progress" }</h3>
<table>
<thead>
<tr><th>{ "Step" }</th><th>{ "Pending" }</th><th>{ "Running" }</th><th>{ "Done" }</th><th>{ "Failed" }</th></tr>
</thead>
<tbody>
{ for [("Download", &wq.download), ("Index", &wq.index), ("Tag", &wq.tag), ("Organize", &wq.organize)].iter().map(|(name, c)| {
html! {
<tr>
<td>{ name }</td>
<td>{ c.pending }</td>
<td>{ if c.running > 0 { html! { <span class="badge badge-accent">{ c.running }</span> } } else { html! { { "0" } } } }</td>
<td>{ c.completed }</td>
<td>{ if c.failed > 0 { html! { <span class="badge badge-danger">{ c.failed }</span> } } else { html! { { "0" } } } }</td>
</tr>
}
})}
</tbody>
</table>
</div>
}
}
{ pipeline_progress_html }
// Scheduled Jobs (always visible)
{ scheduled_jobs_html }

View File

@@ -88,8 +88,8 @@ pub fn library_page() -> Html {
<span style="color: var(--success);" title="Monitored">{ "\u{2713}" }</span>
}
</td>
<td>
if a.total_items > 0 {
if a.enriched {
<td>
<span class="text-sm" style={
if a.total_owned >= a.total_watched && a.total_watched > 0 { "color: var(--success);" }
else if a.total_owned > 0 { "color: var(--warning);" }
@@ -97,20 +97,22 @@ pub fn library_page() -> Html {
}>
{ format!("{}/{}", a.total_owned, a.total_watched) }
</span>
}
</td>
<td>
if a.total_items > 0 {
</td>
<td>
<span class="text-sm" style={
if a.total_watched > 0 { "color: var(--accent);" }
else { "color: var(--text-muted);" }
}>
{ format!("{}/{}", a.total_watched, a.total_items) }
</span>
}
</td>
</td>
} else {
<td colspan="2" class="text-sm text-muted loading">
{ "Awaiting artist enrichment..." }
</td>
}
<td class="text-muted text-sm">
if a.total_items > 0 {
if a.enriched && a.total_items > 0 {
{ a.total_items }
}
</td>

View File

@@ -30,6 +30,8 @@ pub struct ArtistListItem {
pub musicbrainz_id: Option<String>,
#[serde(default)]
pub monitored: bool,
#[serde(default)]
pub enriched: bool,
pub total_watched: usize,
pub total_owned: usize,
pub total_items: usize,
@@ -265,7 +267,7 @@ pub struct ScheduledTasks {
pub next_monitor: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]
#[derive(Debug, Clone, PartialEq, Default, Deserialize)]
pub struct WorkQueueCounts {
pub pending: u64,
pub running: u64,
@@ -279,6 +281,8 @@ pub struct WorkQueueStats {
pub index: WorkQueueCounts,
pub tag: WorkQueueCounts,
pub organize: WorkQueueCounts,
#[serde(default)]
pub enrich: WorkQueueCounts,
}
#[derive(Debug, Clone, PartialEq, Deserialize)]