feat: initial TUI for administration #49
3 changed files with 6 additions and 28 deletions
|
|
@ -1,6 +1,6 @@
|
|||
//! Keyboard handling
|
||||
|
||||
use crossterm::event::{KeyCode, KeyEvent};
|
||||
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
|
||||
|
||||
use super::state::{Mode, State};
|
||||
|
||||
|
|
@ -18,8 +18,10 @@ pub async fn handle_key(state: &mut State, key_event: KeyEvent) {
|
|||
KeyCode::Esc | KeyCode::Char('q') => state.quit = true,
|
||||
_ => {}
|
||||
},
|
||||
Mode::Edit => match key_event.code {
|
||||
KeyCode::Esc => state.mode = Mode::List,
|
||||
Mode::Edit => match (key_event.modifiers, key_event.code) {
|
||||
(KeyModifiers::NONE, KeyCode::Esc) => state.mode = Mode::List,
|
||||
(KeyModifiers::NONE, KeyCode::Tab) => {}
|
||||
(KeyModifiers::SHIFT, KeyCode::Tab) => {}
|
||||
_ => {}
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,28 +74,4 @@ impl State {
|
|||
}
|
||||
self.places_status = DataStatus::Fresh;
|
||||
}
|
||||
|
||||
pub async fn fetch_places(&mut self) {
|
||||
if let DataStatus::Fresh = self.places_status {
|
||||
return;
|
||||
}
|
||||
let limit = (self.height as u8).saturating_sub(3);
|
||||
let offset = (limit as u32) * self.page;
|
||||
match self
|
||||
.places_repository
|
||||
.get_places_paginated(offset, limit)
|
||||
.await
|
||||
{
|
||||
Ok(places) => {
|
||||
self.places = places;
|
||||
if !self.places.is_empty() {
|
||||
self.selected_place.select(Some(0));
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
tracing::error!("{err}");
|
||||
}
|
||||
}
|
||||
self.places_status = DataStatus::Fresh;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ fn list_draw(state: &mut State, f: &mut Frame<'_>, area: Rect) {
|
|||
f.render_stateful_widget(places_table, area, &mut state.selected_place);
|
||||
}
|
||||
|
||||
fn edit_draw(state: &mut State, f: &mut Frame<'_>, area: Rect) {}
|
||||
fn edit_draw(_state: &mut State, _f: &mut Frame<'_>, _area: Rect) {}
|
||||
|
||||
#[expect(unstable_name_collisions)]
|
||||
fn footer_draw(state: &mut State, f: &mut Frame<'_>, area: Rect) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue