Skip to content

Commit

Permalink
Render events page
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest committed Dec 22, 2023
1 parent dea64be commit 36f8199
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions src/app/dashboard/tab_pallets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use ratatui::{
style::Stylize,
widgets::*,
};
use scale_info::TypeDef;
// this crate
use super::DashBoard;
use crate::{handler::print_storage_type, networks::ChainInfo};
Expand Down Expand Up @@ -109,11 +110,48 @@ fn render_pallet_events_page<CI: ChainInfo>(f: &mut Frame, dash_board: &mut Dash
.title_style(Style::default().bold().italic())
.borders(Borders::ALL)
.border_type(BorderType::Double)
.padding(Padding::horizontal(2))
.style(Style::default().fg(Color::Yellow));

let text = "Events Page".to_string();
let paragraph = Paragraph::new(text).block(block_style).wrap(Wrap { trim: true });
f.render_widget(paragraph, area);
if let Some((id, name)) = dash_board.selected_pallet.clone() {
let pallet = dash_board.metadata.pallets().find(|p| p.name() == name && p.index() == id);
if let Some(pallet) = pallet {
let event_type = pallet.event_ty_id();
if let Some(event_type) = event_type {
let events = dash_board.metadata.types().resolve(event_type);
if let Some(t) = events {
let enums: Vec<ListItem> = match &t.type_def {
TypeDef::Variant(def_variant) => def_variant
.variants
.iter()
.map(|v| {
ListItem::new(vec![Line::from(Span::styled(
format!("> {}{}", t.path, v.name.to_string()),
Style::default().fg(Color::Yellow),
))])
})
.collect(),
_ => {
vec![]
},
};

if enums.len() != 0 {
let l = List::new(enums).block(block_style);
f.render_widget(l, area);
} else {
let text = "None".to_string();
let paragraph = Paragraph::new(text).block(block_style).wrap(Wrap { trim: true });
f.render_widget(paragraph, area);
}
}
} else {
let text = "None".to_string();
let paragraph = Paragraph::new(text).block(block_style).wrap(Wrap { trim: true });
f.render_widget(paragraph, area)
}
}
}
}
fn render_pallet_errors_page<CI: ChainInfo>(f: &mut Frame, dash_board: &mut DashBoard<CI>, area: Rect) {
let block_style = Block::default()
Expand Down

0 comments on commit 36f8199

Please sign in to comment.