1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use maud::{Markup, PreEscaped, html};
// Function to render the Mint V2 module UI section
pub async fn render(mint: &fedimint_mintv2_server::Mint) -> Markup {
let distribution = mint.note_distribution_ui().await;
let labels: Vec<String> = distribution.keys().map(|d| format!("2^{}", d.0)).collect();
let counts: Vec<u64> = distribution.values().copied().collect();
html! {
div class="card h-100" {
div class="card-header dashboard-header" { "Mint V2" }
div class="card-body" {
@if distribution.is_empty() {
p class="text-muted mb-0" { "No notes have been issued yet." }
} @else {
canvas id="mintv2-chart" {}
script src="/assets/chart.umd.min.js" {}
(PreEscaped(format!(
r#"<script>
document.addEventListener('DOMContentLoaded', function() {{
new Chart(document.getElementById('mintv2-chart'), {{
type: 'bar',
data: {{
labels: {labels},
datasets: [{{
label: 'Outstanding Notes',
data: {counts:?},
borderWidth: 1
}}]
}},
options: {{
responsive: true,
plugins: {{
legend: {{ display: false }},
tooltip: {{ enabled: false }}
}},
scales: {{
x: {{
title: {{
display: true,
text: 'Denomination'
}}
}},
y: {{
beginAtZero: true,
title: {{
display: true,
text: 'Outstanding Note Count'
}}
}}
}}
}}
}});
}});
</script>"#,
labels = serde_json::to_string(&labels)
.expect("Failed to serialize labels"),
)))
}
}
}
}
}