From c39e224d56ddc78c1b88556aee0a852ce473731b Mon Sep 17 00:00:00 2001 From: Jack Wills <32690432+mrjackwills@users.noreply.github.com> Date: Fri, 22 Jul 2022 20:54:43 +0000 Subject: [PATCH] docs: readme updated --- README.md | 13 +++++ src/app_data/mod.rs | 13 +---- src/docker_data/mod.rs | 8 ++- src/input_handler/mod.rs | 2 +- src/main.rs | 1 - src/ui/draw_blocks.rs | 109 ++++----------------------------------- 6 files changed, 31 insertions(+), 115 deletions(-) diff --git a/README.md b/README.md index c4e7f8e..2f7e4cb 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,19 @@ rm oxker_linux_x86_64.tar.gz oxker ```oxker``` +In application controls +| button| result| +|--|--| +| ```( tab )``` or ```( shift+tab )``` | Change panel (containers > controls > logs). Clicking panels also changed the selected panel| +| ```( ↑ ↓ )``` or ```( j k )``` or ```(PgUp PgDown)``` or ```(Home End)```| Change selected line in selected panel, mouse scroll also changes selected line | +| ```( enter )```| execute selected docker commands| +| ```( 1-9 )``` | sort containers by heading. Clicking on headings also sorts selected column | +| ```( 0 )``` | stop sorting | +| ```( h )``` | Show help menu - displays these options| +| ```( m )``` | toggle mouse capture - if disabled, text on screen can be selected, to be copied etc| +| ```( q )``` | to quit at any time | + + available command line arguments | argument|result| |--|--| diff --git a/src/app_data/mod.rs b/src/app_data/mod.rs index ec3fad4..ca1be83 100644 --- a/src/app_data/mod.rs +++ b/src/app_data/mod.rs @@ -1,10 +1,9 @@ use bollard::models::ContainerSummary; use core::fmt; use std::{ - collections::HashMap, time::{SystemTime, UNIX_EPOCH}, }; -use tui::{layout::Rect, widgets::ListItem}; +use tui::widgets::ListItem; mod container_state; @@ -216,16 +215,6 @@ impl AppData { .items .sort_by(|a, b| b.status.cmp(&a.status)), }, - Header::Status => match so { - SortedOrder::Asc => self - .containers - .items - .sort_by(|a, b| a.status.cmp(&b.status)), - SortedOrder::Desc => self - .containers - .items - .sort_by(|a, b| b.status.cmp(&a.status)), - }, Header::Cpu => match so { SortedOrder::Desc => self .containers diff --git a/src/docker_data/mod.rs b/src/docker_data/mod.rs index dba467d..e7ba5a5 100644 --- a/src/docker_data/mod.rs +++ b/src/docker_data/mod.rs @@ -1,6 +1,5 @@ use bollard::{ container::{ListContainersOptions, LogsOptions, StartContainerOptions, Stats, StatsOptions}, - models::ContainerSummary, Docker, }; use futures_util::{future::join_all, StreamExt}; @@ -9,7 +8,7 @@ use std::sync::Arc; use tokio::{sync::mpsc::Receiver, task::JoinHandle}; use crate::{ - app_data::{AppData, DockerControls, Header, SortedOrder}, + app_data::{AppData, DockerControls}, app_error::AppError, parse_args::CliArgs, ui::GuiState, @@ -215,6 +214,11 @@ impl DockerData { output } + // async fn stop(&self) { + // self.docker. + + // } + /// Update all logs, spawn each container into own tokio::spawn thread async fn init_all_logs(&mut self, all_ids: &[(bool, String)]) { let mut handles = vec![]; diff --git a/src/input_handler/mod.rs b/src/input_handler/mod.rs index 42ce0cf..0800991 100644 --- a/src/input_handler/mod.rs +++ b/src/input_handler/mod.rs @@ -259,7 +259,7 @@ impl InputHandler { 1, )); - /// Don't like this + // Don't like this let order = if let Some((_, or)) = self.app_data.lock().get_sorted() { match or { SortedOrder::Asc => SortedOrder::Desc, diff --git a/src/main.rs b/src/main.rs index 08b2b5f..8a5e9df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,3 @@ -#![allow(unused)] use app_data::AppData; use app_error::AppError; use bollard::Docker; diff --git a/src/ui/draw_blocks.rs b/src/ui/draw_blocks.rs index d803443..2f2f6e1 100644 --- a/src/ui/draw_blocks.rs +++ b/src/ui/draw_blocks.rs @@ -125,27 +125,6 @@ pub fn draw_containers( ) { let block = generate_block(app_data, area, gui_state, SelectablePanel::Containers); - let sorted = app_data.lock().get_sorted(); - - // if containers sorted, increase width to match headers - // let sorted_width = if app_data.lock().get_sorted().is_some() { - // 2 - // }else { - // 0 - // }; - - // Check if need to alter column width to watch the heading widths - let sorted_width = |(x, s): &(Header, usize)| { - let mut output = 0; - if let Some((h, _)) = &sorted { - if h == x { - output = 2; - } - } - // s + output - s.to_owned() - }; - let items = app_data .lock() .containers @@ -166,7 +145,7 @@ pub fn draw_containers( format!( "{:( "{}{:>width$}", MARGIN, i.status, - width = sorted_width(&widths.status) + width =&widths.status.1 ), state_style, ), @@ -184,7 +163,7 @@ pub fn draw_containers( "{}{:>width$}", MARGIN, i.cpu_stats.back().unwrap_or(&CpuStats::new(0.0)), - width = sorted_width(&widths.cpu) + width = &widths.cpu.1 ), state_style, ), @@ -193,7 +172,7 @@ pub fn draw_containers( "{}{:>width$}", MARGIN, mems, - width = sorted_width(&widths.mem) + width = &widths.mem.1 ), state_style, ), @@ -202,7 +181,7 @@ pub fn draw_containers( "{}{:>width$}", MARGIN, i.id.chars().take(8).collect::(), - width = sorted_width(&widths.id), + width = &widths.id.1 ), blue, ), @@ -211,7 +190,7 @@ pub fn draw_containers( "{}{:>width$}", MARGIN, i.name, - width = sorted_width(&widths.name) + width = widths.name.1 ), blue, ), @@ -220,7 +199,7 @@ pub fn draw_containers( "{}{:>width$}", MARGIN, i.image, - width = sorted_width(&widths.image) + width = widths.image.1 ), blue, ), @@ -229,7 +208,7 @@ pub fn draw_containers( "{}{:>width$}", MARGIN, i.net_rx, - width = sorted_width(&widths.net_rx) + width = widths.net_rx.1 ), Style::default().fg(Color::Rgb(255, 233, 193)), ), @@ -238,7 +217,7 @@ pub fn draw_containers( "{}{:>width$}", MARGIN, i.net_tx, - width = sorted_width(&widths.net_tx) + width = widths.net_tx.1 ), Style::default().fg(Color::Rgb(205, 140, 140)), ), @@ -246,74 +225,6 @@ pub fn draw_containers( ListItem::new(lines) }) .collect::>(); - - // let items = app_data - // .lock() - // .containers - // .items - // .iter() - // .map(|i| { - // let state_style = Style::default().fg(i.state.get_color()); - // let blue = Style::default().fg(Color::Blue); - - // let mems = format!( - // "{:>1} / {:>1}", - // i.mem_stats.back().unwrap_or(&ByteStats::new(0)), - // i.mem_limit - // ); - - // let lines = Spans::from(vec![ - // Span::styled( - // format!("{:width$}", MARGIN, i.status, width = widths.status.1), - // state_style, - // ), - // Span::styled( - // format!( - // "{}{:>width$}", - // MARGIN, - // i.cpu_stats.back().unwrap_or(&CpuStats::new(0.0)), - // width = widths.cpu.1 - // ), - // state_style, - // ), - // Span::styled( - // format!("{}{:>width$}", MARGIN, mems, width = widths.mem.1), - // state_style, - // ), - // Span::styled( - // format!( - // "{}{:>width$}", - // MARGIN, - // i.id.chars().take(8).collect::(), - // width = widths.id.1 - // ), - // blue, - // ), - // Span::styled( - // format!("{}{:>width$}", MARGIN, i.name, width = widths.name.1), - // blue, - // ), - // Span::styled( - // format!("{}{:>width$}", MARGIN, i.image, width = widths.image.1), - // blue, - // ), - // Span::styled( - // format!("{}{:>width$}", MARGIN, i.net_rx, width = widths.net_rx.1), - // Style::default().fg(Color::Rgb(255, 233, 193)), - // ), - // Span::styled( - // format!("{}{:>width$}", MARGIN, i.net_tx, width = widths.net_tx.1), - // Style::default().fg(Color::Rgb(205, 140, 140)), - // ), - // ]); - // ListItem::new(lines) - // }) - // .collect::>(); - if items.is_empty() { let debug_text = String::from("no containers running"); let paragraph = Paragraph::new(debug_text) @@ -488,7 +399,7 @@ pub fn draw_heading_bar( f.render_widget(block(), area); - /// Generate a bloack for the header, if the header is currently being used to sort a column, then highlight it white + // Generate a bloack for the header, if the header is currently being used to sort a column, then highlight it white let header_block = |x: &Header| { let mut color = Color::Black; let mut suffix = "";