31 lines
1.1 KiB
Rust
31 lines
1.1 KiB
Rust
use yew::prelude::*;
|
|
use crate::types::ProcessStatus;
|
|
|
|
#[derive(Properties, PartialEq)]
|
|
pub struct StatusBadgeProps {
|
|
pub status: ProcessStatus,
|
|
#[prop_or_default]
|
|
pub size: Option<String>,
|
|
}
|
|
|
|
#[function_component(StatusBadge)]
|
|
pub fn status_badge(props: &StatusBadgeProps) -> Html {
|
|
let (badge_class, icon, text) = match props.status {
|
|
ProcessStatus::Running => ("badge bg-success", "bi-play-circle-fill", "Running"),
|
|
ProcessStatus::Stopped => ("badge bg-danger", "bi-stop-circle-fill", "Stopped"),
|
|
ProcessStatus::Starting => ("badge bg-warning", "bi-hourglass-split", "Starting"),
|
|
ProcessStatus::Stopping => ("badge bg-warning", "bi-hourglass-split", "Stopping"),
|
|
ProcessStatus::Failed => ("badge bg-danger", "bi-exclamation-triangle-fill", "Failed"),
|
|
ProcessStatus::Unknown => ("badge bg-secondary", "bi-question-circle-fill", "Unknown"),
|
|
};
|
|
|
|
let size_class = props.size.as_deref().unwrap_or("");
|
|
|
|
html! {
|
|
<span class={format!("{} {}", badge_class, size_class)}>
|
|
<i class={format!("{} me-1", icon)}></i>
|
|
{text}
|
|
</span>
|
|
}
|
|
}
|