fix:修复endpoint info图表alerts数据异常

This commit is contained in:
wangwenrui
2020-10-13 16:42:37 +08:00
parent e9e30ecedc
commit 54b66053df

View File

@@ -1225,7 +1225,7 @@
} }
}, },
getEndpointInfoChartData(chartInfo) { getEndpointInfoChartData(chartInfo) {
let detail = [null,null]; let detail = [];
this.$refs['editChart'+chartInfo.id][0].showLoad(); this.$refs['editChart'+chartInfo.id][0].showLoad();
chartInfo.title = this.$t("project.chart.endpointInfo"); chartInfo.title = this.$t("project.chart.endpointInfo");
@@ -1274,8 +1274,7 @@
}); });
basicInfo.stateSeries = [series]; basicInfo.stateSeries = [series];
basicInfo.state = ""; basicInfo.state = "";
detail[0]={title: this.$t("project.chart.basicTitle"), data: basicInfo, type: "endpointInfo"}; resolve({title: this.$t("project.chart.basicTitle"), data: basicInfo, type: "endpointInfo"});
resolve(true);
} }
} }
}); });
@@ -1284,31 +1283,25 @@
let endpointId = this.additionalInfo.id; let endpointId = this.additionalInfo.id;
let alertMsg = new Promise((resolve, reject) => { let alertMsg = new Promise((resolve, reject) => {
this.$get('/alert/message?endpointId=' + endpointId).then(response => { this.$get('/alert/message?endpointId=' + endpointId+"&state=1&pageSize=-1").then(response => {
if (response.code == 200) { if (response.code == 200) {
let alerts = {}; let alerts = {};
response.data && function () { if(response.data){
response.data.list.forEach(item => { response.data.list.forEach(t=>{
let alertName = item.alertRule.alertName; let alertRule = t.alertRule.alertName;
let hasAlert = false; if(alerts[alertRule]){
for (let alert in alerts) { alerts[alertRule]++
if (alertName == alert) { }else{
hasAlert = true; alerts[alertRule]=1
}
} }
if (hasAlert) { })
alerts[alertName]++; }
} else { resolve({title: this.$t("overall.alert"), data: alerts});
alerts[alertName] = 1;
}
});
}();
detail[1]={title: this.$t("overall.alert"), data: alerts};
resolve(true);
} }
}); });
}); });
Promise.all([basicInfoReq, alertMsg]).then(resolves => { Promise.all([basicInfoReq, alertMsg]).then(resolves => {
resolves.forEach(t=>detail.push(t))
this.$refs['editChart'+chartInfo.id][0].setData(chartInfo, detail); this.$refs['editChart'+chartInfo.id][0].setData(chartInfo, detail);
}); });
}, },