perf: alertdetail弹出框使用groupby、增加d&t

This commit is contained in:
陈劲松
2020-11-17 18:07:02 +08:00
committed by chenjinsong
parent cc818f67cc
commit b0e8821750
3 changed files with 53 additions and 4 deletions

View File

@@ -4,6 +4,7 @@
* type:自定义参数用于区分是y轴调用还是tooltip调用,以设置不同精度 type =1 y轴调用 type=2 tooltip调用
* */
import {parse} from "echarts/extension-src/dataTool/gexf";
import bus from "../../libs/bus"
function none(value, index){
return value;
@@ -412,6 +413,12 @@ function timeCompute(value,unit,dot=0){
}
}
function timeFormat34(value) {
return bus.timeFormate(value, "yyyy-MM-dd hh:mm:ss");
}
function timeFormat35(value) {
return bus.timeFormate(value, "MM/dd/yyyy h:mm:ss a");
}
//unit转化配置信息
/*
* value:传递给数据库的值
@@ -615,7 +622,23 @@ let unitOptions=[
ascii:7,
},
]
}//Time end
},//Time end
{
value:'Date&Time',
label: 'Date & Time',
children: [
{
value:34,
compute: timeFormat34,
label:'YYYY-MM-DD HH:mm:ss',
},
{
value:35,
compute: timeFormat35,
label:'MM/DD/YYYY h:mm:ss a',
}
]
}
]
let units=[];
window.onload=function(){

View File

@@ -567,7 +567,31 @@
},
promQueryParamConvert(obj){
let result="(" + obj.alertRule.expr + ")";
let r = "(" + obj.alertRule.expr + ")";
if (Object.keys(obj.labels).length > 0) {
r += " and " + function(){
let group = "(group({";
let by = " by (";
for (let k in obj.labels) {
if (k != 'alertname' && k != 'severity') {
group += k;
group += "=";
group += ("'" + obj.labels[k] + "',");
by += k;
by += ","
}
}
group = group.substring(0, group.length-1);
group += "})";
by = by.substring(0, by.length-1);
by += ")";
return group + by + ")";
}();
}
return r;
/*let result="(" + obj.alertRule.expr + ")";
if(obj.labels){
if(obj.labels.alertname){
delete obj.labels.alertname;
@@ -591,7 +615,7 @@
return q;
}() + ")";
}
return result;
return result;*/
},
//asset弹框控制
tabControl(data) {

View File

@@ -100,10 +100,11 @@ export default new Vue({
const o = {
'M+': time.getMonth() + 1, // 月份
'd+': time.getDate(), // 日
'h+': time.getHours(), // 小时
'hh': time.getHours(), // 小时
'm+': time.getMinutes(), // 分
's+': time.getSeconds(), // 秒
'q+': Math.floor((time.getMonth() + 3) / 3), // 季度
'a': time.getHours() > 12 ? "pm" : "am",
S: time.getMilliseconds(), // 毫秒
w: week,
};
@@ -116,6 +117,7 @@ export default new Vue({
(o[k]) : ((`00${o[k]}`).substr((`${o[k]}`).length)));
}
});
fm = fm.replace("h", time.getHours() > 12 ? time.getHours()-12 : time.getHours());
return fm;
},
// 格式化tag为字符串表达式