refactor: Multiple UI improvements;

Use FrameData struct to store commonly accessed data, in order to
reduce mutex locks.

rename unpause to resume

use get_selected_panel() function instead of directly
gui_state.selected_panel

debug mode now shows some usefull information
This commit is contained in:
Jack Wills
2023-11-16 10:54:01 +00:00
parent 650aa0fc91
commit 40090865fd
8 changed files with 338 additions and 264 deletions
+19
View File
@@ -28,6 +28,11 @@ impl ContainerId {
pub fn get(&self) -> &str {
self.0.as_str()
}
/// Only return first 8 chars of id, is usually more than enough for uniqueness
pub fn get_short(&self) -> String {
self.0.chars().take(8).collect::<String>()
}
}
impl Ord for ContainerId {
@@ -443,6 +448,20 @@ pub struct ContainerItem {
pub is_oxker: bool,
}
/// Basic display information, for when running in debug mode
impl fmt::Display for ContainerItem {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{}, {}, {}, {}",
self.id.get_short(),
self.name,
self.cpu_stats.back().unwrap_or(&CpuStats::new(0.0)),
self.mem_stats.back().unwrap_or(&ByteStats::new(0))
)
}
}
impl ContainerItem {
/// Create a new container item
pub fn new(