Skip to content

Commit

Permalink
Add metrics section (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
pythops authored Jan 15, 2025
1 parent 0ed04df commit 29c1b69
Show file tree
Hide file tree
Showing 8 changed files with 604 additions and 91 deletions.
129 changes: 42 additions & 87 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Real-time traffic inspection and visualization.
- Comprehensive Traffic Statistics.
- Firewall functionalities.
- Metrics explorer.
- Fuzzy search.

## 💡 Prerequisites
Expand Down
3 changes: 2 additions & 1 deletion oryx-tui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ aya = "0.13"
oryx-common = { path = "../oryx-common" }
mio = { version = "1", features = ["os-poll", "os-ext"] }
itertools = "0.14"
dirs = "5"
dirs = "6"
kanal = "0.1.0-pre8"
mimalloc = "0.1"
clap = { version = "4", features = ["derive", "cargo"] }
Expand All @@ -28,6 +28,7 @@ log = "0.4"
env_logger = "0.11"
serde_json = "1"
serde = { version = "1", features = ["derive"] }
regex = "1"

[[bin]]
name = "oryx"
Expand Down
1 change: 1 addition & 0 deletions oryx-tui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub enum ActivePopup {
UpdateFilters,
PacketInfos,
NewFirewallRule,
NewMetricExplorer,
}

#[derive(Debug)]
Expand Down
25 changes: 24 additions & 1 deletion oryx-tui/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ pub fn handle_key_events(
.handle_keys(key_event, event_sender.clone())?;
app.is_editing = false;
}
ActivePopup::NewMetricExplorer => {
app.section.metrics.handle_popup_keys(key_event)?;
app.is_editing = false;
}
_ => {}
}
}
Expand All @@ -92,6 +96,12 @@ pub fn handle_key_events(
app.is_editing = false;
}
}
ActivePopup::NewMetricExplorer => {
if app.section.metrics.handle_popup_keys(key_event).is_ok() {
app.active_popup = None;
app.is_editing = false;
}
}
_ => {}
},

Expand All @@ -104,6 +114,9 @@ pub fn handle_key_events(
.firewall
.handle_keys(key_event, event_sender.clone())?;
}
ActivePopup::NewMetricExplorer => {
app.section.metrics.handle_popup_keys(key_event)?;
}
_ => {}
},
}
Expand Down Expand Up @@ -158,11 +171,21 @@ pub fn handle_key_events(

KeyCode::Char('n') | KeyCode::Char('e') => {
if app.section.focused_section == FocusedSection::Firewall
&& app.section.handle_keys(key_event, event_sender).is_ok()
&& app
.section
.handle_keys(key_event, event_sender.clone())
.is_ok()
{
app.is_editing = true;
app.active_popup = Some(ActivePopup::NewFirewallRule);
}

if app.section.focused_section == FocusedSection::Metrics
&& app.section.handle_keys(key_event, event_sender).is_ok()
{
app.is_editing = true;
app.active_popup = Some(ActivePopup::NewMetricExplorer);
}
}

KeyCode::Char('i') => {
Expand Down
Loading

0 comments on commit 29c1b69

Please sign in to comment.