mcai_workflow/components/
step_jobs_progress.rs1use css_in_rust_next::Style;
2use mcai_models::JobsStatus;
3use yew::{html, Component, Context, Html, Properties};
4
5#[derive(PartialEq, Properties)]
6pub struct StepJobsProgressProperties {
7 pub title: Option<String>,
8 pub expanded: bool,
9 pub jobs_status: JobsStatus,
10}
11
12pub struct StepJobsProgress {
13 style: Style,
14}
15
16impl Component for StepJobsProgress {
17 type Message = ();
18 type Properties = StepJobsProgressProperties;
19
20 fn create(_ctx: &Context<Self>) -> Self {
21 let style = Style::create("Component", include_str!("step_jobs_progress.css")).unwrap();
22
23 StepJobsProgress { style }
24 }
25
26 fn view(&self, ctx: &Context<Self>) -> Html {
27 let classes = ctx.props().expanded.then(|| "extended").unwrap_or_default();
28 let inner = ctx
29 .props()
30 .expanded
31 .then(|| ctx.props().title.clone().unwrap_or_default())
32 .unwrap_or_default();
33
34 html!(
35 <slot class={self.style.clone()}>
36 <span class={format!("step {}", classes)}>
37 <span class="progress completed" style={format!("flex: {}", ctx.props().jobs_status.completed)}></span>
38 <span class="progress processing" style={format!("flex: {}", ctx.props().jobs_status.processing)}></span>
39 <span class="progress queued" style={format!("flex: {}", ctx.props().jobs_status.queued)}></span>
40 <span class="progress stopped" style={format!("flex: {}", ctx.props().jobs_status.stopped)}></span>
41 <span class="progress skipped" style={format!("flex: {}", ctx.props().jobs_status.skipped)}></span>
42 <span class="progress error" style={format!("flex: {}", ctx.props().jobs_status.errors)}></span>
43 <span class="title">{inner}</span>
44 </span>
45 </slot>
46 )
47 }
48}