Use dashboards to show the graphs

This commit is contained in:
Olivier 'reivilibre' 2021-11-28 14:14:15 +00:00
parent a1208eed48
commit 1d8ba23969
2 changed files with 25 additions and 5 deletions

View File

@ -3,11 +3,11 @@ use serde::Deserialize;
#[derive(Deserialize, Default, Clone)]
pub struct DashboardConfig {
graphs: Vec<GraphConfig>,
pub graphs: Vec<GraphConfig>,
}
#[derive(Deserialize, Clone)]
pub struct GraphConfig {
name: String,
kind: MetricKind,
pub name: String,
pub kind: MetricKind,
}

View File

@ -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);
}
});
});
}