Dashboard page for sccache-dash (crates/ui)

An eframe/egui page compiled to WebAssembly with trunk. It draws the one
View the server sends: controls on top, three big figures, six cards, and
the collapsible sections Problems, Where compiles went, Over time, Speed,
Extras and Raw counters. The range, refresh interval and theme are
remembered between visits with eframe storage.

mise.toml names trunk 0.22.2 as the build tool.
This commit is contained in:
swaits committed 2026-11-28 11:30:54 -07:00
1 parent a8e7bd66cf
commit b80749ebb5
16 files changed
+2242

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
//! Raw counters: the sccache stats exactly as the server read them.
use eframe::egui::{self, RichText, Ui};
use sccache_dash_api::View;
use crate::style;
pub fn section(ui: &mut Ui, view: &View) {
style::section(ui, "raw", "Raw counters", |ui| match &view.raw {
serde_json::Value::Null => {
ui.label("sccache's raw counters could not be read.");
}
value => tree(ui, value, "raw"),
});
}
/// A tree: one collapsible line per group, `name value` per counter.
fn tree(ui: &mut Ui, value: &serde_json::Value, path: &str) {
match value {
serde_json::Value::Object(fields) => {
for (name, value) in fields {
branch(ui, name, value, path);
}
}
serde_json::Value::Array(items) => {
for (index, value) in items.iter().enumerate() {
branch(ui, &index.to_string(), value, path);
}
}
leaf => counter(ui, "", leaf),
}
}
fn branch(ui: &mut Ui, name: &str, value: &serde_json::Value, path: &str) {
let path = format!("{path}/{name}");
if value.is_object() || value.is_array() {
egui::CollapsingHeader::new(RichText::new(name).strong())
.id_salt(path.clone())
.default_open(true)
.show(ui, |ui| tree(ui, value, &path));
} else {
counter(ui, name, value);
}
}
/// One counter as sccache prints its value.
fn counter(ui: &mut Ui, name: &str, value: &serde_json::Value) {
let text = match value {
serde_json::Value::String(text) => text.clone(),
serde_json::Value::Null => "null".to_owned(),
number => number.to_string(),
};
ui.horizontal_wrapped(|ui| {
if !name.is_empty() {
ui.label(name);
}
ui.label(RichText::new(text).weak());
});
}