fc-server: add metrics visualization dashboard

Adds a /metrics page with Chart.js charts, which requires an annoying
CDN fetch but until I figure out a good method of fetching things during
build it's our best bet. I've pinned the thing so it's probably good.

The page displays build counts, duration percentiles and system
distribution. Time range and project filters are included, and the
metrics page is linked from navigation.

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I99059594c29a9b35d2fd4d140628d6f46a6a6964
This commit is contained in:
raf 2026-02-14 13:40:42 +03:00
commit 83071514a3
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
3 changed files with 428 additions and 0 deletions

View file

@ -423,6 +423,13 @@ struct StarredTemplate {
auth_name: String,
}
#[derive(Template)]
#[template(path = "metrics.html")]
struct MetricsTemplate {
is_admin: bool,
auth_name: String,
}
// --- Handlers ---
async fn home(
@ -1565,6 +1572,18 @@ async fn starred_page(
)
}
async fn metrics_page(extensions: Extensions) -> Html<String> {
let tmpl = MetricsTemplate {
is_admin: is_admin(&extensions),
auth_name: auth_name(&extensions),
};
Html(
tmpl
.render()
.unwrap_or_else(|e| format!("Template error: {e}")),
)
}
pub fn router() -> Router<AppState> {
Router::new()
.route("/login", get(login_page).post(login_action))
@ -1583,4 +1602,5 @@ pub fn router() -> Router<AppState> {
.route("/admin", get(admin_page))
.route("/users", get(users_page))
.route("/starred", get(starred_page))
.route("/metrics", get(metrics_page))
}