working profiler tree

This commit is contained in:
filipriec
2025-03-21 22:20:43 +01:00
parent d55dff8a3e
commit 911dba9bce
5 changed files with 70 additions and 10 deletions

View File

@@ -7,6 +7,8 @@ use ratatui::{
Frame,
};
use crate::config::colors::Theme;
use common::proto::multieko2::table_definition::{ProfileTreeResponse, profile_tree_response::Profile};
use ratatui::text::{Span, Line};
const SIDEBAR_WIDTH: u16 = 16;
@@ -25,15 +27,42 @@ pub fn calculate_sidebar_layout(show_sidebar: bool, main_content_area: Rect) ->
}
}
pub fn render_sidebar(f: &mut Frame, area: Rect, theme: &Theme) {
pub fn render_sidebar(f: &mut Frame, area: Rect, theme: &Theme, profile_tree: &ProfileTreeResponse) {
let sidebar_block = Block::default()
.style(Style::default().bg(theme.bg));
let items = vec![
ListItem::new(Text::from(" Navigation ")),
ListItem::new(Text::from(" Search ")),
ListItem::new(Text::from(" Settings ")),
];
let mut items = Vec::new();
for profile in &profile_tree.profiles {
// Profile header
items.push(ListItem::new(Line::from(vec![
Span::styled("📁 ", Style::default().fg(theme.accent)),
Span::styled(&profile.name, Style::default().fg(theme.highlight)),
])));
// Profile tables
for (table_idx, table) in profile.tables.iter().enumerate() {
let is_last_table = table_idx == profile.tables.len() - 1;
let tree_prefix = if is_last_table { "└─ " } else { "├─ " };
// Table name
items.push(ListItem::new(Line::from(vec![
Span::styled(format!(" {}", tree_prefix), Style::default().fg(theme.fg)),
Span::styled(&table.name, Style::default().fg(theme.fg)),
])));
// Dependencies
if !table.depends_on.is_empty() {
let dep_prefix = if is_last_table { " " } else { "" };
let deps = table.depends_on.join(", ");
items.push(ListItem::new(Line::from(vec![
Span::styled(format!(" {} └─ ", dep_prefix), Style::default().fg(theme.secondary)),
Span::styled(format!("{}", deps), Style::default().fg(theme.secondary)),
])));
}
}
}
let list = List::new(items)
.block(sidebar_block)