Skip to content

Commit

Permalink
dixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adgaultier committed Sep 30, 2024
1 parent 80aefba commit 37f7e50
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions oryx-tui/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
app::{App, AppResult, Mode},
event::Event,
phase::Phase,
popup::PopupEnum,
popup::ActivePopup,
};
use ratatui::crossterm::event::{KeyCode, KeyEvent, KeyModifiers};

Expand All @@ -11,7 +11,7 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
if app.mode == Mode::Normal {
match key_event.code {
KeyCode::Char('?') => {
app.phase.popup = Some(PopupEnum::Help);
app.phase.popup = Some(ActivePopup::Help);
return Ok(());
}
KeyCode::Char('q') => {
Expand Down
12 changes: 6 additions & 6 deletions oryx-tui/src/phase.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{app::App, popup::ActivePopup};

use crate::sections::section::Section;
use ratatui::{layout::Rect, Frame};
use ratatui::Frame;
#[derive(Debug, Clone, PartialEq)]
pub enum Step {
Startup,
Expand All @@ -17,7 +17,7 @@ pub struct Phase {
impl Phase {
pub fn render(&mut self, frame: &mut Frame, app: &mut App) {
match self.step {
Step::Startup => app.startup.render(frame, app),
Step::Startup => app.startup.clone().render(frame, app),
Step::Sniffing(section) => section.render(frame, app),
}
match self.popup {
Expand All @@ -27,7 +27,7 @@ impl Phase {
}
pub fn new() -> Self {
Self {
phase_enum: PhaseEnum::Startup,
step: Step::Startup,
popup: None,
}
}
Expand All @@ -39,9 +39,9 @@ impl Phase {
.unwrap()
.handle_key_events(key_event, app);
}
None => match &self.phase_enum {
PhaseEnum::Startup => app.startup.clone().handle_key_events(key_event, app),
PhaseEnum::Sniffing(mut section) => section.handle_key_events(key_event, app),
None => match &self.step {
Step::Startup => app.startup.clone().handle_key_events(key_event, app),
Step::Sniffing(mut section) => section.handle_key_events(key_event, app),
},
}
}
Expand Down
12 changes: 6 additions & 6 deletions oryx-tui/src/sections/section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::{
network::{IpPacket, IpProto},
packet::AppPacket,
},
phase::PhaseEnum,
popup::PopupEnum,
phase::Step,
popup::ActivePopup,
traits::MenuComponent,
};
use crossterm::event::{KeyCode, KeyEvent};
Expand Down Expand Up @@ -39,7 +39,7 @@ impl Section {
Section::Firewall => Section::Packet,
};

app.phase.phase_enum = PhaseEnum::Sniffing(section);
app.phase.step = Step::Sniffing(section);
}
pub fn previous(&self, app: &mut App) {
let x = match self {
Expand All @@ -48,7 +48,7 @@ impl Section {
Section::Alerts => Section::Stats,
Section::Firewall => Section::Alerts,
};
app.phase.phase_enum = PhaseEnum::Sniffing(x);
app.phase.step = Step::Sniffing(x);
}

pub fn handle_key_events(&mut self, key_event: KeyEvent, app: &mut App) {
Expand Down Expand Up @@ -87,7 +87,7 @@ impl Section {
match key_event.code {
KeyCode::Char('i') => {
if !app.packet_index.is_none() && !fuzzy.packets.is_empty() {
app.phase.popup = Some(PopupEnum::PacketInfo);
app.phase.popup = Some(ActivePopup::PacketInfo);
}
}
KeyCode::Char('/') => {
Expand Down Expand Up @@ -149,7 +149,7 @@ impl Section {
app.packets_table_state.select(Some(i));
}
KeyCode::Char('f') => {
app.phase.popup = Some(PopupEnum::FilterUpdate);
app.phase.popup = Some(ActivePopup::FilterUpdate);

app.filter.transport.set_state(Some(0));

Expand Down
8 changes: 4 additions & 4 deletions oryx-tui/src/startup.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::app::App;

use crate::filters::direction::TrafficDirection;
use crate::phase::{Phase, PhaseEnum};
use crate::popup::PopupEnum;
use crate::phase::{Phase, Step};
use crate::popup::ActivePopup;
use crate::sections::section::Section;
use crate::traits::ScrollableMenuComponent;
use crossterm::event::{KeyCode, KeyEvent};
Expand Down Expand Up @@ -30,7 +30,7 @@ pub enum StartupBlockEnum {
#[derive(Debug, Clone, PartialEq)]
pub struct Startup {
pub focus_block: StartupBlockEnum,
pub popup: Option<PopupEnum>,
pub popup: Option<ActivePopup>,
}
impl Startup {
pub fn new() -> Self {
Expand Down Expand Up @@ -144,7 +144,7 @@ impl Startup {
}

app.phase = Phase {
phase_enum: PhaseEnum::Sniffing(Section::Packet),
step: Step::Sniffing(Section::Packet),
popup: None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion oryx-tui/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn render(app: &mut App, frame: &mut Frame) {
// }
// }
// }
app.phase.clone().render(frame, frame.area(), app);
app.phase.clone().render(frame, app);

for (index, notification) in app.notifications.iter().enumerate() {
notification.render(index, frame);
Expand Down
4 changes: 2 additions & 2 deletions oryx-tui/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use tui_big_text::{BigText, PixelSize};

use crate::app::App;
use crate::filters::direction::TrafficDirection;
use crate::phase::{Phase, PhaseEnum};
use crate::phase::{Phase, Step};
use crate::sections::section::Section;
use crate::traits::ScrollableMenuComponent;

Expand Down Expand Up @@ -105,7 +105,7 @@ impl UpdateBlockEnum {
}

app.phase = Phase {
phase_enum: PhaseEnum::Sniffing(Section::Packet),
step: Step::Sniffing(Section::Packet),
popup: None,
}
}
Expand Down

0 comments on commit 37f7e50

Please sign in to comment.