CN-789 fix: 修复NPM ip下钻后,顶部的分数问题
This commit is contained in:
@@ -63,12 +63,13 @@ import {
|
|||||||
drillDownPanelTypeMapping,
|
drillDownPanelTypeMapping,
|
||||||
metricOptions
|
metricOptions
|
||||||
} from '@/utils/constants'
|
} from '@/utils/constants'
|
||||||
import { getPanelList, getChartList } from '@/utils/api'
|
import { getPanelList, getChartList, api } from '@/utils/api'
|
||||||
import { getNowTime, getSecond } from '@/utils/date-util'
|
import { getNowTime, getSecond } from '@/utils/date-util'
|
||||||
import { getTypeCategory } from '@/views/charts/charts/tools'
|
import { getTypeCategory } from '@/views/charts/charts/tools'
|
||||||
import { urlParamsHandler, overwriteUrl, getDnsMapData } from '@/utils/tools'
|
import { urlParamsHandler, overwriteUrl, getDnsMapData, computeScore } from '@/utils/tools'
|
||||||
import ChartList from '@/views/charts2/ChartList'
|
import ChartList from '@/views/charts2/ChartList'
|
||||||
import { useStore } from 'vuex'
|
import { useStore } from 'vuex'
|
||||||
|
import { get } from '@/utils/http'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Panel',
|
name: 'Panel',
|
||||||
@@ -183,6 +184,7 @@ export default {
|
|||||||
return chart
|
return chart
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
this.scoreCalculation()
|
||||||
},
|
},
|
||||||
setup (props, ctx) {
|
setup (props, ctx) {
|
||||||
// todo 目前在panel页面测试,后续会挪到router里
|
// todo 目前在panel页面测试,后续会挪到router里
|
||||||
@@ -249,13 +251,18 @@ export default {
|
|||||||
|
|
||||||
const metric = ref(query.metric || 'Bits/s')
|
const metric = ref(query.metric || 'Bits/s')
|
||||||
|
|
||||||
|
const queryCondition = ref(query.queryCondition || '')
|
||||||
|
const dimensionType = ref(query.dimensionType || '')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
panelType,
|
panelType,
|
||||||
panel,
|
panel,
|
||||||
timeFilter,
|
timeFilter,
|
||||||
showScore,
|
showScore,
|
||||||
metric,
|
metric,
|
||||||
path
|
path,
|
||||||
|
queryCondition,
|
||||||
|
dimensionType
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -325,6 +332,52 @@ export default {
|
|||||||
metric: value
|
metric: value
|
||||||
})
|
})
|
||||||
overwriteUrl(newUrl)
|
overwriteUrl(newUrl)
|
||||||
|
},
|
||||||
|
scoreCalculation () {
|
||||||
|
let condition = ''
|
||||||
|
if (this.queryCondition.indexOf(' OR ') > -1) {
|
||||||
|
condition = this.queryCondition.split(/["|'](.*?)["|']/)
|
||||||
|
} else {
|
||||||
|
condition = this.queryCondition
|
||||||
|
}
|
||||||
|
const type = this.dimensionType
|
||||||
|
const params = {
|
||||||
|
startTime: getSecond(this.timeFilter.startTime),
|
||||||
|
endTime: getSecond(this.timeFilter.endTime),
|
||||||
|
cycle: 0
|
||||||
|
}
|
||||||
|
if (condition && (typeof condition !== 'object') && type) {
|
||||||
|
params.q = condition
|
||||||
|
params.type = type
|
||||||
|
} else if (condition.length > 1 && type && type === 'ip') {
|
||||||
|
params.q = `${type}='${condition[1]}'`
|
||||||
|
params.type = type
|
||||||
|
} else if (condition.length > 1 && type && type !== 'ip') {
|
||||||
|
if (type === 'country' || type === 'asn' || type === 'province' || type === 'city' || type === 'isp') {
|
||||||
|
params.q = `${type}='${condition[1]}'`
|
||||||
|
params.type = type
|
||||||
|
} else if (type === 'idcRenter') {
|
||||||
|
params.q = `idc_renter='${condition[1]}'`
|
||||||
|
params.type = type
|
||||||
|
} else {
|
||||||
|
params.q = `${condition[0]}'${condition[1]}'`
|
||||||
|
params.type = type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type && condition) {
|
||||||
|
get(api.npm.overview.networkAnalysis, params).then(res => {
|
||||||
|
if (res.code === 200) {
|
||||||
|
const data = {
|
||||||
|
establishLatencyMs: res.data.result.establishLatencyMsAvg || null,
|
||||||
|
httpResponseLatency: res.data.result.httpResponseLatencyAvg || null,
|
||||||
|
sslConLatency: res.data.result.sslConLatencyAvg || null,
|
||||||
|
tcpLostlenPercent: res.data.result.tcpLostlenPercentAvg || null,
|
||||||
|
pktRetransPercent: res.data.result.pktRetransPercentAvg || null
|
||||||
|
}
|
||||||
|
this.score = computeScore(data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -57,24 +57,21 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
npmNetworkCycleQuery () {
|
npmNetworkCycleQuery () {
|
||||||
// const conditionStr = this.$route.query.queryCondition ? this.$route.query.queryCondition : ''
|
|
||||||
let condition = ''
|
let condition = ''
|
||||||
if (this.queryCondition.indexOf(' OR ') > -1) {
|
if (this.queryCondition.indexOf(' OR ') > -1) {
|
||||||
condition = this.queryCondition.split(/["|'](.*?)["|']/)
|
condition = this.queryCondition.split(/["|'](.*?)["|']/)
|
||||||
} else {
|
} else {
|
||||||
condition = this.queryCondition
|
condition = this.queryCondition
|
||||||
}
|
}
|
||||||
// const type = this.$store.getters.getDimensionType
|
|
||||||
// const type = this.$route.query.dimensionType ? this.$route.query.dimensionType : ''
|
|
||||||
const type = this.dimensionType
|
const type = this.dimensionType
|
||||||
const params = {
|
const params = {
|
||||||
startTime: getSecond(this.timeFilter.startTime),
|
startTime: getSecond(this.timeFilter.startTime),
|
||||||
endTime: getSecond(this.timeFilter.endTime),
|
endTime: getSecond(this.timeFilter.endTime),
|
||||||
cycle: 0
|
cycle: 0
|
||||||
}
|
}
|
||||||
if (this.chartData.id === 23) {
|
if (this.chartData.name === 'npm-ip下钻-client-多单值') {
|
||||||
this.side = 'client'
|
this.side = 'client'
|
||||||
} else if (this.chartData.id === 26) {
|
} else if (this.chartData.name === 'npm-ip下钻-server-多单值') {
|
||||||
this.side = 'server'
|
this.side = 'server'
|
||||||
}
|
}
|
||||||
if (condition && (typeof condition !== 'object') && type) {
|
if (condition && (typeof condition !== 'object') && type) {
|
||||||
@@ -98,20 +95,10 @@ export default {
|
|||||||
if (type && condition) {
|
if (type && condition) {
|
||||||
this.toggleLoading(true)
|
this.toggleLoading(true)
|
||||||
get(api.npm.overview.networkAnalysis, params).then(res => {
|
get(api.npm.overview.networkAnalysis, params).then(res => {
|
||||||
let score = 0
|
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
const data = {
|
|
||||||
establishLatencyMs: res.data.result.establishLatencyMsAvg || null,
|
|
||||||
httpResponseLatency: res.data.result.httpResponseLatencyAvg || null,
|
|
||||||
sslConLatency: res.data.result.sslConLatencyAvg || null,
|
|
||||||
tcpLostlenPercent: res.data.result.tcpLostlenPercentAvg || null,
|
|
||||||
pktRetransPercent: res.data.result.pktRetransPercentAvg || null
|
|
||||||
}
|
|
||||||
score = computeScore(data)
|
|
||||||
this.npmNetworkCycleData = res.data.result
|
this.npmNetworkCycleData = res.data.result
|
||||||
this.npmNetworkLastCycleQuery()
|
|
||||||
}
|
}
|
||||||
this.$store.commit('setNpmThirdLevelMenuScore', score)
|
this.npmNetworkLastCycleQuery()
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
this.toggleLoading(false)
|
this.toggleLoading(false)
|
||||||
})
|
})
|
||||||
@@ -124,21 +111,11 @@ export default {
|
|||||||
this.toggleLoading(true)
|
this.toggleLoading(true)
|
||||||
Promise.all([tcp, http, ssl, tcpPercent, packetPercent]).then(res => {
|
Promise.all([tcp, http, ssl, tcpPercent, packetPercent]).then(res => {
|
||||||
this.npmNetworkCycleData = []
|
this.npmNetworkCycleData = []
|
||||||
let score = 0
|
|
||||||
res.forEach(t => {
|
res.forEach(t => {
|
||||||
if (t.code === 200) {
|
if (t.code === 200) {
|
||||||
this.npmNetworkCycleData.push(t.data.result)
|
this.npmNetworkCycleData.push(t.data.result)
|
||||||
const data = {
|
|
||||||
establishLatencyMs: t.data.result.establishLatencyMsAvg,
|
|
||||||
httpResponseLatency: t.data.result.httpResponseLatencyAvg,
|
|
||||||
sslConLatency: t.data.result.sslConLatencyAvg,
|
|
||||||
tcpLostlenPercent: t.data.result.tcpLostlenPercentAvg,
|
|
||||||
pktRetransPercent: t.data.result.pktRetransPercentAvg
|
|
||||||
}
|
|
||||||
score = computeScore(data)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.$store.commit('setNpmThirdLevelMenuScore', score)
|
|
||||||
this.npmNetworkLastCycleQuery()
|
this.npmNetworkLastCycleQuery()
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
this.toggleLoading(false)
|
this.toggleLoading(false)
|
||||||
@@ -152,16 +129,15 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
condition = this.queryCondition
|
condition = this.queryCondition
|
||||||
}
|
}
|
||||||
// const type = this.$store.getters.getDimensionType
|
|
||||||
const type = this.dimensionType
|
const type = this.dimensionType
|
||||||
const params = {
|
const params = {
|
||||||
startTime: getSecond(this.timeFilter.startTime),
|
startTime: getSecond(this.timeFilter.startTime),
|
||||||
endTime: getSecond(this.timeFilter.endTime),
|
endTime: getSecond(this.timeFilter.endTime),
|
||||||
cycle: 1
|
cycle: 1
|
||||||
}
|
}
|
||||||
if (this.chartData.id === 23) {
|
if (this.chartData.name === 'npm-ip下钻-client-多单值') {
|
||||||
this.side = 'client'
|
this.side = 'client'
|
||||||
} else if (this.chartData.id === 26) {
|
} else if (this.chartData.name === 'npm-ip下钻-server-多单值') {
|
||||||
this.side = 'server'
|
this.side = 'server'
|
||||||
}
|
}
|
||||||
if (condition && (typeof condition !== 'object') && type) {
|
if (condition && (typeof condition !== 'object') && type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user