pp/src/tui/mode_deleting.rs
Trevor Merritt 7d830c4e3b ** RatatuiUi **
displays a preset list of hosts and their response state

Updates format of input file to CSV with <host ip>,<host name> as the format.
UI now has red/green for down/up hosts
duration_to_string now in lib
improves display of how long ago change happened
log events are now displayed on the monitoring page to show when a host comes up/goes down
Modularize ui better
Adds ability to return to monitoring or quit from editing page
table in place for displaying hosts

WIP: start of being able to go up/down through the list of hosts to eventually edit them.
2025-04-28 13:49:36 -04:00

47 lines
1.5 KiB
Rust

use std::time::Duration;
use crossterm::event;
use crossterm::event::{Event, KeyCode, KeyEventKind};
use ratatui::Frame;
use ratatui::style::Stylize;
use ratatui::text::Line;
use ratatui::widgets::{Block, Paragraph};
use crate::tui::ratatui_app::RatatuiApp;
use crate::tui::ratatui_screens::RatatuiScreens::Monitoring;
use color_eyre::Result;
pub struct RatatuiDeletingMode {}
impl RatatuiDeletingMode {
pub fn render(frame: &mut Frame, state: &mut RatatuiApp) {
let title = Line::from("Delete Host").bold().red().centered();
let mut body = format!("Do you really want to delete {} (Y/N)", state.selected_host);
frame.render_widget(
Paragraph::new(body)
.block(Block::bordered().title(title))
.centered(),
frame.area()
);
}
pub fn handle_crossterm_events(app: &mut RatatuiApp) -> Result<()> {
if event::poll(Duration::from_millis(100))? {
match event::read()? {
Event::Key(key) if key.kind == KeyEventKind::Press => match key.code {
KeyCode::Enter | KeyCode::Char('y') | KeyCode::Char('Y') => {
println!("TiME TO DELETE SELECTED");
}
KeyCode::Esc | KeyCode::Char('n') | KeyCode::Char('N') => {
app.set_screen(Monitoring)
}
_ => {}
}
_ => {}
}
}
Ok(())
}
}