monitor.js.method.tree.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of trace-spring-boot-starter Show documentation
Show all versions of trace-spring-boot-starter Show documentation
Used to invoke the chain visualization.
The newest version!
function initListener() {
//监听折叠
element.on('collapse(static)', function (data) {
if (data.show === true) {
const chainId = data.content[0].children[0].id;
asyncHttpGet(static_chain_api + '/' + chainId, function (rtn) {
if (!isEmpty(rtn)) {
$('#' + chainId).html('' + buildTree(rtn) + '
');
bindAnimation(chainId);
} else {
layer.msg('This id:' + chainId + ' server has no corresponding data');
}
});
}
});
}
// 构建tree dom
function buildTree(obj) {
let signatureId = obj.signatureId;
signatureId += '$' + getRandomId();
let methodName = obj.name;
let className = obj.className;
// if (!isEmpty(className)) {
// className = className.substring(className.lastIndexOf(".") + 1) + '.';
// }
let child = obj.children;
let html = '';
if (hasChild(child)) {
html += '';// 菜单结点
} else {
html += '';// 叶子结点
}
html += className +'-->'+ methodName + '()详情';
if (hasChild(child)) {
html += '';
for (let i = 0; i < child.length; i++) {
html += buildTree(child[i]);
}
html += '
';
}
html += ' ';
return html;
}
// 为不同traceId绑定动画
function bindAnimation(id) {
if (!isEmpty(id)) {
$('div #' + id + ' li:has(ul)').addClass('parent_li');
$('div #' + id + ' li.parent_li > span').on('click', function (e) {
const children = $(this).parent('li.parent_li').find(' > ul > li');
if (children.is(":visible")) {
children.hide('fast');
$(this).find(' > i').addClass('icon-plus-sign').removeClass('icon-minus-sign');
} else {
children.show('fast');
$(this).find(' > i').addClass('icon-minus-sign').removeClass('icon-plus-sign');
}
e.stopPropagation();
});
}
}