forked from CloudBreadProject/CloudBread-Admin-Web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.html
335 lines (304 loc) · 9.45 KB
/
main.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
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<!--Load the js and jquery API-->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.5/socket.io.min.js"></script>
<script type="text/javascript" charset="utf-8"></script>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<!--Load the google icon API-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Load the Customed css-->
<link rel="stylesheet" type="text/css" href="./css/main.css">
<link rel="stylesheet" type="text/css" href="./css/font.css">
</head>
<body>
<div id="top">
Overview
</div>
<div id="descript">
<div id="subject">
CloudBread 관리자 페이지에 오신걸 환영합니다.
</div>
<div id="des_main">
<ul>
<li>
<div id="circle" style="background-color: #00bfa5;">
<i id="icon" class="material-icons">cloud_upload</i>
</div>
<div style="font-size:15px;">
<br>
관리자웹 배포 성공
<br>
<b>오류</b>가 난다면?
</div>
</li>
<li>
<div id="circle" style="background-color: #00b8d4;">
<i id="icon" class="material-icons">description</i>
</div>
<div style="font-size:15px;">
<br>
회원 정보 수정
<br>
<b>방법</b> 알고 싶다면?
</div>
</li>
<li>
<div id="circle" style="background-color: #c51162;">
<i id="icon" class="material-icons">assessment</i>
</div>
<div style="font-size:15px;">
<br>
통계 및 머신러닝
<br>
자세히 <b>분석</b>하고 싶다면?
</div>
</li>
</ul>
</div>
</div>
<div id="main_content">
<div id="graph_loading" style="text-align:center;">
<br>
Loading...
<br>
<div id="loading">●</div>
</div>
<div class="graph">
<div class="graph_main">
<div style="margin-top:27px; margin-left:29px;">
DAU(일일 활성 유저수)
</div>
</div>
<div id="DAU_div"></div>
<div id="DAU_table_div" style="text-align:center;"></div>
</div>
<div class="graph">
<div class="graph_main">
<div style="margin-top:27px; margin-left:29px;">
BPI(구매수 높은 아이템)
</div>
</div>
<div id="BPI_div" style="text-align:center;"></div>
<div id="BPI_table_div" style="text-align:center;"></div>
</div>
</div>
</body>
<!--main page bi graph js-->
<script>
google.charts.load('current', {packages: ['corechart', 'table']});
var host = "/";
var DAU_list = new Array();
var BPI_list = new Array();
var BPItem1 = {}, BPItem2 = {}, BPItem3 = {};
$(function() {
callDAU();
})
function callDAU() {
DAU_list = [];
$.ajax({
type: "GET",
url: host + "odata/StatsDatas?$top=10&$filter=CategoryName%20eq%20'DAU'&$orderby=Fields%20desc",
dataType: "text",
error: function() {
alert('Host not found! Please check the host name.');
},
success: function(data) {
//anything
}
}).done(function(data) {
var pars = JSON.parse(data);
var value = pars['value'];
var max = (value.length != 10) ? value.length-1 : 9
if(value.length == 0) {
alert('Not exist "DAU" Data anything');
return;
}
for (var i = max; i >= 0; i--) {
var dataset = {
'Field': value[i]['Fields'],
'Count': Number(value[i]['CountNum'])
};
DAU_list.push(dataset);
}
google.charts.setOnLoadCallback(drawDAUGraph);
google.charts.setOnLoadCallback(drawDAUTable);
$("#graph_loading").empty();
});
}
var pro_BPI1 = new Promise(function (resolve, reject) {
$.ajax({
type: "GET",
url: host + "odata/StatsDatas?$top=1&$filter=CategoryName%20eq%20'BPI1'&$orderby=Fields%20desc",
dataType: "text",
error: function() {
alert('Host not found! Please check the host name.');
reject();
},
success: function(data) {
//anything
}
}).done(function(data) {
var pars = JSON.parse(data);
var value = pars['value'];
if(value.length == 0) {
alert('Not exist "BPI1" Data anything');
return;
}
var dataset = {
'Field': value[0]['Fields'],
'Item' : value[0]['Groups'],
'Count': Number(value[0]['CountNum'])
};
BPItem1 = dataset;
resolve("Complete");
});
});
var pro_BPI2 = new Promise(function (resolve, reject) {
$.ajax({
type: "GET",
url: host + "odata/StatsDatas?$top=1&$filter=CategoryName%20eq%20'BPI2'&$orderby=Fields%20desc",
dataType: "text"
}).done(function(data) {
var pars = JSON.parse(data);
var value = pars['value'];
if(value.length == 0) {
alert('Not exist "BPI2" Data anything');
reject();
}
var dataset = {
'Field': value[0]['Fields'],
'Item' : value[0]['Groups'],
'Count': Number(value[0]['CountNum'])
};
BPItem2 = dataset;
resolve("Complete");
});
});
var pro_BPI3 = new Promise(function (resolve, reject) {
$.ajax({
type: "GET",
url: host + "odata/StatsDatas?$top=1&$filter=CategoryName%20eq%20'BPI3'&$orderby=Fields%20desc",
dataType: "text"
}).done(function(data) {
var pars = JSON.parse(data);
var value = pars['value'];
if(value.length == 0) {
alert('Not exist "BPI3" Data anything');
reject();
}
var dataset = {
'Field': value[0]['Fields'],
'Item' : value[0]['Groups'],
'Count': Number(value[0]['CountNum'])
};
BPItem3 = dataset;
resolve("Complete");
});
});
function drawDAUGraph() {
var DAU_data = new google.visualization.DataTable();
DAU_data.addColumn('string', 'Time of Day');
DAU_data.addColumn('number', '재방문 유저');
DAU_data.addColumn('number', '신규 유저');
for (i = 0; i < DAU_list.length; i++) {
var mon = DAU_list[i]['Field'].substring(4, 6);
var day = DAU_list[i]['Field'].substring(6, 8);
DAU_data.addRows([
[{
v: mon + '/' + day
}, Number(DAU_list[i]['Count']), 1]
]);
}
var DAU_options = {
title: 'DAU 일일 활동 유저수',
isStacked: true,
hAxis: {
title: 'Date'
},
vAxis: {
title: 'DAU (명)'
},
backgroundColor: '#fafafa',
legend: {position: 'top', maxLines: 1, alignment: 'end'}
};
var chart = new google.visualization.ColumnChart(document.getElementById('DAU_div'));
chart.draw(DAU_data, DAU_options);
}
function drawDAUTable() {
var DAU_table = new google.visualization.DataTable();
DAU_table.addColumn('string', 'Date (mon/day)');
DAU_table.addColumn('number', 'User');
DAU_table.addColumn('number', 'New User');
DAU_table.addRows(5);
for(var i = 0; i < 5; i++) {
var mon = DAU_list[i]['Field'].substring(4, 6);
var day = DAU_list[i]['Field'].substring(6, 8);
DAU_table.setCell(i, 0, mon + '/' + day);
DAU_table.setCell(i, 1, DAU_list[i]['Count']);
DAU_table.setCell(i, 2, 1);
}
var table = new google.visualization.Table(document.getElementById('DAU_table_div'));
table.draw(DAU_table, {showRowNumber: false, width: '90%', height: '150px'});
}
Promise.all([pro_BPI1, pro_BPI2, pro_BPI3]).then(function() {
BPI_list.push(BPItem1);
BPI_list.push(BPItem2);
BPI_list.push(BPItem3);
google.charts.setOnLoadCallback(drawBPIGraph);
google.charts.setOnLoadCallback(drawBPITable);
$("#graph_loading").empty();
});
function drawBPIGraph() {
var BPI_data = new google.visualization.DataTable();
BPI_data.addColumn('string', 'ItemName');
BPI_data.addColumn('number', 'Amount');
for (var i = 0; i < BPI_list.length; i++) {
BPI_data.addRows([
[BPI_list[i]['Item'], Number(BPI_list[i]['Count'])]
]);
}
var mon = BPI_list[0]['Field'].substring(4, 6);
var day = BPI_list[0]['Field'].substring(6, 8);
var BPI_options = {
title: 'BPI 주간 아이템 순위 (' + mon + '/' + day + ')',
isStacked: true,
hAxis: {
title: 'The number'
},
vAxis: {
title: 'Item'
},
backgroundColor: '#fafafa',
legend: {position: 'top', maxLines: 1, alignment: 'end'}
};
var chart = new google.visualization.BarChart(document.getElementById('BPI_div'));
chart.draw(BPI_data, BPI_options);
}
function drawBPITable() {
var BPI_table = new google.visualization.DataTable();
BPI_table.addColumn('string', 'Date');
BPI_table.addColumn('string', 'BestItem');
BPI_table.addColumn('number', 'Full Time');
BPI_table.addRows(3);
var mon = BPI_list[0]['Field'].substring(4, 6);
var day = BPI_list[0]['Field'].substring(6, 8);
for(var i = 0; i < 3; i++) {
BPI_table.setCell(i, 0, mon + '/' + day);
BPI_table.setCell(i, 1, BPI_list[i]['Item']);
BPI_table.setCell(i, 2, BPI_list[i]['Count']);
}
var table = new google.visualization.Table(document.getElementById('BPI_table_div'));
table.draw(BPI_table, {showRowNumber: false, width: '90%', height: '150px'});
}
$(window).resize(function() {
drawDAUGraph();
drawBPIGraph();
});
</script>
</html>