/
index.html
140 lines (132 loc) · 3.53 KB
/
index.html
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html>
<html lang="{{ @this->lang() }}">
<head>
<include href="blocks/head.html" />
<style type="text/css">
.tab-pane .progress {
margin: 0 auto;
max-width: 200px;
}
.tab-pane .progress .progress-bar {
width: 100%;
}
</style>
</head>
<body>
<div class="container">
<include href="blocks/navbar.html" />
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">
<a href="#tab-trends" aria-controls="tab-trends" role="tab" data-toggle="tab">Trends</a>
</li>
<li role="presentation">
<a href="#tab-users" aria-controls="tab-users" role="tab" data-toggle="tab">{{ @dict.users }}</a>
</li>
<li role="presentation">
<a href="#tab-issues" aria-controls="tab-issues" role="tab" data-toggle="tab">{{ @dict.issues }}</a>
</li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="tab-trends">
<div>
<h2>Daily</h2>
<canvas id="daily" width="960" height="200"></canvas>
</div>
<div>
<h2>Monthly</h2>
<canvas id="monthly" width="960" height="200"></canvas>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="tab-users">
<div class="progress progress-striped active">
<div class="progress-bar"></div>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="tab-issues">
<div class="progress progress-striped active">
<div class="progress-bar"></div>
</div>
</div>
</div>
<include href="blocks/footer.html" />
<script src="{{ @BASE }}/js/chart.js"></script>
<script type="text/javascript">
$(function() {
var chartOptions = {
maintainAspectRatio: false,
legend: {
position: 'left',
labels: {
boxWidth: 1
}
},
animation: {
duration: 250
},
tooltips: {
mode: 'x-axis',
titleSpacing: 0,
titleMarginBottom: 3,
yPadding: 4,
},
hover: {
mode: 'x-axis'
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
},
elements: {
line: {
tension: 0.3,
borderWidth: 2,
},
point: {
radius: 2,
hoverRadius: 3,
hitRadius: 15,
}
}
};
Chart.defaults.global.defaultFontColor = "rgba(127,127,127,1)";
Chart.defaults.scale.gridLines.color = "rgba(127,127,127,.3)";
Chart.defaults.scale.gridLines.zeroLineColor = "rgba(127,127,127,.3)";
// Load trends immediately
$.get(BASE + '/stats/trends', function(data) {
var dCtx = document.getElementById("daily").getContext("2d");
var daily = new Chart(dCtx, {
type: 'line',
data: data.daily,
options: chartOptions
});
var mCtx = document.getElementById("monthly").getContext("2d");
var monthly = new Chart(mCtx, {
type: 'line',
data: data.monthly,
options: chartOptions
});
// @todo: display monthly data
}, 'json').fail(function() {
$('#tab-trends').empty().append($('<p />').addClass('text-center text-danger').text('Error loading data'));
});
// Defer loading secondary tabs
setTimeout(function() {
$.get(BASE + '/stats/users', function(data) {
$('#tab-users').html(data);
}).fail(function() {
$('#tab-users').empty().append($('<p />').addClass('text-center text-danger').text('Error loading data'));
});
$.get(BASE + '/stats/issues', function(data) {
$('#tab-issues').html(data);
}).fail(function() {
$('#tab-issues').empty().append($('<p />').addClass('text-center text-danger').text('Error loading data'));
});
}, 1000);
});
</script>
</div>
</body>
</html>