mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-31 01:24:31 +02:00
Fix issue with network legend, by moving it down.
This commit is contained in:
parent
e5749234a2
commit
4e6e32a0ea
@ -115,8 +115,7 @@ impl App {
|
|||||||
if self.awaiting_second_char && self.second_char == 'd' {
|
if self.awaiting_second_char && self.second_char == 'd' {
|
||||||
self.awaiting_second_char = false;
|
self.awaiting_second_char = false;
|
||||||
self.second_char = ' ';
|
self.second_char = ' ';
|
||||||
// TODO: Redo this in DD rewrite!
|
self.kill_highlighted_process().unwrap_or(()); // TODO: Return error to user? We have a dialog box...
|
||||||
self.kill_highlighted_process().unwrap_or(());
|
|
||||||
} else {
|
} else {
|
||||||
self.awaiting_second_char = true;
|
self.awaiting_second_char = true;
|
||||||
self.second_char = 'd';
|
self.second_char = 'd';
|
||||||
|
@ -202,8 +202,6 @@ pub fn draw_data<B: backend::Backend>(terminal: &mut Terminal<B>, app_state: &mu
|
|||||||
&app_state,
|
&app_state,
|
||||||
&canvas_data.network_data_rx,
|
&canvas_data.network_data_rx,
|
||||||
&canvas_data.network_data_tx,
|
&canvas_data.network_data_tx,
|
||||||
canvas_data.rx_display.clone(),
|
|
||||||
canvas_data.tx_display.clone(),
|
|
||||||
if cfg!(not(target_os = "windows")) {
|
if cfg!(not(target_os = "windows")) {
|
||||||
network_chunk[0]
|
network_chunk[0]
|
||||||
} else {
|
} else {
|
||||||
@ -215,6 +213,8 @@ pub fn draw_data<B: backend::Backend>(terminal: &mut Terminal<B>, app_state: &mu
|
|||||||
draw_network_labels(
|
draw_network_labels(
|
||||||
&mut f,
|
&mut f,
|
||||||
app_state,
|
app_state,
|
||||||
|
canvas_data.rx_display.clone(),
|
||||||
|
canvas_data.tx_display.clone(),
|
||||||
canvas_data.total_rx_display.clone(),
|
canvas_data.total_rx_display.clone(),
|
||||||
canvas_data.total_tx_display.clone(),
|
canvas_data.total_tx_display.clone(),
|
||||||
network_chunk[1],
|
network_chunk[1],
|
||||||
@ -377,8 +377,7 @@ fn draw_memory_graph<B: backend::Backend>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn draw_network_graph<B: backend::Backend>(
|
fn draw_network_graph<B: backend::Backend>(
|
||||||
f: &mut Frame<B>, app_state: &app::App, network_data_rx: &[(f64, f64)], network_data_tx: &[(f64, f64)], rx_display: String, tx_display: String,
|
f: &mut Frame<B>, app_state: &app::App, network_data_rx: &[(f64, f64)], network_data_tx: &[(f64, f64)], draw_loc: Rect,
|
||||||
draw_loc: Rect,
|
|
||||||
) {
|
) {
|
||||||
let x_axis: Axis<String> = Axis::default().style(Style::default().fg(GRAPH_COLOUR)).bounds([0.0, 600_000.0]);
|
let x_axis: Axis<String> = Axis::default().style(Style::default().fg(GRAPH_COLOUR)).bounds([0.0, 600_000.0]);
|
||||||
let y_axis = Axis::default()
|
let y_axis = Axis::default()
|
||||||
@ -399,12 +398,10 @@ fn draw_network_graph<B: backend::Backend>(
|
|||||||
.y_axis(y_axis)
|
.y_axis(y_axis)
|
||||||
.datasets(&[
|
.datasets(&[
|
||||||
Dataset::default()
|
Dataset::default()
|
||||||
.name(&(rx_display))
|
|
||||||
.marker(if app_state.use_dot { Marker::Dot } else { Marker::Braille })
|
.marker(if app_state.use_dot { Marker::Dot } else { Marker::Braille })
|
||||||
.style(Style::default().fg(COLOUR_LIST[0]))
|
.style(Style::default().fg(COLOUR_LIST[0]))
|
||||||
.data(&network_data_rx),
|
.data(&network_data_rx),
|
||||||
Dataset::default()
|
Dataset::default()
|
||||||
.name(&(tx_display))
|
|
||||||
.marker(if app_state.use_dot { Marker::Dot } else { Marker::Braille })
|
.marker(if app_state.use_dot { Marker::Dot } else { Marker::Braille })
|
||||||
.style(Style::default().fg(COLOUR_LIST[1]))
|
.style(Style::default().fg(COLOUR_LIST[1]))
|
||||||
.data(&network_data_tx),
|
.data(&network_data_tx),
|
||||||
@ -413,23 +410,29 @@ fn draw_network_graph<B: backend::Backend>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn draw_network_labels<B: backend::Backend>(
|
fn draw_network_labels<B: backend::Backend>(
|
||||||
f: &mut Frame<B>, app_state: &mut app::App, total_rx_display: String, total_tx_display: String, draw_loc: Rect,
|
f: &mut Frame<B>, app_state: &mut app::App, rx_display: String, tx_display: String, total_rx_display: String, total_tx_display: String,
|
||||||
|
draw_loc: Rect,
|
||||||
) {
|
) {
|
||||||
// Gross but I need it to work...
|
// Gross but I need it to work...
|
||||||
let total_network = vec![vec![total_rx_display, total_tx_display]];
|
let total_network = vec![vec![rx_display, tx_display, total_rx_display, total_tx_display]];
|
||||||
let mapped_network = total_network.iter().map(|val| Row::Data(val.iter()));
|
let mapped_network = total_network.iter().map(|val| Row::Data(val.iter()));
|
||||||
|
|
||||||
Table::new(["Total RX", "Total TX"].iter(), mapped_network)
|
Table::new(["RX", "TX", "Total RX", "Total TX"].iter(), mapped_network)
|
||||||
.block(
|
.block(
|
||||||
Block::default()
|
Block::default()
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.border_style(match app_state.current_application_position {
|
.border_style(match app_state.current_application_position {
|
||||||
app::ApplicationPosition::Temp => *CANVAS_HIGHLIGHTED_BORDER_STYLE,
|
app::ApplicationPosition::Network => *CANVAS_HIGHLIGHTED_BORDER_STYLE,
|
||||||
_ => *CANVAS_BORDER_STYLE,
|
_ => *CANVAS_BORDER_STYLE,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.header_style(Style::default().fg(Color::LightBlue))
|
.header_style(Style::default().fg(Color::LightBlue))
|
||||||
.widths(&[Constraint::Percentage(50), Constraint::Percentage(50)])
|
.widths(&[
|
||||||
|
Constraint::Percentage(25),
|
||||||
|
Constraint::Percentage(25),
|
||||||
|
Constraint::Percentage(25),
|
||||||
|
Constraint::Percentage(25),
|
||||||
|
])
|
||||||
.render(f, draw_loc);
|
.render(f, draw_loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,23 +279,23 @@ pub fn convert_network_data_points(network_data: &[data_collection::network::Net
|
|||||||
let tx_converted_result: (f64, String);
|
let tx_converted_result: (f64, String);
|
||||||
|
|
||||||
if let Some(last_num_bytes_entry) = network_data.last() {
|
if let Some(last_num_bytes_entry) = network_data.last() {
|
||||||
rx_converted_result = get_exact_byte_values(last_num_bytes_entry.rx, true);
|
rx_converted_result = get_exact_byte_values(last_num_bytes_entry.rx, false);
|
||||||
total_rx_converted_result = get_exact_byte_values(last_num_bytes_entry.total_rx, false)
|
total_rx_converted_result = get_exact_byte_values(last_num_bytes_entry.total_rx, false)
|
||||||
} else {
|
} else {
|
||||||
rx_converted_result = get_exact_byte_values(0, true);
|
rx_converted_result = get_exact_byte_values(0, false);
|
||||||
total_rx_converted_result = get_exact_byte_values(0, false);
|
total_rx_converted_result = get_exact_byte_values(0, false);
|
||||||
}
|
}
|
||||||
let rx_display = format!("RX: {:5.*}{}", 1, rx_converted_result.0, rx_converted_result.1);
|
let rx_display = format!("{:.*}{}", 1, rx_converted_result.0, rx_converted_result.1);
|
||||||
let total_rx_display = format!("{:.*}{}", 1, total_rx_converted_result.0, total_rx_converted_result.1);
|
let total_rx_display = format!("{:.*}{}", 1, total_rx_converted_result.0, total_rx_converted_result.1);
|
||||||
|
|
||||||
if let Some(last_num_bytes_entry) = network_data.last() {
|
if let Some(last_num_bytes_entry) = network_data.last() {
|
||||||
tx_converted_result = get_exact_byte_values(last_num_bytes_entry.tx, true);
|
tx_converted_result = get_exact_byte_values(last_num_bytes_entry.tx, false);
|
||||||
total_tx_converted_result = get_exact_byte_values(last_num_bytes_entry.total_tx, false);
|
total_tx_converted_result = get_exact_byte_values(last_num_bytes_entry.total_tx, false);
|
||||||
} else {
|
} else {
|
||||||
tx_converted_result = get_exact_byte_values(0, true);
|
tx_converted_result = get_exact_byte_values(0, false);
|
||||||
total_tx_converted_result = get_exact_byte_values(0, false);
|
total_tx_converted_result = get_exact_byte_values(0, false);
|
||||||
}
|
}
|
||||||
let tx_display = format!("TX: {:5.*}{}", 1, tx_converted_result.0, tx_converted_result.1);
|
let tx_display = format!("{:.*}{}", 1, tx_converted_result.0, tx_converted_result.1);
|
||||||
let total_tx_display = format!("{:.*}{}", 1, total_tx_converted_result.0, total_tx_converted_result.1);
|
let total_tx_display = format!("{:.*}{}", 1, total_tx_converted_result.0, total_tx_converted_result.1);
|
||||||
|
|
||||||
ConvertedNetworkData {
|
ConvertedNetworkData {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user