Refactor task sections

Still very much WIP
This commit is contained in:
2Shirt 2025-05-20 19:24:19 -07:00
parent 7b0deb4cc7
commit a2f61e310f
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
5 changed files with 26 additions and 33 deletions

View file

@ -236,7 +236,7 @@ impl App {
// Late init // Late init
self.system32 = if cfg!(windows) { self.system32 = if cfg!(windows) {
if let Ok(path) = env::var("SYSTEMROOT") { if let Ok(path) = env::var("SYSTEMROOT") {
format!("{path}/System32") format!("{path}\\System32")
} else { } else {
self.action_tx.send(Action::Error(String::from( self.action_tx.send(Action::Error(String::from(
"ERROR\n\n\nFailed to find SYSTEMROOT", "ERROR\n\n\nFailed to find SYSTEMROOT",
@ -400,32 +400,21 @@ impl App {
self.action_tx.send(build_right_items(self))?; self.action_tx.send(build_right_items(self))?;
self.action_tx.send(Action::Select(None, None))?; self.action_tx.send(Action::Select(None, None))?;
} }
Action::TaskStart(ref task_type) => { Action::TaskStart(ref title) => {
if self.cur_mode == Mode::BootScan { if self.cur_mode == Mode::BootScan {
let title: Option<String> = match task_type { info!("TaskGroup: {:?}", self.task_groups.front());
TaskType::CommandWait(cmd, _args) => { if self.task_groups.front().is_some() {
let cmd_str = cmd.to_string_lossy().into_owned(); if self.task_groups.front().unwrap().is_some() {
let diag_type = diags::get_type(&cmd_str); // None here means that we're in the middle of a group of tasks
Some(format!("{diag_type}")) // i.e. don't start a new diag line
} self.action_tx.send(Action::DiagStartLine {
TaskType::TestPaths(_) => Some(String::from("Critical Paths")), text: title.clone(),
_ => None, })?;
};
if let Some(title) = title {
info!("{:?}", self.task_groups.front());
if self.task_groups.front().is_some() {
if self.task_groups.front().unwrap().is_some() {
// None here means that we're in the middle of a group of tasks
// i.e. don't start a new diag line
self.action_tx.send(Action::DiagStartLine {
text: title.clone(),
})?;
}
}
if !self.diag_groups.contains(&title) {
self.diag_groups.update(title, None, None);
} }
} }
if !self.diag_groups.contains(&title) {
self.diag_groups.update(title.to_owned(), None, None);
}
} }
} }
Action::TasksComplete => { Action::TasksComplete => {
@ -534,12 +523,12 @@ impl App {
if passed { if passed {
self.action_tx.send(Action::DiagEndLine { self.action_tx.send(Action::DiagEndLine {
result: DiagResult::Pass, result: DiagResult::Pass,
text: String::from("Maybe?"), text: String::from("Pass?"),
})?; })?;
} else { } else {
self.action_tx.send(Action::DiagEndLine { self.action_tx.send(Action::DiagEndLine {
result: DiagResult::Fail, result: DiagResult::Fail,
text: String::from("Nope?"), text: String::from("Fail?"),
})?; })?;
}; };
} }
@ -548,14 +537,14 @@ impl App {
// If title was set but there wasn't a result // If title was set but there wasn't a result
self.action_tx.send(Action::DiagEndLine { self.action_tx.send(Action::DiagEndLine {
result: DiagResult::Warn, result: DiagResult::Warn,
text: String::from("Yellow result?"), text: String::from("Yellow no result?"),
})?; })?;
} }
} else { } else {
// title was not set // title was not set
self.action_tx.send(Action::DiagEndLine { self.action_tx.send(Action::DiagEndLine {
result: DiagResult::Warn, result: DiagResult::Warn,
text: String::from("Yellow title?"), text: String::from("Yellow no title?"),
})?; })?;
} }
} }
@ -910,6 +899,7 @@ fn build_left_items(app: &App) -> Action {
let (new_title, _) = get_mode_strings(app.cur_mode); let (new_title, _) = get_mode_strings(app.cur_mode);
title = new_title; title = new_title;
app.diag_groups.get().iter().for_each(|group| { app.diag_groups.get().iter().for_each(|group| {
info!("BootDiags Group: {:?}", group);
items.push(if group.passed { items.push(if group.passed {
group.title.clone() group.title.clone()
} else { } else {

View file

@ -85,7 +85,10 @@ impl Component for Progress {
}); });
} }
Action::DiagEndLine { result, text } => { Action::DiagEndLine { result, text } => {
info!("Caught Action::DiagEndLine"); info!(
"Caught Action::DiagEndLine {{ {}, \"{}\" }}",
&result, &text
);
if let Some(line) = self.lines.last_mut() { if let Some(line) = self.lines.last_mut() {
line.result = result; line.result = result;
line.text = text; line.text = text;

View file

@ -79,7 +79,7 @@ impl Groups {
title.clone(), title.clone(),
Line { Line {
title, title,
passed: passed.unwrap_or(false), passed: passed.unwrap_or(true),
info: info_list, info: info_list,
}, },
); );

View file

@ -44,7 +44,7 @@ pub enum Action {
ScanDisks, ScanDisks,
Select(Option<usize>, Option<usize>), // indicies for (source, dest) etc Select(Option<usize>, Option<usize>), // indicies for (source, dest) etc
SelectRight(Option<usize>, Option<usize>), // indicies for right info pane SelectRight(Option<usize>, Option<usize>), // indicies for right info pane
TaskStart(TaskType), TaskStart(String),
TasksComplete, TasksComplete,
UpdateDiskList(Vec<Disk>), UpdateDiskList(Vec<Disk>),
UpdateFooter(String), UpdateFooter(String),

View file

@ -173,8 +173,6 @@ impl Tasks {
self.cur_task = self.task_list.pop_front(); self.cur_task = self.task_list.pop_front();
if let Some(task) = self.cur_task.take() { if let Some(task) = self.cur_task.take() {
let task_tx = self.task_tx.clone(); let task_tx = self.task_tx.clone();
self.action_tx
.send(Action::TaskStart(task.task_type.clone()))?;
match task.task_type { match task.task_type {
TaskType::CommandNoWait(ref cmd_path, ref cmd_args) => { TaskType::CommandNoWait(ref cmd_path, ref cmd_args) => {
self.cur_handle = None; self.cur_handle = None;
@ -186,6 +184,8 @@ impl Tasks {
cmd_args.clone(), cmd_args.clone(),
task_tx, task_tx,
)); ));
self.action_tx
.send(Action::TaskStart(cmd_path.to_string_lossy().into_owned()))?;
} }
TaskType::Diskpart(ref script) => { TaskType::Diskpart(ref script) => {
self.cur_handle = Some(run_task_diskpart(script, task_tx)); self.cur_handle = Some(run_task_diskpart(script, task_tx));