2022-07-06 21:08:12 +08:00
|
|
|
|
<template>
|
2022-09-01 18:28:22 +08:00
|
|
|
|
<div class="panel-box2">
|
2022-07-06 21:08:12 +08:00
|
|
|
|
<div class="panel__header">
|
2022-08-24 07:29:40 +08:00
|
|
|
|
<div class="panel__title">{{panelName?panelName:(panel.i18n ? $t(panel.i18n) : panel.name)}}
|
2022-10-09 15:46:53 +08:00
|
|
|
|
<div v-if="showScore" class="score">
|
2022-11-17 15:55:34 +08:00
|
|
|
|
<div class="circle-icon" v-if="score <= 2 || score === '-'" :class="{'data-score-red': score <= 2 || score === '-'}" ></div>
|
2022-08-24 07:29:40 +08:00
|
|
|
|
<div class="circle-icon" v-else-if="score <= 4" :class="{'data-score-yellow': score <= 4}" ></div>
|
|
|
|
|
|
<div class="circle-icon" v-else-if="score <= 6" :class="{'data-score-green': score <= 6}" ></div>
|
|
|
|
|
|
Score:{{score}}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2022-11-01 16:46:11 +08:00
|
|
|
|
<div class="panel__tools">
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
size="mini"
|
|
|
|
|
|
v-model="metric"
|
|
|
|
|
|
placeholder=""
|
2022-11-02 11:28:25 +08:00
|
|
|
|
popper-class="common-select"
|
2022-11-01 17:11:55 +08:00
|
|
|
|
v-if="panelType === panelTypeAndRouteMapping.networkOverview"
|
2022-11-01 16:46:11 +08:00
|
|
|
|
:popper-append-to-body="false"
|
|
|
|
|
|
@change="metricChange"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template #prefix>
|
|
|
|
|
|
<span class="select-prefix">Metric:</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<el-option v-for="item in metricOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
<div class="panel__time">
|
|
|
|
|
|
<date-time-range
|
|
|
|
|
|
class="date-time-range"
|
|
|
|
|
|
:start-time="timeFilter.startTime"
|
|
|
|
|
|
:end-time="timeFilter.endTime"
|
|
|
|
|
|
:date-range="timeFilter.dateRangeValue"
|
|
|
|
|
|
ref="dateTimeRange"
|
|
|
|
|
|
@change="reload"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<time-refresh
|
|
|
|
|
|
class="date-time-range"
|
|
|
|
|
|
@change="timeRefreshChange"
|
|
|
|
|
|
:end-time="timeFilter.endTime"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2022-07-06 21:08:12 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<chart-list
|
|
|
|
|
|
ref="chartList"
|
|
|
|
|
|
:time-filter="timeFilter"
|
2022-11-01 16:46:11 +08:00
|
|
|
|
:metric="metric"
|
2022-07-06 21:08:12 +08:00
|
|
|
|
:chart-list="chartList"
|
2022-07-18 15:04:32 +08:00
|
|
|
|
:panel-type="panelType"
|
2022-07-06 21:08:12 +08:00
|
|
|
|
:panel-lock="panelLock"
|
2022-07-22 18:09:18 +08:00
|
|
|
|
:extra-params="extraParams"
|
2022-07-06 21:08:12 +08:00
|
|
|
|
:entity="entity"
|
|
|
|
|
|
></chart-list>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-09-07 20:17:38 +08:00
|
|
|
|
import { useRoute } from 'vue-router'
|
2022-07-06 21:08:12 +08:00
|
|
|
|
import { ref } from 'vue'
|
2022-10-09 15:46:53 +08:00
|
|
|
|
import {
|
|
|
|
|
|
panelTypeAndRouteMapping,
|
|
|
|
|
|
curTabState,
|
2022-11-01 16:46:11 +08:00
|
|
|
|
drillDownPanelTypeMapping,
|
2022-11-21 11:28:56 +08:00
|
|
|
|
metricOptions,
|
|
|
|
|
|
fromRoute
|
2022-10-09 15:46:53 +08:00
|
|
|
|
} from '@/utils/constants'
|
2022-11-10 17:20:00 +08:00
|
|
|
|
import { getPanelList, getChartList, api } from '@/utils/api'
|
2022-08-24 07:29:40 +08:00
|
|
|
|
import { getNowTime, getSecond } from '@/utils/date-util'
|
2022-07-06 21:08:12 +08:00
|
|
|
|
import { getTypeCategory } from '@/views/charts/charts/tools'
|
2022-11-10 17:20:00 +08:00
|
|
|
|
import { urlParamsHandler, overwriteUrl, getDnsMapData, computeScore } from '@/utils/tools'
|
2022-07-06 21:08:12 +08:00
|
|
|
|
import ChartList from '@/views/charts2/ChartList'
|
2022-10-19 15:27:26 +08:00
|
|
|
|
import { useStore } from 'vuex'
|
2022-11-10 17:20:00 +08:00
|
|
|
|
import { get } from '@/utils/http'
|
2022-07-06 21:08:12 +08:00
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: 'Panel',
|
|
|
|
|
|
props: {
|
|
|
|
|
|
entity: Object,
|
|
|
|
|
|
typeName: String
|
|
|
|
|
|
},
|
|
|
|
|
|
components: {
|
|
|
|
|
|
ChartList
|
|
|
|
|
|
},
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
2022-11-01 17:11:55 +08:00
|
|
|
|
panelTypeAndRouteMapping,
|
2022-11-01 16:46:11 +08:00
|
|
|
|
metricOptions,
|
2022-07-06 21:08:12 +08:00
|
|
|
|
chartList: [], // 普通panel的chart
|
2022-07-22 18:09:18 +08:00
|
|
|
|
panelLock: true,
|
2022-08-05 15:46:31 +08:00
|
|
|
|
extraParams: {},
|
2022-08-24 07:29:40 +08:00
|
|
|
|
panelName: '',
|
2022-11-04 12:18:26 +08:00
|
|
|
|
dnsRcodeMapData: [],
|
|
|
|
|
|
dnsQtypeMapData: [],
|
2022-09-20 09:33:49 +08:00
|
|
|
|
score: null,
|
|
|
|
|
|
curTabState: curTabState
|
2022-07-06 21:08:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-08-24 13:29:21 +08:00
|
|
|
|
computed: {
|
2022-11-28 16:36:05 +08:00
|
|
|
|
// npmThirdLevelMenuScore () {
|
|
|
|
|
|
// return this.$store.getters.getNpmThirdLevelMenuScore
|
|
|
|
|
|
// }
|
2022-08-24 13:29:21 +08:00
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
2022-11-28 16:36:05 +08:00
|
|
|
|
// npmThirdLevelMenuScore: {
|
|
|
|
|
|
// deep: true,
|
|
|
|
|
|
// immediate: true,
|
|
|
|
|
|
// handler (n) {
|
|
|
|
|
|
// this.score = n
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2022-11-28 16:41:31 +08:00
|
|
|
|
timeFilter: {
|
2022-11-29 17:21:01 +08:00
|
|
|
|
handler () {
|
2022-11-28 16:41:31 +08:00
|
|
|
|
if (this.$route.path === '/panel/networkAppPerformance' && (this.queryCondition || this.networkOverviewBeforeTab)) {
|
|
|
|
|
|
this.scoreCalculation()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-08-24 13:29:21 +08:00
|
|
|
|
},
|
2022-07-06 21:08:12 +08:00
|
|
|
|
async mounted () {
|
2022-09-20 09:33:49 +08:00
|
|
|
|
// this.panelName = this.$store.getters.getPanelName
|
2022-11-09 15:22:09 +08:00
|
|
|
|
const pName = this.$route.query.panelName ? this.$t(this.$route.query.panelName) : ''
|
|
|
|
|
|
const curTabProp = this.$route.query.dimensionType ? this.$route.query.dimensionType : null
|
2022-11-29 17:21:01 +08:00
|
|
|
|
if (this.$route.params.typeName === fromRoute.dnsServiceInsights) {
|
2022-11-21 11:28:56 +08:00
|
|
|
|
this.dnsQtypeMapData = await getDnsMapData('dnsQtype')
|
|
|
|
|
|
this.dnsRcodeMapData = await getDnsMapData('dnsRcode')
|
|
|
|
|
|
this.$store.commit('setDnsQtypeMapData', this.dnsQtypeMapData)
|
|
|
|
|
|
this.$store.commit('setDnsRcodeMapData', this.dnsRcodeMapData)
|
|
|
|
|
|
}
|
2022-11-09 15:22:09 +08:00
|
|
|
|
if (curTabProp === 'qtype') {
|
2022-11-04 12:18:26 +08:00
|
|
|
|
this.panelName = this.dnsQtypeMapData.get(pName)
|
2022-11-09 15:22:09 +08:00
|
|
|
|
} else if (curTabProp === 'rcode') {
|
2022-11-04 12:18:26 +08:00
|
|
|
|
this.panelName = this.dnsRcodeMapData.get(pName)
|
2022-11-09 15:22:09 +08:00
|
|
|
|
} else {
|
2022-11-04 12:18:26 +08:00
|
|
|
|
this.panelName = pName
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-23 19:01:30 +08:00
|
|
|
|
// const curOperationType = this.$store.getters.getTabOperationType
|
2022-10-09 19:58:30 +08:00
|
|
|
|
/* const curOperationType = this.getUrlParam(this.curTabState.tabOperationType, '', true)
|
2022-08-24 13:29:21 +08:00
|
|
|
|
if (this.panelName && this.$route.path === '/panel/networkAppPerformance' && curOperationType !== operationType.thirdMenu) {
|
2022-09-20 09:33:49 +08:00
|
|
|
|
// const columnValue = this.$store.getters.getBreadcrumbColumnValue
|
|
|
|
|
|
const columnValue = this.getUrlParam(this.curTabState.fourthMenu, '')
|
2022-08-24 07:29:40 +08:00
|
|
|
|
const queryParams = {
|
|
|
|
|
|
startTime: getSecond(this.timeFilter.startTime),
|
|
|
|
|
|
endTime: getSecond(this.timeFilter.endTime),
|
2022-09-20 09:33:49 +08:00
|
|
|
|
// type: this.$store.getters.getDimensionType,
|
|
|
|
|
|
type: this.$route.query.dimensionType ? this.$route.query.dimensionType : '',
|
2022-08-24 07:29:40 +08:00
|
|
|
|
params: columnValue || ''
|
|
|
|
|
|
}
|
|
|
|
|
|
const requestGroup = []
|
|
|
|
|
|
scoreUrl.forEach(url => {
|
|
|
|
|
|
if (url) {
|
|
|
|
|
|
const request = get(url, queryParams, true)
|
|
|
|
|
|
requestGroup.push(request)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
const scoreGroup = []
|
|
|
|
|
|
let score = 0
|
|
|
|
|
|
Promise.all(requestGroup).then(res => {
|
|
|
|
|
|
res.forEach(t => {
|
|
|
|
|
|
if (t.code === 200) {
|
|
|
|
|
|
const data = t.data.result ? t.data.result[0] : null
|
|
|
|
|
|
if (data) {
|
|
|
|
|
|
customTableTitlesForAppPerformance.forEach(item => {
|
|
|
|
|
|
if (data[bytesColumnNameGroupForNpm[item.prop]]) {
|
|
|
|
|
|
score = computeScore(data, item.scoreType)
|
|
|
|
|
|
scoreGroup.push(score)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
scoreGroup.push(0)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
scoreGroup.forEach(i => {
|
|
|
|
|
|
score = Number(score) + Number(i)
|
|
|
|
|
|
})
|
|
|
|
|
|
score = Math.ceil(score * 6)
|
|
|
|
|
|
if (score > 6) {
|
|
|
|
|
|
score = 6
|
|
|
|
|
|
}
|
|
|
|
|
|
this.score = score || 0
|
|
|
|
|
|
})
|
2022-08-24 13:29:21 +08:00
|
|
|
|
} else if (this.$route.path === '/panel/networkAppPerformance' && curOperationType === operationType.thirdMenu) {
|
|
|
|
|
|
this.score = this.$store.getters.getNpmThirdLevelMenuScore
|
2022-10-09 19:58:30 +08:00
|
|
|
|
} */
|
2022-08-24 07:29:40 +08:00
|
|
|
|
|
2022-07-06 21:08:12 +08:00
|
|
|
|
await this.init()
|
2022-07-26 13:54:09 +08:00
|
|
|
|
const vm = this
|
|
|
|
|
|
this.emitter.on('reloadChartList', async function () {
|
2022-08-04 12:03:15 +08:00
|
|
|
|
vm.chartList = []
|
2022-07-26 13:54:09 +08:00
|
|
|
|
vm.chartList = (await getChartList({ panelId: vm.panel.id, pageSize: -1 })).map(chart => {
|
|
|
|
|
|
chart.i = chart.id
|
|
|
|
|
|
// 递归初始化各属性
|
|
|
|
|
|
vm.initChartAttr(chart)
|
|
|
|
|
|
return chart
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
2022-11-17 15:55:34 +08:00
|
|
|
|
if (this.$route.path === '/panel/networkAppPerformance' && (this.queryCondition || this.networkOverviewBeforeTab)) {
|
2022-11-11 17:37:07 +08:00
|
|
|
|
this.scoreCalculation()
|
|
|
|
|
|
}
|
2022-07-06 21:08:12 +08:00
|
|
|
|
},
|
2022-11-29 17:21:01 +08:00
|
|
|
|
setup (props) {
|
2022-10-19 15:27:26 +08:00
|
|
|
|
// todo 目前在panel页面测试,后续会挪到router里
|
|
|
|
|
|
const store = useStore()
|
|
|
|
|
|
const cancelList = store.state.panel.httpCancel
|
|
|
|
|
|
|
|
|
|
|
|
// 进入页面时,发现有未结束的请求,终止请求
|
|
|
|
|
|
if (cancelList.length > 0) {
|
|
|
|
|
|
cancelList.forEach((cancel, index) => {
|
|
|
|
|
|
cancel()
|
|
|
|
|
|
delete cancelList[index]
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-07-06 21:08:12 +08:00
|
|
|
|
const panel = ref({})
|
|
|
|
|
|
let panelType = 1 // 取得panel的type
|
2022-11-07 15:28:25 +08:00
|
|
|
|
let { params, query, path } = useRoute()
|
|
|
|
|
|
|
|
|
|
|
|
// 获取路由跳转过的历史状态,赋值给当前界面,起到保留状态的作用,如浏览器的回退前进等
|
2022-11-11 15:17:44 +08:00
|
|
|
|
const routerObj = store.getters.getRouterHistoryList.find(item => item.t === query.t)
|
2022-11-07 15:28:25 +08:00
|
|
|
|
if (routerObj) {
|
|
|
|
|
|
params = routerObj.params
|
|
|
|
|
|
query = routerObj.query
|
|
|
|
|
|
path = routerObj.path
|
|
|
|
|
|
|
|
|
|
|
|
// 如果当前界面之前载入过,获取状态后更新地址栏,以便后续的赋值操作
|
|
|
|
|
|
const newUrl = urlParamsHandler(window.location.href, useRoute().query, query)
|
2022-10-28 10:28:12 +08:00
|
|
|
|
overwriteUrl(newUrl)
|
2022-10-27 15:47:38 +08:00
|
|
|
|
}
|
2022-11-07 15:28:25 +08:00
|
|
|
|
|
2022-09-16 17:46:20 +08:00
|
|
|
|
const thirdPanel = query.thirdPanel
|
|
|
|
|
|
const fourthPanel = query.fourthPanel
|
2022-08-24 07:29:40 +08:00
|
|
|
|
if (fourthPanel) {
|
2022-08-19 10:46:24 +08:00
|
|
|
|
panelType = Number(fourthPanel)
|
2022-08-24 07:29:40 +08:00
|
|
|
|
} else if (thirdPanel) {
|
2022-08-19 10:46:24 +08:00
|
|
|
|
panelType = Number(thirdPanel)
|
2022-08-24 07:29:40 +08:00
|
|
|
|
} else {
|
2022-08-19 10:46:24 +08:00
|
|
|
|
panelType = props.entity ? props.entity.type : panelTypeAndRouteMapping[params.typeName]
|
|
|
|
|
|
}
|
2022-09-07 20:17:38 +08:00
|
|
|
|
// 获取url携带的range、startTime、endTime
|
|
|
|
|
|
const rangeParam = query.range
|
|
|
|
|
|
const startTimeParam = query.startTime
|
|
|
|
|
|
const endTimeParam = query.endTime
|
|
|
|
|
|
// 若url携带了,使用携带的值,否则使用默认值。
|
2022-11-07 15:28:25 +08:00
|
|
|
|
|
2023-03-11 20:40:35 +08:00
|
|
|
|
const dateRangeValue = rangeParam ? parseInt(query.range) : 60
|
2022-09-07 20:17:38 +08:00
|
|
|
|
const timeFilter = ref({ dateRangeValue })
|
|
|
|
|
|
if (!startTimeParam || !endTimeParam) {
|
2023-03-11 20:40:35 +08:00
|
|
|
|
const { startTime, endTime } = getNowTime(60)
|
2022-09-07 20:17:38 +08:00
|
|
|
|
timeFilter.value.startTime = startTime
|
|
|
|
|
|
timeFilter.value.endTime = endTime
|
|
|
|
|
|
} else {
|
|
|
|
|
|
timeFilter.value.startTime = parseInt(startTimeParam)
|
|
|
|
|
|
timeFilter.value.endTime = parseInt(endTimeParam)
|
|
|
|
|
|
}
|
2022-07-06 21:08:12 +08:00
|
|
|
|
|
2022-10-09 15:46:53 +08:00
|
|
|
|
// npm是否展示分数
|
|
|
|
|
|
const showScorePanel = [drillDownPanelTypeMapping.npmOverviewIp, drillDownPanelTypeMapping.npmOverviewDomain, drillDownPanelTypeMapping.npmOverviewApp, drillDownPanelTypeMapping.npmOverviewCommon, drillDownPanelTypeMapping.npmThirdMenu]
|
|
|
|
|
|
const showScore = showScorePanel.indexOf(panelType) > -1
|
2022-11-01 16:46:11 +08:00
|
|
|
|
|
|
|
|
|
|
const metric = ref(query.metric || 'Bits/s')
|
2022-11-07 15:28:25 +08:00
|
|
|
|
|
2022-11-10 17:20:00 +08:00
|
|
|
|
const queryCondition = ref(query.queryCondition || '')
|
|
|
|
|
|
const dimensionType = ref(query.dimensionType || '')
|
2022-11-25 16:08:32 +08:00
|
|
|
|
// 三级菜单判断
|
|
|
|
|
|
const tabOperationType = ref(query.tabOperationType)
|
2022-11-17 15:55:34 +08:00
|
|
|
|
const networkOverviewBeforeTab = ref(query.networkOverviewBeforeTab || '')
|
2022-07-06 21:08:12 +08:00
|
|
|
|
return {
|
|
|
|
|
|
panelType,
|
|
|
|
|
|
panel,
|
2022-10-09 15:46:53 +08:00
|
|
|
|
timeFilter,
|
2022-11-01 16:46:11 +08:00
|
|
|
|
showScore,
|
2022-11-07 15:28:25 +08:00
|
|
|
|
metric,
|
2022-11-10 17:20:00 +08:00
|
|
|
|
path,
|
|
|
|
|
|
queryCondition,
|
2022-11-17 15:55:34 +08:00
|
|
|
|
dimensionType,
|
2022-11-25 16:08:32 +08:00
|
|
|
|
tabOperationType,
|
2022-11-17 15:55:34 +08:00
|
|
|
|
networkOverviewBeforeTab
|
2022-07-06 21:08:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
async init () {
|
|
|
|
|
|
const panels = await getPanelList({ type: this.panelType })
|
|
|
|
|
|
if (panels && panels.length > 0) {
|
|
|
|
|
|
this.panel = panels[0]
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.panel.id) {
|
|
|
|
|
|
if (this.panel.params) {
|
|
|
|
|
|
this.panel.params = JSON.parse(this.panel.params)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.panel.params = {}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.chartList = (await getChartList({ panelId: this.panel.id, pageSize: -1 })).map(chart => {
|
|
|
|
|
|
chart.i = chart.id
|
|
|
|
|
|
// 递归初始化各属性
|
|
|
|
|
|
this.initChartAttr(chart)
|
|
|
|
|
|
return chart
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
initChartAttr (chart) {
|
|
|
|
|
|
chart.i = chart.id
|
|
|
|
|
|
chart.category = getTypeCategory(chart.type)
|
|
|
|
|
|
// 初始化params
|
|
|
|
|
|
chart.params = chart.params ? JSON.parse(chart.params) : {}
|
|
|
|
|
|
chart.firstShow = false
|
|
|
|
|
|
if (!this.$_.isEmpty(chart.children)) {
|
|
|
|
|
|
chart.children.forEach(c => {
|
|
|
|
|
|
this.initChartAttr(c)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-08-23 21:42:42 +08:00
|
|
|
|
reload (startTime, endTime, dateRangeValue) {
|
2022-09-07 20:17:38 +08:00
|
|
|
|
this.timeFilter = { startTime: getSecond(startTime), endTime: getSecond(endTime), dateRangeValue: dateRangeValue }
|
|
|
|
|
|
const { query } = this.$route
|
2022-10-27 15:47:38 +08:00
|
|
|
|
this.$store.commit('setTimeRangeArray', [this.timeFilter.startTime, this.timeFilter.endTime])
|
|
|
|
|
|
this.$store.commit('setTimeRangeFlag', dateRangeValue.value)
|
|
|
|
|
|
|
2022-09-07 20:17:38 +08:00
|
|
|
|
const newUrl = urlParamsHandler(window.location.href, query, {
|
|
|
|
|
|
startTime: this.timeFilter.startTime,
|
|
|
|
|
|
endTime: this.timeFilter.endTime,
|
|
|
|
|
|
range: dateRangeValue.value
|
|
|
|
|
|
})
|
|
|
|
|
|
overwriteUrl(newUrl)
|
2022-07-06 21:08:12 +08:00
|
|
|
|
},
|
2022-08-23 21:42:42 +08:00
|
|
|
|
timeRefreshChange () {
|
|
|
|
|
|
// 不是自选时间
|
2022-12-29 14:43:12 +08:00
|
|
|
|
if (this.$refs.dateTimeRange) {
|
|
|
|
|
|
if (!this.$refs.dateTimeRange.isCustom) {
|
|
|
|
|
|
const value = this.timeFilter.dateRangeValue
|
|
|
|
|
|
this.$refs.dateTimeRange.quickChange(value)
|
|
|
|
|
|
}
|
2022-08-23 21:42:42 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.timeFilter = JSON.parse(JSON.stringify(this.timeFilter))
|
|
|
|
|
|
}
|
2022-09-20 09:33:49 +08:00
|
|
|
|
},
|
2022-09-23 19:01:30 +08:00
|
|
|
|
getUrlParam (param, defaultValue, isNumber) {
|
|
|
|
|
|
if (isNumber) {
|
2022-09-20 11:44:39 +08:00
|
|
|
|
return this.$route.query[param] ? Number(this.$route.query[param]) : defaultValue
|
2022-09-23 19:01:30 +08:00
|
|
|
|
} else {
|
2022-09-20 11:44:39 +08:00
|
|
|
|
return this.$route.query[param] ? this.$route.query[param] : defaultValue
|
|
|
|
|
|
}
|
2022-11-01 16:46:11 +08:00
|
|
|
|
},
|
|
|
|
|
|
metricChange (value) {
|
|
|
|
|
|
const { query } = this.$route
|
|
|
|
|
|
const newUrl = urlParamsHandler(window.location.href, query, {
|
|
|
|
|
|
metric: value
|
|
|
|
|
|
})
|
|
|
|
|
|
overwriteUrl(newUrl)
|
2022-11-10 17:20:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
scoreCalculation () {
|
|
|
|
|
|
let condition = ''
|
2022-11-25 16:08:32 +08:00
|
|
|
|
let url = ''
|
2022-11-10 17:20:00 +08:00
|
|
|
|
if (this.queryCondition.indexOf(' OR ') > -1) {
|
|
|
|
|
|
condition = this.queryCondition.split(/["|'](.*?)["|']/)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
condition = this.queryCondition
|
|
|
|
|
|
}
|
2022-11-29 17:21:01 +08:00
|
|
|
|
const type = this.dimensionType || this.networkOverviewBeforeTab
|
2022-11-10 17:20:00 +08:00
|
|
|
|
const params = {
|
|
|
|
|
|
startTime: getSecond(this.timeFilter.startTime),
|
|
|
|
|
|
endTime: getSecond(this.timeFilter.endTime),
|
|
|
|
|
|
cycle: 0
|
|
|
|
|
|
}
|
|
|
|
|
|
if (condition && (typeof condition !== 'object') && type) {
|
2022-11-15 11:13:11 +08:00
|
|
|
|
if (type === 'clientIp') {
|
|
|
|
|
|
params.q = `ip='${condition.split(/'(.*?)'/)[1]}' and side='client'`
|
|
|
|
|
|
} else if (type === 'serverIp') {
|
|
|
|
|
|
params.q = `ip='${condition.split(/'(.*?)'/)[1]}' and side='server'`
|
2022-11-16 11:55:11 +08:00
|
|
|
|
} else if (type === 'clientCity') {
|
2022-11-17 15:55:34 +08:00
|
|
|
|
params.q = `client_city='${condition.split(/'(.*?)'/)[1]}'`
|
2022-11-16 11:55:11 +08:00
|
|
|
|
} else if (type === 'serverCity') {
|
2022-11-17 15:55:34 +08:00
|
|
|
|
params.q = `server_city='${condition.split(/'(.*?)'/)[1]}'`
|
2022-11-15 11:13:11 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
params.q = condition
|
|
|
|
|
|
}
|
2022-11-10 17:20:00 +08:00
|
|
|
|
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
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-11-25 16:08:32 +08:00
|
|
|
|
if (parseFloat(this.tabOperationType) === 3) {
|
|
|
|
|
|
url = api.npm.overview.allNetworkAnalysis
|
|
|
|
|
|
} else {
|
|
|
|
|
|
url = api.npm.overview.networkAnalysis
|
|
|
|
|
|
}
|
2022-11-17 15:55:34 +08:00
|
|
|
|
if ((type && condition) || type) {
|
|
|
|
|
|
params.type = params.type || type
|
2022-11-25 16:08:32 +08:00
|
|
|
|
get(url, params).then(res => {
|
2022-11-10 17:20:00 +08:00
|
|
|
|
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)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2022-09-23 19:01:30 +08:00
|
|
|
|
}
|
2022-11-07 15:28:25 +08:00
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 页面销毁前,更新历史中已保存的状态
|
|
|
|
|
|
* 之所以会在下钻时、销毁前保存状态,是因为panel第一次下钻时,beforeUnmount获取不到下钻前参数
|
|
|
|
|
|
*/
|
|
|
|
|
|
beforeUnmount () {
|
|
|
|
|
|
const query = this.$_.cloneDeep(this.$route.query)
|
2022-11-11 15:17:44 +08:00
|
|
|
|
const routerObj = this.$store.getters.getRouterHistoryList.find(item => item.t === query.t)
|
|
|
|
|
|
// const routerObj = window.localRouterHistoryList.find(item => item.t === query.t)
|
2022-11-07 15:28:25 +08:00
|
|
|
|
if (routerObj !== undefined) {
|
|
|
|
|
|
if (Object.getOwnPropertyNames(query).length >= Object.getOwnPropertyNames(routerObj.query).length) {
|
|
|
|
|
|
routerObj.query = query
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-11-29 17:21:01 +08:00
|
|
|
|
|
|
|
|
|
|
this.emitter.off('reloadChartList')
|
|
|
|
|
|
this.$store = null
|
|
|
|
|
|
this.emitter = null
|
2022-07-06 21:08:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|