-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathappAdmin_profile_counter.html
469 lines (434 loc) · 14.1 KB
/
appAdmin_profile_counter.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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>环信开发者中心</title>
<!--
<link href="//cdnjscn.b0.upaiyun.com/libs/twitter-bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="//cdnjscn.b0.upaiyun.com/libs/twitter-bootstrap/2.3.2/css/bootstrap-responsive.css" rel="stylesheet" type="text/css" media="screen"/>
-->
<link href="assets/css/bootstrap-2.3.2.min.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/css/bootstrap-responsive-2.3.2.min.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/css/font-awesome-3.1.0.min.css" rel="stylesheet" type="text/css" media="screen"/>
<!--[if IE 7]>
<link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css" />
<![endif]-->
<!--fonts-->
<!-- <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,300" /> -->
<!--ace styles-->
<link href="assets/css/ace.min.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/css/ace-responsive.min.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/css/ace-skins.min.css" rel="stylesheet" type="text/css" media="screen"/>
<!--[if lte IE 8]>
<link rel="stylesheet" href="assets/css/ace-ie.min.css" />
<![endif]-->
<link href="assets/css/management.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/css/manage.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/css/SpryTabbedPanels.css" rel="stylesheet" type="text/css" media="screen"/>
<!--
<script src="//cdnjscn.b0.upaiyun.com/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="//cdnjscn.b0.upaiyun.com/libs/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script src="//cdnjscn.b0.upaiyun.com/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script src="//cdnjscn.b0.upaiyun.com/libs/json2/20130526/json2.min.js"></script>
-->
<script src="assets/js/ace-elements.min.js"></script>
<script src="assets/js/ace.min.js"></script>
<script src="assets/js/ichart.1.2.js"></script>
<script src="assets/js/management.js"></script>
<script src="assets/js/jquery-1.7.2.min.js"></script>
<script src="assets/js/jquery.cookie-1.3.js"></script>
<script src="assets/js/bootstrap-2.3.2.min.js"></script>
<script src="assets/js/json2.js"></script>
<script tyep="text/javascript">
var appUuid = getQueryString('appUuid');
$(function(){
if (!getToken() || getToken()==''){
logout();
}
getAppProfile(appUuid);
// 初始化先绘制好两幅图,默认把用户数据图显示
drawUser(7);
drawMessage(7);
$('#canvasMsgDiv').hide();
$('#canvasUserDiv').show();
//控制图的显示
$('#userDiv').click(function(){
$('#userDiv').checked = true;
$('#msgDiv').checked = false;
$('#canvasMsgDiv').hide();
$('#canvasUserDiv').show();
});
$('#msgDiv').click(function(){
$('#msgDiv').checked = true;
$('#userDiv').checked = false;
$('#canvasUserDiv').hide();
$('#canvasMsgDiv').show();
});
});
// 当前时间的时间戳
function getNowTTamp(){
return new Date().getTime();
}
// 时间格式转换 1399434332770 ->
function add1(m){
return m<10?'0'+m:m;
}
function format1(timeST){
var time = new Date(parseInt(timeST));
var y = time.getFullYear();
var m = time.getMonth()+1;
var d = time.getDate();
//var h = time.getHours();
//var mm = time.getMinutes();
//var s = time.getSeconds();
return y+'-'+add0(m)+'-'+add0(d);
}
// 用户数据图
function drawUser(internal){
var spot=[], t,labels=[];
var access_token = $.cookie('access_token');
var orgName = $.cookie('orgName');
var start_time = getNowTTamp() - internal*24*60*60*1000;
var end_time = getNowTTamp();
var resolution = 'day';
var pad = 'true';
// 获取每个app的用户数:按时间端统计 起止按start到end算 间隔按resolution算
$.ajax({
url:baseUrl+'/'+ orgName +'/' + appUuid + '/counters?counter=application.collection.users&start_time='+start_time+'&end_time='+end_time+'&resolution='+resolution+'&pad='+pad,
type:'GET',
async:false,
headers:{
'Authorization':'Bearer ' + access_token,
'Content-Type':'application/json'
},
success: function(respData, textStatus, jqXHR) {
$.each(respData.counters,function(){
if(this.values.length == 0){
spot.push(0);
labels.push(0);
} else {
$.each(this.values,function(){
spot.push(this.value);
labels.push(format1(this.timestamp));
});
}
});
},
error: function(jqXHR, textStatus, errorThrown) {
alert('提示\n\n数据获取失败!');
},
});
function getMaximin (arr,maximin) {
if (maximin == "max") {
return Math.max.apply(Math, arr);
}else if (maximin == "min") {
return Math.min.apply(Math, arr);
}
}
var yMax = getMaximin(spot,'max');
var sspace = 0;
if(yMax > 0 && yMax < 1000){
sspace = 10;
} else if(yMax > 1000 && yMax < 10000){
sspace = 100;
} else if(yMax > 10000 && yMax < 100000){
sspace = 1000;
}
var data = [
{
name : internal+'日内',
value : spot,
color:'#0d8ecf',
line_width:1
}
];
var line = new iChart.LineBasic2D({
render : 'canvasUserDiv',
data : data,
align : 'center', // 图标的显示位置center 居中
title : '每日新增用户数量统计',
subtitle : '( 单位:个)',
footnote : '数据来源:环信',
width : 1000,
height : 450,
tip:{
enable : true,
shadow : true
},
legend : {
enable : true,
row : 2,//设置在一行上显示,与column配合使用
column : 'max',
valign :'top',
sign : 'bar',
background_color : null,//设置透明背景
offsetx : -80,//设置x轴偏移,满足位置需要
border : true
},
crosshair : {
enable : true,
line_color : '#62bce9'
},
sub_option : {
label : false,
point_hollow : false
},
coordinate : {
width : 770, // 坐标线的长度
height : yMax*10 + sspace, // 坐标线的高度
axis : {
color : '#9f9f9f',
width : [0, 0, 2, 2] //width : [0, 0, 2, 2] 分别代表上下左右的宽度
},
grids : {
vertical : {
way : 'share_alike',
value : spot.length - 1 // 横轴有几个grid
}
},
scale:
[{
position : 'left',
start_scale : 0,
end_scale : yMax + sspace, //y轴最大值
scale_space : sspace,
scale_size : 2,
scale_color : '#1f7e92'
},{
position : 'bottom',
labels : labels
}]
}
});
//开始画图
line.draw();
}
// 消息发送统计图
function drawMessage(internal){
var spot=[], t,labels1=[];
var access_token = $.cookie('access_token');
var orgName = $.cookie('orgName');
var start_time1 = getNowTTamp() - internal*24*60*60*1000;
var end_time1 = getNowTTamp();
var resolution1 = 'day';
var pad1 = 'true';
// 获取每个app的用户数:按时间端统计 起止按start到end算 间隔按resolution算
$.ajax({
url:baseUrl+'/'+ orgName +'/' + appUuid + '/counters?counter=application.collection.chatmessages&start_time='+start_time1+'&end_time='+end_time1+'&resolution='+resolution1+'&pad='+pad1,
type:'GET',
async:false,
headers:{
'Authorization':'Bearer ' + access_token,
'Content-Type':'application/json'
},
success: function(respData, textStatus, jqXHR) {
$.each(respData.counters,function(){
if(this.values.length == 0){
spot.push(0);
labels1.push(0);
} else {
$.each(this.values,function(){
spot.push(this.value);
labels1.push(format1(this.timestamp));
});
}
});
},
error: function(jqXHR, textStatus, errorThrown) {
alert('提示\n\n数据获取失败!');
},
});
function getMaximin (arr,maximin) {
if (maximin == "max") {
return Math.max.apply(Math, arr);
}else if (maximin == "min") {
return Math.min.apply(Math, arr);
}
}
var yMax1 = getMaximin(spot,'max');
var sspace = 0;
if(yMax1 > 10 && yMax1 < 100){
sspace = 1;
} else if(yMax1 > 100 && yMax1 < 1000){
sspace = 10;
} else if(yMax1 > 1000 && yMax1 < 10000){
sspace = 100;
} else if(yMax1 > 10000 && yMax1 < 100000){
sspace = 1000;
}
var data = [
{
name : internal+'日内',
value : spot,
color:'#0d8ecf',
line_width:1 // 折线的粗线
}
];
var line = new iChart.LineBasic2D({
render : 'canvasMsgDiv',
data : data,
align : 'center', // 图标的显示位置center 居中
title : '每日消息发送数量统计',
subtitle : '( 单位:条)',
footnote : '数据来源:环信',
width : 1000,
height : 550,
tip:{
enable : true,
shadow : true
},
legend : {
enable : true,
row : 2,//设置在一行上显示,与column配合使用
column : 'max',
valign :'top',
sign : 'bar',
background_color : null,//设置透明背景
offsetx : -80,//设置x轴偏移,满足位置需要
border : true
},
crosshair : {
enable : true,
line_color : '#62bce9'
},
sub_option : {
label : false,
point_hollow : false
},
coordinate : {
width : 770, // 坐标线的长度
height : yMax1*100 + sspace, // 坐标线的高度
axis : {
color : '#9f9f9f',
width : [0, 0, 2, 2] //width : [0, 0, 2, 2] 分别代表上下左右的宽度
},
grids : {
vertical : {
way : 'share_alike',
value : spot.length - 1 // 横轴有几个grid
}
},
scale:
[{
position : 'left',
start_scale : 0,
end_scale : yMax1 + sspace, //y轴最大值
scale_space : sspace, // y轴数值的梯度
scale_size : 2,
scale_color : '#1f7e92'
},{
position : 'bottom',
labels : labels1
}]
}
});
//开始画图
line.draw();
}
// 应用概述页
function toApppofile(){
window.location.href = 'app_profile.html?appUuid='+appUuid;
}
// 用户管理页
function toAppUsersPage(){
window.location.href = 'app_users.html?appUuid='+appUuid;
}
// 群组管理页
function toAppChatroomsPage(){
window.location.href = 'app_chatrooms.html?appUuid='+appUuid;
}
// 推送证书管理页
function toAppCredentialsPage(){
window.location.href = 'app_credentials.html?appUuid='+appUuid;
}
// 数据统计页面
function toApppofileCounter(){
window.location.href = 'app_profile_counter.html?appUuid='+appUuid;
}
</script>
</head>
<body>
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<div class="container-fluid"> <a class="brand" href="javascript:void(0);"> <small> <img style="height:45px;" src="assets/images/home_logo.png" alt="管理后台"/> </small> </a>
<div class="lianjie">
<ol>
<li><a href="http://www.easemob.com" target="_blank"><h5>主页</h5></a></li>
<li><a href="http://developer.easemob.com" target="_blank"><h5>文档</h5></a></li>
<li><a href="http://www.easemob.com/faq" target="_blank"><h5>帮助</h5></a></li>
<li><a href="http://www.easemob.com/sdk" target="_blank"><h5>下载SDK</h5></a></li>
</ol>
</div>
<ul class="nav ace-nav pull-right">
<li class="light-blue user-profile"> <a class="user-menu dropdown-toggle" href="javascript:void(0);" data-toggle="dropdown"> <span id="user_info"></span> <i class="icon-caret-down"></i> </a>
<ul id="user_menu" class="pull-right dropdown-menu dropdown-yellow dropdown-caret dropdown-closer">
<li class="divider"></li>
<li> <a href="admin_home.html"> <i class="icon-user"></i> 账户 </a> </li>
<li> <a onclick="logout();" href="javascript:void(0);"> <i class="icon-off"></i> 退出 </a> </li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div id="main-container" class="container-fluid"> <a href="javascript:void(0);" id="menu-toggler"> <span></span> </a>
<div id="sidebar">
<div id="sidebar-shortcuts">
<div style="min-height: 40px;" id="sidebar-shortcuts-large"> </div>
<div style="min-height: 40px;" id="sidebar-shortcuts-mini"> </div>
</div>
<ul class="nav nav-list">
<li class="active"> <a href="app_list.html" target="_self"> <i class="icon-ambulance"></i> <span>我的应用</span> </a></li>
<li> <a href="admin_home.html" target="_self"> <i class="icon-user"></i> <span>个人信息</span> </a></li>
</ul>
<div id="sidebar-collapse"> <i class="icon-double-angle-left"></i> </div>
</div>
<div class="clearfix" id="main-content">
<div id="breadcrumbs">
<ul class="breadcrumb">
<li> <i class="icon-home"></i> 我的应用 <span class="divider"> <i class="icon-angle-right"></i> </span> </li>
<li> <a href="javascript:void(0);" target="_self"> <span id="showName"></span></a></li>
</ul>
</div>
<div class="clearfix" id="page-content">
<div class="row-fluid">
<div class="pagination pagination-left">
<ul>
<li> <a href="javascript:toApppofile()">应用概况</a> </li>
</ul>
<ul>
<li> <a href="javascript:toAppUsersPage()">IM用户</a> </li>
</ul>
<!--
<ul>
<li> <a href="javascript:toAppChatroomsPage()">群组管理</a> </li>
</ul>
-->
<ul>
<li> <a href="javascript:toAppCredentialsPage()">推送证书</a> </li>
</ul>
<ul>
<li> <a href="javascript:toApppofileCounter()"><font color="green">统计数据</font></a> </li>
</ul>
</div>
<hr>
<div style="width:1000px; margin:0 auto; overflow:hidden;">
<div style="float:right;">
<input type="radio" name="divRadio" id="userDiv" checked="checked"/><span class="lbl">新增用户</span>
<input type="radio" name="divRadio" id="msgDiv" /><span class="lbl">消息</span>
</div>
<div> </div><div> </div>
<!-- 用户数据 -->
<div id='canvasUserDiv'></div>
<!-- 消息数据 -->
<div id='canvasMsgDiv'></div>
</div>
</div>
</div>
</div>
</body>
</html>