wip: sort by
This commit is contained in:
@@ -5,9 +5,12 @@ use tui::{
|
||||
widgets::{ListItem, ListState},
|
||||
};
|
||||
|
||||
use super::Header;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StatefulList<T> {
|
||||
pub state: ListState,
|
||||
// HASH MAP!
|
||||
pub items: Vec<T>,
|
||||
}
|
||||
|
||||
@@ -114,18 +117,18 @@ impl State {
|
||||
_ => Color::Red,
|
||||
}
|
||||
}
|
||||
pub fn as_text(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Dead => "dead",
|
||||
Self::Exited => "exited",
|
||||
Self::Paused => "paused",
|
||||
Self::Removing => "removing",
|
||||
Self::Restarting => "restarting",
|
||||
Self::Running => "running",
|
||||
Self::Unknown => "unknown",
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn as_text(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Dead => "dead",
|
||||
Self::Exited => "exited",
|
||||
Self::Paused => "paused",
|
||||
Self::Removing => "removing",
|
||||
Self::Restarting => "restarting",
|
||||
Self::Running => "running",
|
||||
Self::Unknown => "unknown",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for State {
|
||||
fn from(input: &str) -> Self {
|
||||
@@ -420,31 +423,31 @@ impl ContainerItem {
|
||||
/// Container information panel headings + widths, for nice pretty formatting
|
||||
#[derive(Debug)]
|
||||
pub struct Columns {
|
||||
pub state: (String, usize),
|
||||
pub status: (String, usize),
|
||||
pub cpu: (String, usize),
|
||||
pub mem: (String, usize),
|
||||
pub id: (String, usize),
|
||||
pub name: (String, usize),
|
||||
pub image: (String, usize),
|
||||
pub net_rx: (String, usize),
|
||||
pub net_tx: (String, usize),
|
||||
pub state: (Header, usize),
|
||||
pub status: (Header, usize),
|
||||
pub cpu: (Header, usize),
|
||||
pub mem: (Header, usize),
|
||||
pub id: (Header, usize),
|
||||
pub name: (Header, usize),
|
||||
pub image: (Header, usize),
|
||||
pub net_rx: (Header, usize),
|
||||
pub net_tx: (Header, usize),
|
||||
}
|
||||
|
||||
impl Columns {
|
||||
//. (Column titles, minimum header string length)
|
||||
// (Column titles, minimum header string length)
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
state: (String::from("state"), 11),
|
||||
status: (String::from("status"), 16),
|
||||
state: (Header::State, 11),
|
||||
status: (Header::Status, 16),
|
||||
// 7 to allow for "100.00%"
|
||||
cpu: (String::from("cpu"), 7),
|
||||
mem: (String::from("memory/limit"), 12),
|
||||
id: (String::from("id"), 8),
|
||||
name: (String::from("name"), 4),
|
||||
image: (String::from("image"), 5),
|
||||
net_rx: (String::from("↓ rx"), 5),
|
||||
net_tx: (String::from("↑ tx"), 5),
|
||||
cpu: (Header::Cpu, 7),
|
||||
mem: (Header::Memory, 12),
|
||||
id: (Header::Id, 8),
|
||||
name: (Header::Name, 4),
|
||||
image: (Header::Image, 5),
|
||||
net_rx: (Header::Rx, 5),
|
||||
net_tx: (Header::Tx, 5),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user