-
Notifications
You must be signed in to change notification settings - Fork 28
/
monthly_usage_report.html
289 lines (262 loc) · 10.1 KB
/
monthly_usage_report.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> OCL | Usage Report</title>
<style>
body{
background-color: #f3f3f3;
color: #444;
font-family: sans-serif;
padding: 2rem 1rem;
}
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
.main-heading{
text-align: center;
font-size: 2.5rem;
}
h2{
text-align: center;
padding: 1rem;
opacity: .8;
}
.swap-graph{
padding-bottom: .5rem;
font-size: 1.1rem;
text-align: right;
}
.swap-graph input{
transform: scale(1.25) translateX(-2px);
}
.flex{
display: flex;
}
.flex *{
flex:1;
}
section{
background-color: #eee;
margin: .5rem;
padding: 2rem;
text-align: center;
padding: 2rem 3.5rem;
background-color: #fff;
border-radius: 10px;
}
.chart{
width: 100%;
}
.chart-label{
display: inline-block;
margin-top: .75rem;
font-size: 1.4rem;
}
section h3{
font-size: 1.8rem;
margin-top: 1.35rem;
}
@media (max-width:1250px) {
.flex{
flex-direction: column;
}
section{
min-height: max-content;
}
section h3 {
font-size: 1.3rem;
margin-top: 1.35rem;
}
}
@media (max-width:700px) {
.chart-label{
font-size: 1.2rem;
}
section h3{
font-size: 1.4rem;
}
}
@media (max-width:600px) {
.chart-label{
font-size: 1rem;
}
section h3{
font-size: 1.2rem;
}
body{
padding: 2rem 1rem;
}
}
</style>
</head>
<body>
<h1 class="main-heading" >{{env|title}} Usage Report</h1>
<h2><span>{{current_month_start}}</span> to <span>{{current_month_end}}</span></h2>
<main style="margin-top: 15px;">
<div class="flex" style="width:70%;margin:0 auto;margin-bottom:40px;">
<table>
<thead>
<tr>
<th style="text-align:left;">
Resource
</th>
<th style="text-align:center;">
Created
</th>
<th style="text-align:center;">
Active
</th>
<th style="text-align:center;">
Inactive
</th>
</tr>
</thead>
<tbody>
{% for resource, stats in current_month.items %}
<tr>
<td>{{resource|title}}</td>
<td style="text-align:center;">{{stats.created_monthly}}</td>
<td style="text-align:center;">{{stats.active}}</td>
<td style="text-align:center;">{{stats.inactive}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<h3 style="text-align:center;">Trends</h3>
<h3 style="text-align:center;"><span>{{start}}</span> to <span>{{end}}</span></h3>
<div class="swap-graph">
<input type="checkbox" name="Swap Graph" id="swap">
<label for="swap">Line Graphs</label>
</div>
<div class="flex">
<section>
<canvas id="concepts_created_monthly" class="chart"></canvas>
<label class="chart-label">Concepts created monthly</label>
<h3>{{concepts.total | safe}} Total Concepts • {% widthratio concepts.active concepts.total 100 %}% Active</h3>
</section>
<section>
<canvas id="mappings_created_monthly" class="chart"></canvas>
<label class="chart-label">Mappings created monthly</label>
<h3>{{mappings.total | safe}} Total Mappings • {% widthratio mappings.active mappings.total 100 %}% Active</h3>
</section>
</div>
<div class="flex">
<section>
<canvas id="sources_created_monthly" class="chart"></canvas>
<label class="chart-label">Sources created monthly</label>
<h3>{{sources.total | safe}} Total Sources • {% widthratio sources.active sources.total 100 %}% Active</h3>
</section>
<section>
<canvas id="source_versions_created_monthly" class="chart"></canvas>
<label class="chart-label">Source Versions created monthly</label>
<h3>{{source_versions.total | safe}} Total Source Versions • {% widthratio source_versions.active source_versions.total 100 %}% Active</h3>
</section>
</div>
<div class="flex">
<section>
<canvas id="collections_created_monthly" class="chart"></canvas>
<label class="chart-label">Collections created monthly</label>
<h3>{{collections.total | safe}} Total Collections <br/> {% widthratio collections.active collections.total 100 %}% Active</h3>
</section>
<section>
<canvas id="collection_versions_created_monthly" class="chart"></canvas>
<label class="chart-label">Collection Versions created monthly</label>
<h3>{{collection_versions.total | safe}} Total Collection Versions <br/> {% widthratio collection_versions.active collection_versions.total 100 %}% Active</h3>
</section>
<section>
<canvas id="collection_references_created_monthly" class="chart"></canvas>
<label class="chart-label">Collection References created monthly</label>
<h3>{{collection_references.total | safe}} Total Collection References <br/> {% widthratio collection_references.active collection_references.total 100 %}% Active</h3>
</section>
</div>
<div class="flex">
<section>
<canvas id="organizations_created_monthly" class="chart"></canvas>
<label class="chart-label">Organizations created monthly</label>
<h3>{{organizations.total | safe}} Total Organizations <br/> {% widthratio organizations.active organizations.total 100 %}% Active</h3>
</section>
<section>
<canvas id="users_created_monthly" class="chart"></canvas>
<label class="chart-label">Users joined monthly</label>
<h3>{{users.total | safe}} Total Users</h3>
</section>
<section>
<canvas id="users_last_login_monthly" class="chart"></canvas>
<label class="chart-label">Users login Monthly</label>
<h3>{% widthratio users.active users.total 100 %}% Active Users</h3>
</section>
</div>
</main>
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.5.0/dist/chart.min.js"></script>
<script>
const swapGraphCheckbox = document.getElementById('swap')
const dates = document.querySelectorAll('h2 span')
dates.forEach((date) => {
date.innerText = date.innerText.split('-').reverse().join('-')
})
let CHARTS = []
const makeChart=(id, label, graphData, type) => {
const ctx = document.getElementById(id).getContext('2d');
const labels= [];
const data= [];
(51, 115, 170)
const color = "rgba(51, 115, 170, 1)"
const colorLight = "rgba(51, 115, 170, .2)"
graphData.forEach((ele) => {
const key = Object.keys(ele)[0];
labels.push(key);
data.push(ele[key]);
})
const chart = new Chart(ctx, {
type,
data: {
labels,
datasets: [{
label,
data,
backgroundColor: [colorLight],
borderColor: [color],
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
CHARTS.push(chart)
}
const renderGraphs = type => {
makeChart('users_created_monthly', "Users", {{users.created_monthly | safe}}, type)
makeChart('users_last_login_monthly', "Users", {{users.last_login_monthly | safe}}, type)
makeChart('concepts_created_monthly', "Concepts", {{concepts.created_monthly | safe}}, type)
makeChart('mappings_created_monthly', "Mappings", {{mappings.created_monthly | safe}}, type)
makeChart('sources_created_monthly', "Sources", {{sources.created_monthly | safe}}, type)
makeChart('source_versions_created_monthly', "Source Versions",{{source_versions.created_monthly | safe}}, type)
makeChart('collections_created_monthly', "Collections",{{collections.created_monthly | safe}}, type)
makeChart('collection_versions_created_monthly', "Collection Versions",{{collection_versions.created_monthly | safe}}, type)
makeChart('organizations_created_monthly', "Organizations",{{organizations.created_monthly | safe}}, type)
makeChart('collection_references_created_monthly', "Collection References",{{collection_references.created_monthly | safe}}, type)
}
const destroyCharts = () => {
CHARTS.forEach((chart) => chart.destroy())
CHARTS = []
}
renderGraphs('bar')
swapGraphCheckbox.addEventListener('change', (e) => {
destroyCharts()
if (e.currentTarget.checked) renderGraphs('line')
else renderGraphs('bar')
})
</script>
</body>
</html>