feat: change log panel size, closes #50
This commit is contained in:
+32
-25
@@ -14,7 +14,7 @@ use crate::{
|
||||
ENTRY_POINT,
|
||||
app_error::AppError,
|
||||
config::Config,
|
||||
ui::{GuiState, Redraw, Status, log_sanitizer},
|
||||
ui::{GuiState, Rerender, Status, log_sanitizer},
|
||||
};
|
||||
pub use container_state::*;
|
||||
|
||||
@@ -122,7 +122,7 @@ pub struct AppData {
|
||||
error: Option<AppError>,
|
||||
filter: Filter,
|
||||
hidden_containers: Vec<ContainerItem>,
|
||||
redraw: Arc<Redraw>,
|
||||
redraw: Arc<Rerender>,
|
||||
sorted_by: Option<(Header, SortedOrder)>,
|
||||
current_sorted_id: Vec<ContainerId>,
|
||||
pub config: Config,
|
||||
@@ -137,13 +137,13 @@ pub struct AppData {
|
||||
pub filter: Filter,
|
||||
pub hidden_containers: Vec<ContainerItem>,
|
||||
pub current_sorted_id: Vec<ContainerId>,
|
||||
pub redraw: Arc<Redraw>,
|
||||
pub redraw: Arc<Rerender>,
|
||||
pub sorted_by: Option<(Header, SortedOrder)>,
|
||||
}
|
||||
|
||||
impl AppData {
|
||||
/// Generate a default app_state
|
||||
pub fn new(config: Config, redraw: &Arc<Redraw>) -> Self {
|
||||
pub fn new(config: Config, redraw: &Arc<Rerender>) -> Self {
|
||||
Self {
|
||||
config,
|
||||
containers: StatefulList::new(vec![]),
|
||||
@@ -192,7 +192,7 @@ impl AppData {
|
||||
/// sets the state to start if any filtering has occurred
|
||||
/// Also search in the "hidden" vec for items and insert back into the main containers vec
|
||||
fn filter_containers(&mut self) {
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
let pre_len = self.get_container_len();
|
||||
|
||||
if !self.hidden_containers.is_empty() {
|
||||
@@ -296,7 +296,7 @@ impl AppData {
|
||||
/// Remove the sorted header & order, and sort by default - created datetime
|
||||
pub fn reset_sorted(&mut self) {
|
||||
self.set_sorted(None);
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
|
||||
/// Sort containers based on a given header, if headings match, and already ascending, remove sorting
|
||||
@@ -392,7 +392,7 @@ impl AppData {
|
||||
|
||||
self.containers.items.sort_by(sort_closure);
|
||||
if pre_order != self.get_current_ids() {
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
} else if self.current_sorted_id != self.get_current_ids() {
|
||||
self.containers.items.sort_by(|a, b| {
|
||||
@@ -400,13 +400,20 @@ impl AppData {
|
||||
.cmp(&b.created)
|
||||
.then_with(|| a.name.get().cmp(b.name.get()))
|
||||
});
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
self.current_sorted_id = self.get_current_ids();
|
||||
}
|
||||
}
|
||||
|
||||
/// Container state methods
|
||||
/// Get the total number of none "hidden" containers
|
||||
// TODO remove this once zigbuild uses Rust v1.87.0
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn get_container_len(&self) -> usize {
|
||||
self.containers.items.len()
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub const fn get_container_len(&self) -> usize {
|
||||
self.containers.items.len()
|
||||
}
|
||||
@@ -439,25 +446,25 @@ impl AppData {
|
||||
/// Select the first container
|
||||
pub fn containers_start(&mut self) {
|
||||
self.containers.start();
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
|
||||
/// select the last container
|
||||
pub fn containers_end(&mut self) {
|
||||
self.containers.end();
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
|
||||
/// Select the next container
|
||||
pub fn containers_next(&mut self) {
|
||||
self.containers.next();
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
|
||||
/// select the previous container
|
||||
pub fn containers_previous(&mut self) {
|
||||
self.containers.previous();
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
|
||||
/// Get ListState of containers
|
||||
@@ -579,7 +586,7 @@ impl AppData {
|
||||
pub fn docker_controls_next(&mut self) {
|
||||
if let Some(i) = self.get_mut_selected_container() {
|
||||
i.docker_controls.next();
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -587,7 +594,7 @@ impl AppData {
|
||||
pub fn docker_controls_previous(&mut self) {
|
||||
if let Some(i) = self.get_mut_selected_container() {
|
||||
i.docker_controls.previous();
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -595,7 +602,7 @@ impl AppData {
|
||||
pub fn docker_controls_start(&mut self) {
|
||||
if let Some(i) = self.get_mut_selected_container() {
|
||||
i.docker_controls.start();
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,7 +610,7 @@ impl AppData {
|
||||
pub fn docker_controls_end(&mut self) {
|
||||
if let Some(i) = self.get_mut_selected_container() {
|
||||
i.docker_controls.end();
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -641,7 +648,7 @@ impl AppData {
|
||||
pub fn log_next(&mut self) {
|
||||
if let Some(i) = self.get_mut_selected_container() {
|
||||
i.logs.next();
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -649,7 +656,7 @@ impl AppData {
|
||||
pub fn log_previous(&mut self) {
|
||||
if let Some(i) = self.get_mut_selected_container() {
|
||||
i.logs.previous();
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -657,7 +664,7 @@ impl AppData {
|
||||
pub fn log_end(&mut self) {
|
||||
if let Some(i) = self.get_mut_selected_container() {
|
||||
i.logs.end();
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -665,7 +672,7 @@ impl AppData {
|
||||
pub fn log_start(&mut self) {
|
||||
if let Some(i) = self.get_mut_selected_container() {
|
||||
i.logs.start();
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -706,14 +713,14 @@ impl AppData {
|
||||
/// Remove single app_state error
|
||||
pub fn remove_error(&mut self) {
|
||||
self.error = None;
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
|
||||
/// Insert single app_state error
|
||||
pub fn set_error(&mut self, error: AppError, gui_state: &Arc<Mutex<GuiState>>, status: Status) {
|
||||
gui_state.lock().status_push(status);
|
||||
self.error = Some(error);
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
|
||||
/// Check if the selected container is a dockerised version of oxker
|
||||
@@ -803,7 +810,7 @@ impl AppData {
|
||||
container.mem_limit.update(mem_limit);
|
||||
}
|
||||
if self.is_selected_container(id) {
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
self.sort_containers();
|
||||
}
|
||||
@@ -841,7 +848,7 @@ impl AppData {
|
||||
if self.containers.items.get(index).is_some() {
|
||||
self.containers.items.remove(index);
|
||||
if self.is_selected_container(id) {
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -971,7 +978,7 @@ impl AppData {
|
||||
}
|
||||
}
|
||||
if self.is_selected_container(id) {
|
||||
self.redraw.set_true();
|
||||
self.redraw.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user