-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
432 lines (403 loc) · 15.5 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
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>
Honeypots Admin Dashboard
</title>
<!-- Favicon -->
<link href="./assets/img/brand/logo.png" rel="icon" type="image/jpeg">
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">
<!-- Icons -->
<link href="./assets/js/plugins/nucleo/css/nucleo.css" rel="stylesheet" />
<link href="./assets/js/plugins/@fortawesome/fontawesome-free/css/all.min.css" rel="stylesheet" />
<!-- CSS Files -->
<link href="./assets/css/argon-dashboard.css?v=1.1.2" rel="stylesheet" />
<style>
canvas {
position: absolute;
max-height: 100%;
max-width: 100%;
}
</style>
</head>
<body class="">
<div class="main-content">
<!-- Navbar -->
<nav class="navbar navbar-top navbar-expand-md navbar-dark" id="navbar-main">
<div class="container-fluid">
<!-- Brand -->
<a class="h4 mb-0 text-white text-uppercase d-none d-lg-inline-block" href="./index.html">Dashboard</a>
<!-- User -->
<ul class="navbar-nav align-items-center d-none d-md-flex">
<a class="nav-link pr-0">
<div class="media align-items-center">
<span class="avatar avatar-sm rounded-circle">
<img alt="Image placeholder" src="./assets/img/brand/logo.jpg">
</span>
<div class="media-body ml-2 d-none d-lg-block">
<span class="mb-0 text-sm font-weight-bold">꿀단지</span>
</div>
</div>
</a>
</ul>
</div>
</nav>
<!-- End Navbar -->
<!-- Header -->
<div class="header bg-gradient-primary pb-8 pt-5 pt-md-8">
<div class="container-fluid">
<div class="header-body">
<!-- Card stats -->
<div class="row">
<div class="col-xl-3 col-lg-6">
<div class="card card-stats mb-4 mb-xl-0">
<div class="card-body">
<div class="row">
<div class="col">
<h5 class="card-title text-uppercase text-muted mb-0">Total Users</h5>
<span class="h2 font-weight-bold mb-0" id="totalMemberCount">-</span>
</div>
<div class="col-auto">
<div class="icon icon-shape bg-danger text-white rounded-circle shadow">
<i class="fas fa-users"></i>
</div>
</div>
</div>
<p class="mt-3 mb-0 text-muted text-sm">
<span class="text-success mr-2" id="totalMemberCountCompare"><i class="fa fa-arrow-up"></i>-</span>
<span class="text-nowrap">Since Last week</span>
</p>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-6">
<div class="card card-stats mb-4 mb-xl-0">
<div class="card-body">
<div class="row">
<div class="col">
<h5 class="card-title text-uppercase text-muted mb-0">Total Posts</h5>
<span class="h2 font-weight-bold mb-0" id="totalPostCount">-</span>
</div>
<div class="col-auto">
<div class="icon icon-shape bg-warning text-white rounded-circle shadow">
<i class="fas fa-chart-bar"></i>
</div>
</div>
</div>
<p class="mt-3 mb-0 text-muted text-sm">
<span class="text-danger mr-2" id="totalPostCountCompare"><i class="fas fa-arrow-down"></i></span>
<span class="text-nowrap">Since Last week</span>
</p>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-6">
<div class="card card-stats mb-4 mb-xl-0">
<div class="card-body">
<div class="row">
<div class="col">
<h5 class="card-title text-uppercase text-muted mb-0">Total Comments</h5>
<span class="h2 font-weight-bold mb-0" id="totalCommentCount">-</span>
</div>
<div class="col-auto">
<div class="icon icon-shape bg-yellow text-white rounded-circle shadow">
<i class="fas fa-chart-bar"></i>
</div>
</div>
</div>
<p class="mt-3 mb-0 text-muted text-sm">
<span class="text-warning mr-2" id="totalCommentCountCompare"><i class="fas fa-arrow-down"></i></span>
<span class="text-nowrap">Since Last week</span>
</p>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-6">
<div class="card card-stats mb-4 mb-xl-0">
<div class="card-body">
<div class="row">
<div class="col">
<h5 class="card-title text-uppercase text-muted mb-0">Total Likes</h5>
<span class="h2 font-weight-bold mb-0" id="totalLikeReactionCount">-</span>
</div>
<div class="col-auto">
<div class="icon icon-shape bg-info text-white rounded-circle shadow">
<i class="fas fa-chart-bar"></i>
</div>
</div>
</div>
<p class="mt-3 mb-0 text-muted text-sm">
<span class="text-success mr-2" id="totalLikeReactionCountCompare"><i class="fas fa-arrow-up"></i></span>
<span class="text-nowrap">Total period</span>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container-fluid mt--7">
<div class="row">
<div class="col-xl-6 mb-5 mb-xl-0">
<div class="card bg-gradient-default shadow">
<div class="card-header bg-transparent">
<div class="row align-items-center">
<div class="col">
<h6 class="text-uppercase text-light ls-1 mb-1">Statistics</h6>
<h2 class="text-white mb-0">Joined Member</h2>
</div>
</div>
</div>
<div class="card-body">
<!-- Chart -->
<div class="chart">
<!-- Chart wrapper -->
<canvas id="joinedMemberChart" style="width: 100%; height: 100%; position: relative;"></canvas>
</div>
</div>
</div>
</div>
<div class="col-xl-6">
<div class="card shadow">
<div class="card-header bg-transparent">
<div class="row align-items-center">
<div class="col">
<h6 class="text-uppercase text-muted ls-1 mb-1">Statistics</h6>
<h2 class="mb-0">Active Users</h2>
</div>
</div>
</div>
<div class="card-body">
<!-- Chart -->
<div class="chart">
<canvas id="activeUserChart" style="width: 100%; height: 100%; position: relative;"></canvas>
</div>
</div>
</div>
</div>
</div>
<!-- Footer -->
<footer class="footer">
<div class="row align-items-center justify-content-xl-between">
<div class="col-xl-6">
<div class="copyright text-center text-xl-left text-muted">
© 2022 <a href="" class="font-weight-bold ml-1" target="_blank">HoneyPots</a>
</div>
</div>
<div class="col-xl-6">
<ul class="nav nav-footer justify-content-center justify-content-xl-end">
<li class="nav-item">
<a href="https://github.com/HoneyPots" class="nav-link" target="_blank">About Us</a>
</li>
<li class="nav-item">
<a href="https://github.com/HoneyPots" class="nav-link" target="_blank">GitHub</a>
</li>
</ul>
</div>
</div>
</footer>
</div>
</div>
<!-- Core -->
<script src="./assets/js/plugins/jquery/dist/jquery.min.js"></script>
<script src="./assets/js/plugins/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<!-- Optional JS -->
<script src="./assets/js/plugins/chart.js/dist/Chart.min.js"></script>
<script src="./assets/js/plugins/chart.js/dist/Chart.extension.js"></script>
<!-- Argon JS -->
<script src="./assets/js/argon-dashboard.min.js?v=1.1.2"></script>
<script src="https://cdn.trackjs.com/agent/v3/latest/t.js"></script>
<!-- Chart.js -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.min.js"></script>
<script>
let today = new Date();
let lastWeek = new Date(today);
lastWeek.setDate(today.getDate() - 7);
let todayYMD = getFormatDate(today, '');
let lastWeekYMD = getFormatDate(lastWeek, '');
// KPI - User Engagement
fetch('http://localhost:8090/api/admin/kpi?type=userEngagement&from=20220817&to=' + todayYMD)
.then((response) => response.json())
.then((data) => {
document.getElementById("totalMemberCount").innerHTML = data.totalMemberCount;
document.getElementById("totalPostCount").innerHTML = data.totalPostCount;
document.getElementById("totalCommentCount").innerHTML = data.totalCommentCount;
document.getElementById("totalLikeReactionCount").innerHTML = data.totalLikeReactionCount;
fetch('http://localhost:8090/api/admin/kpi?type=userEngagement&from=20220817&to=' + lastWeekYMD)
.then((response) => response.json())
.then((data) => {
renderKpiCompareIcon('totalMemberCount', data.totalMemberCount);
renderKpiCompareIcon('totalPostCount', data.totalPostCount);
renderKpiCompareIcon('totalCommentCount', data.totalCommentCount);
});
});
// KPI - Joined member count by date
let serviceStartDate = new Date('2022-08-17');
let serviceStartDateYMD = getFormatDate(serviceStartDate, '');
fetch('http://localhost:8090/api/admin/kpi?type=joinMemberCount&from=' + serviceStartDateYMD + '&to=' + todayYMD)
.then((response) => response.json())
.then((data) => {
drawJoinedMemberKpiChart(document.getElementById('joinedMemberChart'), serviceStartDate, today, data);
// console.log(data);
});
// KPI - Active user count
fetch('http://localhost:8090/api/admin/kpi?type=activeUserCount&from=' + serviceStartDateYMD + '&to=' + todayYMD)
.then((response) => response.json())
.then((data) => {
drawActiveUserKpiChart(document.getElementById('activeUserChart'), serviceStartDate, today, data);
// console.log(data);
});
// Functions ========================
function renderKpiCompareIcon(id, compare) {
let base = document.getElementById(id).innerHTML;
let arrowIcon = base >= compare ? '<i class="fas fa-arrow-up"></i>' : '<i class="fas fa-arrow-down"></i>';
document.getElementById(id + 'Compare').innerHTML = arrowIcon + ' ' + (base - compare);
}
function getFormatDate(date, delimiter){
var month = (1 + date.getMonth());
month = month >= 10 ? month : '0' + month;
var day = date.getDate();
day = day >= 10 ? day : '0' + day;
return date.getFullYear() + delimiter + month + delimiter + day;
}
function drawJoinedMemberKpiChart(chartDiv, fromDate, toDate, data) {
const labels = createGraphDateLabels(new Date(fromDate), new Date(toDate))
const createdData = createJoinMemberChartDataByDate(new Date(fromDate), new Date(toDate), data);
const chartData = {
labels: labels,
datasets: [{
label: '가입 회원 수',
data: createdData,
fill: {
target: 'origin',
above: '#5c649042',
},
borderColor: '#5e72e4',
tension: 0.1,
borderWidth: 2
}]
};
const joinedMemberChart = new Chart(chartDiv,
{
type: 'line',
data: chartData,
options: {
plugins: {
legend: {
display: false
}
},
scales: {
y: {
min: 0
}
}
},
}
);
}
function drawActiveUserKpiChart(chartDiv, fromDate, toDate, data) {
const labels = createGraphDateLabels(new Date(fromDate), new Date(toDate))
const createdData = createActiveUserChartDataByDate(new Date(fromDate), new Date(toDate), data);
const chartData = {
labels: labels,
datasets: [{
label: '활성 사용자 수',
data: createdData,
fill: {
target: 'origin',
above: '#5c649042',
},
borderColor: '#5e72e4',
tension: 0.1,
borderWidth: 2
}]
};
const joinedMemberChart = new Chart(chartDiv,
{
type: 'line',
data: chartData,
options: {
plugins: {
legend: {
display: false
}
},
scales: {
y: {
min: 0
}
}
},
}
);
}
function createGraphDateLabels(fromDate, toDate) {
let lastDate = toDate;
lastDate.setDate(toDate.getDate() + 1);
let result = [];
while(true){
result.push((fromDate.getMonth() + 1) + '/' + fromDate.getDate());
let nextDate = fromDate;
nextDate.setDate(fromDate.getDate() + 1);
if(getFormatDate(nextDate, '') == getFormatDate(lastDate, '')) {
break;
}
}
return result;
}
function createJoinMemberChartDataByDate(fromDate, toDate, data) {
let lastDate = toDate;
lastDate.setDate(toDate.getDate() + 1);
let result = [];
while(true){
let nextDate = fromDate;
let isNoValue = true;
for(var i = 0; i < data.length; i++) {
if(getFormatDate(new Date(data[i].date), '') == getFormatDate(nextDate, '')) {
isNoValue = false;
result.push(data[i].joinMemberCount);
break;
}
}
if(isNoValue) {
result.push(0);
}
nextDate.setDate(fromDate.getDate() + 1);
if(getFormatDate(nextDate, '') == getFormatDate(lastDate, '')) {
break;
}
}
return result;
}
function createActiveUserChartDataByDate(fromDate, toDate, data) {
let lastDate = toDate;
lastDate.setDate(toDate.getDate() + 1);
let result = [];
while(true){
let nextDate = fromDate;
let isNoValue = true;
for(var i = 0; i < data.length; i++) {
if(getFormatDate(new Date(data[i].date), '') == getFormatDate(nextDate, '')) {
isNoValue = false;
result.push(data[i].count);
break;
}
}
if(isNoValue) {
result.push(0);
}
nextDate.setDate(fromDate.getDate() + 1);
if(getFormatDate(nextDate, '') == getFormatDate(lastDate, '')) {
break;
}
}
return result;
}
</script>
</body>
</html>