Page polish from the live service
- Both charts always span exactly the selected range, edge to edge. Time nothing was recorded in is shaded and labelled once, and each chart's key is drawn under the chart instead of over the data. - The time saved says "not enough data yet" or "nothing saved yet" when nothing can be counted, and a saving under a second reads "under 1 s", never in milliseconds. - The six cards are exact boxes of one size, so their tops line up. - Tables have headed columns at fixed shares of the width, text left and numbers right; each row is one rectangle with a place for every cell. - The cache usage bar has an outlined track. - When the server can't be reached, the notice is drawn over the page, so what is on screen keeps its place and height.
This commit is contained in:
1 parent
bcc178330b
commit
73c8138072
6 files changed
+367
-179
No files matched your search
+77
-29
@@ -180,6 +180,14 @@ impl eframe::App for Dashboard {
|
||||
|
||||
fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame) {
|
||||
controls(self, ui);
|
||||
if let (Some(view), Some(error)) = (&self.view, &self.error) {
|
||||
lost_contact(
|
||||
ui.ctx(),
|
||||
error,
|
||||
view.generated_at,
|
||||
ui.available_rect_before_wrap().width(),
|
||||
);
|
||||
}
|
||||
egui::CentralPanel::default().show(ui, |ui| {
|
||||
egui::ScrollArea::vertical()
|
||||
.auto_shrink([false; 2])
|
||||
@@ -188,15 +196,12 @@ impl eframe::App for Dashboard {
|
||||
let Self {
|
||||
range,
|
||||
view,
|
||||
error,
|
||||
hidden_languages,
|
||||
..
|
||||
} = self;
|
||||
match view {
|
||||
None => waiting(ui, error.as_deref(), self.refresh_secs),
|
||||
Some(view) => {
|
||||
page(ui, view, *range, error.as_deref(), hidden_languages)
|
||||
}
|
||||
None => waiting(ui, self.error.as_deref(), self.refresh_secs),
|
||||
Some(view) => page(ui, view, *range, hidden_languages),
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -397,23 +402,39 @@ fn waiting(ui: &mut egui::Ui, error: Option<&str>, refresh_secs: u64) {
|
||||
}
|
||||
|
||||
/// The whole page below the controls.
|
||||
fn page(
|
||||
ui: &mut egui::Ui,
|
||||
view: &View,
|
||||
asked: Range,
|
||||
error: Option<&str>,
|
||||
hidden_languages: &mut Vec<String>,
|
||||
) {
|
||||
/// A notice that the server can't be reached, shown over the page rather than
|
||||
/// in it, so what is already on screen keeps its place and height.
|
||||
fn lost_contact(ctx: &egui::Context, error: &str, from: i64, page_width: f32) {
|
||||
let [_, _, bad] = style::marks(ctx.theme() == egui::Theme::Dark);
|
||||
let when = fmt::moment_text(from + fmt::local_offset());
|
||||
egui::Area::new(egui::Id::unique("lost-contact"))
|
||||
.anchor(egui::Align2::RIGHT_TOP, egui::vec2(-8.0, 52.0))
|
||||
.order(egui::Order::Foreground)
|
||||
.show(ctx, |ui| {
|
||||
let width = (page_width - 16.0).min(440.0);
|
||||
egui::Frame::NONE
|
||||
.fill(bad.gamma_multiply(0.25))
|
||||
.stroke(egui::Stroke::new(1.0, bad))
|
||||
.corner_radius(6.0)
|
||||
.inner_margin(8.0)
|
||||
.show(ui, |ui| {
|
||||
ui.set_max_width(width);
|
||||
ui.add(
|
||||
egui::Label::new(
|
||||
egui::RichText::new(format!(
|
||||
"Can't reach the server: {error}. These figures are from {when}."
|
||||
))
|
||||
.strong(),
|
||||
)
|
||||
.wrap(),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn page(ui: &mut egui::Ui, view: &View, asked: Range, hidden_languages: &mut Vec<String>) {
|
||||
let dark = ui.visuals().dark_mode;
|
||||
let [_, _, bad] = style::marks(dark);
|
||||
if let Some(error) = error {
|
||||
let from = fmt::moment_text(view.generated_at + fmt::local_offset());
|
||||
style::banner(
|
||||
ui,
|
||||
format!("Lost contact with the server: {error}. These figures are from {from}."),
|
||||
bad,
|
||||
);
|
||||
}
|
||||
if let Some(error) = &view.server.error {
|
||||
style::banner(ui, format!("sccache is not working: {error}"), bad);
|
||||
}
|
||||
@@ -432,6 +453,8 @@ fn page(
|
||||
/// One of the three big figures.
|
||||
struct Figure<'a> {
|
||||
value: String,
|
||||
/// How big the figure is written: 30 for numbers, less for words.
|
||||
size: f32,
|
||||
color: egui::Color32,
|
||||
caption: String,
|
||||
/// Smaller print under the figure.
|
||||
@@ -453,7 +476,9 @@ impl Figure<'_> {
|
||||
|ui| {
|
||||
ui.set_width(width);
|
||||
ui.add(
|
||||
egui::Label::new(egui::RichText::new(&self.value).size(30.0).color(self.color))
|
||||
egui::Label::new(
|
||||
egui::RichText::new(&self.value).size(self.size).color(self.color),
|
||||
)
|
||||
.truncate(),
|
||||
);
|
||||
ui.add(egui::Label::new(egui::RichText::new(&self.caption).small()).truncate());
|
||||
@@ -510,6 +535,7 @@ fn headline(ui: &mut egui::Ui, view: &View, asked: Range, dark: bool) {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
Figure {
|
||||
value: fmt::percent(totals.hit_rate()),
|
||||
size: 30.0,
|
||||
color: style::hit_rate_color(totals.hit_rate(), dark),
|
||||
caption: "from cache".into(),
|
||||
small: format!("{} of all compiler calls", fmt::percent(totals.hit_rate_of_all())),
|
||||
@@ -518,22 +544,43 @@ fn headline(ui: &mut egui::Ui, view: &View, asked: Range, dark: bool) {
|
||||
small2: String::new(),
|
||||
}
|
||||
.draw(ui, column);
|
||||
// A saving is never written in milliseconds; and when no language's build time is
|
||||
// known yet, the figure says so instead of showing nothing.
|
||||
let seconds = view.time_saved.seconds;
|
||||
let left_out = view.time_saved.hits_left_out;
|
||||
// The 90% range goes first; the hits left out are the line under it.
|
||||
let left_out_line = if left_out > 0 {
|
||||
format!("{} hits left out of this figure", fmt::count(left_out))
|
||||
} else {
|
||||
"every hit counted".to_owned()
|
||||
};
|
||||
let interval = view
|
||||
.time_saved
|
||||
.interval_90
|
||||
.map(|(low, high)| format!("{} – {} (90% range)", fmt::duration(low), fmt::duration(high)));
|
||||
let (value, size, small, small2) = if seconds >= 1.0 {
|
||||
(format!("~{}", fmt::duration(seconds)), 30.0, interval.unwrap_or_default(), left_out_line)
|
||||
} else if seconds > 0.0 {
|
||||
("~under 1 s".to_owned(), 30.0, interval.unwrap_or_default(), left_out_line)
|
||||
} else if left_out > 0 {
|
||||
(
|
||||
"not enough data yet".to_owned(),
|
||||
22.0,
|
||||
String::new(),
|
||||
format!(
|
||||
"{} hits not counted: no build time known yet for their language",
|
||||
fmt::count(left_out)
|
||||
),
|
||||
)
|
||||
} else {
|
||||
("nothing saved yet".to_owned(), 22.0, String::new(), String::new())
|
||||
};
|
||||
Figure {
|
||||
value: format!("~{}", fmt::duration(view.time_saved.seconds)),
|
||||
value,
|
||||
size,
|
||||
color: text_color,
|
||||
caption: "saved (rough)".into(),
|
||||
small: interval.unwrap_or_default(),
|
||||
small2: if left_out > 0 {
|
||||
format!("{} hits left out of this figure", fmt::count(left_out))
|
||||
} else {
|
||||
"every hit counted".into()
|
||||
},
|
||||
small,
|
||||
small2,
|
||||
trend: Some((&saved, saved_top)),
|
||||
hover: Some(view.time_saved.note.clone()),
|
||||
}
|
||||
@@ -546,6 +593,7 @@ fn headline(ui: &mut egui::Ui, view: &View, asked: Range, dark: bool) {
|
||||
} else {
|
||||
format!("{} problems", fmt::count(problems as u64))
|
||||
},
|
||||
size: 30.0,
|
||||
color: problem_color,
|
||||
caption: worst
|
||||
.map(|problem| problem.title.clone())
|
||||
|
||||
Reference in new issue
Block a user