feat: update Rust edition to 2024
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "oxker"
|
name = "oxker"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
authors = ["Jack Wills <email@mrjackwills.com>"]
|
authors = ["Jack Wills <email@mrjackwills.com>"]
|
||||||
description = "A simple tui to view & control docker containers"
|
description = "A simple tui to view & control docker containers"
|
||||||
repository = "https://github.com/mrjackwills/oxker"
|
repository = "https://github.com/mrjackwills/oxker"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use bollard::service::Port;
|
use bollard::service::Port;
|
||||||
use jiff::{tz::TimeZone, Timestamp};
|
use jiff::{Timestamp, tz::TimeZone};
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
style::Color,
|
style::Color,
|
||||||
widgets::{ListItem, ListState},
|
widgets::{ListItem, ListState},
|
||||||
@@ -177,25 +177,24 @@ impl<T> StatefulList<T> {
|
|||||||
|
|
||||||
pub fn next(&mut self) {
|
pub fn next(&mut self) {
|
||||||
if !self.items.is_empty() {
|
if !self.items.is_empty() {
|
||||||
self.state.select(Some(self.state.selected().map_or(0, |i| {
|
self.state.select(Some(
|
||||||
if i < self.items.len() - 1 {
|
self.state.selected().map_or(
|
||||||
i + 1
|
0,
|
||||||
} else {
|
|i| {
|
||||||
i
|
if i < self.items.len() - 1 { i + 1 } else { i }
|
||||||
}
|
},
|
||||||
})));
|
),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn previous(&mut self) {
|
pub fn previous(&mut self) {
|
||||||
if !self.items.is_empty() {
|
if !self.items.is_empty() {
|
||||||
self.state.select(Some(self.state.selected().map_or(0, |i| {
|
self.state.select(Some(
|
||||||
if i == 0 {
|
self.state
|
||||||
0
|
.selected()
|
||||||
} else {
|
.map_or(0, |i| if i == 0 { 0 } else { i - 1 }),
|
||||||
i - 1
|
));
|
||||||
}
|
|
||||||
})));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,7 +696,7 @@ impl ContainerItem {
|
|||||||
self.cpu_stats
|
self.cpu_stats
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|i| (i.0 as f64, i.1 .0))
|
.map(|i| (i.0 as f64, i.1.0))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -707,7 +706,7 @@ impl ContainerItem {
|
|||||||
self.mem_stats
|
self.mem_stats
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|i| (i.0 as f64, i.1 .0 as f64))
|
.map(|i| (i.0 as f64, i.1.0 as f64))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -11,10 +11,10 @@ use std::{
|
|||||||
mod container_state;
|
mod container_state;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
ENTRY_POINT,
|
||||||
app_error::AppError,
|
app_error::AppError,
|
||||||
config::Config,
|
config::Config,
|
||||||
ui::{log_sanitizer, GuiState, Redraw, Status},
|
ui::{GuiState, Redraw, Status, log_sanitizer},
|
||||||
ENTRY_POINT,
|
|
||||||
};
|
};
|
||||||
pub use container_state::*;
|
pub use container_state::*;
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
use bollard::{
|
use bollard::{
|
||||||
|
Docker,
|
||||||
container::{
|
container::{
|
||||||
ListContainersOptions, LogsOptions, MemoryStatsStats, RemoveContainerOptions,
|
ListContainersOptions, LogsOptions, MemoryStatsStats, RemoveContainerOptions,
|
||||||
StartContainerOptions, Stats, StatsOptions,
|
StartContainerOptions, Stats, StatsOptions,
|
||||||
},
|
},
|
||||||
service::ContainerSummary,
|
service::ContainerSummary,
|
||||||
Docker,
|
|
||||||
};
|
};
|
||||||
use futures_util::StreamExt;
|
use futures_util::StreamExt;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
sync::{atomic::AtomicUsize, Arc},
|
sync::{Arc, atomic::AtomicUsize},
|
||||||
};
|
};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
sync::mpsc::{Receiver, Sender},
|
sync::mpsc::{Receiver, Sender},
|
||||||
@@ -19,11 +19,11 @@ use tokio::{
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
ENTRY_POINT,
|
||||||
app_data::{AppData, ContainerId, DockerCommand, State},
|
app_data::{AppData, ContainerId, DockerCommand, State},
|
||||||
app_error::AppError,
|
app_error::AppError,
|
||||||
config::Config,
|
config::Config,
|
||||||
ui::{GuiState, Status},
|
ui::{GuiState, Status},
|
||||||
ENTRY_POINT,
|
|
||||||
};
|
};
|
||||||
mod message;
|
mod message;
|
||||||
pub use message::DockerMessage;
|
pub use message::DockerMessage;
|
||||||
|
|||||||
+11
-8
@@ -1,16 +1,16 @@
|
|||||||
use std::{
|
use std::{
|
||||||
io::{Read, Stdout, Write},
|
io::{Read, Stdout, Write},
|
||||||
sync::{atomic::AtomicBool, mpsc::Sender, Arc},
|
sync::{Arc, atomic::AtomicBool, mpsc::Sender},
|
||||||
};
|
};
|
||||||
|
|
||||||
use bollard::{
|
use bollard::{
|
||||||
exec::{CreateExecOptions, ResizeExecOptions, StartExecOptions, StartExecResults},
|
|
||||||
Docker,
|
Docker,
|
||||||
|
exec::{CreateExecOptions, ResizeExecOptions, StartExecOptions, StartExecResults},
|
||||||
};
|
};
|
||||||
use crossterm::terminal::enable_raw_mode;
|
use crossterm::terminal::enable_raw_mode;
|
||||||
use futures_util::StreamExt;
|
use futures_util::StreamExt;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use ratatui::{backend::CrosstermBackend, Terminal};
|
use ratatui::{Terminal, backend::CrosstermBackend};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
fs::File,
|
fs::File,
|
||||||
io::{AsyncReadExt, AsyncWriteExt},
|
io::{AsyncReadExt, AsyncWriteExt},
|
||||||
@@ -253,10 +253,7 @@ impl ExecMode {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
if let Ok(StartExecResults::Attached {
|
match docker
|
||||||
mut output,
|
|
||||||
mut input,
|
|
||||||
}) = docker
|
|
||||||
.start_exec(
|
.start_exec(
|
||||||
&exec_result.id,
|
&exec_result.id,
|
||||||
Some(StartExecOptions {
|
Some(StartExecOptions {
|
||||||
@@ -266,6 +263,10 @@ impl ExecMode {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
Ok(StartExecResults::Attached {
|
||||||
|
mut output,
|
||||||
|
mut input,
|
||||||
|
}) => {
|
||||||
if let Some(tty) = AsyncTTY::get(&cancel_token) {
|
if let Some(tty) = AsyncTTY::get(&cancel_token) {
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
enable_raw_mode().ok();
|
enable_raw_mode().ok();
|
||||||
@@ -298,10 +299,12 @@ impl ExecMode {
|
|||||||
|
|
||||||
self.internal_cleanup()?;
|
self.internal_cleanup()?;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
_ => {
|
||||||
return Err(AppError::Terminal);
|
return Err(AppError::Terminal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::{
|
use std::{
|
||||||
fs::OpenOptions,
|
fs::OpenOptions,
|
||||||
io::{BufWriter, Write},
|
io::{BufWriter, Write},
|
||||||
sync::{atomic::AtomicBool, Arc},
|
sync::{Arc, atomic::AtomicBool},
|
||||||
time::SystemTime,
|
time::SystemTime,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ use crate::{
|
|||||||
app_error::AppError,
|
app_error::AppError,
|
||||||
config,
|
config,
|
||||||
docker_data::DockerMessage,
|
docker_data::DockerMessage,
|
||||||
exec::{tty_readable, ExecMode},
|
exec::{ExecMode, tty_readable},
|
||||||
ui::{DeleteButton, GuiState, SelectablePanel, Status, Ui},
|
ui::{DeleteButton, GuiState, SelectablePanel, Status, Ui},
|
||||||
};
|
};
|
||||||
pub use message::InputMessages;
|
pub use message::InputMessages;
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
use app_data::AppData;
|
use app_data::AppData;
|
||||||
use app_error::AppError;
|
use app_error::AppError;
|
||||||
use bollard::{Docker, API_DEFAULT_VERSION};
|
use bollard::{API_DEFAULT_VERSION, Docker};
|
||||||
use config::Config;
|
use config::Config;
|
||||||
use docker_data::DockerData;
|
use docker_data::DockerData;
|
||||||
use input_handler::InputMessages;
|
use input_handler::InputMessages;
|
||||||
@@ -8,12 +8,12 @@ use parking_lot::Mutex;
|
|||||||
use std::{
|
use std::{
|
||||||
process,
|
process,
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, Ordering},
|
|
||||||
Arc,
|
Arc,
|
||||||
|
atomic::{AtomicBool, Ordering},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use tokio::sync::mpsc::{Receiver, Sender};
|
use tokio::sync::mpsc::{Receiver, Sender};
|
||||||
use tracing::{error, info, Level};
|
use tracing::{Level, error, info};
|
||||||
|
|
||||||
mod app_data;
|
mod app_data;
|
||||||
mod app_error;
|
mod app_error;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
pub mod log_sanitizer {
|
pub mod log_sanitizer {
|
||||||
|
|
||||||
use cansi::{v3::categorise_text, Color as CansiColor, Intensity};
|
use cansi::{Color as CansiColor, Intensity, v3::categorise_text};
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
style::{Color, Modifier, Style},
|
style::{Color, Modifier, Style},
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
Frame,
|
||||||
layout::{Alignment, Direction, Layout, Rect},
|
layout::{Alignment, Direction, Layout, Rect},
|
||||||
style::{Color, Modifier, Style, Stylize},
|
style::{Color, Modifier, Style, Stylize},
|
||||||
symbols,
|
symbols,
|
||||||
text::Span,
|
text::Span,
|
||||||
widgets::{Axis, Block, BorderType, Borders, Chart, Dataset, GraphType},
|
widgets::{Axis, Block, BorderType, Borders, Chart, Dataset, GraphType},
|
||||||
Frame,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{FrameData, CONSTRAINT_50_50};
|
use super::{CONSTRAINT_50_50, FrameData};
|
||||||
use crate::{
|
use crate::{
|
||||||
app_data::{ByteStats, CpuStats, State, Stats},
|
app_data::{ByteStats, CpuStats, State, Stats},
|
||||||
config::AppColors,
|
config::AppColors,
|
||||||
@@ -124,16 +124,20 @@ pub fn draw(area: Rect, colors: AppColors, f: &mut Frame, fd: &FrameData) {
|
|||||||
.constraints(CONSTRAINT_50_50)
|
.constraints(CONSTRAINT_50_50)
|
||||||
.split(area);
|
.split(area);
|
||||||
|
|
||||||
let cpu_dataset = vec![Dataset::default()
|
let cpu_dataset = vec![
|
||||||
|
Dataset::default()
|
||||||
.marker(symbols::Marker::Dot)
|
.marker(symbols::Marker::Dot)
|
||||||
.style(Style::default().fg(colors.chart_cpu.points))
|
.style(Style::default().fg(colors.chart_cpu.points))
|
||||||
.graph_type(GraphType::Line)
|
.graph_type(GraphType::Line)
|
||||||
.data(&cpu.0)];
|
.data(&cpu.0),
|
||||||
let mem_dataset = vec![Dataset::default()
|
];
|
||||||
|
let mem_dataset = vec![
|
||||||
|
Dataset::default()
|
||||||
.marker(symbols::Marker::Dot)
|
.marker(symbols::Marker::Dot)
|
||||||
.style(Style::default().fg(colors.chart_memory.points))
|
.style(Style::default().fg(colors.chart_memory.points))
|
||||||
.graph_type(GraphType::Line)
|
.graph_type(GraphType::Line)
|
||||||
.data(&mem.0)];
|
.data(&mem.0),
|
||||||
|
];
|
||||||
|
|
||||||
let cpu_stats = CpuStats::new(cpu.0.last().map_or(0.00, |f| f.1));
|
let cpu_stats = CpuStats::new(cpu.0.last().map_or(0.00, |f| f.1));
|
||||||
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
|
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
|
||||||
@@ -169,10 +173,10 @@ mod tests {
|
|||||||
app_data::State,
|
app_data::State,
|
||||||
config::AppColors,
|
config::AppColors,
|
||||||
ui::{
|
ui::{
|
||||||
draw_blocks::tests::{
|
|
||||||
expected_to_vec, get_result, insert_chart_data, test_setup, COLOR_ORANGE,
|
|
||||||
},
|
|
||||||
FrameData,
|
FrameData,
|
||||||
|
draw_blocks::tests::{
|
||||||
|
COLOR_ORANGE, expected_to_vec, get_result, insert_chart_data, test_setup,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
Frame,
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
style::{Modifier, Style, Stylize},
|
style::{Modifier, Style, Stylize},
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
widgets::{List, ListItem, Paragraph},
|
widgets::{List, ListItem, Paragraph},
|
||||||
Frame,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::generate_block;
|
use super::generate_block;
|
||||||
@@ -61,8 +61,8 @@ mod tests {
|
|||||||
config::AppColors,
|
config::AppColors,
|
||||||
tests::gen_container_summary,
|
tests::gen_container_summary,
|
||||||
ui::{
|
ui::{
|
||||||
draw_blocks::tests::{expected_to_vec, get_result, test_setup, BORDER_CHARS},
|
|
||||||
FrameData,
|
FrameData,
|
||||||
|
draw_blocks::tests::{BORDER_CHARS, expected_to_vec, get_result, test_setup},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ use std::sync::Arc;
|
|||||||
use super::MARGIN;
|
use super::MARGIN;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
Frame,
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
style::{Modifier, Style, Stylize},
|
style::{Modifier, Style, Stylize},
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
widgets::{List, ListItem, Paragraph},
|
widgets::{List, ListItem, Paragraph},
|
||||||
Frame,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -16,7 +16,7 @@ use crate::{
|
|||||||
ui::{FrameData, GuiState, SelectablePanel},
|
ui::{FrameData, GuiState, SelectablePanel},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{generate_block, CIRCLE};
|
use super::{CIRCLE, generate_block};
|
||||||
|
|
||||||
/// Format the container data to display nicely on the screen
|
/// Format the container data to display nicely on the screen
|
||||||
fn format_containers<'a>(colors: AppColors, i: &ContainerItem, widths: &Columns) -> Line<'a> {
|
fn format_containers<'a>(colors: AppColors, i: &ContainerItem, widths: &Columns) -> Line<'a> {
|
||||||
@@ -142,11 +142,11 @@ mod tests {
|
|||||||
app_data::{ContainerImage, ContainerName, ContainerStatus, State, StatefulList},
|
app_data::{ContainerImage, ContainerName, ContainerStatus, State, StatefulList},
|
||||||
config::AppColors,
|
config::AppColors,
|
||||||
ui::{
|
ui::{
|
||||||
draw_blocks::tests::{
|
|
||||||
expected_to_vec, get_result, test_setup, TuiTestSetup, BORDER_CHARS, COLOR_ORANGE,
|
|
||||||
COLOR_RX, COLOR_TX,
|
|
||||||
},
|
|
||||||
FrameData,
|
FrameData,
|
||||||
|
draw_blocks::tests::{
|
||||||
|
BORDER_CHARS, COLOR_ORANGE, COLOR_RX, COLOR_TX, TuiTestSetup, expected_to_vec,
|
||||||
|
get_result, test_setup,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -318,7 +318,7 @@ mod tests {
|
|||||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||||
"│ │",
|
"│ │",
|
||||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
|
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||||
];
|
];
|
||||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||||
let colors = setup.app_data.lock().config.app_colors;
|
let colors = setup.app_data.lock().config.app_colors;
|
||||||
@@ -671,13 +671,13 @@ mod tests {
|
|||||||
setup.app_data.lock().containers.items[0].state = State::from(("running", &status));
|
setup.app_data.lock().containers.items[0].state = State::from(("running", &status));
|
||||||
setup.app_data.lock().containers.items[0].status = status;
|
setup.app_data.lock().containers.items[0].status = status;
|
||||||
|
|
||||||
let expected= [
|
let expected = [
|
||||||
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
"╭ Containers 1/3 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮",
|
||||||
"│⚪ container_1 ! running Up 1 hour (unhealthy) 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
"│⚪ container_1 ! running Up 1 hour (unhealthy) 00.00% 0.00 kB / 0.00 kB 1 image_1 0.00 kB 0.00 kB │",
|
||||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||||
"│ │",
|
"│ │",
|
||||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
|
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||||
];
|
];
|
||||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||||
let colors = setup.app_data.lock().config.app_colors;
|
let colors = setup.app_data.lock().config.app_colors;
|
||||||
@@ -778,7 +778,7 @@ mod tests {
|
|||||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||||
"│ │",
|
"│ │",
|
||||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
|
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||||
];
|
];
|
||||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||||
let mut colors = AppColors::new();
|
let mut colors = AppColors::new();
|
||||||
@@ -852,7 +852,7 @@ mod tests {
|
|||||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||||
"│ │",
|
"│ │",
|
||||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
|
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||||
];
|
];
|
||||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||||
|
|
||||||
@@ -898,7 +898,7 @@ mod tests {
|
|||||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||||
"│ │",
|
"│ │",
|
||||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
|
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||||
];
|
];
|
||||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||||
|
|
||||||
@@ -945,7 +945,7 @@ mod tests {
|
|||||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||||
"│ │",
|
"│ │",
|
||||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
|
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||||
];
|
];
|
||||||
|
|
||||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||||
@@ -991,7 +991,7 @@ mod tests {
|
|||||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||||
"│ │",
|
"│ │",
|
||||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
|
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||||
];
|
];
|
||||||
|
|
||||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||||
@@ -1037,7 +1037,7 @@ mod tests {
|
|||||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||||
"│ │",
|
"│ │",
|
||||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
|
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||||
];
|
];
|
||||||
|
|
||||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||||
@@ -1083,7 +1083,7 @@ mod tests {
|
|||||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||||
"│ │",
|
"│ │",
|
||||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
|
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||||
];
|
];
|
||||||
|
|
||||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||||
@@ -1129,7 +1129,7 @@ mod tests {
|
|||||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||||
"│ │",
|
"│ │",
|
||||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
|
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||||
];
|
];
|
||||||
|
|
||||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||||
@@ -1175,7 +1175,7 @@ mod tests {
|
|||||||
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
"│ container_2 ✓ running Up 2 hour 00.00% 0.00 kB / 0.00 kB 2 image_2 0.00 kB 0.00 kB │",
|
||||||
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
"│ container_3 ✓ running Up 3 hour 00.00% 0.00 kB / 0.00 kB 3 image_3 0.00 kB 0.00 kB │",
|
||||||
"│ │",
|
"│ │",
|
||||||
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
|
"╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯",
|
||||||
];
|
];
|
||||||
|
|
||||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
Frame,
|
||||||
layout::{Alignment, Direction, Layout},
|
layout::{Alignment, Direction, Layout},
|
||||||
style::{Modifier, Style},
|
style::{Modifier, Style},
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
widgets::{Block, BorderType, Borders, Clear, Paragraph},
|
widgets::{Block, BorderType, Borders, Clear, Paragraph},
|
||||||
Frame,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{CONSTRAINT_BUTTONS, CONSTRAINT_POPUP};
|
use super::{CONSTRAINT_BUTTONS, CONSTRAINT_POPUP};
|
||||||
@@ -14,8 +14,8 @@ use crate::{
|
|||||||
app_data::ContainerName,
|
app_data::ContainerName,
|
||||||
config::{AppColors, Keymap},
|
config::{AppColors, Keymap},
|
||||||
ui::{
|
ui::{
|
||||||
gui_state::{BoxLocation, Region},
|
|
||||||
DeleteButton, GuiState,
|
DeleteButton, GuiState,
|
||||||
|
gui_state::{BoxLocation, Region},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
Frame,
|
||||||
layout::Alignment,
|
layout::Alignment,
|
||||||
style::Style,
|
style::Style,
|
||||||
widgets::{Block, BorderType, Borders, Clear, Paragraph},
|
widgets::{Block, BorderType, Borders, Clear, Paragraph},
|
||||||
Frame,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{max_line_width, NAME, VERSION};
|
use super::{NAME, VERSION, max_line_width};
|
||||||
use crate::{
|
use crate::{
|
||||||
app_error::AppError,
|
app_error::AppError,
|
||||||
config::{AppColors, Keymap},
|
config::{AppColors, Keymap},
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
Frame,
|
||||||
layout::Rect,
|
layout::Rect,
|
||||||
style::{Modifier, Style, Stylize},
|
style::{Modifier, Style, Stylize},
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
Frame,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{app_data::FilterBy, config::AppColors, ui::FrameData};
|
use crate::{app_data::FilterBy, config::AppColors, ui::FrameData};
|
||||||
@@ -76,8 +76,8 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
config::AppColors,
|
config::AppColors,
|
||||||
ui::{
|
ui::{
|
||||||
draw_blocks::tests::{expected_to_vec, get_result, test_setup},
|
|
||||||
FrameData,
|
FrameData,
|
||||||
|
draw_blocks::tests::{expected_to_vec, get_result, test_setup},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let expected = [
|
let expected = [
|
||||||
" Esc clear ← by → Name Image Status All term: "
|
" Esc clear ← by → Name Image Status All term: ",
|
||||||
];
|
];
|
||||||
|
|
||||||
for (row_index, result_row) in get_result(&setup, w) {
|
for (row_index, result_row) in get_result(&setup, w) {
|
||||||
@@ -148,7 +148,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let expected = [
|
let expected = [
|
||||||
" Esc clear ← by → Name Image Status All term: cd "
|
" Esc clear ← by → Name Image Status All term: cd ",
|
||||||
];
|
];
|
||||||
|
|
||||||
for (row_index, result_row) in get_result(&setup, w) {
|
for (row_index, result_row) in get_result(&setup, w) {
|
||||||
@@ -193,7 +193,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let expected = [
|
let expected = [
|
||||||
" Esc clear ← by → Name Image Status All term: cd "
|
" Esc clear ← by → Name Image Status All term: cd ",
|
||||||
];
|
];
|
||||||
|
|
||||||
for (row_index, result_row) in get_result(&setup, w) {
|
for (row_index, result_row) in get_result(&setup, w) {
|
||||||
@@ -257,7 +257,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let expected = [
|
let expected = [
|
||||||
" Esc clear ← by → Name Image Status All term: cd "
|
" Esc clear ← by → Name Image Status All term: cd ",
|
||||||
];
|
];
|
||||||
|
|
||||||
for (row_index, result_row) in get_result(&setup, w) {
|
for (row_index, result_row) in get_result(&setup, w) {
|
||||||
|
|||||||
+150
-28
@@ -2,17 +2,17 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
Frame,
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||||
style::{Color, Style},
|
style::{Color, Style},
|
||||||
widgets::{Block, Paragraph},
|
widgets::{Block, Paragraph},
|
||||||
Frame,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{CONSTRAINT_100, MARGIN};
|
use super::{CONSTRAINT_100, MARGIN};
|
||||||
use crate::{
|
use crate::{
|
||||||
app_data::{Header, SortedOrder},
|
app_data::{Header, SortedOrder},
|
||||||
config::{AppColors, Keymap},
|
config::{AppColors, Keymap},
|
||||||
ui::{gui_state::Region, FrameData, GuiState, Status},
|
ui::{FrameData, GuiState, Status, gui_state::Region},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Draw heading bar at top of program, always visible
|
// Draw heading bar at top of program, always visible
|
||||||
@@ -191,8 +191,8 @@ mod tests {
|
|||||||
app_data::{Header, SortedOrder, StatefulList},
|
app_data::{Header, SortedOrder, StatefulList},
|
||||||
config::{AppColors, Keymap},
|
config::{AppColors, Keymap},
|
||||||
ui::{
|
ui::{
|
||||||
draw_blocks::tests::{expected_to_vec, get_result, test_setup},
|
|
||||||
FrameData, Status,
|
FrameData, Status,
|
||||||
|
draw_blocks::tests::{expected_to_vec, get_result, test_setup},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -205,7 +205,9 @@ mod tests {
|
|||||||
|
|
||||||
let mut fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
let mut fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||||
|
|
||||||
let expected = [" ( h ) show help "];
|
let expected = [
|
||||||
|
" ( h ) show help ",
|
||||||
|
];
|
||||||
|
|
||||||
setup
|
setup
|
||||||
.terminal
|
.terminal
|
||||||
@@ -231,7 +233,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fd.status.insert(Status::Help);
|
fd.status.insert(Status::Help);
|
||||||
let expected = [" ( h ) exit help "];
|
let expected = [
|
||||||
|
" ( h ) exit help ",
|
||||||
|
];
|
||||||
setup
|
setup
|
||||||
.terminal
|
.terminal
|
||||||
.draw(|f| {
|
.draw(|f| {
|
||||||
@@ -263,7 +267,9 @@ mod tests {
|
|||||||
let mut setup = test_setup(w, h, true, true);
|
let mut setup = test_setup(w, h, true, true);
|
||||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||||
|
|
||||||
let expected = [" name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "];
|
let expected = [
|
||||||
|
" name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
];
|
||||||
setup
|
setup
|
||||||
.terminal
|
.terminal
|
||||||
.draw(|f| {
|
.draw(|f| {
|
||||||
@@ -385,32 +391,140 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
test(&[" name ▲ state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "], 1..=17, (Header::Name, SortedOrder::Asc));
|
test(
|
||||||
test(&[" name ▼ state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "], 1..=17, (Header::Name, SortedOrder::Desc));
|
&[
|
||||||
|
" name ▲ state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
1..=17,
|
||||||
|
(Header::Name, SortedOrder::Asc),
|
||||||
|
);
|
||||||
|
test(
|
||||||
|
&[
|
||||||
|
" name ▼ state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
1..=17,
|
||||||
|
(Header::Name, SortedOrder::Desc),
|
||||||
|
);
|
||||||
// state
|
// state
|
||||||
test(&[" name state ▲ status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "],18..=29, (Header::State, SortedOrder::Asc));
|
test(
|
||||||
test(&[" name state ▼ status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "], 18..=29, (Header::State, SortedOrder::Desc));
|
&[
|
||||||
|
" name state ▲ status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
18..=29,
|
||||||
|
(Header::State, SortedOrder::Asc),
|
||||||
|
);
|
||||||
|
test(
|
||||||
|
&[
|
||||||
|
" name state ▼ status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
18..=29,
|
||||||
|
(Header::State, SortedOrder::Desc),
|
||||||
|
);
|
||||||
// status
|
// status
|
||||||
test(&[" name state status ▲ cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "], 30..=41, (Header::Status, SortedOrder::Asc));
|
test(
|
||||||
test(&[" name state status ▼ cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "], 30..=41, (Header::Status, SortedOrder::Desc));
|
&[
|
||||||
|
" name state status ▲ cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
30..=41,
|
||||||
|
(Header::Status, SortedOrder::Asc),
|
||||||
|
);
|
||||||
|
test(
|
||||||
|
&[
|
||||||
|
" name state status ▼ cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
30..=41,
|
||||||
|
(Header::Status, SortedOrder::Desc),
|
||||||
|
);
|
||||||
// cpu
|
// cpu
|
||||||
test(&[" name state status cpu ▲ memory/limit id image ↓ rx ↑ tx ( h ) show help "],42..=50, (Header::Cpu, SortedOrder::Asc));
|
test(
|
||||||
test(&[" name state status cpu ▼ memory/limit id image ↓ rx ↑ tx ( h ) show help "],42..=50, (Header::Cpu, SortedOrder::Desc));
|
&[
|
||||||
|
" name state status cpu ▲ memory/limit id image ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
42..=50,
|
||||||
|
(Header::Cpu, SortedOrder::Asc),
|
||||||
|
);
|
||||||
|
test(
|
||||||
|
&[
|
||||||
|
" name state status cpu ▼ memory/limit id image ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
42..=50,
|
||||||
|
(Header::Cpu, SortedOrder::Desc),
|
||||||
|
);
|
||||||
// memory
|
// memory
|
||||||
test(&[" name state status cpu memory/limit ▲ id image ↓ rx ↑ tx ( h ) show help "], 51..=70, (Header::Memory, SortedOrder::Asc));
|
test(
|
||||||
test(&[" name state status cpu memory/limit ▼ id image ↓ rx ↑ tx ( h ) show help "], 51..=70, (Header::Memory, SortedOrder::Desc));
|
&[
|
||||||
|
" name state status cpu memory/limit ▲ id image ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
51..=70,
|
||||||
|
(Header::Memory, SortedOrder::Asc),
|
||||||
|
);
|
||||||
|
test(
|
||||||
|
&[
|
||||||
|
" name state status cpu memory/limit ▼ id image ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
51..=70,
|
||||||
|
(Header::Memory, SortedOrder::Desc),
|
||||||
|
);
|
||||||
//id
|
//id
|
||||||
test(&[" name state status cpu memory/limit id ▲ image ↓ rx ↑ tx ( h ) show help "], 71..=81, (Header::Id, SortedOrder::Asc));
|
test(
|
||||||
test(&[" name state status cpu memory/limit id ▼ image ↓ rx ↑ tx ( h ) show help "], 71..=81, (Header::Id, SortedOrder::Desc));
|
&[
|
||||||
|
" name state status cpu memory/limit id ▲ image ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
71..=81,
|
||||||
|
(Header::Id, SortedOrder::Asc),
|
||||||
|
);
|
||||||
|
test(
|
||||||
|
&[
|
||||||
|
" name state status cpu memory/limit id ▼ image ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
71..=81,
|
||||||
|
(Header::Id, SortedOrder::Desc),
|
||||||
|
);
|
||||||
// image
|
// image
|
||||||
test(&[" name state status cpu memory/limit id image ▲ ↓ rx ↑ tx ( h ) show help "], 82..=91, (Header::Image, SortedOrder::Asc));
|
test(
|
||||||
test(&[" name state status cpu memory/limit id image ▼ ↓ rx ↑ tx ( h ) show help "], 82..=91, (Header::Image, SortedOrder::Desc));
|
&[
|
||||||
|
" name state status cpu memory/limit id image ▲ ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
82..=91,
|
||||||
|
(Header::Image, SortedOrder::Asc),
|
||||||
|
);
|
||||||
|
test(
|
||||||
|
&[
|
||||||
|
" name state status cpu memory/limit id image ▼ ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
82..=91,
|
||||||
|
(Header::Image, SortedOrder::Desc),
|
||||||
|
);
|
||||||
// rx
|
// rx
|
||||||
test(&[" name state status cpu memory/limit id image ↓ rx ▲ ↑ tx ( h ) show help "], 92..=101, (Header::Rx, SortedOrder::Asc));
|
test(
|
||||||
test(&[" name state status cpu memory/limit id image ↓ rx ▼ ↑ tx ( h ) show help "], 92..=101, (Header::Rx, SortedOrder::Desc));
|
&[
|
||||||
|
" name state status cpu memory/limit id image ↓ rx ▲ ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
92..=101,
|
||||||
|
(Header::Rx, SortedOrder::Asc),
|
||||||
|
);
|
||||||
|
test(
|
||||||
|
&[
|
||||||
|
" name state status cpu memory/limit id image ↓ rx ▼ ↑ tx ( h ) show help ",
|
||||||
|
],
|
||||||
|
92..=101,
|
||||||
|
(Header::Rx, SortedOrder::Desc),
|
||||||
|
);
|
||||||
// tx
|
// tx
|
||||||
test(&[" name state status cpu memory/limit id image ↓ rx ↑ tx ▲ ( h ) show help "], 102..=111, (Header::Tx, SortedOrder::Asc));
|
test(
|
||||||
test(&[" name state status cpu memory/limit id image ↓ rx ↑ tx ▼ ( h ) show help "], 102..=111, (Header::Tx, SortedOrder::Desc));
|
&[
|
||||||
|
" name state status cpu memory/limit id image ↓ rx ↑ tx ▲ ( h ) show help ",
|
||||||
|
],
|
||||||
|
102..=111,
|
||||||
|
(Header::Tx, SortedOrder::Asc),
|
||||||
|
);
|
||||||
|
test(
|
||||||
|
&[
|
||||||
|
" name state status cpu memory/limit id image ↓ rx ↑ tx ▼ ( h ) show help ",
|
||||||
|
],
|
||||||
|
102..=111,
|
||||||
|
(Header::Tx, SortedOrder::Desc),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -422,7 +536,9 @@ mod tests {
|
|||||||
setup.gui_state.lock().next_loading(uuid);
|
setup.gui_state.lock().next_loading(uuid);
|
||||||
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
let fd = FrameData::from((&setup.app_data, &setup.gui_state));
|
||||||
|
|
||||||
let expected = [" ⠙ name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "];
|
let expected = [
|
||||||
|
" ⠙ name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
];
|
||||||
|
|
||||||
setup
|
setup
|
||||||
.terminal
|
.terminal
|
||||||
@@ -472,7 +588,9 @@ mod tests {
|
|||||||
colors.headers_bar.text = Color::Blue;
|
colors.headers_bar.text = Color::Blue;
|
||||||
colors.headers_bar.text_selected = Color::Yellow;
|
colors.headers_bar.text_selected = Color::Yellow;
|
||||||
|
|
||||||
let expected = [" ⠙ name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help "];
|
let expected = [
|
||||||
|
" ⠙ name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) show help ",
|
||||||
|
];
|
||||||
|
|
||||||
setup
|
setup
|
||||||
.terminal
|
.terminal
|
||||||
@@ -509,7 +627,9 @@ mod tests {
|
|||||||
|
|
||||||
keymap.toggle_help = (KeyCode::Char('T'), None);
|
keymap.toggle_help = (KeyCode::Char('T'), None);
|
||||||
|
|
||||||
let expected = [" name state status cpu memory/limit id image ↓ rx ↑ tx ( T ) show help "];
|
let expected = [
|
||||||
|
" name state status cpu memory/limit id image ↓ rx ↑ tx ( T ) show help ",
|
||||||
|
];
|
||||||
setup
|
setup
|
||||||
.terminal
|
.terminal
|
||||||
.draw(|f| {
|
.draw(|f| {
|
||||||
@@ -532,7 +652,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
keymap.toggle_help = (KeyCode::Char('T'), Some(KeyCode::Tab));
|
keymap.toggle_help = (KeyCode::Char('T'), Some(KeyCode::Tab));
|
||||||
let expected = [" name state status cpu memory/limit id image ↓ rx ↑ tx ( T | Tab ) show help "];
|
let expected = [
|
||||||
|
" name state status cpu memory/limit id image ↓ rx ↑ tx ( T | Tab ) show help ",
|
||||||
|
];
|
||||||
setup
|
setup
|
||||||
.terminal
|
.terminal
|
||||||
.draw(|f| {
|
.draw(|f| {
|
||||||
|
|||||||
+24
-12
@@ -1,11 +1,11 @@
|
|||||||
use crossterm::event::KeyCode;
|
use crossterm::event::KeyCode;
|
||||||
use jiff::tz::TimeZone;
|
use jiff::tz::TimeZone;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
Frame,
|
||||||
layout::{Alignment, Constraint, Direction, Layout},
|
layout::{Alignment, Constraint, Direction, Layout},
|
||||||
style::{Color, Modifier, Style},
|
style::{Color, Modifier, Style},
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
widgets::{Block, BorderType, Borders, Clear, Paragraph},
|
widgets::{Block, BorderType, Borders, Clear, Paragraph},
|
||||||
Frame,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -13,7 +13,7 @@ use crate::{
|
|||||||
ui::gui_state::BoxLocation,
|
ui::gui_state::BoxLocation,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{popup, DESCRIPTION, NAME_TEXT, REPO, VERSION};
|
use super::{DESCRIPTION, NAME_TEXT, REPO, VERSION, popup};
|
||||||
|
|
||||||
/// Help popup box needs these three pieces of information
|
/// Help popup box needs these three pieces of information
|
||||||
struct HelpInfo {
|
struct HelpInfo {
|
||||||
@@ -445,7 +445,9 @@ mod tests {
|
|||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let version_row = format!(" ╭ {VERSION} ────────────────────────────────────────────────────────────────────────────╮ ");
|
let version_row = format!(
|
||||||
|
" ╭ {VERSION} ────────────────────────────────────────────────────────────────────────────╮ "
|
||||||
|
);
|
||||||
let expected = [
|
let expected = [
|
||||||
" ",
|
" ",
|
||||||
version_row.as_str(),
|
version_row.as_str(),
|
||||||
@@ -479,7 +481,7 @@ mod tests {
|
|||||||
" │ │ ",
|
" │ │ ",
|
||||||
" │ │ ",
|
" │ │ ",
|
||||||
" ╰───────────────────────────────────────────────────────────────────────────────────╯ ",
|
" ╰───────────────────────────────────────────────────────────────────────────────────╯ ",
|
||||||
" "
|
" ",
|
||||||
];
|
];
|
||||||
|
|
||||||
for (row_index, result_row) in get_result(&setup, w) {
|
for (row_index, result_row) in get_result(&setup, w) {
|
||||||
@@ -551,7 +553,9 @@ mod tests {
|
|||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let version_row = format!(" ╭ {VERSION} ────────────────────────────────────────────────────────────────────────────╮ ");
|
let version_row = format!(
|
||||||
|
" ╭ {VERSION} ────────────────────────────────────────────────────────────────────────────╮ "
|
||||||
|
);
|
||||||
let expected = [
|
let expected = [
|
||||||
" ",
|
" ",
|
||||||
version_row.as_str(),
|
version_row.as_str(),
|
||||||
@@ -585,7 +589,7 @@ mod tests {
|
|||||||
" │ │ ",
|
" │ │ ",
|
||||||
" │ │ ",
|
" │ │ ",
|
||||||
" ╰───────────────────────────────────────────────────────────────────────────────────╯ ",
|
" ╰───────────────────────────────────────────────────────────────────────────────────╯ ",
|
||||||
" "
|
" ",
|
||||||
];
|
];
|
||||||
|
|
||||||
for (row_index, result_row) in get_result(&setup, w) {
|
for (row_index, result_row) in get_result(&setup, w) {
|
||||||
@@ -675,7 +679,9 @@ mod tests {
|
|||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let version_row = format!(" ╭ {VERSION} ─────────────────────────────────────────────────────────────────────────────────────╮ ");
|
let version_row = format!(
|
||||||
|
" ╭ {VERSION} ─────────────────────────────────────────────────────────────────────────────────────╮ "
|
||||||
|
);
|
||||||
let expected = [
|
let expected = [
|
||||||
" ",
|
" ",
|
||||||
version_row.as_str(),
|
version_row.as_str(),
|
||||||
@@ -723,7 +729,7 @@ mod tests {
|
|||||||
" │ │ ",
|
" │ │ ",
|
||||||
" │ │ ",
|
" │ │ ",
|
||||||
" ╰────────────────────────────────────────────────────────────────────────────────────────────╯ ",
|
" ╰────────────────────────────────────────────────────────────────────────────────────────────╯ ",
|
||||||
" "
|
" ",
|
||||||
];
|
];
|
||||||
|
|
||||||
for (row_index, result_row) in get_result(&setup, w) {
|
for (row_index, result_row) in get_result(&setup, w) {
|
||||||
@@ -777,7 +783,9 @@ mod tests {
|
|||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let version_row = format!(" ╭ {VERSION} ───────────────────────────────────────────────────────────────────────────────────────────────────╮ ");
|
let version_row = format!(
|
||||||
|
" ╭ {VERSION} ───────────────────────────────────────────────────────────────────────────────────────────────────╮ "
|
||||||
|
);
|
||||||
let expected = [
|
let expected = [
|
||||||
" ",
|
" ",
|
||||||
version_row.as_str(),
|
version_row.as_str(),
|
||||||
@@ -881,7 +889,9 @@ mod tests {
|
|||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let version_row = format!(" ╭ {VERSION} ───────────────────────────────────────────────────────────────────────────────────────────────────╮ ");
|
let version_row = format!(
|
||||||
|
" ╭ {VERSION} ───────────────────────────────────────────────────────────────────────────────────────────────────╮ "
|
||||||
|
);
|
||||||
let expected = [
|
let expected = [
|
||||||
" ",
|
" ",
|
||||||
version_row.as_str(),
|
version_row.as_str(),
|
||||||
@@ -958,7 +968,9 @@ mod tests {
|
|||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let version_row = format!(" ╭ {VERSION} ────────────────────────────────────────────────────────────────────────────╮ ");
|
let version_row = format!(
|
||||||
|
" ╭ {VERSION} ────────────────────────────────────────────────────────────────────────────╮ "
|
||||||
|
);
|
||||||
let expected = [
|
let expected = [
|
||||||
" ",
|
" ",
|
||||||
version_row.as_str(),
|
version_row.as_str(),
|
||||||
@@ -994,7 +1006,7 @@ mod tests {
|
|||||||
" │ │ ",
|
" │ │ ",
|
||||||
" │ │ ",
|
" │ │ ",
|
||||||
" ╰───────────────────────────────────────────────────────────────────────────────────╯ ",
|
" ╰───────────────────────────────────────────────────────────────────────────────────╯ ",
|
||||||
" "
|
" ",
|
||||||
];
|
];
|
||||||
|
|
||||||
for (row_index, result_row) in get_result(&setup, w) {
|
for (row_index, result_row) in get_result(&setup, w) {
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ use std::{sync::Arc, time::Instant};
|
|||||||
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
Frame,
|
||||||
layout::Alignment,
|
layout::Alignment,
|
||||||
style::Style,
|
style::Style,
|
||||||
widgets::{Block, Borders, Clear, Paragraph},
|
widgets::{Block, Borders, Clear, Paragraph},
|
||||||
Frame,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::AppColors,
|
config::AppColors,
|
||||||
ui::{gui_state::BoxLocation, GuiState},
|
ui::{GuiState, gui_state::BoxLocation},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{max_line_width, popup};
|
use super::{max_line_width, popup};
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
Frame,
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
style::{Modifier, Style, Stylize},
|
style::{Modifier, Style, Stylize},
|
||||||
widgets::{List, Paragraph},
|
widgets::{List, Paragraph},
|
||||||
Frame,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -14,7 +14,7 @@ use crate::{
|
|||||||
ui::{FrameData, GuiState, SelectablePanel, Status},
|
ui::{FrameData, GuiState, SelectablePanel, Status},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{generate_block, RIGHT_ARROW};
|
use super::{RIGHT_ARROW, generate_block};
|
||||||
|
|
||||||
/// Draw the logs panel
|
/// Draw the logs panel
|
||||||
pub fn draw(
|
pub fn draw(
|
||||||
@@ -81,10 +81,10 @@ mod tests {
|
|||||||
app_data::{ContainerImage, ContainerName},
|
app_data::{ContainerImage, ContainerName},
|
||||||
config::AppColors,
|
config::AppColors,
|
||||||
ui::{
|
ui::{
|
||||||
draw_blocks::tests::{
|
|
||||||
expected_to_vec, get_result, insert_logs, test_setup, BORDER_CHARS,
|
|
||||||
},
|
|
||||||
FrameData, Status,
|
FrameData, Status,
|
||||||
|
draw_blocks::tests::{
|
||||||
|
BORDER_CHARS, expected_to_vec, get_result, insert_logs, test_setup,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use ratatui::{
|
|||||||
|
|
||||||
use crate::config::AppColors;
|
use crate::config::AppColors;
|
||||||
|
|
||||||
use super::{gui_state::Region, FrameData, GuiState, SelectablePanel, Status};
|
use super::{FrameData, GuiState, SelectablePanel, Status, gui_state::Region};
|
||||||
|
|
||||||
pub mod charts;
|
pub mod charts;
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
@@ -118,12 +118,12 @@ pub mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use ratatui::{backend::TestBackend, layout::Rect, style::Color, Terminal};
|
use ratatui::{Terminal, backend::TestBackend, layout::Rect, style::Color};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app_data::{AppData, ContainerId, ContainerImage, ContainerName, ContainerPorts},
|
app_data::{AppData, ContainerId, ContainerImage, ContainerName, ContainerPorts},
|
||||||
tests::{gen_appdata, gen_containers},
|
tests::{gen_appdata, gen_containers},
|
||||||
ui::{draw_frame, GuiState, Redraw},
|
ui::{GuiState, Redraw, draw_frame},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::FrameData;
|
use super::FrameData;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
Frame,
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
style::{Color, Modifier, Style, Stylize},
|
style::{Color, Modifier, Style, Stylize},
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
widgets::{Block, BorderType, Borders, Paragraph},
|
widgets::{Block, BorderType, Borders, Paragraph},
|
||||||
Frame,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{app_data::State, config::AppColors, ui::FrameData};
|
use crate::{app_data::State, config::AppColors, ui::FrameData};
|
||||||
@@ -82,10 +82,10 @@ mod tests {
|
|||||||
app_data::{ContainerPorts, RunningState, State},
|
app_data::{ContainerPorts, RunningState, State},
|
||||||
config::AppColors,
|
config::AppColors,
|
||||||
ui::{
|
ui::{
|
||||||
draw_blocks::tests::{
|
|
||||||
expected_to_vec, get_result, test_setup, COLOR_ORANGE, COLOR_RX, COLOR_TX,
|
|
||||||
},
|
|
||||||
FrameData,
|
FrameData,
|
||||||
|
draw_blocks::tests::{
|
||||||
|
COLOR_ORANGE, COLOR_RX, COLOR_TX, expected_to_vec, get_result, test_setup,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+8
-5
@@ -2,18 +2,18 @@ use anyhow::Result;
|
|||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, DisableMouseCapture, Event},
|
event::{self, DisableMouseCapture, Event},
|
||||||
execute,
|
execute,
|
||||||
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
terminal::{EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode, enable_raw_mode},
|
||||||
};
|
};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
Frame, Terminal,
|
||||||
backend::CrosstermBackend,
|
backend::CrosstermBackend,
|
||||||
layout::{Constraint, Direction, Layout, Position},
|
layout::{Constraint, Direction, Layout, Position},
|
||||||
Frame, Terminal,
|
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashSet,
|
collections::HashSet,
|
||||||
io::{self, Stdout, Write},
|
io::{self, Stdout, Write},
|
||||||
sync::{atomic::Ordering, Arc},
|
sync::{Arc, atomic::Ordering},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use std::{sync::atomic::AtomicBool, time::Instant};
|
use std::{sync::atomic::AtomicBool, time::Instant};
|
||||||
@@ -75,7 +75,8 @@ impl Ui {
|
|||||||
is_running: Arc<AtomicBool>,
|
is_running: Arc<AtomicBool>,
|
||||||
redraw: Arc<Redraw>,
|
redraw: Arc<Redraw>,
|
||||||
) {
|
) {
|
||||||
if let Ok(mut terminal) = Self::setup_terminal() {
|
match Self::setup_terminal() {
|
||||||
|
Ok(mut terminal) => {
|
||||||
let cursor_position = terminal.get_cursor_position().unwrap_or_default();
|
let cursor_position = terminal.get_cursor_position().unwrap_or_default();
|
||||||
let mut ui = Self {
|
let mut ui = Self {
|
||||||
app_data,
|
app_data,
|
||||||
@@ -93,10 +94,12 @@ impl Ui {
|
|||||||
if let Err(e) = ui.reset_terminal() {
|
if let Err(e) = ui.reset_terminal() {
|
||||||
error!("{e}");
|
error!("{e}");
|
||||||
};
|
};
|
||||||
} else {
|
}
|
||||||
|
_ => {
|
||||||
error!("Terminal Error");
|
error!("Terminal Error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Setup the terminal for full-screen drawing mode, with mouse capture
|
/// Setup the terminal for full-screen drawing mode, with mouse capture
|
||||||
fn setup_terminal() -> Result<Terminal<CrosstermBackend<Stdout>>> {
|
fn setup_terminal() -> Result<Terminal<CrosstermBackend<Stdout>>> {
|
||||||
|
|||||||
Reference in New Issue
Block a user