diff --git a/lapon-tui/src/app.rs b/lapon-tui/src/app.rs index 239c2cc..4feb304 100644 --- a/lapon-tui/src/app.rs +++ b/lapon-tui/src/app.rs @@ -4,9 +4,7 @@ use lapon_common::action::ActionMessage; use ratatui::{ buffer::Buffer, layout::{Constraint, Direction, Layout, Rect}, - style::{Style, Stylize}, - text::{Line, Text}, - widgets::{Block, Borders, Paragraph, Widget}, + widgets::{Block, Borders, List, Widget}, Frame, }; use uuid::Uuid; @@ -129,9 +127,6 @@ impl App { impl Widget for &App { fn render(self, area: Rect, buf: &mut Buffer) { - let counter_text = Text::from(vec![Line::from(vec!["This is the first task This is the first task This is the first task This is the first task".into()]) - .style(Style::default().on_gray())]); - let layout = Layout::default() .direction(Direction::Horizontal) .constraints(vec![ @@ -143,12 +138,17 @@ impl Widget for &App { if let Some(run) = self.runs.first() { run.render(layout[1], buf); + List::new(run.hosts.iter().map(|host| host.host.clone())) + .block(Block::default().borders(Borders::RIGHT)) + .render(layout[0], buf); } - Paragraph::new(counter_text.clone()) - .block(Block::default().borders(Borders::RIGHT)) - .render(layout[0], buf); - Paragraph::new(counter_text) - .block(Block::default().borders(Borders::LEFT)) - .render(layout[2], buf); + List::new( + self.runs + .iter() + .enumerate() + .map(|(i, run)| run.name.clone().unwrap_or_else(|| format!("Run {}", i + 1))), + ) + .block(Block::default().borders(Borders::LEFT)) + .render(layout[2], buf); } } diff --git a/lapon-tui/src/run.rs b/lapon-tui/src/run.rs index 54088e8..4e25181 100644 --- a/lapon-tui/src/run.rs +++ b/lapon-tui/src/run.rs @@ -14,6 +14,7 @@ use crate::reflow::{LineComposer, WordWrapper, WrappedLine}; pub struct HostSection { pub id: Uuid, + pub host: String, pub actions: Vec, pub scroll: u16, } @@ -82,12 +83,13 @@ impl ActionSection { pub struct RunPanel { pub id: Uuid, + pub name: Option, pub hosts: Vec, } impl RunPanel { - pub fn new(id: Uuid, hosts: Vec) -> Self { - Self { id, hosts } + pub fn new(id: Uuid, name: Option, hosts: Vec) -> Self { + Self { id, name, hosts } } pub fn render(&self, area: Rect, buf: &mut Buffer) { @@ -106,9 +108,10 @@ const fn get_line_offset(line_width: u16, text_area_width: u16, alignment: Align } impl HostSection { - pub fn new(id: Uuid, actions: Vec) -> Self { + pub fn new(id: Uuid, host: String, actions: Vec) -> Self { Self { id, + host, actions, scroll: 0, } diff --git a/lapon/src/run.rs b/lapon/src/run.rs index 7a466d9..1268885 100644 --- a/lapon/src/run.rs +++ b/lapon/src/run.rs @@ -156,6 +156,7 @@ impl Run { .map(|host| { HostSection::new( host.id, + host.host.clone(), self.actions .iter() .map(|action| ActionSection::new(action.id, action.name.clone())) @@ -163,6 +164,6 @@ impl Run { ) }) .collect(); - RunPanel::new(self.id, hosts) + RunPanel::new(self.id, None, hosts) } }