diff --git a/bare-metrics-gui/src/config.rs b/bare-metrics-gui/src/config.rs index a223496..974ebbe 100644 --- a/bare-metrics-gui/src/config.rs +++ b/bare-metrics-gui/src/config.rs @@ -3,11 +3,11 @@ use serde::Deserialize; #[derive(Deserialize, Default, Clone)] pub struct DashboardConfig { - graphs: Vec, + pub graphs: Vec, } #[derive(Deserialize, Clone)] pub struct GraphConfig { - name: String, - kind: MetricKind, + pub name: String, + pub kind: MetricKind, } diff --git a/bare-metrics-gui/src/main.rs b/bare-metrics-gui/src/main.rs index cd27d24..6a97e98 100644 --- a/bare-metrics-gui/src/main.rs +++ b/bare-metrics-gui/src/main.rs @@ -22,9 +22,29 @@ pub struct MetricsGui { impl App for MetricsGui { fn update(&mut self, ctx: &CtxRef, _frame: &mut Frame<'_>) { + let Self { + requester, + dashboard, + } = self; CentralPanel::default().show(ctx, |ui| { - ui.label("Hah"); - Graph::draw(ui, MetricId(0), &self.requester); + egui::ScrollArea::new([false, true]).show(ui, |ui| { + if let Some(dashboard) = dashboard { + let window = requester.shared.current_window.read().unwrap(); + for graph in dashboard.graphs.iter() { + ui.label(&graph.name); + + if let Some(metric) = window.metrics.get(&graph.name) { + // TODO support multiple labelled metrics + if let Some((_, first_one)) = metric.iter().next() { + Graph::draw(ui, *first_one, requester); + } + } + } + } else { + ui.label("(no dashboard)"); + Graph::draw(ui, MetricId(0), &requester); + } + }); }); }