docs: comments improved
This commit is contained in:
@@ -134,8 +134,6 @@ impl fmt::Display for State {
|
||||
}
|
||||
|
||||
/// Items for the container control list
|
||||
/// Should probably have a vec for each container
|
||||
/// so that can remove Pause if container currently Paused etc
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum DockerControls {
|
||||
Pause,
|
||||
@@ -411,6 +409,7 @@ pub struct Columns {
|
||||
}
|
||||
|
||||
impl Columns {
|
||||
//. (Column titles, minimum header string length)
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
state: (String::from("state"), 11),
|
||||
|
||||
+5
-6
@@ -99,7 +99,7 @@ impl AppData {
|
||||
self.error = Some(error);
|
||||
}
|
||||
|
||||
/// Find the if of the currently selected container.
|
||||
/// Find the id of the currently selected container.
|
||||
/// If any containers on system, will always return a string.
|
||||
/// Only returns None when no containers found.
|
||||
pub fn get_selected_container_id(&self) -> Option<String> {
|
||||
@@ -183,7 +183,7 @@ impl AppData {
|
||||
self.containers.items.len()
|
||||
}
|
||||
|
||||
/// Find the widths for the strings in the containers panel
|
||||
/// Find the widths for the strings in the containers panel.
|
||||
/// So can display nicely and evenly
|
||||
pub fn get_width(&self) -> Columns {
|
||||
let mut output = Columns::new();
|
||||
@@ -228,11 +228,9 @@ impl AppData {
|
||||
if status_count > output.status.1 {
|
||||
output.status.1 = status_count;
|
||||
};
|
||||
|
||||
if net_rx_count > output.net_rx.1 {
|
||||
output.net_rx.1 = net_rx_count;
|
||||
};
|
||||
|
||||
if net_tx_count > output.net_tx.1 {
|
||||
output.net_tx.1 = net_tx_count;
|
||||
};
|
||||
@@ -254,7 +252,7 @@ impl AppData {
|
||||
self.containers.items.iter_mut().find(|i| i.id == id)
|
||||
}
|
||||
|
||||
/// Update container mem + cpu stats, in single function so only need to call .lock() once
|
||||
/// Update container mem, cpu, & network stats, in single function so only need to call .lock() once
|
||||
pub fn update_stats(
|
||||
&mut self,
|
||||
id: String,
|
||||
@@ -318,7 +316,7 @@ impl AppData {
|
||||
.as_ref()
|
||||
.unwrap_or(&vec!["".to_owned()])
|
||||
.get(0)
|
||||
.unwrap()
|
||||
.unwrap_or(&String::from(""))
|
||||
.to_owned();
|
||||
if let Some(c) = name.chars().next() {
|
||||
if c == '/' {
|
||||
@@ -391,6 +389,7 @@ impl AppData {
|
||||
self.logs_parsed = true;
|
||||
}
|
||||
|
||||
/// Update all containers logs, should only be used on first initialisation
|
||||
pub fn update_all_logs(&mut self, all_logs: Vec<Vec<String>>) {
|
||||
for (index, output) in all_logs.into_iter().enumerate() {
|
||||
self.update_log_by_index(output, index);
|
||||
|
||||
@@ -175,8 +175,6 @@ impl InputHandler {
|
||||
}
|
||||
KeyCode::Enter => {
|
||||
// This isn't great, just means you can't send docker commands before full initialization of the program
|
||||
// could change to to if loading = true, although at the moment don't have a loading bool
|
||||
// Does is matter though?
|
||||
let panel = self.gui_state.lock().selected_panel;
|
||||
if panel == SelectablePanel::Commands {
|
||||
let option_command = self.app_data.lock().get_docker_command();
|
||||
|
||||
@@ -44,7 +44,6 @@ impl CliArgs {
|
||||
docker_interval: args.docker_interval,
|
||||
gui: !args.gui,
|
||||
raw: args.raw,
|
||||
// install: args.install,
|
||||
timestamp: !args.timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
+8
-15
@@ -456,6 +456,7 @@ pub fn draw_heading_bar<B: Backend>(
|
||||
f.render_widget(paragraph, split_bar[index]);
|
||||
}
|
||||
|
||||
/// From a given &String, return the maximum number of chars on a single line
|
||||
fn max_line_width(text: &str) -> usize {
|
||||
let mut max_line_width = 0;
|
||||
text.lines().into_iter().for_each(|line| {
|
||||
@@ -590,21 +591,14 @@ pub fn draw_error<B: Backend>(f: &mut Frame<'_, B>, error: AppError, seconds: Op
|
||||
f.render_widget(paragraph, area);
|
||||
}
|
||||
|
||||
/// Show info box in bottom right corner
|
||||
/// Draw info box in one of the 9 BoxLocations
|
||||
pub fn draw_info<B: Backend>(f: &mut Frame<'_, B>, text: String) {
|
||||
let block = Block::default()
|
||||
.title("")
|
||||
.title_alignment(Alignment::Center)
|
||||
.borders(Borders::NONE);
|
||||
|
||||
let mut max_line_width = 0;
|
||||
text.lines().into_iter().for_each(|line| {
|
||||
let width = line.chars().count();
|
||||
if width > max_line_width {
|
||||
max_line_width = width;
|
||||
}
|
||||
});
|
||||
|
||||
let mut max_line_width = max_line_width(&text);
|
||||
let mut lines = text.lines().count();
|
||||
|
||||
// Add some horizontal & vertical margins
|
||||
@@ -626,7 +620,7 @@ pub fn draw_info<B: Backend>(f: &mut Frame<'_, B>, text: String) {
|
||||
f.render_widget(paragraph, area);
|
||||
}
|
||||
|
||||
/// draw a box in the center of the screen, based on max line width + number of lines
|
||||
/// draw a box in the one of the BoxLocations, based on max line width + number of lines
|
||||
fn draw_popup(text_lines: u16, text_width: u16, r: Rect, box_location: BoxLocation) -> Rect {
|
||||
// Make sure blank_space can't be an negative, as will crash
|
||||
let blank_vertical = if r.height > text_lines {
|
||||
@@ -640,19 +634,18 @@ fn draw_popup(text_lines: u16, text_width: u16, r: Rect, box_location: BoxLocati
|
||||
1
|
||||
};
|
||||
|
||||
let vertical_constraints = box_location.get_vertical_constraints(blank_vertical, text_lines);
|
||||
let horizontal_constraints =
|
||||
box_location.get_horizontal_constraints(blank_horizontal, text_width);
|
||||
let v_constraints = box_location.get_vertical_constraints(blank_vertical, text_lines);
|
||||
let h_constraints = box_location.get_horizontal_constraints(blank_horizontal, text_width);
|
||||
|
||||
let indexes = box_location.get_indexes();
|
||||
|
||||
let popup_layout = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints(vertical_constraints)
|
||||
.constraints(v_constraints)
|
||||
.split(r);
|
||||
|
||||
Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints(horizontal_constraints)
|
||||
.constraints(h_constraints)
|
||||
.split(popup_layout[indexes.0])[indexes.1]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user