Refactor task sections
Still very much WIP
This commit is contained in:
parent
7b0deb4cc7
commit
a2f61e310f
5 changed files with 26 additions and 33 deletions
|
|
@ -236,7 +236,7 @@ impl App {
|
|||
// Late init
|
||||
self.system32 = if cfg!(windows) {
|
||||
if let Ok(path) = env::var("SYSTEMROOT") {
|
||||
format!("{path}/System32")
|
||||
format!("{path}\\System32")
|
||||
} else {
|
||||
self.action_tx.send(Action::Error(String::from(
|
||||
"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(Action::Select(None, None))?;
|
||||
}
|
||||
Action::TaskStart(ref task_type) => {
|
||||
Action::TaskStart(ref title) => {
|
||||
if self.cur_mode == Mode::BootScan {
|
||||
let title: Option<String> = match task_type {
|
||||
TaskType::CommandWait(cmd, _args) => {
|
||||
let cmd_str = cmd.to_string_lossy().into_owned();
|
||||
let diag_type = diags::get_type(&cmd_str);
|
||||
Some(format!("{diag_type}"))
|
||||
}
|
||||
TaskType::TestPaths(_) => Some(String::from("Critical Paths")),
|
||||
_ => 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);
|
||||
info!("TaskGroup: {:?}", 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.to_owned(), None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
Action::TasksComplete => {
|
||||
|
|
@ -534,12 +523,12 @@ impl App {
|
|||
if passed {
|
||||
self.action_tx.send(Action::DiagEndLine {
|
||||
result: DiagResult::Pass,
|
||||
text: String::from("Maybe?"),
|
||||
text: String::from("Pass?"),
|
||||
})?;
|
||||
} else {
|
||||
self.action_tx.send(Action::DiagEndLine {
|
||||
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
|
||||
self.action_tx.send(Action::DiagEndLine {
|
||||
result: DiagResult::Warn,
|
||||
text: String::from("Yellow result?"),
|
||||
text: String::from("Yellow no result?"),
|
||||
})?;
|
||||
}
|
||||
} else {
|
||||
// title was not set
|
||||
self.action_tx.send(Action::DiagEndLine {
|
||||
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);
|
||||
title = new_title;
|
||||
app.diag_groups.get().iter().for_each(|group| {
|
||||
info!("BootDiags Group: {:?}", group);
|
||||
items.push(if group.passed {
|
||||
group.title.clone()
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,10 @@ impl Component for Progress {
|
|||
});
|
||||
}
|
||||
Action::DiagEndLine { result, text } => {
|
||||
info!("Caught Action::DiagEndLine");
|
||||
info!(
|
||||
"Caught Action::DiagEndLine {{ {}, \"{}\" }}",
|
||||
&result, &text
|
||||
);
|
||||
if let Some(line) = self.lines.last_mut() {
|
||||
line.result = result;
|
||||
line.text = text;
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ impl Groups {
|
|||
title.clone(),
|
||||
Line {
|
||||
title,
|
||||
passed: passed.unwrap_or(false),
|
||||
passed: passed.unwrap_or(true),
|
||||
info: info_list,
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ pub enum Action {
|
|||
ScanDisks,
|
||||
Select(Option<usize>, Option<usize>), // indicies for (source, dest) etc
|
||||
SelectRight(Option<usize>, Option<usize>), // indicies for right info pane
|
||||
TaskStart(TaskType),
|
||||
TaskStart(String),
|
||||
TasksComplete,
|
||||
UpdateDiskList(Vec<Disk>),
|
||||
UpdateFooter(String),
|
||||
|
|
|
|||
|
|
@ -173,8 +173,6 @@ impl Tasks {
|
|||
self.cur_task = self.task_list.pop_front();
|
||||
if let Some(task) = self.cur_task.take() {
|
||||
let task_tx = self.task_tx.clone();
|
||||
self.action_tx
|
||||
.send(Action::TaskStart(task.task_type.clone()))?;
|
||||
match task.task_type {
|
||||
TaskType::CommandNoWait(ref cmd_path, ref cmd_args) => {
|
||||
self.cur_handle = None;
|
||||
|
|
@ -186,6 +184,8 @@ impl Tasks {
|
|||
cmd_args.clone(),
|
||||
task_tx,
|
||||
));
|
||||
self.action_tx
|
||||
.send(Action::TaskStart(cmd_path.to_string_lossy().into_owned()))?;
|
||||
}
|
||||
TaskType::Diskpart(ref script) => {
|
||||
self.cur_handle = Some(run_task_diskpart(script, task_tx));
|
||||
|
|
|
|||
Loading…
Reference in a new issue