libsurfer/transactions.rs
1use egui::{Layout, RichText};
2use egui_extras::{Column, TableBuilder};
3use emath::Align;
4
5use crate::SystemState;
6
7impl SystemState {
8 pub fn draw_focused_transaction_details(&self, ui: &mut egui::Ui) {
9 ui.with_layout(
10 Layout::top_down(Align::LEFT).with_cross_justify(true),
11 |ui| {
12 ui.label("Focused Transaction Details");
13 let column_width = ui.available_width() / 2.;
14 TableBuilder::new(ui)
15 .column(Column::exact(column_width))
16 .column(Column::auto())
17 .header(20.0, |mut header| {
18 header.col(|ui| {
19 ui.heading("Properties");
20 });
21 })
22 .body(|mut body| {
23 let focused_transaction = self
24 .user
25 .waves
26 .as_ref()
27 .unwrap()
28 .focused_transaction
29 .1
30 .as_ref()
31 .unwrap();
32 let row_height = 15.;
33 body.row(row_height, |mut row| {
34 row.col(|ui| {
35 ui.label("Transaction ID");
36 });
37 row.col(|ui| {
38 ui.label(focused_transaction.get_tx_id().to_string());
39 });
40 });
41 body.row(row_height, |mut row| {
42 row.col(|ui| {
43 ui.label("Type");
44 });
45 row.col(|ui| {
46 let gen = self
47 .user
48 .waves
49 .as_ref()
50 .unwrap()
51 .inner
52 .as_transactions()
53 .unwrap()
54 .get_generator(focused_transaction.get_gen_id())
55 .unwrap();
56 ui.label(gen.name.to_string());
57 });
58 });
59 body.row(row_height, |mut row| {
60 row.col(|ui| {
61 ui.label("Start Time");
62 });
63 row.col(|ui| {
64 ui.label(focused_transaction.get_start_time().to_string());
65 });
66 });
67 body.row(row_height, |mut row| {
68 row.col(|ui| {
69 ui.label("End Time");
70 });
71 row.col(|ui| {
72 ui.label(focused_transaction.get_end_time().to_string());
73 });
74 });
75 body.row(row_height + 5., |mut row| {
76 row.col(|ui| {
77 ui.heading("Attributes");
78 });
79 });
80
81 body.row(row_height + 3., |mut row| {
82 row.col(|ui| {
83 ui.label(RichText::new("Name").size(15.));
84 });
85 row.col(|ui| {
86 ui.label(RichText::new("Value").size(15.));
87 });
88 });
89
90 for attr in &focused_transaction.attributes {
91 body.row(row_height, |mut row| {
92 row.col(|ui| {
93 ui.label(attr.name.to_string());
94 });
95 row.col(|ui| {
96 ui.label(attr.value().to_string());
97 });
98 });
99 }
100
101 if !focused_transaction.inc_relations.is_empty() {
102 body.row(row_height + 5., |mut row| {
103 row.col(|ui| {
104 ui.heading("Incoming Relations");
105 });
106 });
107
108 body.row(row_height + 3., |mut row| {
109 row.col(|ui| {
110 ui.label(RichText::new("Source Tx").size(15.));
111 });
112 row.col(|ui| {
113 ui.label(RichText::new("Sink Tx").size(15.));
114 });
115 });
116
117 for rel in &focused_transaction.inc_relations {
118 body.row(row_height, |mut row| {
119 row.col(|ui| {
120 ui.label(rel.source_tx_id.to_string());
121 });
122 row.col(|ui| {
123 ui.label(rel.sink_tx_id.to_string());
124 });
125 });
126 }
127 }
128
129 if !focused_transaction.out_relations.is_empty() {
130 body.row(row_height + 5., |mut row| {
131 row.col(|ui| {
132 ui.heading("Outgoing Relations");
133 });
134 });
135
136 body.row(row_height + 3., |mut row| {
137 row.col(|ui| {
138 ui.label(RichText::new("Source Tx").size(15.));
139 });
140 row.col(|ui| {
141 ui.label(RichText::new("Sink Tx").size(15.));
142 });
143 });
144
145 for rel in &focused_transaction.out_relations {
146 body.row(row_height, |mut row| {
147 row.col(|ui| {
148 ui.label(rel.source_tx_id.to_string());
149 });
150 row.col(|ui| {
151 ui.label(rel.sink_tx_id.to_string());
152 });
153 });
154 }
155 }
156 });
157 },
158 );
159 }
160}