feat: log title show container name, closes #16

This commit is contained in:
Jack Wills
2022-10-16 01:22:04 +00:00
parent a98e8b7260
commit 9cb0c414af
+11 -2
View File
@@ -253,11 +253,20 @@ impl AppData {
}
/// Get the title for log panel for selected container
/// will be "logs x/x"
/// will be either
/// 1) "logs x/x - container_name" where container_name is 32 chars max
/// 2) "logs - container_name" when no logs found, again 32 chars max
pub fn get_log_title(&self) -> String {
self.get_selected_log_index()
.map_or("".to_owned(), |index| {
self.containers.items[index].logs.get_state_title()
let logs_len = self.containers.items[index].logs.get_state_title();
let mut name = self.containers.items[index].name.clone();
name.truncate(32);
if logs_len.is_empty() {
format!("- {} ", name)
} else {
format!("{} - {}", logs_len, name)
}
})
}