Code cleanup
This commit is contained in:
parent
ac89e93b7a
commit
33b3fe59db
@ -1,11 +1,9 @@
|
|||||||
use core::panic;
|
|
||||||
|
|
||||||
use ratatui::{crossterm::event::KeyCode, widgets::ListState};
|
use ratatui::{crossterm::event::KeyCode, widgets::ListState};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::snowballing::{Publication, get_publication_by_id};
|
use crate::snowballing::{Publication, get_publication_by_id};
|
||||||
|
|
||||||
use log::{debug, error, info, warn};
|
use log::warn;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Default, PartialEq)]
|
#[derive(Serialize, Deserialize, Default, PartialEq)]
|
||||||
pub enum ActivePane {
|
pub enum ActivePane {
|
||||||
@ -129,6 +127,7 @@ pub struct App {
|
|||||||
// TODO: Implement possibility of pushing excluded papers back into pending
|
// TODO: Implement possibility of pushing excluded papers back into pending
|
||||||
// TODO: Implement export of included papers as csv for keywording with a spreadsheet
|
// TODO: Implement export of included papers as csv for keywording with a spreadsheet
|
||||||
// TODO: Implement export of included papers into zotero (Use RIS format somehow)
|
// TODO: Implement export of included papers into zotero (Use RIS format somehow)
|
||||||
|
// TODO: Implement proper ui and actor thread separation
|
||||||
// TODO: Log everything relevant
|
// TODO: Log everything relevant
|
||||||
impl App {
|
impl App {
|
||||||
pub async fn add_seed_paper(&mut self, api_link: &String) {
|
pub async fn add_seed_paper(&mut self, api_link: &String) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use std::{error::Error, io, time::Duration};
|
use std::{error::Error, io, time::Duration};
|
||||||
|
|
||||||
use log::{warn, error};
|
use log::{error};
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
Terminal,
|
Terminal,
|
||||||
backend::{Backend, CrosstermBackend},
|
backend::{Backend, CrosstermBackend},
|
||||||
@ -54,11 +54,11 @@ where
|
|||||||
loop {
|
loop {
|
||||||
terminal.draw(|frame| ui::draw(frame, &mut app))?;
|
terminal.draw(|frame| ui::draw(frame, &mut app))?;
|
||||||
|
|
||||||
// if event::poll(Duration::from_millis(10))? {
|
if event::poll(Duration::from_millis(100))? {
|
||||||
if let Event::Key(key) = event::read()? {
|
if let Event::Key(key) = event::read()? {
|
||||||
app.handle_key(key.code).await;
|
app.handle_key(key.code).await;
|
||||||
}
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
if app.should_quit {
|
if app.should_quit {
|
||||||
return Ok(app);
|
return Ok(app);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use log::{error, info};
|
use log::{error};
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
mod app;
|
mod app;
|
||||||
|
|||||||
14
src/ui.rs
14
src/ui.rs
@ -4,7 +4,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
Frame,
|
Frame,
|
||||||
layout::{Constraint, Direction, Layout, Rect, VerticalAlignment},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
style::{Color, Modifier, Style, Stylize},
|
style::{Color, Modifier, Style, Stylize},
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
widgets::{Block, Borders, List, ListItem, ListState, Paragraph},
|
widgets::{Block, Borders, List, ListItem, ListState, Paragraph},
|
||||||
@ -275,9 +275,9 @@ fn draw_left_pane(frame: &mut Frame, app: &mut App, area: Rect) {
|
|||||||
|
|
||||||
frame.render_stateful_widget(list, chunks[0], &mut app.included_list_state);
|
frame.render_stateful_widget(list, chunks[0], &mut app.included_list_state);
|
||||||
|
|
||||||
// Snowballing status
|
// Snowballing progress
|
||||||
|
|
||||||
let status = vec![
|
let progress = vec![
|
||||||
Line::from(vec![
|
Line::from(vec![
|
||||||
Span::raw("Iteration: "),
|
Span::raw("Iteration: "),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
@ -294,14 +294,12 @@ fn draw_left_pane(frame: &mut Frame, app: &mut App, area: Rect) {
|
|||||||
]),
|
]),
|
||||||
];
|
];
|
||||||
|
|
||||||
let status_widget =
|
let progress_widget =
|
||||||
ratatui::widgets::Paragraph::new(status).style(Style::default());
|
ratatui::widgets::Paragraph::new(progress).style(Style::default());
|
||||||
frame.render_widget(status_widget, chunks[1]);
|
frame.render_widget(progress_widget, chunks[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_right_pane(frame: &mut Frame, app: &mut App, area: Rect) {
|
fn draw_right_pane(frame: &mut Frame, app: &mut App, area: Rect) {
|
||||||
// Included Publication list
|
|
||||||
|
|
||||||
let items = create_publication_item_list(
|
let items = create_publication_item_list(
|
||||||
&app.pending_publications,
|
&app.pending_publications,
|
||||||
if app.active_pane == ActivePane::PendingPublications {
|
if app.active_pane == ActivePane::PendingPublications {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user