2022-09-10 23:13:42 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="link-blocks">
|
2022-10-13 16:36:39 +08:00
|
|
|
|
<div class="block-list" style="position: relative">
|
2023-03-16 19:07:37 +08:00
|
|
|
|
<div class="block-list__title">{{ $t('linkMonitor.links') }}</div>
|
2022-10-13 16:36:39 +08:00
|
|
|
|
|
|
|
|
|
|
<!--无数据noData-->
|
2023-02-27 16:01:25 +08:00
|
|
|
|
<chart-no-data v-if="linkNoData" test-id="linkBlockNoData"></chart-no-data>
|
2022-10-13 16:36:39 +08:00
|
|
|
|
|
2023-03-16 19:07:37 +08:00
|
|
|
|
<chart-error style="top: 40px;" v-show="!linkNoData" v-if="showError1" :content="errorMsg1" />
|
|
|
|
|
|
<div class="block-list__list" v-show="!linkNoData" v-else>
|
2022-09-16 17:41:57 +08:00
|
|
|
|
<el-popover
|
|
|
|
|
|
placement="bottom"
|
2024-04-09 16:33:56 +08:00
|
|
|
|
effect="dark"
|
2022-09-16 17:41:57 +08:00
|
|
|
|
trigger="hover"
|
|
|
|
|
|
popper-class="link-block__popper"
|
|
|
|
|
|
v-for="(item, index) in linkData"
|
2022-10-09 15:34:24 +08:00
|
|
|
|
:width="item.popoverWidth"
|
2022-09-16 17:41:57 +08:00
|
|
|
|
:key="index"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template #reference>
|
2022-10-07 21:04:35 +08:00
|
|
|
|
<div class="block-list__block" :key="index" @click="drillLinkId(item)">
|
2022-09-16 17:41:57 +08:00
|
|
|
|
<span class="block-hex">
|
2023-09-26 21:02:55 +08:00
|
|
|
|
<span class="block-hex-in" :test-id="`linkBlock${index}`" :style="`background-color: ${item.color}`"></span>
|
2022-09-16 17:41:57 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #default>
|
|
|
|
|
|
<div class="popper-content">
|
2023-12-25 18:35:14 +08:00
|
|
|
|
<div class="popper-content__link-id">Link ID: {{ item.interfaceName }}</div>
|
2022-09-16 17:41:57 +08:00
|
|
|
|
<div class="popper-content__link-info">
|
2022-09-30 14:16:23 +08:00
|
|
|
|
<div class="info__label">{{ $t('linkMonitor.linkBlock.total') }}</div>
|
2023-02-02 18:14:20 +08:00
|
|
|
|
<div class="info__value" :test-id="`linkBlockTotal${index}`" style="margin-left: 8px">
|
2022-10-13 19:53:52 +08:00
|
|
|
|
{{ unitConvert(item.totalBitsRate, unitTypes.bps).join(' ') }}
|
2022-09-30 14:16:23 +08:00
|
|
|
|
</div>
|
2022-09-16 17:41:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="popper-content__link-info">
|
2022-09-30 14:16:23 +08:00
|
|
|
|
<div class="info__label">{{ $t('linkMonitor.linkBlock.bandwidthUsage') }}</div>
|
|
|
|
|
|
<div class="info__value" style="display: flex">
|
2023-02-02 18:14:20 +08:00
|
|
|
|
<div :test-id="`linkBlockEgressUsage${index}`">
|
2022-09-30 14:16:23 +08:00
|
|
|
|
<svg class="icon item-popover-up" aria-hidden="true">
|
|
|
|
|
|
<use xlink:href="#cn-icon-egress"></use>
|
|
|
|
|
|
</svg>
|
2023-08-29 16:24:02 +08:00
|
|
|
|
{{ convertValue(item.outUsage) }}
|
2022-09-30 14:16:23 +08:00
|
|
|
|
</div>
|
2023-02-02 18:14:20 +08:00
|
|
|
|
<div :test-id="`linkBlockIngressUsage${index}`">
|
2022-09-30 14:16:23 +08:00
|
|
|
|
<svg class="icon item-popover-down" aria-hidden="true">
|
|
|
|
|
|
<use xlink:href="#cn-icon-ingress"></use>
|
|
|
|
|
|
</svg>
|
2023-08-29 16:24:02 +08:00
|
|
|
|
{{ convertValue(item.inUsage) }}
|
2022-09-30 14:16:23 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2022-09-16 17:41:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2022-09-30 14:16:23 +08:00
|
|
|
|
|
2022-11-21 17:31:30 +08:00
|
|
|
|
<div class="block-list" >
|
2023-03-16 19:07:37 +08:00
|
|
|
|
<div class="block-list__title">{{ $t('linkMonitor.nextHopInternet') }}</div>
|
2022-10-13 16:36:39 +08:00
|
|
|
|
|
2023-02-27 16:01:25 +08:00
|
|
|
|
<chart-no-data v-if="nextHopNoData" test-id="nextHpNoData"></chart-no-data>
|
2023-03-16 19:07:37 +08:00
|
|
|
|
<chart-error style="top: 40px;" v-show="!nextHopNoData" class="link-block-error" v-if="showError2" :content="errorMsg2" />
|
|
|
|
|
|
<div class="block-list__list" v-show="!nextHopNoData" v-else>
|
2022-09-16 17:41:57 +08:00
|
|
|
|
<el-popover
|
|
|
|
|
|
placement="bottom"
|
2024-06-16 17:03:06 +08:00
|
|
|
|
effect="dark"
|
2022-09-16 17:41:57 +08:00
|
|
|
|
trigger="hover"
|
|
|
|
|
|
popper-class="link-block__popper"
|
2022-09-30 14:16:23 +08:00
|
|
|
|
v-for="(item, index) in nextHopData"
|
2022-10-09 15:34:24 +08:00
|
|
|
|
:width="item.popoverWidth"
|
2022-09-16 17:41:57 +08:00
|
|
|
|
:key="index"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template #reference>
|
2022-10-07 21:04:35 +08:00
|
|
|
|
<div class="block-list__block" :key="index" @click="drillNextHop(item)">
|
2022-09-16 17:41:57 +08:00
|
|
|
|
<span class="block-hex">
|
2023-09-26 21:02:55 +08:00
|
|
|
|
<span class="block-hex-in" :test-id="`nextHopBlock${index}`" :style="`background-color: ${item.color}`"></span>
|
2022-09-16 17:41:57 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #default>
|
|
|
|
|
|
<div class="popper-content">
|
2022-10-11 20:10:04 +08:00
|
|
|
|
<div class="popper-content__link-id">Next-Hop Internet: {{ item.linkDirection }}</div>
|
2022-09-16 17:41:57 +08:00
|
|
|
|
<div class="popper-content__link-info">
|
2022-09-30 14:16:23 +08:00
|
|
|
|
<div class="info__label">{{ $t('linkMonitor.linkBlock.total') }}</div>
|
2023-02-02 18:14:20 +08:00
|
|
|
|
<div class="info__value" :test-id="`nextHopTotal${index}`" style="margin-left: 8px">
|
2022-10-13 19:53:52 +08:00
|
|
|
|
{{ unitConvert(item.totalBitsRate, unitTypes.bps).join(' ') }}
|
2022-09-30 14:16:23 +08:00
|
|
|
|
</div>
|
2022-09-16 17:41:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="popper-content__link-info">
|
2022-09-30 14:16:23 +08:00
|
|
|
|
<div class="info__label">{{ $t('linkMonitor.linkBlock.bandwidthUsage') }}</div>
|
|
|
|
|
|
<div class="info__value" style="display: flex">
|
2023-02-27 16:01:25 +08:00
|
|
|
|
<div :test-id="`nextHopEgressUsage${index}`">
|
2022-09-30 14:16:23 +08:00
|
|
|
|
<svg class="icon item-popover-up" aria-hidden="true">
|
|
|
|
|
|
<use xlink:href="#cn-icon-egress"></use>
|
|
|
|
|
|
</svg>
|
2023-08-29 16:24:02 +08:00
|
|
|
|
{{ convertValue(item.outUsage) }}
|
2022-09-30 14:16:23 +08:00
|
|
|
|
</div>
|
2023-02-27 16:01:25 +08:00
|
|
|
|
<div :test-id="`nextHopIngressUsage${index}`">
|
2022-09-30 14:16:23 +08:00
|
|
|
|
<svg class="icon item-popover-down" aria-hidden="true">
|
|
|
|
|
|
<use xlink:href="#cn-icon-ingress"></use>
|
|
|
|
|
|
</svg>
|
2023-08-29 16:24:02 +08:00
|
|
|
|
{{ convertValue(item.inUsage) }}
|
2022-09-30 14:16:23 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2022-09-16 17:41:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
</div>
|
2022-09-11 19:33:51 +08:00
|
|
|
|
</div>
|
2022-09-10 23:13:42 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import ChartNoData from '@/views/charts/charts/ChartNoData'
|
|
|
|
|
|
import chartMixin from '@/views/charts2/chart-mixin'
|
|
|
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
import { api } from '@/utils/api'
|
2023-09-22 15:07:06 +08:00
|
|
|
|
import { colorGradientCalculation, beforeRouterPush } from '@/utils/tools'
|
2022-09-10 23:13:42 +08:00
|
|
|
|
import unitConvert from '@/utils/unit-convert'
|
2022-10-09 15:04:48 +08:00
|
|
|
|
import { drillDownPanelTypeMapping, storageKey, unitTypes } from '@/utils/constants'
|
2022-09-30 14:16:23 +08:00
|
|
|
|
import { getSecond } from '@/utils/date-util'
|
2022-11-21 17:31:30 +08:00
|
|
|
|
import ChartError from '@/components/common/Error'
|
2023-02-02 18:14:20 +08:00
|
|
|
|
import axios from 'axios'
|
2022-09-10 23:13:42 +08:00
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: 'LinkBlock',
|
|
|
|
|
|
mixins: [chartMixin],
|
|
|
|
|
|
components: {
|
2022-11-21 17:31:30 +08:00
|
|
|
|
ChartError,
|
2022-09-10 23:13:42 +08:00
|
|
|
|
ChartNoData
|
|
|
|
|
|
},
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
2023-02-27 16:01:25 +08:00
|
|
|
|
linkNoData: false,
|
|
|
|
|
|
nextHopNoData: false,
|
2022-09-10 23:13:42 +08:00
|
|
|
|
unitTypes,
|
|
|
|
|
|
linkData: [],
|
2022-09-30 14:16:23 +08:00
|
|
|
|
nextHopData: [],
|
2022-11-21 17:31:30 +08:00
|
|
|
|
gradientColor: ['#FF005C', '#40537E'], // [start, end]
|
2023-02-27 16:01:25 +08:00
|
|
|
|
showError1: false,
|
|
|
|
|
|
showError2: false,
|
2022-11-21 17:31:30 +08:00
|
|
|
|
errorMsg1: '',
|
|
|
|
|
|
errorMsg2: ''
|
2022-09-10 23:13:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
setup () {
|
|
|
|
|
|
const { query } = useRoute()
|
|
|
|
|
|
const tab = ref(query.blockTab || 0)
|
|
|
|
|
|
return {
|
|
|
|
|
|
tab
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-09-30 14:16:23 +08:00
|
|
|
|
watch: {
|
|
|
|
|
|
timeFilter: {
|
2022-11-29 17:21:01 +08:00
|
|
|
|
handler () {
|
2022-09-30 14:16:23 +08:00
|
|
|
|
this.init()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-09-10 23:13:42 +08:00
|
|
|
|
mounted () {
|
|
|
|
|
|
this.init()
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
unitConvert,
|
|
|
|
|
|
init () {
|
|
|
|
|
|
this.toggleLoading(true)
|
2022-09-30 14:16:23 +08:00
|
|
|
|
// 链路基本信息
|
2023-12-25 18:35:14 +08:00
|
|
|
|
let linkConfig = null
|
|
|
|
|
|
linkConfig = localStorage.getItem(storageKey.linkInfo)
|
|
|
|
|
|
linkConfig = JSON.parse(linkConfig)
|
2022-09-30 14:16:23 +08:00
|
|
|
|
const params = {
|
|
|
|
|
|
startTime: getSecond(this.timeFilter.startTime),
|
|
|
|
|
|
endTime: getSecond(this.timeFilter.endTime)
|
|
|
|
|
|
}
|
2023-12-25 18:35:14 +08:00
|
|
|
|
// 根据配置判断是否是单向还是双向,只要有一条数据的direction=0或1,就视为双向。
|
|
|
|
|
|
const isTwoWay = linkConfig.some(config => config.direction === 0 || config.direction === 1)
|
2022-09-30 14:16:23 +08:00
|
|
|
|
|
2023-03-16 19:07:37 +08:00
|
|
|
|
const dataRequest = axios.get(api.linkMonitor.analysis, { params: params }).catch(e => {
|
|
|
|
|
|
console.error(e)
|
|
|
|
|
|
this.linkNoData = false
|
|
|
|
|
|
this.showError1 = true
|
|
|
|
|
|
this.errorMsg1 = this.errorMsgHandler(e)
|
|
|
|
|
|
})
|
|
|
|
|
|
const nextHopRequest = axios.get(api.linkMonitor.nextHopAnalysis, { params: params }).catch(e => {
|
|
|
|
|
|
console.error(e)
|
|
|
|
|
|
this.nextHopNoData = false
|
|
|
|
|
|
this.showError2 = true
|
|
|
|
|
|
this.errorMsg2 = this.errorMsgHandler(e)
|
|
|
|
|
|
})
|
2022-09-30 14:16:23 +08:00
|
|
|
|
|
2023-03-16 19:14:53 +08:00
|
|
|
|
Promise.all([dataRequest, nextHopRequest]).then(response => {
|
2023-03-16 19:07:37 +08:00
|
|
|
|
if (response[0] && response[1]) {
|
|
|
|
|
|
const res = []
|
|
|
|
|
|
res[0] = response[0].data
|
2023-12-25 18:35:14 +08:00
|
|
|
|
// res[0] = analysis.data
|
2023-03-16 19:07:37 +08:00
|
|
|
|
res[1] = response[1].data
|
2023-12-25 18:35:14 +08:00
|
|
|
|
// res[1] = nextHopAnalysis.data
|
2023-08-27 20:34:24 +08:00
|
|
|
|
if (response[0].status === 200) {
|
2023-03-16 19:07:37 +08:00
|
|
|
|
this.showError1 = false
|
2022-11-21 17:31:30 +08:00
|
|
|
|
|
2023-03-16 19:07:37 +08:00
|
|
|
|
const linkData = res[0].data.result
|
|
|
|
|
|
this.linkNoData = linkData.length === 0
|
|
|
|
|
|
if (!this.linkNoData) {
|
|
|
|
|
|
const data = []
|
|
|
|
|
|
linkData.forEach(d => {
|
2023-12-25 18:35:14 +08:00
|
|
|
|
const info = linkConfig.find(i => i.linkId === parseInt(d.linkId))
|
2023-03-16 19:07:37 +08:00
|
|
|
|
if (info) {
|
2023-12-25 18:35:14 +08:00
|
|
|
|
const hit = data.find(d => d.interfaceName === info.interfaceName)
|
2023-03-16 19:07:37 +08:00
|
|
|
|
if (hit) {
|
2023-08-29 15:35:22 +08:00
|
|
|
|
hit.outBitsRate += d.outBitsRate
|
|
|
|
|
|
hit.inBitsRate += d.inBitsRate
|
2023-12-25 18:35:14 +08:00
|
|
|
|
if (info.direction === 0) {
|
2023-08-29 16:24:02 +08:00
|
|
|
|
hit.outBandwidth = info.bandwidth
|
2023-12-25 18:35:14 +08:00
|
|
|
|
} else if (info.direction === 1) {
|
2023-08-29 16:24:02 +08:00
|
|
|
|
hit.inBandwidth = info.bandwidth
|
2023-12-25 18:35:14 +08:00
|
|
|
|
} else if (info.direction === 2) {
|
|
|
|
|
|
hit.bandwidth = info.bandwidth
|
2023-03-16 19:07:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
const hit = {
|
2023-12-25 18:35:14 +08:00
|
|
|
|
interfaceName: info.interfaceName,
|
2023-08-29 15:35:22 +08:00
|
|
|
|
outBitsRate: d.outBitsRate,
|
|
|
|
|
|
inBitsRate: d.inBitsRate
|
2023-03-16 19:07:37 +08:00
|
|
|
|
}
|
2023-12-25 18:35:14 +08:00
|
|
|
|
if (info.direction === 0) {
|
2023-08-29 16:24:02 +08:00
|
|
|
|
hit.outBandwidth = info.bandwidth
|
2023-12-25 18:35:14 +08:00
|
|
|
|
} else if (info.direction === 1) {
|
2023-08-29 16:24:02 +08:00
|
|
|
|
hit.inBandwidth = info.bandwidth
|
2023-12-25 18:35:14 +08:00
|
|
|
|
} else if (info.direction === 2) {
|
|
|
|
|
|
hit.bandwidth = info.bandwidth
|
2023-03-16 19:07:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
data.push(hit)
|
2023-02-27 16:01:25 +08:00
|
|
|
|
}
|
2022-10-07 21:04:35 +08:00
|
|
|
|
}
|
2023-03-16 19:07:37 +08:00
|
|
|
|
})
|
2023-06-25 15:07:24 +08:00
|
|
|
|
this.linkNoData = data.length === 0
|
2023-08-29 15:35:22 +08:00
|
|
|
|
data.forEach(item => {
|
|
|
|
|
|
item.totalBitsRate = item.outBitsRate + item.inBitsRate
|
2023-12-25 18:35:14 +08:00
|
|
|
|
linkConfig.filter(info => info.interfaceName === item.interfaceName).forEach(info => {
|
2024-04-28 18:21:21 +08:00
|
|
|
|
item.linkId = info.linkId
|
2023-09-21 18:49:11 +08:00
|
|
|
|
})
|
2023-03-16 19:07:37 +08:00
|
|
|
|
})
|
2022-09-30 14:16:23 +08:00
|
|
|
|
|
2023-03-16 19:07:37 +08:00
|
|
|
|
const sorted = data.sort((a, b) => b.totalBitsRate - a.totalBitsRate)
|
|
|
|
|
|
const linkColors = colorGradientCalculation(this.gradientColor[0], this.gradientColor[1], sorted.map(s => s.totalBitsRate))
|
|
|
|
|
|
sorted.forEach((s, i) => {
|
|
|
|
|
|
s.color = linkColors[i]
|
2023-12-25 18:35:14 +08:00
|
|
|
|
s.outUsage = this.computeUsage(s.outBitsRate, isTwoWay ? s.outBandwidth : s.bandwidth)
|
|
|
|
|
|
s.inUsage = this.computeUsage(s.inBitsRate, isTwoWay ? s.inBandwidth : s.bandwidth)
|
2023-08-29 16:24:02 +08:00
|
|
|
|
s.popoverWidth = this.computePopoverWidth(s.outUsage, s.inUsage)
|
2023-03-16 19:07:37 +08:00
|
|
|
|
})
|
|
|
|
|
|
this.linkData = sorted
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2023-06-25 15:07:24 +08:00
|
|
|
|
this.linkNoData = true
|
2023-03-16 19:07:37 +08:00
|
|
|
|
this.showError1 = true
|
2023-03-22 10:20:22 +08:00
|
|
|
|
this.errorMsg1 = this.errorMsgHandler(res[0])
|
2023-02-27 16:01:25 +08:00
|
|
|
|
}
|
2022-10-17 11:49:45 +08:00
|
|
|
|
|
2023-08-27 20:34:24 +08:00
|
|
|
|
if (response[1].status === 200) {
|
2023-03-16 19:07:37 +08:00
|
|
|
|
this.showError2 = false
|
2022-10-17 11:49:45 +08:00
|
|
|
|
|
2023-03-16 19:07:37 +08:00
|
|
|
|
const nextHopData = res[1].data.result
|
|
|
|
|
|
this.nextHopNoData = nextHopData.length === 0
|
|
|
|
|
|
if (!this.nextHopNoData) {
|
|
|
|
|
|
let directionArr = []
|
|
|
|
|
|
nextHopData.forEach((item) => {
|
2023-08-29 15:35:22 +08:00
|
|
|
|
if (item.outLinkDirection !== '' && item.inLinkDirection !== '') {
|
|
|
|
|
|
directionArr.push(item.outLinkDirection)
|
|
|
|
|
|
directionArr.push(item.inLinkDirection)
|
2023-02-27 16:01:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2023-03-16 19:07:37 +08:00
|
|
|
|
directionArr = Array.from(new Set(directionArr))
|
2022-09-30 14:16:23 +08:00
|
|
|
|
|
2023-03-16 19:07:37 +08:00
|
|
|
|
const newNextHopData = []
|
2023-06-25 15:07:24 +08:00
|
|
|
|
this.nextHopNoData = directionArr.length === 0
|
2023-03-16 19:07:37 +08:00
|
|
|
|
directionArr.forEach((item1) => {
|
2023-08-29 15:35:22 +08:00
|
|
|
|
const newObj = { outBitsRate: 0, inBitsRate: 0, totalBitsRate: 0, linkDirection: item1 }
|
2023-03-16 19:07:37 +08:00
|
|
|
|
nextHopData.forEach((item2) => {
|
2023-08-29 15:35:22 +08:00
|
|
|
|
if (item1 === item2.outLinkDirection) {
|
|
|
|
|
|
newObj.outBitsRate += item2.outBitsRate
|
|
|
|
|
|
newObj.totalBitsRate += item2.outBitsRate
|
2023-03-16 19:07:37 +08:00
|
|
|
|
}
|
2023-08-29 15:35:22 +08:00
|
|
|
|
if (item1 === item2.inLinkDirection) {
|
|
|
|
|
|
newObj.inBitsRate += item2.inBitsRate
|
|
|
|
|
|
newObj.totalBitsRate += item2.inBitsRate
|
2023-03-16 19:07:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
newNextHopData.push(newObj)
|
2023-02-27 16:01:25 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2023-03-16 19:07:37 +08:00
|
|
|
|
// 下一跳数据处理
|
|
|
|
|
|
const nextHopSorted = newNextHopData.sort((a, b) => b.totalBitsRate - a.totalBitsRate)
|
|
|
|
|
|
const nextHopColors = colorGradientCalculation(this.gradientColor[0], this.gradientColor[1], nextHopSorted.map(s => s.totalBitsRate))
|
|
|
|
|
|
nextHopSorted.forEach((s, i) => {
|
|
|
|
|
|
s.color = nextHopColors[i]
|
|
|
|
|
|
|
2023-12-25 18:35:14 +08:00
|
|
|
|
let outTotalBandwidth = 0
|
|
|
|
|
|
let inTotalBandwidth = 0
|
|
|
|
|
|
let totalBandwidth = 0
|
|
|
|
|
|
linkConfig.forEach((item) => {
|
|
|
|
|
|
if (s.linkDirection === item.peerCity) {
|
|
|
|
|
|
if (item.direction === 0) {
|
|
|
|
|
|
outTotalBandwidth += item.bandwidth
|
|
|
|
|
|
} else if (item.direction === 1) {
|
|
|
|
|
|
inTotalBandwidth += item.bandwidth
|
|
|
|
|
|
} else if (item.direction === 2) {
|
|
|
|
|
|
totalBandwidth += item.bandwidth
|
|
|
|
|
|
}
|
2023-03-16 19:07:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 上行使用情况计算
|
2023-12-25 18:35:14 +08:00
|
|
|
|
const outUsage = this.computeUsage(s.outBitsRate, isTwoWay ? outTotalBandwidth : totalBandwidth)
|
2023-03-16 19:07:37 +08:00
|
|
|
|
// 下行使用情况计算
|
2023-12-25 18:35:14 +08:00
|
|
|
|
const inUsage = this.computeUsage(s.inBitsRate, isTwoWay ? inTotalBandwidth : totalBandwidth)
|
2023-08-29 16:24:02 +08:00
|
|
|
|
s.outUsage = outUsage
|
|
|
|
|
|
s.inUsage = inUsage
|
|
|
|
|
|
s.popoverWidth = this.computePopoverWidth(outUsage, inUsage)
|
2023-03-16 19:07:37 +08:00
|
|
|
|
})
|
2023-02-27 16:01:25 +08:00
|
|
|
|
|
2023-03-16 19:07:37 +08:00
|
|
|
|
this.nextHopData = nextHopSorted
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.showError2 = true
|
2023-06-25 15:07:24 +08:00
|
|
|
|
this.nextHopNoData = true
|
2023-03-22 10:20:22 +08:00
|
|
|
|
this.errorMsg2 = this.errorMsgHandler(res[1])
|
2023-02-27 16:01:25 +08:00
|
|
|
|
}
|
2022-09-10 23:13:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).catch(e => {
|
|
|
|
|
|
console.error(e)
|
2023-02-27 16:01:25 +08:00
|
|
|
|
this.linkNoData = false
|
|
|
|
|
|
this.nextHopNoData = false
|
|
|
|
|
|
this.showError1 = true
|
|
|
|
|
|
this.showError2 = true
|
2023-03-20 18:52:42 +08:00
|
|
|
|
this.errorMsg1 = this.errorMsgHandler(e)
|
|
|
|
|
|
this.errorMsg2 = this.errorMsgHandler(e)
|
2022-09-10 23:13:42 +08:00
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.toggleLoading(false)
|
|
|
|
|
|
})
|
2022-09-30 14:16:23 +08:00
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 计算上下行使用占比
|
|
|
|
|
|
*/
|
|
|
|
|
|
computeUsage (e, bandwidth) {
|
|
|
|
|
|
let usage = e / bandwidth
|
|
|
|
|
|
if (usage >= 1) {
|
|
|
|
|
|
usage = 1
|
|
|
|
|
|
}
|
|
|
|
|
|
return usage
|
2022-10-07 21:04:35 +08:00
|
|
|
|
},
|
2022-10-09 15:04:48 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 计算popover弹窗的宽度
|
|
|
|
|
|
* 最小宽度为252px,百分比每大一位,popover弹窗宽度增加7px
|
|
|
|
|
|
*/
|
2023-08-29 16:24:02 +08:00
|
|
|
|
computePopoverWidth (out, _in) {
|
2022-10-09 15:04:48 +08:00
|
|
|
|
let width = 252
|
|
|
|
|
|
let length = 0
|
|
|
|
|
|
|
|
|
|
|
|
// 将上下行乘100保留2位转换,即10.00为5位,100.00为6位,popover弹窗宽度就增加7px
|
|
|
|
|
|
// 最小宽度为252px,最少位数为上下行相加为8位
|
2023-08-29 16:24:02 +08:00
|
|
|
|
let outUsage = ''
|
|
|
|
|
|
let inUsage = ''
|
2022-10-14 18:04:13 +08:00
|
|
|
|
|
2023-08-29 16:24:02 +08:00
|
|
|
|
if (out < 0.0001 && out !== 0) {
|
|
|
|
|
|
outUsage = '< 0.01%'
|
2022-10-14 18:04:13 +08:00
|
|
|
|
} else {
|
2023-10-12 10:34:09 +08:00
|
|
|
|
outUsage = JSON.stringify(parseFloat(out * 100).toFixed(2))
|
2022-10-14 18:04:13 +08:00
|
|
|
|
}
|
2023-08-29 16:24:02 +08:00
|
|
|
|
if (_in < 0.0001 && _in !== 0) {
|
|
|
|
|
|
inUsage = '< 0.01%'
|
2022-10-14 18:04:13 +08:00
|
|
|
|
} else {
|
2023-10-12 10:34:09 +08:00
|
|
|
|
inUsage = JSON.stringify(parseFloat(_in * 100).toFixed(2))
|
2022-10-14 18:04:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-29 16:24:02 +08:00
|
|
|
|
length = outUsage.length + inUsage.length
|
2022-10-09 15:04:48 +08:00
|
|
|
|
|
|
|
|
|
|
if (length > 8) {
|
|
|
|
|
|
width = 252 + (length - 8) * 7
|
|
|
|
|
|
}
|
|
|
|
|
|
return width
|
|
|
|
|
|
},
|
2022-10-07 21:04:35 +08:00
|
|
|
|
drillLinkId (item) {
|
2024-04-28 18:21:21 +08:00
|
|
|
|
const queryCondition = `out_link_id = ${item.linkId} or in_link_id = ${item.linkId}`
|
2023-09-22 15:07:06 +08:00
|
|
|
|
beforeRouterPush()
|
2022-10-09 18:47:09 +08:00
|
|
|
|
this.$router.push({
|
|
|
|
|
|
query: {
|
|
|
|
|
|
...this.$route.query,
|
|
|
|
|
|
thirdPanel: drillDownPanelTypeMapping.linkMonitor,
|
2023-12-25 18:35:14 +08:00
|
|
|
|
thirdMenu: `Link ID: ${item.interfaceName}`,
|
|
|
|
|
|
panelName: `Link ID: ${item.interfaceName}`,
|
2022-10-09 18:47:09 +08:00
|
|
|
|
queryCondition,
|
|
|
|
|
|
t: +new Date()
|
|
|
|
|
|
}
|
2022-10-07 21:04:35 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
drillNextHop (item) {
|
2023-08-29 16:24:02 +08:00
|
|
|
|
const queryCondition = `out_link_direction = '${item.linkDirection}' or in_link_direction = '${item.linkDirection}'`
|
2022-10-09 18:47:09 +08:00
|
|
|
|
this.$router.push({
|
|
|
|
|
|
query: {
|
|
|
|
|
|
...this.$route.query,
|
|
|
|
|
|
thirdPanel: drillDownPanelTypeMapping.linkMonitor,
|
2022-10-11 20:10:04 +08:00
|
|
|
|
thirdMenu: `Next-Hop Internet: ${item.linkDirection}`,
|
|
|
|
|
|
panelName: `Next-Hop Internet: ${item.linkDirection}`,
|
2022-10-09 18:47:09 +08:00
|
|
|
|
queryCondition,
|
|
|
|
|
|
t: +new Date()
|
|
|
|
|
|
}
|
2022-10-07 21:04:35 +08:00
|
|
|
|
})
|
2022-10-14 18:04:13 +08:00
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 对单位进行转换,值小于0.0001的显示为<0.01%,除此之外正常转换显示
|
|
|
|
|
|
* @param value
|
|
|
|
|
|
* @returns {string}
|
|
|
|
|
|
*/
|
|
|
|
|
|
convertValue (value) {
|
|
|
|
|
|
let newValue = null
|
|
|
|
|
|
if (value < 0.0001 && value !== 0) {
|
2022-10-17 09:56:56 +08:00
|
|
|
|
newValue = '< 0.01%'
|
2022-10-14 18:04:13 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
newValue = unitConvert(value, unitTypes.percent).join('')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return newValue
|
2022-09-10 23:13:42 +08:00
|
|
|
|
}
|
2022-11-29 17:21:01 +08:00
|
|
|
|
},
|
|
|
|
|
|
beforeUnmount () {
|
|
|
|
|
|
this.unitConvert = null
|
2022-09-10 23:13:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|