pref:endpoint 最新指标列表查询功能优化

This commit is contained in:
wangwenrui
2020-02-13 12:33:22 +08:00
parent 87ac19ef41
commit c0830516e5

View File

@@ -158,6 +158,10 @@
</div> </div>
<!--时间选择器--> <!--时间选择器-->
<div class="top-tool-right"> <div class="top-tool-right">
<div class="top-tool-search">
<!-- <metric-search :metrics="metricList" :labels="labelList" v-if="tableShow == 3" @expression-change="tableFilter"></metric-search>-->
<el-input id="elementQuery" v-model="queryExpression" suffix-icon="el-icon-search" size="mini" clearable :placeholder="$t('project.endpoint.promExpr')" ></el-input>
</div>
<div class="margin-r-20 margin-t-m1"> <div class="margin-r-20 margin-t-m1">
<button @click="changeTime(-10)" class="nz-btn nz-btn-size-normal nz-btn-style-light"><i class="el-icon-d-arrow-left"></i></button> <button @click="changeTime(-10)" class="nz-btn nz-btn-size-normal nz-btn-style-light"><i class="el-icon-d-arrow-left"></i></button>
<el-date-picker <el-date-picker
@@ -174,9 +178,7 @@
</el-date-picker> </el-date-picker>
<button @click="changeTime(10)" class="nz-btn nz-btn-size-normal nz-btn-style-light"><i class="el-icon-d-arrow-right"></i></button> <button @click="changeTime(10)" class="nz-btn nz-btn-size-normal nz-btn-style-light"><i class="el-icon-d-arrow-right"></i></button>
</div> </div>
<div class="top-tool-search">
<metric-search :metrics="metricList" :labels="labelList" v-if="tableShow == 3" @expression-change="tableFilter"></metric-search>
</div>
<button @click="viewGraph" slot="reference" class="nz-btn nz-btn-size-normal nz-btn-style-normal nz-btn-min-width-120"> <button @click="viewGraph" slot="reference" class="nz-btn nz-btn-size-normal nz-btn-style-normal nz-btn-min-width-120">
<span class='top-tool-btn-txt'>{{$t('project.endpoint.addGraph')}}</span> <span class='top-tool-btn-txt'>{{$t('project.endpoint.addGraph')}}</span>
</button> </button>
@@ -382,6 +384,7 @@
curEndpoint:null, curEndpoint:null,
endpointQueryTabData:[],//endpoint 查询列表数据 endpointQueryTabData:[],//endpoint 查询列表数据
showTableData:[], showTableData:[],
showTableDataCopy:'',
queryExpression:'', queryExpression:'',
metricList: [], // metric列表 metricList: [], // metric列表
labelSet:new Set(), labelSet:new Set(),
@@ -904,6 +907,7 @@
} }
this.endpointQueryTabData=[]; this.endpointQueryTabData=[];
this.showTableData=[]; this.showTableData=[];
this.showTableDataCopy='';
this.$get("/prom/api/v1/query?query={job='ed_"+this.curEndpoint.id+"'}&time="+this.formatTime).then(response=>{ this.$get("/prom/api/v1/query?query={job='ed_"+this.curEndpoint.id+"'}&time="+this.formatTime).then(response=>{
if(response.status==="success"){ if(response.status==="success"){
let results=response.data.result; let results=response.data.result;
@@ -925,7 +929,7 @@
return {key:item,type:'label'} return {key:item,type:'label'}
}) })
} }
this.showTableDataCopy=JSON.stringify(this.showTableData);
this.tableShow=3; this.tableShow=3;
this.queryEdpLoading=false; this.queryEdpLoading=false;
} }
@@ -1102,7 +1106,15 @@
} }
}); });
}, },
tableFilter:function(expression){ tableFilter:function(){
let tableDatas=JSON.parse(this.showTableDataCopy);
this.showTableData=tableDatas.filter((item)=>{
let element=item.element;
return element.indexOf(this.queryExpression) != -1;
})
},
tableFilterHistory:function(expression){
let metric=''; let metric='';
let labels=[]; let labels=[];
if(/\w*\{.*\}.*/i.test(expression)){ if(/\w*\{.*\}.*/i.test(expression)){
@@ -1223,7 +1235,13 @@
}, },
curEndpoint:function(n,o){ curEndpoint:function(n,o){
// this.chartOptions.title.text=n.host+ " tsg disk" // this.chartOptions.title.text=n.host+ " tsg disk"
} },
queryExpression:function(n,o){
let temp=this;
setTimeout(function(){
temp.tableFilter();
},100)
},
} }
} }
</script> </script>
@@ -1470,4 +1488,12 @@
line-height: 37px; line-height: 37px;
} }
/* end--覆盖分页组件样式*/ /* end--覆盖分页组件样式*/
.query-inactive{
border: 1px solid #dfdfdf;
background-color: #dfdfdf;
border-radius:20%;
width: 40px;
height: 26px;
padding: 2px 10px 2px 10px;
}
</style> </style>