profile_server.hbs
3.38 KB
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
<div class="pageheader">
<div class="media">
<div class="pageicon pull-left">
<i class="fa fa-th-list"></i>
</div>
<div class="media-body">
<ul class="breadcrumb">
<li><a href=""><i class="glyphicon glyphicon-home"></i></a></li>
<li><a href="">性能监控</a></li>
<li>慢路由统计统计</li>
</ul>
<h4>慢路由统计</h4>
</div>
</div>
<!-- media -->
</div>
<!-- pageheader -->
<div class="contentpanel page-servers">
<div class="panel panel-primary-head">
<div class="panel-heading" style="overflow: hidden">
<div class="pull-left">
<select id="selectedApp" class="selectpicker show-menu-arrow form-control" style="margin-left: 10px;">
<option value="default">全部</option>
<option value="pc">PC</option>
<option value="h5">H5</option>
</select>
</div>
<div class="pull-left">
<button id="search" class="btn btn-info" style="margin-left: 20px;">查询</button>
</div>
</div>
<!-- panel-heading -->
<table id="table-servers" class="table table-striped table-bordered">
<thead class="">
<tr>
<td >时间</td>
<td >应用名称</td>
<td >接口名称</td>
<td >路由</td>
<td >耗时</td>
</thead>
<tbody>
</tbody>
</table>
</div>
<!-- panel -->
</div>
<script>
var selectedServer, selectedApp;
var data_end_point = '/profile/server.json';
var dataTable = null;
function ajaxUrl() {
let url = `${data_end_point}?app=${selectedApp}&server=${selectedServer}`;
return url
}
$(function() {
init();
initTable();
initSelect();
});
function init() {
selectedServer = 'aws';
selectedApp = 'default';
}
function initTable() {
dataTable = $("#table-servers").DataTable({
pageLength: 20,
serverSide: true,
retrieve: true,
searching: false,
ajax: ajaxUrl(),
dataSrc: 'data',
pageLength: 25,
columns: [
{data: 'time'},
{data: 'app'},
{data: 'api'},
{data: 'route'},
{data: 'duration'},
],
data: [{
time: '',
app: '',
api: 0,
route: 0,
duration: 0,
}],
columnDefs: [
{
render: function(data, type, row) {
if (!data) {
return '';
}
return moment(data).format('YYYY/MM/DD HH:MM:ss');
},
targets: 0
}
]
});
}
function initSelect() {
$('#selectedApp').change(function() {
selectedApp = $('#selectedApp').val();
});
$('#search').on('click', () => {
_handleChanged();
})
}
function _handleChanged() {
dataTable && dataTable.ajax.url(ajaxUrl()).load();
}
</script>