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:
1 parent
a8e7bd66cf
commit
b80749ebb5
16 files changed
+2242
No files matched your search
@@ -0,0 +1,41 @@
|
||||
//! Problems: what is wrong, most serious first.
|
||||
|
||||
use eframe::egui::{self, RichText, Stroke, Ui};
|
||||
use sccache_dash_api::{Severity, View};
|
||||
|
||||
use crate::style;
|
||||
|
||||
pub fn section(ui: &mut Ui, view: &View, dark: bool) {
|
||||
style::section(ui, "problems", "Problems", |ui| {
|
||||
if view.problems.is_empty() {
|
||||
ui.label("No problems.");
|
||||
return;
|
||||
}
|
||||
let [_, warn, bad] = style::marks(dark);
|
||||
for problem in &view.problems {
|
||||
let color = match problem.severity {
|
||||
Severity::Error => bad,
|
||||
Severity::Warning => warn,
|
||||
};
|
||||
let kind = match problem.severity {
|
||||
Severity::Error => "Error",
|
||||
Severity::Warning => "Warning",
|
||||
};
|
||||
let width = ui.available_width();
|
||||
egui::Frame::NONE
|
||||
.fill(color.gamma_multiply(0.14))
|
||||
.stroke(Stroke::new(1.0, color))
|
||||
.corner_radius(6.0)
|
||||
.inner_margin(8.0)
|
||||
.show(ui, |ui| {
|
||||
ui.set_width(width - 16.0);
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label(RichText::new(kind).small().strong().color(color));
|
||||
ui.label(RichText::new(&problem.title).strong());
|
||||
});
|
||||
ui.add(egui::Label::new(&problem.detail).wrap());
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user