|
|
@@ -16,79 +16,67 @@ pub fn ui<B: Backend>(f: &mut Frame<'_, B>, mut view: View) {
|
|
|
let list_cnstrnts = vec![Constraint::Percentage(50), Constraint::Percentage(50)];
|
|
|
|
|
|
let mut nodes = Vec::new();
|
|
|
+ let style = Style::default();
|
|
|
|
|
|
for id in &view.id_list.node_id {
|
|
|
- let mut msgs = Vec::new();
|
|
|
- let mut lines = vec![Spans::from(id.to_string())];
|
|
|
+ let id_span = Span::raw(id.to_string());
|
|
|
+ let mut lines = vec![Spans::from(id_span)];
|
|
|
match &view.info_list.infos.get(id) {
|
|
|
Some(node) => {
|
|
|
- //data.push(id.to_string());
|
|
|
for outbound in &node.outbound.clone() {
|
|
|
- lines.push(Spans::from(Span::styled("Outgoing", Style::default())));
|
|
|
- //data.push("Outgoing".to_string());
|
|
|
+ lines.push(Spans::from(Span::styled(" Outgoing", style)));
|
|
|
for slot in outbound.slots.clone() {
|
|
|
- if slot.addr.as_str() == "Empty" {
|
|
|
- msgs.push(Spans::from(format!("{}", slot.addr.as_str())));
|
|
|
- //data.push("Empty".to_string());
|
|
|
+ lines.push(Spans::from(Span::styled(
|
|
|
+ format!(" {}", slot.addr),
|
|
|
+ style,
|
|
|
+ )));
|
|
|
+ if slot.channel.last_status.as_str() != "Null" {
|
|
|
+ let msg: Span = match slot.channel.last_status.as_str() {
|
|
|
+ "recv" => {
|
|
|
+ Span::styled(format!("[R: {}]", slot.channel.last_msg), style)
|
|
|
+ }
|
|
|
+ "sent" => {
|
|
|
+ Span::styled(format!("[S: {}]", slot.channel.last_msg), style)
|
|
|
+ }
|
|
|
+ a => Span::styled(format!("{}", a), style),
|
|
|
+ };
|
|
|
} else {
|
|
|
- msgs.push(Spans::from(format!("{}", slot.addr)));
|
|
|
- //data.push(format!("{}", slot.addr));
|
|
|
- }
|
|
|
- match slot.channel.last_status.as_str() {
|
|
|
- "recv" => {
|
|
|
- msgs.push(Spans::from(format!("[R: {}]", slot.channel.last_msg)));
|
|
|
- //data.push(format!("{}", slot.channel.last_msg));
|
|
|
- }
|
|
|
- "sent" => {
|
|
|
- msgs.push(Spans::from(format!("[S: {}]", slot.channel.last_msg)));
|
|
|
- //data.push(format!("{}", slot.channel.last_msg));
|
|
|
- }
|
|
|
- "Null" => {
|
|
|
- //data.push("Null".to_string());
|
|
|
- }
|
|
|
- _ => {
|
|
|
- // TODO
|
|
|
- debug!("This is a bug");
|
|
|
- }
|
|
|
+ // TODO
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
for connect in &node.inbound {
|
|
|
- lines.push(Spans::from(Span::styled("Incoming", Style::default())));
|
|
|
- //lines.push("Incoming".to_string());
|
|
|
- lines.push(Spans::from(connect.connected.clone()));
|
|
|
- //data.push(connect.connected.clone());
|
|
|
+ lines.push(Spans::from(Span::styled(" Incoming", Style::default())));
|
|
|
+ lines.push(Spans::from(Span::styled(
|
|
|
+ format!(" {}", connect.connected),
|
|
|
+ style,
|
|
|
+ )));
|
|
|
|
|
|
- match connect.channel.last_status.as_str() {
|
|
|
- "recv" => {
|
|
|
- msgs.push(Spans::from(format!("[R: {}]", connect.channel.last_msg)));
|
|
|
- //data.push(format!("[R: {}]", connect.channel.last_msg));
|
|
|
- }
|
|
|
- "sent" => {
|
|
|
- msgs.push(Spans::from(format!("[S: {}]", connect.channel.last_msg)));
|
|
|
- //data.push(format!("[S: {}]", connect.channel.last_msg));
|
|
|
- }
|
|
|
- "Null" => {
|
|
|
- //data.push("Null".to_string());
|
|
|
- }
|
|
|
- _ => {
|
|
|
- // TODO
|
|
|
- debug!("This is a bug");
|
|
|
- }
|
|
|
- }
|
|
|
+ if connect.channel.last_status.as_str() != "Null" {
|
|
|
+ let msg: Span = match connect.channel.last_status.as_str() {
|
|
|
+ "recv" => {
|
|
|
+ Span::styled(format!("[R: {}]", connect.channel.last_msg), style)
|
|
|
+ }
|
|
|
+ "sent" => {
|
|
|
+ Span::styled(format!("[R: {}]", connect.channel.last_msg), style)
|
|
|
+ }
|
|
|
+ a => Span::styled(format!("{}", a), style),
|
|
|
+ };
|
|
|
+ };
|
|
|
}
|
|
|
for connect in &node.manual {
|
|
|
- lines.push(Spans::from(Span::styled("Manual", Style::default())));
|
|
|
- lines.push(Spans::from(format!("{}", connect.key)));
|
|
|
+ lines.push(Spans::from(Span::styled(" Manual", Style::default())));
|
|
|
+ lines.push(Spans::from(Span::styled(format!(" {}", connect.key), style)));
|
|
|
}
|
|
|
}
|
|
|
None => {
|
|
|
- debug!("NONE VALUE TRIGGERD");
|
|
|
- // TODO: Error
|
|
|
+ // TODO
|
|
|
+ debug!("This is also a bug");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
let ids = ListItem::new(lines);
|
|
|
- nodes.push(ids)
|
|
|
+ nodes.push(ids);
|
|
|
}
|
|
|
|
|
|
let nodes =
|
|
|
@@ -100,6 +88,10 @@ pub fn ui<B: Backend>(f: &mut Frame<'_, B>, mut view: View) {
|
|
|
.split(f.size());
|
|
|
|
|
|
f.render_stateful_widget(nodes, slice[0], &mut view.id_list.state);
|
|
|
+
|
|
|
+ //let msgs = Paragraph::new(msgs).style(Style::default()).alignment(Alignment::Right);
|
|
|
+ //f.render_widget(msgs, slice[0]);
|
|
|
+
|
|
|
//render_info_right(view.clone(), f, slice);
|
|
|
}
|
|
|
|