docs: comments improved
This commit is contained in:
@@ -134,8 +134,6 @@ impl fmt::Display for State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Items for the container control list
|
/// 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)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum DockerControls {
|
pub enum DockerControls {
|
||||||
Pause,
|
Pause,
|
||||||
@@ -411,6 +409,7 @@ pub struct Columns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Columns {
|
impl Columns {
|
||||||
|
//. (Column titles, minimum header string length)
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
state: (String::from("state"), 11),
|
state: (String::from("state"), 11),
|
||||||
|
|||||||
+5
-6
@@ -99,7 +99,7 @@ impl AppData {
|
|||||||
self.error = Some(error);
|
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.
|
/// If any containers on system, will always return a string.
|
||||||
/// Only returns None when no containers found.
|
/// Only returns None when no containers found.
|
||||||
pub fn get_selected_container_id(&self) -> Option<String> {
|
pub fn get_selected_container_id(&self) -> Option<String> {
|
||||||
@@ -183,7 +183,7 @@ impl AppData {
|
|||||||
self.containers.items.len()
|
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
|
/// So can display nicely and evenly
|
||||||
pub fn get_width(&self) -> Columns {
|
pub fn get_width(&self) -> Columns {
|
||||||
let mut output = Columns::new();
|
let mut output = Columns::new();
|
||||||
@@ -228,11 +228,9 @@ impl AppData {
|
|||||||
if status_count > output.status.1 {
|
if status_count > output.status.1 {
|
||||||
output.status.1 = status_count;
|
output.status.1 = status_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
if net_rx_count > output.net_rx.1 {
|
if net_rx_count > output.net_rx.1 {
|
||||||
output.net_rx.1 = net_rx_count;
|
output.net_rx.1 = net_rx_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
if net_tx_count > output.net_tx.1 {
|
if net_tx_count > output.net_tx.1 {
|
||||||
output.net_tx.1 = net_tx_count;
|
output.net_tx.1 = net_tx_count;
|
||||||
};
|
};
|
||||||
@@ -254,7 +252,7 @@ impl AppData {
|
|||||||
self.containers.items.iter_mut().find(|i| i.id == id)
|
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(
|
pub fn update_stats(
|
||||||
&mut self,
|
&mut self,
|
||||||
id: String,
|
id: String,
|
||||||
@@ -318,7 +316,7 @@ impl AppData {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap_or(&vec!["".to_owned()])
|
.unwrap_or(&vec!["".to_owned()])
|
||||||
.get(0)
|
.get(0)
|
||||||
.unwrap()
|
.unwrap_or(&String::from(""))
|
||||||
.to_owned();
|
.to_owned();
|
||||||
if let Some(c) = name.chars().next() {
|
if let Some(c) = name.chars().next() {
|
||||||
if c == '/' {
|
if c == '/' {
|
||||||
@@ -391,6 +389,7 @@ impl AppData {
|
|||||||
self.logs_parsed = true;
|
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>>) {
|
pub fn update_all_logs(&mut self, all_logs: Vec<Vec<String>>) {
|
||||||
for (index, output) in all_logs.into_iter().enumerate() {
|
for (index, output) in all_logs.into_iter().enumerate() {
|
||||||
self.update_log_by_index(output, index);
|
self.update_log_by_index(output, index);
|
||||||
|
|||||||
@@ -175,8 +175,6 @@ impl InputHandler {
|
|||||||
}
|
}
|
||||||
KeyCode::Enter => {
|
KeyCode::Enter => {
|
||||||
// This isn't great, just means you can't send docker commands before full initialization of the program
|
// 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;
|
let panel = self.gui_state.lock().selected_panel;
|
||||||
if panel == SelectablePanel::Commands {
|
if panel == SelectablePanel::Commands {
|
||||||
let option_command = self.app_data.lock().get_docker_command();
|
let option_command = self.app_data.lock().get_docker_command();
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ impl CliArgs {
|
|||||||
docker_interval: args.docker_interval,
|
docker_interval: args.docker_interval,
|
||||||
gui: !args.gui,
|
gui: !args.gui,
|
||||||
raw: args.raw,
|
raw: args.raw,
|
||||||
// install: args.install,
|
|
||||||
timestamp: !args.timestamp,
|
timestamp: !args.timestamp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-15
@@ -456,6 +456,7 @@ pub fn draw_heading_bar<B: Backend>(
|
|||||||
f.render_widget(paragraph, split_bar[index]);
|
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 {
|
fn max_line_width(text: &str) -> usize {
|
||||||
let mut max_line_width = 0;
|
let mut max_line_width = 0;
|
||||||
text.lines().into_iter().for_each(|line| {
|
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);
|
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) {
|
pub fn draw_info<B: Backend>(f: &mut Frame<'_, B>, text: String) {
|
||||||
let block = Block::default()
|
let block = Block::default()
|
||||||
.title("")
|
.title("")
|
||||||
.title_alignment(Alignment::Center)
|
.title_alignment(Alignment::Center)
|
||||||
.borders(Borders::NONE);
|
.borders(Borders::NONE);
|
||||||
|
|
||||||
let mut max_line_width = 0;
|
let mut max_line_width = max_line_width(&text);
|
||||||
text.lines().into_iter().for_each(|line| {
|
|
||||||
let width = line.chars().count();
|
|
||||||
if width > max_line_width {
|
|
||||||
max_line_width = width;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut lines = text.lines().count();
|
let mut lines = text.lines().count();
|
||||||
|
|
||||||
// Add some horizontal & vertical margins
|
// 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);
|
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 {
|
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
|
// Make sure blank_space can't be an negative, as will crash
|
||||||
let blank_vertical = if r.height > text_lines {
|
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
|
1
|
||||||
};
|
};
|
||||||
|
|
||||||
let vertical_constraints = box_location.get_vertical_constraints(blank_vertical, text_lines);
|
let v_constraints = box_location.get_vertical_constraints(blank_vertical, text_lines);
|
||||||
let horizontal_constraints =
|
let h_constraints = box_location.get_horizontal_constraints(blank_horizontal, text_width);
|
||||||
box_location.get_horizontal_constraints(blank_horizontal, text_width);
|
|
||||||
|
|
||||||
let indexes = box_location.get_indexes();
|
let indexes = box_location.get_indexes();
|
||||||
|
|
||||||
let popup_layout = Layout::default()
|
let popup_layout = Layout::default()
|
||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
.constraints(vertical_constraints)
|
.constraints(v_constraints)
|
||||||
.split(r);
|
.split(r);
|
||||||
|
|
||||||
Layout::default()
|
Layout::default()
|
||||||
.direction(Direction::Horizontal)
|
.direction(Direction::Horizontal)
|
||||||
.constraints(horizontal_constraints)
|
.constraints(h_constraints)
|
||||||
.split(popup_layout[indexes.0])[indexes.1]
|
.split(popup_layout[indexes.0])[indexes.1]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user