Skip to content

Commit d904faa

Browse files
committed
Convert dashboard page to a template
1 parent f37a9fb commit d904faa

File tree

4 files changed

+76
-92
lines changed

4 files changed

+76
-92
lines changed

site/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ async fn handle_fs_path(req: &Request, path: &str) -> Option<http::Response<hype
599599
}
600600

601601
let source = match path {
602-
"/bootstrap.html" | "/help.html" | "/status.html" => TEMPLATES
602+
"/bootstrap.html" | "/dashboard.html" | "/help.html" | "/status.html" => TEMPLATES
603603
.render(&format!("pages/{}", path.trim_start_matches("/")))
604604
.await
605605
.unwrap()

site/static/dashboard.html

Lines changed: 0 additions & 91 deletions
This file was deleted.

site/static/scripts/dashboard.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
function render(element, name, data, versions) {
2+
let articles = {"check": "a", "debug": "a", "opt": "an", "doc": "a"};
3+
new Highcharts.chart(document.getElementById(element), {
4+
chart: {
5+
zoomType: "xy",
6+
renderTo: document.getElementById(element),
7+
type: "line",
8+
},
9+
title: {
10+
text: `Average time for ${articles[name]} ${name} build`,
11+
},
12+
yAxis: {
13+
title: {text: "Seconds"},
14+
min: 0,
15+
},
16+
xAxis: {
17+
categories: versions,
18+
title: {text: "Version"},
19+
},
20+
series: [
21+
{
22+
name: "full",
23+
animation: false,
24+
data: data.clean_averages,
25+
},
26+
{
27+
name: "incremental full",
28+
animation: false,
29+
data: data.base_incr_averages,
30+
},
31+
{
32+
name: "incremental unchanged",
33+
animation: false,
34+
data: data.clean_incr_averages,
35+
},
36+
{
37+
name: "incremental patched: println",
38+
animation: false,
39+
data: data.println_incr_averages,
40+
},
41+
],
42+
});
43+
}
44+
45+
function populate_data(data) {
46+
data = data.Ok;
47+
render("check-average-times", "check", data.check, data.versions);
48+
render("debug-average-times", "debug", data.debug, data.versions);
49+
render("opt-average-times", "opt", data.opt, data.versions);
50+
render("doc-average-times", "doc", data.doc, data.versions);
51+
}
52+
53+
function make_data() {
54+
fetch(BASE_URL + "/dashboard", {}).then(function (response) {
55+
response.json().then(data => populate_data(data));
56+
});
57+
}
58+
59+
make_data();

site/templates/pages/dashboard.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% extends "layout.html" %}
2+
{% block head %}
3+
<link rel="stylesheet" type="text/css" href="perf.css">
4+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highcharts/6.0.7/highcharts.js"></script>
5+
{% endblock %}
6+
{% block content %}
7+
<div id="check-average-times"></div>
8+
<div id="debug-average-times"></div>
9+
<div id="opt-average-times"></div>
10+
<div id="doc-average-times"></div>
11+
<div id="as-of"></div>
12+
{% endblock %}
13+
{% block script %}
14+
<script src="shared.js"></script>
15+
<script src="scripts/dashboard.js"></script>
16+
{% endblock %}

0 commit comments

Comments
 (0)