-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tui): display individual tracing flows in Tui (#777) - WIP
- Loading branch information
1 parent
9223c8b
commit 8424854
Showing
16 changed files
with
230 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use crate::frontend::tui_app::TuiApp; | ||
use ratatui::layout::{Alignment, Rect}; | ||
use ratatui::prelude::Color; | ||
use ratatui::style::{Modifier, Style}; | ||
use ratatui::text::Line; | ||
use ratatui::widgets::{Bar, BarChart, BarGroup, Block, BorderType, Borders}; | ||
use ratatui::Frame; | ||
|
||
/// Render the flows. | ||
pub fn render(f: &mut Frame<'_>, rect: Rect, app: &TuiApp) { | ||
let round_flow_id = app.tracer_data().round_flow_id(); | ||
let data: Vec<_> = app | ||
.flow_counts | ||
.iter() | ||
.map(|(flow_id, count)| { | ||
let (bar_fg, bg, fg) = if flow_id == &app.selected_flow && flow_id == &round_flow_id { | ||
( | ||
Color::Green, | ||
app.tui_config.theme.frequency_chart_bar_color, | ||
Color::Green, | ||
) | ||
} else if flow_id == &app.selected_flow { | ||
( | ||
Color::Green, | ||
app.tui_config.theme.frequency_chart_bar_color, | ||
app.tui_config.theme.frequency_chart_text_color, | ||
) | ||
} else if flow_id == &round_flow_id { | ||
(Color::DarkGray, Color::DarkGray, Color::Green) | ||
} else { | ||
(Color::DarkGray, Color::DarkGray, Color::White) | ||
}; | ||
Bar::default() | ||
.label(Line::from(format!("{flow_id}"))) | ||
.value(*count as u64) | ||
.style(Style::default().fg(bar_fg)) | ||
.value_style(Style::default().bg(bg).fg(fg).add_modifier(Modifier::BOLD)) | ||
}) | ||
.collect(); | ||
let block = Block::default() | ||
.title("Flows") | ||
.title_alignment(Alignment::Left) | ||
.borders(Borders::ALL) | ||
.border_type(BorderType::Rounded) | ||
.border_style(Style::default().fg(app.tui_config.theme.border_color)) | ||
.style( | ||
Style::default() | ||
.bg(app.tui_config.theme.bg_color) | ||
.fg(app.tui_config.theme.text_color), | ||
); | ||
let group = BarGroup::default().bars(&data); | ||
let flow_counts = BarChart::default() | ||
.block(block) | ||
.data(group) | ||
.bar_width(4) | ||
.bar_gap(1); | ||
f.render_widget(flow_counts, rect); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.