refactor: dead code removed
This commit is contained in:
@@ -154,10 +154,9 @@ fn draw_columns(
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let container_splits = header_data.iter().map(|i| i.2).collect::<Vec<_>>();
|
|
||||||
let headers_section = Layout::default()
|
let headers_section = Layout::default()
|
||||||
.direction(Direction::Horizontal)
|
.direction(Direction::Horizontal)
|
||||||
.constraints(container_splits)
|
.constraints(header_data.iter().map(|i| i.2))
|
||||||
.split(split_bar[1]);
|
.split(split_bar[1]);
|
||||||
|
|
||||||
for (index, (paragraph, header, _)) in header_data.into_iter().enumerate() {
|
for (index, (paragraph, header, _)) in header_data.into_iter().enumerate() {
|
||||||
@@ -196,7 +195,10 @@ pub fn draw(
|
|||||||
|
|
||||||
let column_width = usize::from(area.width).saturating_sub(help_width);
|
let column_width = usize::from(area.width).saturating_sub(help_width);
|
||||||
let column_width = if column_width > 0 { column_width } else { 1 };
|
let column_width = if column_width > 0 { column_width } else { 1 };
|
||||||
let splits = if fd.has_containers {
|
|
||||||
|
let split_bar = Layout::default()
|
||||||
|
.direction(Direction::Horizontal)
|
||||||
|
.constraints(if fd.has_containers {
|
||||||
vec![
|
vec![
|
||||||
Constraint::Max(4),
|
Constraint::Max(4),
|
||||||
Constraint::Max(column_width.try_into().unwrap_or_default()),
|
Constraint::Max(column_width.try_into().unwrap_or_default()),
|
||||||
@@ -204,11 +206,7 @@ pub fn draw(
|
|||||||
]
|
]
|
||||||
} else {
|
} else {
|
||||||
CONSTRAINT_100.to_vec()
|
CONSTRAINT_100.to_vec()
|
||||||
};
|
})
|
||||||
|
|
||||||
let split_bar = Layout::default()
|
|
||||||
.direction(Direction::Horizontal)
|
|
||||||
.constraints(splits)
|
|
||||||
.split(area);
|
.split(area);
|
||||||
|
|
||||||
draw_loading_spinner(colors, f, fd, split_bar[0]);
|
draw_loading_spinner(colors, f, fd, split_bar[0]);
|
||||||
|
|||||||
+17
-42
@@ -302,25 +302,11 @@ impl From<&Ui> for FrameData {
|
|||||||
fn from(ui: &Ui) -> Self {
|
fn from(ui: &Ui) -> Self {
|
||||||
let (app_data, gui_data) = (ui.app_data.lock(), ui.gui_state.lock());
|
let (app_data, gui_data) = (ui.app_data.lock(), ui.gui_state.lock());
|
||||||
|
|
||||||
// set a flag if the - or = button has been pressed, and if so use that calc, else use this calc
|
|
||||||
// set max height for container section, needs +5 to deal with docker commands list and borders
|
|
||||||
// TODO fix this
|
|
||||||
// let container_len = app_data.get_container_len();
|
|
||||||
// let container_section_height = if container_len < 12 {
|
|
||||||
// // u16::try_from(container_len + 5).unwrap_or_default()
|
|
||||||
// 8
|
|
||||||
// } else {
|
|
||||||
// 12
|
|
||||||
// };
|
|
||||||
// TODO work out what to do with this
|
|
||||||
// container_section_height = 8;
|
|
||||||
|
|
||||||
let (filter_by, filter_term) = app_data.get_filter();
|
let (filter_by, filter_term) = app_data.get_filter();
|
||||||
Self {
|
Self {
|
||||||
chart_data: app_data.get_chart_data(),
|
chart_data: app_data.get_chart_data(),
|
||||||
color_logs: app_data.config.color_logs,
|
color_logs: app_data.config.color_logs,
|
||||||
columns: app_data.get_width(),
|
columns: app_data.get_width(),
|
||||||
// container_section_height,
|
|
||||||
container_title: app_data.get_container_title(),
|
container_title: app_data.get_container_title(),
|
||||||
delete_confirm: gui_data.get_delete_container(),
|
delete_confirm: gui_data.get_delete_container(),
|
||||||
filter_by,
|
filter_by,
|
||||||
@@ -351,15 +337,13 @@ fn draw_frame(
|
|||||||
fd: &FrameData,
|
fd: &FrameData,
|
||||||
gui_state: &Arc<Mutex<GuiState>>,
|
gui_state: &Arc<Mutex<GuiState>>,
|
||||||
) {
|
) {
|
||||||
let whole_constraints = if fd.status.contains(&Status::Filter) {
|
let whole_layout = Layout::default()
|
||||||
|
.direction(Direction::Vertical)
|
||||||
|
.constraints(if fd.status.contains(&Status::Filter) {
|
||||||
vec![Constraint::Max(1), Constraint::Min(1), Constraint::Max(1)]
|
vec![Constraint::Max(1), Constraint::Min(1), Constraint::Max(1)]
|
||||||
} else {
|
} else {
|
||||||
vec![Constraint::Max(1), Constraint::Min(1)]
|
vec![Constraint::Max(1), Constraint::Min(1)]
|
||||||
};
|
})
|
||||||
|
|
||||||
let whole_layout = Layout::default()
|
|
||||||
.direction(Direction::Vertical)
|
|
||||||
.constraints(whole_constraints)
|
|
||||||
.split(f.area());
|
.split(f.area());
|
||||||
|
|
||||||
draw_blocks::headers::draw(whole_layout[0], colors, f, fd, gui_state, keymap);
|
draw_blocks::headers::draw(whole_layout[0], colors, f, fd, gui_state, keymap);
|
||||||
@@ -369,45 +353,36 @@ fn draw_frame(
|
|||||||
draw_blocks::filter::draw(*rect, colors, f, fd);
|
draw_blocks::filter::draw(*rect, colors, f, fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// What we should do is work out the container+logs size, and then set the percentage to height - 6
|
let upper_main = Layout::default()
|
||||||
|
.direction(Direction::Vertical)
|
||||||
let container_logs_section_constraints = if fd.show_logs {
|
.constraints(if fd.has_containers {
|
||||||
vec![Constraint::Min(6), Constraint::Percentage(fd.log_height)]
|
|
||||||
} else {
|
|
||||||
vec![Constraint::Percentage(100)]
|
|
||||||
};
|
|
||||||
|
|
||||||
let upper_main_constraints = if fd.has_containers {
|
|
||||||
vec![Constraint::Percentage(75), Constraint::Percentage(25)]
|
vec![Constraint::Percentage(75), Constraint::Percentage(25)]
|
||||||
} else {
|
} else {
|
||||||
vec![Constraint::Percentage(100), Constraint::Percentage(0)]
|
vec![Constraint::Percentage(100), Constraint::Percentage(0)]
|
||||||
};
|
})
|
||||||
let upper_main = Layout::default()
|
|
||||||
.direction(Direction::Vertical)
|
|
||||||
.constraints(upper_main_constraints)
|
|
||||||
.split(whole_layout[1]);
|
.split(whole_layout[1]);
|
||||||
|
|
||||||
let containers_logs_section = Layout::default()
|
let containers_logs_section = Layout::default()
|
||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
.constraints(container_logs_section_constraints)
|
.constraints(if fd.show_logs {
|
||||||
.split(upper_main[0]);
|
vec![Constraint::Min(6), Constraint::Percentage(fd.log_height)]
|
||||||
|
|
||||||
// Containers & Command Horizontal split
|
|
||||||
let container_command_constraints = if fd.has_containers {
|
|
||||||
vec![Constraint::Percentage(90), Constraint::Percentage(10)]
|
|
||||||
} else {
|
} else {
|
||||||
vec![Constraint::Percentage(100)]
|
vec![Constraint::Percentage(100)]
|
||||||
};
|
})
|
||||||
|
.split(upper_main[0]);
|
||||||
|
|
||||||
// Containers + docker commands
|
// Containers + docker commands
|
||||||
let containers_commands = Layout::default()
|
let containers_commands = Layout::default()
|
||||||
.direction(Direction::Horizontal)
|
.direction(Direction::Horizontal)
|
||||||
.constraints(container_command_constraints)
|
.constraints(if fd.has_containers {
|
||||||
|
vec![Constraint::Percentage(90), Constraint::Percentage(10)]
|
||||||
|
} else {
|
||||||
|
vec![Constraint::Percentage(100)]
|
||||||
|
})
|
||||||
.split(containers_logs_section[0]);
|
.split(containers_logs_section[0]);
|
||||||
|
|
||||||
draw_blocks::containers::draw(app_data, containers_commands[0], colors, f, fd, gui_state);
|
draw_blocks::containers::draw(app_data, containers_commands[0], colors, f, fd, gui_state);
|
||||||
|
|
||||||
// TODO redraw logs
|
|
||||||
if fd.show_logs {
|
if fd.show_logs {
|
||||||
draw_blocks::logs::draw(
|
draw_blocks::logs::draw(
|
||||||
app_data,
|
app_data,
|
||||||
|
|||||||
Reference in New Issue
Block a user