mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-08-30 12:45:32 +08:00
67 lines
3.2 KiB
PHP
67 lines
3.2 KiB
PHP
$(function(){
|
||
ua.table.render({
|
||
init: init,
|
||
toolbar: [],
|
||
cols: [[
|
||
{field: 'id', title: 'ID', width: 80, sort: true},
|
||
{field: 'watch_id', title: '监控规则', width: 160, search: 'select', searchOp: '=', selectList: ua.getDataBrage('select_list_watch'), templet: function(d) {
|
||
return d.watch && d.watch.name ? d.watch.name : ('#' + d.watch_id);
|
||
}},
|
||
{field: 'run.url', title: '请求 URL', minWidth: 220, search: false, templet: function(d) {
|
||
if (!d.run || !d.run.url) {
|
||
return '<span class="layui-text-em">#' + d.run_id + '</span>';
|
||
}
|
||
var esc = String(d.run.url).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||
return '<span title="' + esc + '">' + esc + '</span>';
|
||
}},
|
||
{field: 'run.request_time', title: '请求时间', width: 170, search: 'range', templet: function(d) {
|
||
if (!d.run || !d.run.request_time) {
|
||
return '-';
|
||
}
|
||
var ts = parseFloat(d.run.request_time);
|
||
if (isNaN(ts) || ts <= 0) {
|
||
return '-';
|
||
}
|
||
var dt = new Date(ts * 1000);
|
||
var p = function (n) {
|
||
return n < 10 ? '0' + n : '' + n;
|
||
};
|
||
return dt.getFullYear() + '-' + p(dt.getMonth() + 1) + '-' + p(dt.getDate())
|
||
+ ' ' + p(dt.getHours()) + ':' + p(dt.getMinutes()) + ':' + p(dt.getSeconds());
|
||
}},
|
||
{field: 'ct', title: '命中次数', width: 100, search: 'number_limit'},
|
||
{field: 'wt_sum', title: '耗时合计(ms)', width: 140, search: 'number_limit', templet: function(d) {
|
||
var ms = parseFloat(d.wt_sum) / 1000;
|
||
var threshold = d.watch ? parseInt(d.watch.threshold_ms, 10) : 0;
|
||
var text = (isNaN(ms) ? 0 : ms).toFixed(3) + ' ms';
|
||
if (threshold > 0 && ms > threshold) {
|
||
return '<span class="layui-badge layui-bg-red">' + text + '(超阈值 ' + threshold + 'ms)</span>';
|
||
}
|
||
return text;
|
||
}},
|
||
{field: 'wt_max', title: '单次最大(ms)', width: 130, search: 'number_limit', templet: function(d) {
|
||
var ms = parseFloat(d.wt_max) / 1000;
|
||
return (isNaN(ms) ? 0 : ms).toFixed(3) + ' ms';
|
||
}},
|
||
{field: 'create_time', title: '入库时间', width: 170, search: false, templet: ua.table.date},
|
||
{
|
||
width: 100, title: '操作', templet: ua.table.tool, fixed: 'right', operat: [
|
||
[{
|
||
class: 'layui-btn layui-btn-primary layui-btn-xs',
|
||
method: 'tab',
|
||
field: 'id',
|
||
text: '详情',
|
||
title: '查看详情',
|
||
auth: 'read',
|
||
url: init.readUrl,
|
||
icon: ''
|
||
}]
|
||
]
|
||
},
|
||
|
||
]],
|
||
});
|
||
|
||
ua.listen();
|
||
})
|