add:abbreviationEnable

This commit is contained in:
huoyo 2024-09-03 00:21:44 +08:00
parent 4f39f788da
commit 8ecfe58e75
9 changed files with 65 additions and 7 deletions

View File

@ -6,7 +6,7 @@
<groupId>cn.langpy</groupId>
<artifactId>ko-time</artifactId>
<version>2.4.5</version>
<version>2.4.6</version>
<name>KoTime</name>
<description>A springboot tool for tracking the paths of the methods,which can help you find method's performances easily.</description>
<licenses>

View File

@ -46,6 +46,7 @@ public class DefaultConfig {
private Integer mailThreshold;
private String mailScope;
private String propertyFile;
private Boolean abbreviationEnable;
public String getPropertyFile() {
return propertyFile;
@ -312,4 +313,11 @@ public class DefaultConfig {
this.paramAnalyse = paramAnalyse;
}
public Boolean getAbbreviationEnable() {
return abbreviationEnable;
}
public void setAbbreviationEnable(Boolean abbreviationEnable) {
this.abbreviationEnable = abbreviationEnable;
}
}

View File

@ -117,6 +117,7 @@ public class LoadConfig {
config.setParamAnalyse(defaultConfig.getParamAnalyse() == null ? true : defaultConfig.getParamAnalyse());
config.setDataReset(defaultConfig.getDataReset() == null ? false : defaultConfig.getDataReset());
config.setVersionNotice(defaultConfig.getVersionNotice() == null ? true : defaultConfig.getVersionNotice());
config.setAbbreviationEnable(defaultConfig.getAbbreviationEnable() == null ? true : defaultConfig.getAbbreviationEnable());
config.setStaticToken(defaultConfig.getStaticToken());
config.setMailEnable(defaultConfig.getMailEnable());

View File

@ -144,6 +144,8 @@ public class KoInitController {
line = line.replace("KoTimeUtil", KoTimeUtil);
} else if (line.indexOf("koTimeVersionValue") > -1) {
line = line.replace("koTimeVersionValue", "'" + KoUtil.getVerssion()+ "'");
}else if (line.indexOf("abbreviationEnableValue") > -1) {
line = line.replace("abbreviationEnableValue", Context.getConfig().getAbbreviationEnable()+"");
}
return line;
}

View File

@ -124,6 +124,9 @@ public class KoTimeController {
if (config.getMailEnable() != null) {
koTimeConfig.setMailEnable(config.getMailEnable());
}
if (config.getAbbreviationEnable() != null) {
koTimeConfig.setAbbreviationEnable(config.getAbbreviationEnable());
}
if (config.getThreshold() != null) {
koTimeConfig.setThreshold(config.getThreshold());
}

View File

@ -35,6 +35,13 @@
"description": "to print log in console",
"sourceType": "cn.langpy.kotime.config.DefaultConfig"
},
{
"name": "ko-time.abbreviation-enable",
"type": "java.lang.Boolean",
"defaultValue": true,
"description": "to abbreviate the interface name",
"sourceType": "cn.langpy.kotime.config.DefaultConfig"
},
{
"name": "ko-time.language",
"defaultValue": "chinese",

View File

@ -82,6 +82,7 @@ tab.configuration.kotime-config.enable-kotime-tip=开启KoTime
tab.configuration.kotime-config.enable-exception-tip=开启异常检测
tab.configuration.kotime-config.enable-console-tip=开启控制台日志
tab.configuration.kotime-config.enable-email-tip=开启邮件通知
tab.configuration.kotime-config.enable-abbreviation-tip=开启接口缩写
tab.configuration.kotime-config.select-language-tip=语言选择
tab.configuration.kotime-config.select-language-chinese=中文
tab.configuration.kotime-config.select-language-english=英文

View File

@ -82,6 +82,7 @@ tab.configuration.kotime-config.enable-kotime-tip=KoTime switch
tab.configuration.kotime-config.enable-exception-tip=exception switch
tab.configuration.kotime-config.enable-console-tip=console log switch
tab.configuration.kotime-config.enable-email-tip=email switch
tab.configuration.kotime-config.enable-abbreviation-tip=abbreviation switch
tab.configuration.kotime-config.select-language-tip=language switch
tab.configuration.kotime-config.select-language-chinese=Chinese
tab.configuration.kotime-config.select-language-english=English

View File

@ -19,6 +19,7 @@
var globalToken = staticTokenVisit ? staticToken : sessionStorage.getItem("kotimeToken");
let globalIsLogin = false;
let koTimeVersion = koTimeVersionValue;
let abbreviationEnable = abbreviationEnableValue;
function concatToken(url) {
if (globalNeedLogin) {
@ -73,6 +74,7 @@
let element = getDom('apiList');
html = '';
for (let i = 0; i < data.length; i++) {
let simName = data[i]['name'].replace('.','#');
let className = data[i]['className'];
let methodName = data[i]['methodName'];
let avgRunTime = data[i]['avgRunTime'];
@ -82,9 +84,17 @@
let apiId = className + "." + methodName;
let color = avgRunTime > globalThreshold ? 'danger' : 'success';
if (methodType == 'Controller' && routeName != null && routeName != '') {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\">" + className + "#<span style='font-size: 16px;font-weight: 500;'>" + methodName + "</span>&nbsp(<span style='font-size: 14px;font-weight: 430;color:#032b11'>" + routeName + "</span>)&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>";
if (abbreviationEnable) {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\"><span style='font-size: 16px;font-weight: 500;'>" + simName + "</span>&nbsp(<span style='font-size: 14px;font-weight: 430;color:#032b11'>" + routeName + "</span>)&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>";
}else {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\">" + className + "#<span style='font-size: 16px;font-weight: 500;'>" + methodName + "</span>&nbsp(<span style='font-size: 14px;font-weight: 430;color:#032b11'>" + routeName + "</span>)&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>";
}
} else {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\">" + className + "#<span style='font-size: 16px;font-weight: 500;'>" + methodName + "</span>&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>";
if (abbreviationEnable) {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\"><span style='font-size: 16px;font-weight: 500;'>" + simName + "</span>&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>";
}else {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\">" + className + "#<span style='font-size: 16px;font-weight: 500;'>" + methodName + "</span>&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>";
}
}
}
;
@ -173,6 +183,14 @@
})
};
getDom('abbreviationEnable').onclick = function () {
post(concatToken('contextPath/koTime/updateConfig'),{abbreviationEnable: getDom('abbreviationEnable').checked},function (res) {
noticeSuccess('{{tab.configuration.kotime-config.change-ok-tip}}')
},function () {
noticeError('{{tab.configuration.kotime-config.change-fail-tip}}')
})
};
getDom('languageSwitch').onclick = function () {
let selectedObj = getDom('languageSwitch');
post(concatToken('contextPath/koTime/updateConfig'),{language: selectedObj.options[selectedObj.selectedIndex].value},function (res) {
@ -217,7 +235,8 @@
kotimeEnableDom.checked = kotimeEnable;
let apiTip = getDom('apiTip');
apiTip.innerHTML = kotimeEnable == true ? "{{tab.summary.bottom-normal-tip}}" : "{{tab.summary.bottom-close-tip}}";
apiTip.innerHTML = kotimeEnable == true ? "{{tab.summary.bottom-normal-tip}}" :
"{{tab.summary.bottom-close-tip}}";
let threshold = data['threshold'];
@ -232,6 +251,10 @@
let mailEnableDom = getDom('mailEnable');
mailEnableDom.checked = mailEnable;
let abbreviationEnable = data['abbreviationEnable'];
let abbreviationEnableDom = getDom('abbreviationEnable');
abbreviationEnableDom.checked = abbreviationEnable;
let language = data['language'];
$("#languageSwitch").val(language)
});
@ -302,7 +325,8 @@
{'name': '<span style="color:gray">{{tab.interface.interface-list.show-metric.min}}</span>' + data['minRunTime'] + ' ms'}
];
if (data['exceptionNum'] != null && data['exceptionNum'] > 0) {
data['data'].push({'name': '<span style="color:gray">{{tab.interface.interface-list.show-metric.exception-num}}</span>' + data['exceptionNum'] + ' {{tab.interface.interface-list.show-metric.exception-unit}}'});
data['data'].push({'name': '<span style="color:gray">{{tab.interface.interface-list.show-metric.exception-num}}</span>' + data['exceptionNum'] +
' {{tab.interface.interface-list.show-metric.exception-unit}}'});
}
data["dblclick"] = "paramGraph";
return data;
@ -398,6 +422,7 @@
let element = getDom('apiList');
html = '';
for (let i = 0; i < data.length; i++) {
let simName = data[i]['name'].replace('.','#');
let className = data[i]['className'];
let methodName = data[i]['methodName'];
let avgRunTime = data[i]['avgRunTime'];
@ -407,9 +432,17 @@
let color = avgRunTime > globalThreshold ? 'danger' : 'success';
if (methodType == 'Controller' && routeName != null && routeName != '') {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\">" + className + "#<span style='font-size: 16px;font-weight: 500;'>" + methodName + "</span>&nbsp(<span style='font-size: 14px;font-weight: 430;color:#032b11'>" + routeName + "</span>)&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>";
if (abbreviationEnable) {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\"><span style='font-size: 16px;font-weight: 500;'>" + simName + "</span>&nbsp(<span style='font-size: 14px;font-weight: 430;color:#032b11'>" + routeName + "</span>)&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>";
}else {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\">" + className + "#<span style='font-size: 16px;font-weight: 500;'>" + methodName + "</span>&nbsp(<span style='font-size: 14px;font-weight: 430;color:#032b11'>" + routeName + "</span>)&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>";
}
} else {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\">" + className + "#<span style='font-size: 16px;font-weight: 500;'>" + methodName + "</span>&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>";
if (abbreviationEnable) {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\"><span style='font-size: 16px;font-weight: 500;'>" + simName + "</span>&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>";
}else {
html += "<li onclick=\"showMethods('" + apiId + "')\" style='color: #333;font-weight: 400;font-size: 14px;' id=\"" + apiId + "-list\">" + className + "#<span style='font-size: 16px;font-weight: 500;'>" + methodName + "</span>&nbsp &nbsp<span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span></li>";
}
}
}
;
@ -901,6 +934,8 @@
<br>
<label>{{tab.configuration.kotime-config.enable-email-tip}}</label> <input id='mailEnable' type="checkbox">
<br>
<label>{{tab.configuration.kotime-config.enable-abbreviation-tip}}</label> <input id='abbreviationEnable' type="checkbox">
<br>
<label>{{tab.configuration.kotime-config.select-language-tip}}</label>
<select id="languageSwitch">
<option value="chinese">{{tab.configuration.kotime-config.select-language-chinese}}</option>