diff --git a/CHANGELOG.md b/CHANGELOG.md index c90a51e..cceaf3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### Chores ++ dependencies updated, [cf7e02dde94f69832a2e485b99785afc66a5bc15] + +### Features ++ Enable sorting of containers by every heading, via keyboard or mouse, closes [#3], [a6c296f2cde56cf241bcd696cab8bd477270e5f4] ++ Spawn & track docker information update requests, multiple identical requests cannot be executed, [740c059b276f35acd1cb03f1030134646bf8a07d] + # v0.0.6 ### 2022-07-06 diff --git a/README.md b/README.md index ccbe399..09b1fd8 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@

-## Download & install +## Download & install See releases @@ -54,7 +54,7 @@ In application controls available command line arguments | argument|result| |--|--| -|```-d [number > 0]```| set the update interval for docker information, in ms, defaults to 1000 (1 second) | +|```-d [number > 0]```| set the minimum update interval for docker information, in ms, defaults to 1000 (1 second) | |```-r```| Show raw logs, by default oxker will remove ANSI formatting (conflicts with -c) | |```-c```| Attempt to color the logs (conflicts with -r) | |```-t```| Remove timestamps from each log entry | diff --git a/src/app_data/container_state.rs b/src/app_data/container_state.rs index 4195e7f..4dbb32b 100644 --- a/src/app_data/container_state.rs +++ b/src/app_data/container_state.rs @@ -10,7 +10,6 @@ use super::Header; #[derive(Debug, Clone)] pub struct StatefulList { pub state: ListState, - // todo BTreeMap pub items: Vec, } diff --git a/src/ui/draw_blocks.rs b/src/ui/draw_blocks.rs index f9f5c75..565881e 100644 --- a/src/ui/draw_blocks.rs +++ b/src/ui/draw_blocks.rs @@ -20,7 +20,7 @@ use crate::{ app_error::AppError, }; -use super::gui_state::BoxLocation; +use super::gui_state::{BoxLocation, Region}; use super::{GuiState, SelectablePanel}; const NAME_TEXT: &str = r#" @@ -48,7 +48,7 @@ fn generate_block<'a>( gui_state: &Arc>, panel: SelectablePanel, ) -> Block<'a> { - gui_state.lock().insert_into_panel_map(panel, area); + gui_state.lock().update_map(Region::Panel(panel), area); let mut block = Block::default() .borders(Borders::ALL) .border_type(BorderType::Rounded); @@ -473,10 +473,11 @@ pub fn draw_heading_bar( // draw the actual header blocks for (index, (paragraph, header, _)) in header_data.into_iter().enumerate() { + let rect = headers_section[index]; gui_state .lock() - .insert_into_header_map(header, headers_section[index]); - f.render_widget(paragraph, headers_section[index]); + .update_map(Region::Header(header), rect); + f.render_widget(paragraph, rect); } } diff --git a/src/ui/gui_state.rs b/src/ui/gui_state.rs index ab40371..d95515e 100644 --- a/src/ui/gui_state.rs +++ b/src/ui/gui_state.rs @@ -10,6 +10,12 @@ pub enum SelectablePanel { Logs, } + +pub enum Region { + Panel(SelectablePanel), + Header(Header) +} + #[allow(unused)] #[derive(Debug, Clone, Copy)] pub enum BoxLocation { @@ -39,7 +45,7 @@ impl BoxLocation { } } - // Should combine and just return a tupple? + // Should combine and just return a tuple? pub fn get_horizontal_constraints( &self, blank_vertical: u16, @@ -177,7 +183,6 @@ pub struct GuiState { pub show_help: bool, pub info_box_text: Option, } - impl GuiState { /// Generate a default gui_state pub fn default() -> Self { @@ -220,18 +225,13 @@ impl GuiState { .map(|data| data.0.to_owned()) } - /// Insert selectable gui panel into area map - /// Remove each time, as terminal may have been resized! - pub fn insert_into_panel_map(&mut self, panel: SelectablePanel, area: Rect) { - self.panel_map.remove(&panel); - self.panel_map.insert(panel, area); - } - - /// Insert selectable gui panel into area map - /// Remove each time, as terminal may have been resized! - pub fn insert_into_header_map(&mut self, header: Header, area: Rect) { - self.heading_map.remove(&header); - self.heading_map.insert(header, area); + /// Insert, or updatem header area panel into heading_map + pub fn update_map(&mut self, region: Region, area: Rect) { + match region { + Region::Header(header) => + self.heading_map.entry(header).and_modify(|w|*w =area).or_insert(area), + Region::Panel(panel) => self.panel_map.entry(panel).and_modify(|w|*w =area).or_insert(area), + }; } /// Change to next selectable panel