Skip to content

Commit

Permalink
added ui changes for cron jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
somayaj committed Jul 5, 2021
1 parent e2c42d5 commit 28abf28
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions src/ui/overview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ static STFS_TITLE: &str = "StatefulSets";
static REPLICA_SETS_TITLE: &str = "ReplicaSets";
static DEPLOYMENTS_TITLE: &str = "Deployments";
static JOBS_TITLE: &str = "Jobs";
static CRON_JOBS_TITLE: &str = "Cron Jobs";
static DESCRIBE_ACTIVE: &str = "-> Describe ";
static YAML_ACTIVE: &str = "-> YAML ";

Expand Down Expand Up @@ -138,6 +139,7 @@ fn draw_resource_tabs_block<B: Backend>(f: &mut Frame<B>, app: &mut App, area: R
5 => draw_replica_sets_tab(app.get_current_route().active_block, f, app, chunks[1]),
6 => draw_deployments_tab(app.get_current_route().active_block, f, app, chunks[1]),
7 => draw_jobs_tab(app.get_current_route().active_block, f, app, chunks[1]),
8 => draw_cronjobs_tab(app.get_current_route().active_block, f, app, chunks[1]),
_ => {}
};
}
Expand Down Expand Up @@ -353,6 +355,30 @@ fn draw_jobs_tab<B: Backend>(block: ActiveBlock, f: &mut Frame<B>, app: &mut App
};
}

fn draw_cronjobs_tab<B: Backend>(block: ActiveBlock, f: &mut Frame<B>, app: &mut App, area: Rect) {
match block {
ActiveBlock::Describe | ActiveBlock::Yaml => draw_describe_block(
f,
app,
area,
title_with_dual_style(
get_resource_title(
app,
CRON_JOBS_TITLE,
get_describe_active(block),
app.data.cronjobs.items.len(),
),
format!("{} | {} <esc>", COPY_HINT, CRON_JOBS_TITLE),
app.light_theme,
),
),
ActiveBlock::Namespaces => {
draw_cronjobs_tab(app.get_prev_route().active_block, f, app, area);
}
_ => draw_cronjobs_block(f, app, area),
};
}

fn draw_context_info_block<B: Backend>(f: &mut Frame<B>, app: &mut App, area: Rect) {
let chunks = vertical_chunks_with_margin(
vec![
Expand Down Expand Up @@ -844,6 +870,52 @@ fn draw_jobs_block<B: Backend>(f: &mut Frame<B>, app: &mut App, area: Rect) {
);
}

fn draw_cronjobs_block<B: Backend>(f: &mut Frame<B>, app: &mut App, area: Rect) {
let title = get_resource_title(app, CRON_JOBS_TITLE, "", app.data.cronjobs.items.len());

draw_resource_block(
f,
area,
ResourceTableProps {
title,
inline_help: DESCRIBE_AND_YAML_HINT.into(),
resource: &mut app.data.cronjobs,
table_headers: vec![
"Namespace",
"Name",
"Schedule",
"Last Scheduled",
"Suspend",
"Active",
"Age",
],
column_widths: vec![
Constraint::Percentage(25),
// workaround for TUI-RS issue : https://github.com/fdehau/tui-rs/issues/470#issuecomment-852562848
Constraint::Percentage(39),
Constraint::Percentage(15),
Constraint::Percentage(10),
Constraint::Percentage(10),
Constraint::Percentage(10),
Constraint::Percentage(10),
],
},
|c| {
Row::new(vec![
Cell::from(c.namespace.to_owned()),
Cell::from(c.name.to_owned()),
Cell::from(c.schedule.to_owned()),
Cell::from(c.last_schedule.to_string()),
Cell::from(c.suspend.to_string()),
Cell::from(c.active.to_string()),
Cell::from(c.age.to_owned()),
])
.style(style_primary())
},
app.light_theme,
app.is_loading,
);
}
fn draw_logs_block<B: Backend>(f: &mut Frame<B>, app: &mut App, area: Rect) {
let selected_container = app.data.selected.container.clone();
let container_name = selected_container.unwrap_or_default();
Expand Down

0 comments on commit 28abf28

Please sign in to comment.