This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use harmony::{
|
||||
instrumentation::{self, HarmonyEvent},
|
||||
modules::application::ApplicationFeatureStatus,
|
||||
topology::TopologyStatus,
|
||||
};
|
||||
use indicatif::MultiProgress;
|
||||
@@ -160,6 +161,35 @@ async fn handle_events(base_progress: MultiProgress) {
|
||||
}
|
||||
}
|
||||
}
|
||||
HarmonyEvent::ApplicationFeatureStateChanged {
|
||||
topology: _,
|
||||
application,
|
||||
feature,
|
||||
status,
|
||||
} => {
|
||||
if let Some(score) = &(*current_score) {
|
||||
let section_key = score_key(score);
|
||||
let task_key = app_feature_key(&application, &feature);
|
||||
|
||||
match status {
|
||||
ApplicationFeatureStatus::Installing => {
|
||||
let message = format!("Feature '{}' installing...", feature);
|
||||
progress_tracker.add_task(§ion_key, &task_key, &message);
|
||||
}
|
||||
ApplicationFeatureStatus::Installed => {
|
||||
let message = format!("Feature '{}' installed", feature);
|
||||
progress_tracker.finish_task(&task_key, &message);
|
||||
}
|
||||
ApplicationFeatureStatus::Failed { details } => {
|
||||
let message = format!(
|
||||
"Feature '{}' installation failed: {}",
|
||||
feature, details
|
||||
);
|
||||
progress_tracker.fail_task(&task_key, &message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
@@ -175,3 +205,7 @@ fn topology_key(topology: &str) -> String {
|
||||
fn score_key(score: &str) -> String {
|
||||
format!("score-{score}")
|
||||
}
|
||||
|
||||
fn app_feature_key(application: &str, feature: &str) -> String {
|
||||
format!("app-{application}-{feature}")
|
||||
}
|
||||
|
||||
@@ -33,29 +33,13 @@ pub struct IndicatifProgressTracker {
|
||||
|
||||
impl IndicatifProgressTracker {
|
||||
pub fn new(base: MultiProgress) -> Self {
|
||||
// The indicatif log bridge will insert a progress bar at the top.
|
||||
// To prevent our first section from being erased, we need to create
|
||||
// a dummy progress bar as our first progress bar.
|
||||
let _ = base.clear();
|
||||
let log_pb = base.add(ProgressBar::new(1));
|
||||
|
||||
let mut sections = HashMap::new();
|
||||
sections.insert(
|
||||
"__log__".into(),
|
||||
Section {
|
||||
header_index: 0,
|
||||
task_count: 0,
|
||||
pb: log_pb.clone(),
|
||||
},
|
||||
);
|
||||
|
||||
let mut tasks = HashMap::new();
|
||||
tasks.insert("__log__".into(), log_pb);
|
||||
let sections = HashMap::new();
|
||||
let tasks = HashMap::new();
|
||||
|
||||
let state = Arc::new(Mutex::new(IndicatifProgressTrackerState {
|
||||
sections,
|
||||
tasks,
|
||||
pb_count: 1,
|
||||
pb_count: 0,
|
||||
}));
|
||||
|
||||
Self { mp: base, state }
|
||||
|
||||
@@ -21,10 +21,14 @@ lazy_static! {
|
||||
pub static ref SUCCESS_SPINNER_STYLE: ProgressStyle = SPINNER_STYLE
|
||||
.clone()
|
||||
.tick_strings(&[format!("{}", EMOJI_SUCCESS).as_str()]);
|
||||
pub static ref SKIP_SPINNER_STYLE: ProgressStyle = SPINNER_STYLE
|
||||
pub static ref SKIP_SPINNER_STYLE: ProgressStyle = ProgressStyle::default_spinner()
|
||||
.template(" {spinner:.orange} {wide_msg}")
|
||||
.unwrap()
|
||||
.clone()
|
||||
.tick_strings(&[format!("{}", EMOJI_SKIP).as_str()]);
|
||||
pub static ref ERROR_SPINNER_STYLE: ProgressStyle = SPINNER_STYLE
|
||||
pub static ref ERROR_SPINNER_STYLE: ProgressStyle = ProgressStyle::default_spinner()
|
||||
.template(" {spinner:.red} {wide_msg}")
|
||||
.unwrap()
|
||||
.clone()
|
||||
.tick_strings(&[format!("{}", EMOJI_ERROR).as_str()]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user