terminal ui fixes
This commit is contained in:
parent
69e612e521
commit
337ec2f660
@ -10,7 +10,7 @@ use crossterm::{
|
||||
execute,
|
||||
};
|
||||
use hero_job::{Job, JobStatus, ScriptType};
|
||||
use log::error;
|
||||
|
||||
use ratatui::{
|
||||
backend::{Backend, CrosstermBackend},
|
||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||
@ -215,9 +215,7 @@ impl App {
|
||||
};
|
||||
|
||||
if let Some(dir) = example_dir {
|
||||
if let Err(e) = app.load_examples_tree(dir) {
|
||||
error!("Failed to load examples tree: {}", e);
|
||||
}
|
||||
let _ = app.load_examples_tree(dir);
|
||||
}
|
||||
|
||||
Ok(app)
|
||||
@ -292,40 +290,6 @@ impl App {
|
||||
Ok(nodes)
|
||||
}
|
||||
|
||||
fn load_flat_examples(&mut self, dir: &PathBuf) -> Result<()> {
|
||||
let mut examples = Vec::new();
|
||||
self.collect_all_rhai_files(&mut examples, dir)?;
|
||||
self.examples = examples;
|
||||
|
||||
if !self.examples.is_empty() {
|
||||
self.example_list_state.select(Some(0));
|
||||
if self.selected_example.is_none() {
|
||||
self.selected_example = Some(self.examples[0].clone());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn collect_all_rhai_files(&self, examples: &mut Vec<ExampleScript>, dir: &PathBuf) -> Result<()> {
|
||||
for entry in fs::read_dir(dir)? {
|
||||
let entry = entry?;
|
||||
let path = entry.path();
|
||||
|
||||
if path.is_dir() {
|
||||
self.collect_all_rhai_files(examples, &path)?;
|
||||
} else if path.extension().map_or(false, |ext| ext == "rhai") {
|
||||
if let Some(name) = path.file_stem().and_then(|s| s.to_str()) {
|
||||
examples.push(ExampleScript {
|
||||
name: name.to_string(),
|
||||
path,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn rebuild_tree_items(&mut self) {
|
||||
self.example_tree_items.clear();
|
||||
let mut index = 0;
|
||||
@ -733,9 +697,7 @@ impl App {
|
||||
/// Setup terminal and run the TUI application
|
||||
pub async fn setup_and_run_tui(mut app: App) -> Result<()> {
|
||||
// Initial job refresh
|
||||
if let Err(e) = app.refresh_jobs().await {
|
||||
error!("Failed to refresh jobs: {}", e);
|
||||
}
|
||||
let _ = app.refresh_jobs().await;
|
||||
|
||||
// Setup terminal
|
||||
enable_raw_mode()?;
|
||||
|
Loading…
Reference in New Issue
Block a user