Skip to main content

csi_webclient/ui/
dashboard.rs

1use crate::state::AppState;
2
3/// Render the dashboard view.
4pub fn render(ui: &mut egui::Ui, state: &mut AppState) {
5    ui.heading("Dashboard");
6    ui.separator();
7
8    ui.horizontal_wrapped(|ui| {
9        ui.strong("Collection role:");
10        ui.label(state.persistent.collection_mode.as_api_value());
11        ui.separator();
12
13        ui.strong("Collection active:");
14        ui.label(if state.runtime.collection_active_estimate {
15            "yes (estimated)"
16        } else {
17            "no (estimated)"
18        });
19        ui.separator();
20
21        ui.strong("Output mode:");
22        ui.label(state.persistent.output_mode.as_api_value());
23        ui.separator();
24
25        ui.strong("Log mode:");
26        ui.label(state.persistent.log_mode.as_api_value());
27    });
28
29    ui.separator();
30
31    ui.horizontal_wrapped(|ui| {
32        ui.label(format!("HTTP Base: {}", state.base_http_url()));
33        ui.separator();
34        ui.label(format!(
35            "WebSocket: {}",
36            if state.runtime.ws_connected {
37                "Connected"
38            } else {
39                "Disconnected"
40            }
41        ));
42        ui.separator();
43        ui.label(format!("Frames: {}", state.runtime.frames_received));
44        ui.separator();
45        ui.label(format!("Bytes: {}", state.runtime.bytes_received));
46    });
47
48    ui.separator();
49    ui.label("Recent events");
50    let remaining_height = ui.available_height();
51    egui::ScrollArea::vertical()
52        .auto_shrink([false, false])
53        .max_height(remaining_height)
54        .show(ui, |ui| {
55        for line in state.runtime.events.iter().rev().take(80) {
56            ui.label(line);
57        }
58        });
59}