Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions src/ui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub struct DevfilerUi {
md_cache: CommonMarkCache,
auto_scroll_time: Option<Duration>,
kind: SampleKind,
requested_time_range: Option<(UtcTimestamp, UtcTimestamp)>,
}

impl eframe::App for DevfilerUi {
Expand All @@ -61,6 +62,7 @@ impl DevfilerUi {
active_tab: Tab::FlameGraph,
tabs: vec![
Box::new(tabs::FlameGraphTab::default()),
Box::new(tabs::FlameScopeTab::default()),
Box::new(tabs::TopFuncsTab::default()),
Box::new(tabs::ExecutablesTab::default()),
Box::new(tabs::LogTab::default()),
Expand All @@ -81,6 +83,7 @@ impl DevfilerUi {
md_cache: CommonMarkCache::default(),
auto_scroll_time: Some(Duration::try_minutes(15).unwrap()),
kind: SampleKind::Mixed,
requested_time_range: None,
}
}

Expand Down Expand Up @@ -114,7 +117,19 @@ impl DevfilerUi {

if let Some(active_tab) = self.tabs.iter_mut().find(|t| t.id() == self.active_tab) {
ui.push_id(active_tab.id(), |ui| {
active_tab.update(ui, &self.cfg, self.kind, data_start, data_end);
let action = active_tab.update(ui, &self.cfg, self.kind, data_start, data_end);

// Handle any tab action returned
if let Some(tabs::TabAction::SwitchTabWithTimeRange { tab, start, end }) =
action
{
self.active_tab = tab;
// Disable auto-scroll when switching with a specific time range
self.auto_scroll_time = None;
// Set the requested time range for the next frame
self.requested_time_range = Some((start, end));
ctx.request_repaint();
}
});
}
});
Expand Down Expand Up @@ -172,7 +187,17 @@ impl DevfilerUi {
let response = plot.show(ui, |pui| {
let data_start;
let data_end;
if let Some(new_lookback) = self.auto_scroll_time {

// If there's a requested time range (from tab action), use it
if let Some((req_start, req_end)) = self.requested_time_range.take() {
data_start = req_start;
data_end = req_end;

pui.set_plot_bounds(PlotBounds::from_min_max(
[data_start as f64, -f64::MIN],
[data_end as f64, f64::MAX],
));
} else if let Some(new_lookback) = self.auto_scroll_time {
let now = chrono::Utc::now();

data_start = (now - new_lookback).timestamp() as UtcTimestamp;
Expand Down
3 changes: 2 additions & 1 deletion src/ui/tabs/dbstats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl TabWidget for DbStatsTab {
_kind: SampleKind,
_start: UtcTimestamp,
_end: UtcTimestamp,
) {
) -> Option<TabAction> {
ScrollArea::vertical().show(ui, |ui| {
let clicked = ui.small_button("Flush Event Data").clicked();
if clicked {
Expand All @@ -47,6 +47,7 @@ impl TabWidget for DbStatsTab {
});
}
});
None
}

fn show_tab_selector(&self, cfg: &DevfilerConfig) -> bool {
Expand Down
3 changes: 2 additions & 1 deletion src/ui/tabs/executables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ impl TabWidget for ExecutablesTab {
_kind: SampleKind,
_start: UtcTimestamp,
_end: UtcTimestamp,
) {
) -> Option<TabAction> {
self.handle_executable_drops(ui.ctx());
self.draw_sym_status_bar(ui);
self.draw_symbol_ingest_area(ui);
self.last_exe_count = self.draw_executable_table(ui);
None
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/ui/tabs/flamegraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl TabWidget for FlameGraphTab {
kind: SampleKind,
start: UtcTimestamp,
end: UtcTimestamp,
) {
) -> Option<TabAction> {
let show_inline = self.show_inline;
let root = self
.cached_root
Expand Down Expand Up @@ -97,7 +97,8 @@ impl TabWidget for FlameGraphTab {
});
ui.add_space(5.0);

self.widget.draw(ui, cfg, &*root)
self.widget.draw(ui, cfg, &*root);
None
}
}

Expand Down
Loading