2022-07-18 15:04:32 +08:00
|
|
|
<template>
|
2022-07-19 09:52:28 +08:00
|
|
|
<div class="npm-network-quantity">
|
2022-08-08 17:45:50 +08:00
|
|
|
<single-value
|
|
|
|
|
:npm-network-name="npmNetworkName"
|
2022-08-23 16:12:24 +08:00
|
|
|
:npm-network-data="npmNetworkData"
|
2022-08-08 17:45:50 +08:00
|
|
|
></single-value>
|
2022-07-19 09:52:28 +08:00
|
|
|
</div>
|
2022-07-18 15:04:32 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-07-19 09:52:28 +08:00
|
|
|
import SingleValue from '@/views/charts2/charts/SingleValue'
|
2022-08-08 17:45:50 +08:00
|
|
|
import { get } from '@/utils/http'
|
|
|
|
|
import { getSecond } from '@/utils/date-util'
|
|
|
|
|
import { api } from '@/utils/api'
|
2022-08-21 22:11:53 +08:00
|
|
|
import chartMixin from '@/views/charts2/chart-mixin'
|
2022-08-22 15:49:38 +08:00
|
|
|
import _ from 'lodash'
|
2022-08-23 16:12:24 +08:00
|
|
|
import { getChainRatio } from '@/utils/tools'
|
2022-07-18 15:04:32 +08:00
|
|
|
export default {
|
2022-07-19 09:52:28 +08:00
|
|
|
name: 'NpmNetworkQuantity',
|
|
|
|
|
components: { SingleValue },
|
2022-08-21 22:11:53 +08:00
|
|
|
mixins: [chartMixin],
|
2022-07-19 09:52:28 +08:00
|
|
|
data () {
|
|
|
|
|
return {
|
2022-08-08 17:45:50 +08:00
|
|
|
npmNetworkName: [
|
2022-08-09 11:39:08 +08:00
|
|
|
{ name: 'networkAppPerformance.tcpConnectionEstablishLatency' },
|
|
|
|
|
{ name: 'networkAppPerformance.httpResponse' },
|
|
|
|
|
{ name: 'networkAppPerformance.sslResponseLatency' },
|
|
|
|
|
{ name: 'networkAppPerformance.packetLoss' },
|
|
|
|
|
{ name: 'overall.packetRetrans' }
|
2022-08-08 17:45:50 +08:00
|
|
|
],
|
2022-08-22 15:49:38 +08:00
|
|
|
npmNetworkCycleData: [],
|
2022-08-23 16:12:24 +08:00
|
|
|
npmNetworkLastCycleData: [],
|
|
|
|
|
npmNetworkData: [],
|
2022-08-22 15:49:38 +08:00
|
|
|
side: '',
|
|
|
|
|
chartData: {}
|
2022-08-08 17:45:50 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
npmNetworkCycleQuery () {
|
2022-08-22 15:49:38 +08:00
|
|
|
const condition = this.$store.getters.getQueryCondition.split(/["|'](.*?)["|']/)
|
|
|
|
|
const type = this.$store.getters.getDimensionType
|
2022-08-08 17:45:50 +08:00
|
|
|
const params = {
|
|
|
|
|
startTime: getSecond(this.timeFilter.startTime),
|
|
|
|
|
endTime: getSecond(this.timeFilter.endTime),
|
|
|
|
|
cycle: 0
|
|
|
|
|
}
|
2022-08-22 15:49:38 +08:00
|
|
|
if (this.chartData.id === 23) {
|
|
|
|
|
this.side = 'client'
|
|
|
|
|
} else {
|
|
|
|
|
this.side = 'server'
|
|
|
|
|
}
|
|
|
|
|
if (condition && type) {
|
|
|
|
|
params.q = `${type}='${condition[1]}' and side='${this.side}'`
|
|
|
|
|
params.type = type
|
|
|
|
|
}
|
2022-08-09 11:39:08 +08:00
|
|
|
const tcp = get(api.npm.overview.tcpSessionDelay, params)
|
|
|
|
|
const http = get(api.npm.overview.httpResponseDelay, params)
|
|
|
|
|
const ssl = get(api.npm.overview.sslConDelay, params)
|
|
|
|
|
const tcpPercent = get(api.npm.overview.tcpLostlenPercent, params)
|
|
|
|
|
const packetPercent = get(api.npm.overview.packetRetransPercent, params)
|
2022-08-21 22:11:53 +08:00
|
|
|
this.toggleLoading(true)
|
2022-08-09 11:39:08 +08:00
|
|
|
Promise.all([tcp, http, ssl, tcpPercent, packetPercent]).then(res => {
|
|
|
|
|
res.forEach(t => {
|
|
|
|
|
if (t.code === 200) {
|
|
|
|
|
this.npmNetworkCycleData.push(t.data.result)
|
|
|
|
|
}
|
|
|
|
|
})
|
2022-08-21 22:11:53 +08:00
|
|
|
}).finally(() => {
|
|
|
|
|
this.toggleLoading(false)
|
2022-08-09 11:39:08 +08:00
|
|
|
})
|
2022-08-23 16:12:24 +08:00
|
|
|
},
|
|
|
|
|
npmNetworkLastCycleQuery () {
|
|
|
|
|
const condition = this.$store.getters.getQueryCondition.split(/["|'](.*?)["|']/)
|
|
|
|
|
const type = this.$store.getters.getDimensionType
|
|
|
|
|
const params = {
|
|
|
|
|
startTime: getSecond(this.timeFilter.startTime),
|
|
|
|
|
endTime: getSecond(this.timeFilter.endTime),
|
|
|
|
|
cycle: 1
|
|
|
|
|
}
|
|
|
|
|
if (this.chartData.id === 23) {
|
|
|
|
|
this.side = 'client'
|
|
|
|
|
} else {
|
|
|
|
|
this.side = 'server'
|
|
|
|
|
}
|
|
|
|
|
if (condition && type) {
|
|
|
|
|
params.q = `${type}='${condition[1]}' and side='${this.side}'`
|
|
|
|
|
params.type = type
|
|
|
|
|
}
|
|
|
|
|
const tcp = get(api.npm.overview.tcpSessionDelay, params)
|
|
|
|
|
const http = get(api.npm.overview.httpResponseDelay, params)
|
|
|
|
|
const ssl = get(api.npm.overview.sslConDelay, params)
|
|
|
|
|
const tcpPercent = get(api.npm.overview.tcpLostlenPercent, params)
|
|
|
|
|
const packetPercent = get(api.npm.overview.packetRetransPercent, params)
|
|
|
|
|
this.toggleLoading(true)
|
|
|
|
|
Promise.all([tcp, http, ssl, tcpPercent, packetPercent]).then(res => {
|
|
|
|
|
res.forEach(t => {
|
|
|
|
|
if (t.code === 200) {
|
|
|
|
|
this.npmNetworkLastCycleData.push(t.data.result)
|
|
|
|
|
this.npmNetworkQuantity(this.npmNetworkCycleData, this.npmNetworkLastCycleData)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
this.toggleLoading(false)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
npmNetworkQuantity (cycle, lastCycle) {
|
|
|
|
|
cycle.forEach(t => {
|
|
|
|
|
lastCycle.forEach(e => {
|
|
|
|
|
Object.keys(t).forEach(r => {
|
|
|
|
|
Object.keys(e).forEach(d => {
|
|
|
|
|
if (r === d) {
|
|
|
|
|
t.value = getChainRatio(t[r], e[d])
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
this.npmNetworkData = cycle
|
2022-07-19 09:52:28 +08:00
|
|
|
}
|
2022-08-08 17:45:50 +08:00
|
|
|
},
|
|
|
|
|
mounted () {
|
2022-08-22 15:49:38 +08:00
|
|
|
if (this.chart) {
|
|
|
|
|
this.chartData = _.cloneDeep(this.chart)
|
|
|
|
|
}
|
2022-08-08 17:45:50 +08:00
|
|
|
this.npmNetworkCycleQuery()
|
2022-08-23 16:12:24 +08:00
|
|
|
this.npmNetworkLastCycleQuery()
|
2022-07-19 09:52:28 +08:00
|
|
|
}
|
2022-07-18 15:04:32 +08:00
|
|
|
}
|
|
|
|
|
</script>
|