Merge branch 'dev-3.2' of https://git.mesalab.cn/nezha/nezha-fronted into dev-3.3

# Conflicts:
#	nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue
#	nezha-fronted/src/components/page/alert/alertMessage.vue
This commit is contained in:
zhangyu
2022-04-01 17:58:57 +08:00
6 changed files with 52 additions and 12 deletions

View File

@@ -139,10 +139,12 @@ export default {
})
})
const timeSorted = datas.sort((a, b) => {
return a[0] - b[0]
return Number(a[0]) - Number(b[0])
})
const valueSorted = datas.sort((a, b) => {
return a[1] - b[1]
const a1 = isNaN(a[1]) ? 0 : Number(a[1])
const b1 = isNaN(b[1]) ? 0 : Number(b[1])
return a1 - b1
})
minTime = timeSorted.length ? timeSorted[0][0] : ''
maxTime = timeSorted.length ? timeSorted[timeSorted.length - 1][0] : ''

View File

@@ -132,7 +132,7 @@ export default {
this.multipleTime = false
}
this.time = [startTime, endTime]
this.chartInfo.loaded && this.chartInfo.alertRule.type !== 3 && this.query(elements, startTime, endTime, step)
this.chartInfo.loaded && this.chartInfo.alertRule && this.chartInfo.alertRule.type !== 3 && this.query(elements, startTime, endTime, step)
},
// 参数 isRefresh 标识是否是刷新操作
getChartData (isRefresh, params) {

View File

@@ -56,7 +56,7 @@
</div>
</div>
</el-timeline-item>
<div v-if="timeLineData.length >= total">{{$t('overall.noMoreData')}}}</div>
<div v-if="timeLineData.length >= total" style="text-align: center">{{$t('overall.noMoreData')}}</div>
<div v-else class="load-more-box">
<el-button size="small" @click="getTimeLineData()" :loading="loading">{{$t('overall.loadMore')}}}</el-button>
</div>

View File

@@ -645,6 +645,7 @@ export default {
color: '#d64f40'
}]
}
chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, ''))
} else if (this.currentMsg.alertRule.type === 2) {
chartInfo = lodash.cloneDeep(logData)
chartInfo.elements = [{}]
@@ -655,11 +656,12 @@ export default {
color: '#d64f40'
}]
}
chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\r|\n+/g, ''))
}
chartInfo.id = this.currentMsg.id
chartInfo.name = this.currentMsg.alertRule.name
chartInfo.isAlertMessage = true
chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, ''))
chartInfo.alertRule = this.currentMsg.alertRule
chartInfo.elements && (chartInfo.elements[0].filter = encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels))))
chartInfo.unit = this.currentMsg.alertRule.unit
this.showFullscreen(true, chartInfo)

View File

@@ -907,15 +907,32 @@ export function getMetricTypeValue (queryItem, type) {
let copy = JSON.parse(JSON.stringify(queryItem))
switch (type) {
case 'min': {
const min = copy.sort((x, y) => { return parseFloat(x[1]) - parseFloat(y[1]) })[0][1]
let min = copy.sort((x, y) => {
const x1 = isNaN(x[1]) ? 0 : x[1]
const y1 = isNaN(x[1]) ? 0 : y[1]
return x1 - y1
})[0][1]
if (isNaN(min)) {
min = 0
}
return min
}
case 'max': {
const max = copy.sort((x, y) => { return parseFloat(y[1]) - parseFloat(x[1]) })[0][1]
let max = copy.sort((x, y) => {
const x1 = isNaN(x[1]) ? 0 : x[1]
const y1 = isNaN(x[1]) ? 0 : y[1]
return y1 - x1
})[0][1]
if (isNaN(max)) {
max = 0
}
return max
}
case 'avg': {
copy = copy.map(t => parseFloat(t[1]))
copy = copy.map(t => {
const t1 = isNaN(t[1]) ? 0 : t[1]
return parseFloat(t1)
})
const sum = eval(copy.join('+'))
const avg = sum / copy.length
return avg
@@ -929,13 +946,30 @@ export function getMetricTypeValue (queryItem, type) {
return first
}
case 'total': {
copy = copy.map(t => parseFloat(t[1]))
copy = copy.map(t => {
const t1 = isNaN(t[1]) ? 0 : t[1]
return parseFloat(t1)
})
const total = eval(copy.join('+'))
return total
}
case 'range': {
const min = copy.sort((x, y) => { return parseFloat(x[1]) - parseFloat(y[1]) })[0][1]
const max = copy.sort((x, y) => { return parseFloat(y[1]) - parseFloat(x[1]) })[0][1]
let min = copy.sort((x, y) => {
const x1 = isNaN(x[1]) ? 0 : x[1]
const y1 = isNaN(x[1]) ? 0 : y[1]
return x1 - y1
})[0][1]
if (isNaN(min)) {
min = 0
}
let max = copy.sort((x, y) => {
const x1 = isNaN(x[1]) ? 0 : x[1]
const y1 = isNaN(x[1]) ? 0 : y[1]
return y1 - x1
})[0][1]
if (isNaN(max)) {
max = 0
}
return max - min
}
case 'different': {

View File

@@ -614,6 +614,7 @@ export default {
color: '#d64f40'
}]
}
chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, ''))
} else if (this.currentMsg.alertRule.type === 2) {
chartInfo = lodash.cloneDeep(logData)
chartInfo.elements = [{}]
@@ -624,11 +625,12 @@ export default {
color: '#d64f40'
}]
}
chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\r|\n+/g, ''))
}
chartInfo.id = this.currentMsg.id
chartInfo.name = this.currentMsg.alertRule.name
chartInfo.isAlertMessage = true
chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, ''))
chartInfo.alertRule = this.currentMsg.alertRule
chartInfo.elements && (chartInfo.elements[0].filter = encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels))))
chartInfo.unit = this.currentMsg.alertRule.unit
this.showFullscreen(true, chartInfo)