CN-732 完成dns页面的下钻表格

This commit is contained in:
hyx
2022-10-09 08:24:07 +08:00
parent 6bfe9f50ff
commit 4252735c92
5 changed files with 132 additions and 47 deletions

View File

@@ -18,6 +18,38 @@
cursor: pointer; cursor: pointer;
} }
} }
.dns-in-ex {
display: flex;
align-items: center;
width: 100%;
.dns-percent-pic {
display: flex !important;
width: 100px;
height: 26px;
justify-content: center;
align-items: center;
.div-yellow {
height: 12px;
background: #e5a219;
border: 1px solid #e5a219;
border-left: none;
}
.div-green {
height: 12px;
background: #749f4d;
border: 1px solid #749f4d;
border-right: none;
}
}
.dns-percent{
display:flex;
align-items:center;
height:100%;
min-width:90px;
padding-left:10px;
justify-content: left;
}
}
.tab-table__average { .tab-table__average {
border: 1px solid #E2E5EC; border: 1px solid #E2E5EC;
border-radius: 4px 4px 0 0; border-radius: 4px 4px 0 0;

View File

@@ -178,22 +178,23 @@
</template> </template>
<script> <script>
import {useRoute} from 'vue-router' import { useRoute } from 'vue-router'
import {get, put} from '@/utils/http' import { get, put } from '@/utils/http'
import { import {
curTabState, curTabState,
dbDrilldownTableConfig, dbDrilldownTableConfig,
entityType, entityType,
networkOverviewSearchUrl, networkOverviewSearchUrl,
networkOverviewTabList, networkOverviewTabList,
networkTable,
operationType, operationType,
storageKey storageKey
} from '@/utils/constants' } from '@/utils/constants'
import {api} from '@/utils/api' import { api } from '@/utils/api'
import {ref} from 'vue' import { ref } from 'vue'
import {combineTabList, getDefaultCurTab, getTabList, overwriteUrl, urlParamsHandler} from '@/utils/tools' import { combineTabList, getDefaultCurTab, getTabList, overwriteUrl, urlParamsHandler } from '@/utils/tools'
import {getNowTime, getSecond} from '@/utils/date-util' import { getNowTime, getSecond } from '@/utils/date-util'
import {db} from '@/indexedDB' import { db } from '@/indexedDB'
export default { export default {
name: 'Header', name: 'Header',
@@ -350,12 +351,12 @@ export default {
}, },
initDropdownList () { initDropdownList () {
const currentValue = document.getElementById('breadcrumbValue') ? document.getElementById('breadcrumbValue').innerText : '' const currentValue = document.getElementById('breadcrumbValue') ? document.getElementById('breadcrumbValue').innerText : ''
// const columnName = this.$store.getters.getBreadcrumbColumnName
const columnName = this.getUrlParam(this.curTabState.thirdMenu, '') const columnName = this.getUrlParam(this.curTabState.thirdMenu, '')
let type = 'ip' let type = 'ip'
const tabObjGroup = networkOverviewTabList.filter(item => item.label == columnName) const tableType = this.$route.params ? this.$route.params.typeName : 'networkOverview'
if (tabObjGroup && tabObjGroup.length > 0) { const curTableInCode = networkTable[tableType] ? networkTable[tableType] : networkTable.networkOverview
const curTab = tabObjGroup[0] if (curTableInCode && curTableInCode.tabList) {
const curTab = curTableInCode.tabList.find(item => item.label == columnName)
if (curTab) { if (curTab) {
type = curTab.prop type = curTab.prop
} }
@@ -367,7 +368,7 @@ export default {
type: type, type: type,
name: this.dropDownValue ? this.dropDownValue : '' name: this.dropDownValue ? this.dropDownValue : ''
} }
get(networkOverviewSearchUrl.drilldownList, params).then(response => { get(curTableInCode.url.drilldownList, params).then(response => {
if (response.code === 200) { if (response.code === 200) {
this.breadcrumbColumnValueListShow = response.data.result this.breadcrumbColumnValueListShow = response.data.result
this.$nextTick(() => { this.$nextTick(() => {
@@ -464,7 +465,6 @@ export default {
this.urlChangeParams = {} this.urlChangeParams = {}
}, },
async handleCurDrilldownTableConfig (thirdMenu, fourthMenu) { async handleCurDrilldownTableConfig (thirdMenu, fourthMenu) {
console.log('handleCurDrilldownTableConfig--------------')
const userId = localStorage.getItem(storageKey.userId) const userId = localStorage.getItem(storageKey.userId)
const tableType = this.$route.params ? this.$route.params.typeName : 'networkOverview' const tableType = this.$route.params ? this.$route.params.typeName : 'networkOverview'
@@ -475,13 +475,11 @@ export default {
drillDownTableConfigs = userLocalConfig.config drillDownTableConfigs = userLocalConfig.config
} }
if (!drillDownTableConfigs || drillDownTableConfigs.length === 0) { // 未找到当前用户的配置,使用默认配置 if (!drillDownTableConfigs || drillDownTableConfigs.length === 0) { // 未找到当前用户的配置,使用默认配置
console.log('default..............')
const defaultConfig = await db[dbDrilldownTableConfig].get({ id: 'default' }) const defaultConfig = await db[dbDrilldownTableConfig].get({ id: 'default' })
if (defaultConfig) { if (defaultConfig) {
drillDownTableConfigs = defaultConfig.config drillDownTableConfigs = defaultConfig.config
} }
} }
console.log(drillDownTableConfigs)
const currentTableConfig = drillDownTableConfigs.find(config => config.route === tableType) const currentTableConfig = drillDownTableConfigs.find(config => config.route === tableType)
const tables = currentTableConfig ? currentTableConfig.tables : [] const tables = currentTableConfig ? currentTableConfig.tables : []
const commonTabList = currentTableConfig ? currentTableConfig.tabs : [] const commonTabList = currentTableConfig ? currentTableConfig.tabs : []
@@ -504,8 +502,6 @@ export default {
id: userId, id: userId,
config: this.$_.cloneDeep(drillDownTableConfigs) config: this.$_.cloneDeep(drillDownTableConfigs)
}) })
console.log('当前测试。。。。。。。。。。。')
console.log(this.$_.cloneDeep(drillDownTableConfigs))
}, },
jump (route, columnName, columnValue, opeType) { jump (route, columnName, columnValue, opeType) {
this.showMenu = false this.showMenu = false
@@ -561,35 +557,35 @@ export default {
if (menus[3]) { if (menus[3]) {
this.handleCurDrilldownTableConfig(this.breadcrumb[2], this.breadcrumb[3]) this.handleCurDrilldownTableConfig(this.breadcrumb[2], this.breadcrumb[3])
} }
/*this.$router.push({ /* this.$router.push({
path: route, path: route,
query: { query: {
t: +new Date() t: +new Date()
} }
})*/ }) */
this.jumpAndCache(route, {}) this.jumpAndCache(route, {})
} else if (opeType === 3) { } else if (opeType === 3) {
/*this.$router.push({ /* this.$router.push({
query: { ...this.$route.query, fourthPanel: '' } query: { ...this.$route.query, fourthPanel: '' }
})*/ }) */
this.jumpAndCache(route, { ...this.$route.query, fourthPanel: '' }) this.jumpAndCache(route, { ...this.$route.query, fourthPanel: '' })
} else if (opeType != 4) { } else if (opeType != 4) {
this.jumpAndCache(route, { ...this.$route.query, fourthPanel: '', thirdPanel: '' }) this.jumpAndCache(route, { ...this.$route.query, fourthPanel: '', thirdPanel: '' })
/*this.$router.push({ /* this.$router.push({
query: { ...this.$route.query, fourthPanel: '', thirdPanel: '' } query: { ...this.$route.query, fourthPanel: '', thirdPanel: '' }
})*/ }) */
} }
if (route === this.route) { if (route === this.route) {
this.refresh() this.refresh()
return return
} }
if (route) { if (route) {
/*this.$router.push({ /* this.$router.push({
path: route, path: route,
query: { query: {
t: +new Date() t: +new Date()
} }
})*/ }) */
this.jumpAndCache(route, {}) this.jumpAndCache(route, {})
} }
}, },

View File

@@ -218,6 +218,7 @@ export const networkOverviewTableUrlName = {
export const tableColumnType = { export const tableColumnType = {
dillDown: 'dillDown', dillDown: 'dillDown',
chainRatio: 'chainRatio', chainRatio: 'chainRatio',
percent: 'percent', // percent类型的列需要2个属性计算百分比
normal: 'normal' normal: 'normal'
} }
@@ -367,8 +368,16 @@ export const customTableTitlesForAppPerformance = [
] ]
export const customTableTitlesForDns = [ export const customTableTitlesForDns = [
{ label: 'dns.dnsServer', prop: 'tab', checked: true, tabColumn: true, columnType: tableColumnType.dillDown }, { label: 'dns.dnsServer', prop: 'tab', checked: true, tabColumn: true, columnType: tableColumnType.dillDown },
{ label: 'dns.queries', prop: 'queryRate', checked: true, tabColumn: true, columnType: tableColumnType.chainRatio }, {
{ label: 'dns.queriesFromIE', prop: 'totalInternalQueryNum,totalExternalQueryNum', checked: true, tabColumn: true, columnType: tableColumnType.normal }, label: 'dns.queries',
prop: 'queryRate',
checked: true,
tabColumn: true,
columnType: tableColumnType.chainRatio,
isInMainUrl: true,
cycleDataUrl: dnsSearchUrl.cycleUrl
},
{ label: 'dns.queriesFromIE', prop: 'totalInExNum', checked: true, tabColumn: true, columnType: tableColumnType.percent },
{ label: 'dns.dnsResponseTime', prop: 'dnsResponseLatencyAvg', checked: true, tabColumn: true, columnType: tableColumnType.normal }, { label: 'dns.dnsResponseTime', prop: 'dnsResponseLatencyAvg', checked: true, tabColumn: true, columnType: tableColumnType.normal },
{ label: 'overall.throughput', prop: 'totalBytes', checked: true, tabColumn: true, columnType: tableColumnType.normal } { label: 'overall.throughput', prop: 'totalBytes', checked: true, tabColumn: true, columnType: tableColumnType.normal }
] ]
@@ -671,7 +680,7 @@ export const dnsServiceInsightsTabList = [
label: 'dns.dnsServer', // tab名称对应的il8n label: 'dns.dnsServer', // tab名称对应的il8n
prop: 'dnsServer', // 接口返回数据中tab第一列对应的属性名 prop: 'dnsServer', // 接口返回数据中tab第一列对应的属性名
queryCycleTotalProp: 'dnsServer', // SQL中查询不同纬度的列名称 queryCycleTotalProp: 'dnsServer', // SQL中查询不同纬度的列名称
dillDownProp: ['server_ip'], // 下钻时传递的查询条件即接口的q参数 dillDownProp: ['common_server_ip'], // 下钻时传递的查询条件即接口的q参数
checked: true, // 自定义设置中,是否默认选中 checked: true, // 自定义设置中,是否默认选中
disabled: false, // 自定义设置中,是否可操作(选中或取消选中) disabled: false, // 自定义设置中,是否可操作(选中或取消选中)
panelId: drillDownPanelTypeMapping.dnsFourthMenu// 下钻后展示的panelId panelId: drillDownPanelTypeMapping.dnsFourthMenu// 下钻后展示的panelId
@@ -689,7 +698,7 @@ export const dnsServiceInsightsTabList = [
label: 'network.cities', label: 'network.cities',
prop: 'city', prop: 'city',
queryCycleTotalProp: 'cities', queryCycleTotalProp: 'cities',
dillDownProp: ['server_city'], dillDownProp: ['server_region'],
checked: true, checked: true,
disabled: false, disabled: false,
panelId: drillDownPanelTypeMapping.dnsFourthMenu panelId: drillDownPanelTypeMapping.dnsFourthMenu
@@ -707,7 +716,7 @@ export const dnsServiceInsightsTabList = [
label: 'dns.dnsServerOrganizations', label: 'dns.dnsServerOrganizations',
prop: 'dnsServerOrganization', prop: 'dnsServerOrganization',
queryCycleTotalProp: 'orgs', queryCycleTotalProp: 'orgs',
dillDownProp: ['server_org'], dillDownProp: ['dns_server_org'],
checked: true, checked: true,
disabled: false, disabled: false,
panelId: drillDownPanelTypeMapping.dnsFourthMenu panelId: drillDownPanelTypeMapping.dnsFourthMenu
@@ -716,7 +725,7 @@ export const dnsServiceInsightsTabList = [
label: 'dns.dnsServerRoles', label: 'dns.dnsServerRoles',
prop: 'dnsServerRole', prop: 'dnsServerRole',
queryCycleTotalProp: 'roles', queryCycleTotalProp: 'roles',
dillDownProp: ['server_role'], dillDownProp: ['dns_server_role'],
checked: true, checked: true,
disabled: false, disabled: false,
panelId: drillDownPanelTypeMapping.dnsFourthMenu panelId: drillDownPanelTypeMapping.dnsFourthMenu
@@ -725,7 +734,7 @@ export const dnsServiceInsightsTabList = [
label: 'QNames', label: 'QNames',
prop: 'dnsServerRole', prop: 'dnsServerRole',
queryCycleTotalProp: 'qnames', queryCycleTotalProp: 'qnames',
dillDownProp: ['qname'], dillDownProp: ['dns_qname'],
checked: true, checked: true,
disabled: false, disabled: false,
panelId: drillDownPanelTypeMapping.dnsFourthMenu panelId: drillDownPanelTypeMapping.dnsFourthMenu
@@ -734,7 +743,7 @@ export const dnsServiceInsightsTabList = [
label: 'SLDs', label: 'SLDs',
prop: 'sld', prop: 'sld',
queryCycleTotalProp: 'slds', queryCycleTotalProp: 'slds',
dillDownProp: ['qname_sld'], dillDownProp: ['dns_qname'],
checked: true, checked: true,
disabled: false, disabled: false,
panelId: drillDownPanelTypeMapping.dnsFourthMenu panelId: drillDownPanelTypeMapping.dnsFourthMenu
@@ -743,7 +752,7 @@ export const dnsServiceInsightsTabList = [
label: 'TLDs', label: 'TLDs',
prop: 'tld', prop: 'tld',
queryCycleTotalProp: 'tlds', queryCycleTotalProp: 'tlds',
dillDownProp: ['qname_tld'], dillDownProp: ['dns_qname'],
checked: true, checked: true,
disabled: false, disabled: false,
panelId: drillDownPanelTypeMapping.dnsFourthMenu panelId: drillDownPanelTypeMapping.dnsFourthMenu
@@ -752,7 +761,7 @@ export const dnsServiceInsightsTabList = [
label: 'QTypes', label: 'QTypes',
prop: 'qtype', prop: 'qtype',
queryCycleTotalProp: 'qtypes', queryCycleTotalProp: 'qtypes',
dillDownProp: ['qtype'], dillDownProp: ['dns_qtype'],
checked: true, checked: true,
disabled: false, disabled: false,
panelId: drillDownPanelTypeMapping.dnsFourthMenu panelId: drillDownPanelTypeMapping.dnsFourthMenu
@@ -761,7 +770,7 @@ export const dnsServiceInsightsTabList = [
label: 'RCodes', label: 'RCodes',
prop: 'rcode', prop: 'rcode',
queryCycleTotalProp: 'rcodes', queryCycleTotalProp: 'rcodes',
dillDownProp: ['rcode'], dillDownProp: ['dns_rcode'],
checked: true, checked: true,
disabled: false, disabled: false,
panelId: drillDownPanelTypeMapping.dnsFourthMenu panelId: drillDownPanelTypeMapping.dnsFourthMenu
@@ -804,6 +813,23 @@ export const bytesColumnNameGroupForNpm = {
sslResponseLatency: 'sslConLatency', sslResponseLatency: 'sslConLatency',
httpResponseLatency: 'httpResponseLatency' httpResponseLatency: 'httpResponseLatency'
} }
export const bytesCycleColumnNameGroupForNmp = {
through: 'throughBitsRate'
}
// 用于组织数据时的名称,对应的属性名称
export const bytesColumnNameGroupForDns = {
queryRate: 'queryRate',
totalInExNum: 'totalInternalQueryNum,totalExternalQueryNum',
dnsResponseLatencyAvg: 'dnsResponseLatencyAvg',
totalBytes: 'totalBytes'
}
export const bytesCycleColumnNameGroupForDns = {
queryRate: 'queryRate'
}
// networkOverview 当前周期返回数据对应的属性名称(与上一周期中的属性名称不一致,total,之所以写在这里是因为有bytepacketssessions3种如果只有一种可以直接写在customTableTitlesForAppPerformance // networkOverview 当前周期返回数据对应的属性名称(与上一周期中的属性名称不一致,total,之所以写在这里是因为有bytepacketssessions3种如果只有一种可以直接写在customTableTitlesForAppPerformance
export const bytesColumnNameGroup = { export const bytesColumnNameGroup = {
total: 'bytesTotalRate', total: 'bytesTotalRate',
@@ -833,10 +859,6 @@ export const sessionsCycleColumnNameGroup = {
total: 'sessionsRate' total: 'sessionsRate'
} }
export const bytesCycleColumnNameGroupForNmp = {
through: 'throughBitsRate'
}
// 不同表格类型对应的相关数据 // 不同表格类型对应的相关数据
export const networkTable = { export const networkTable = {
networkOverview: { networkOverview: {
@@ -870,9 +892,10 @@ export const networkTable = {
column: customTableTitlesForDns, column: customTableTitlesForDns,
url: dnsSearchUrl, url: dnsSearchUrl,
hasMetricSearch: false, // 是否有metric下拉列表 hasMetricSearch: false, // 是否有metric下拉列表
panelIdOfThirdMenu: drillDownPanelTypeMapping.npmThirdMenu, panelIdOfThirdMenu: drillDownPanelTypeMapping.dnsThirdMenu,
bytesColumnNameGroup: bytesColumnNameGroupForNpm, bytesColumnNameGroup: bytesColumnNameGroupForDns,
bytesCycleColumnNameGroup: bytesCycleColumnNameGroupForNmp bytesCycleColumnNameGroup: bytesCycleColumnNameGroupForDns,
defaultOrderBy: 'totalBytes'
} }
} }

View File

@@ -354,7 +354,6 @@ export default {
}) })
this.urlChangeParams[this.curTabState.queryCondition] = queryCondition.join(' OR ') this.urlChangeParams[this.curTabState.queryCondition] = queryCondition.join(' OR ')
this.$store.getters.menuList.forEach(menu => { this.$store.getters.menuList.forEach(menu => {
if (this.$_.isEmpty(menu.children) && menu.route) { if (this.$_.isEmpty(menu.children) && menu.route) {
if (this.$route.path === menu.route) { if (this.$route.path === menu.route) {
@@ -364,7 +363,6 @@ export default {
this.urlChangeParams[this.curTabState.thirdMenu] = tabType this.urlChangeParams[this.curTabState.thirdMenu] = tabType
this.urlChangeParams[this.curTabState.dimensionType] = tabGroup[0] ? tabGroup[0].prop : '' this.urlChangeParams[this.curTabState.dimensionType] = tabGroup[0] ? tabGroup[0].prop : ''
this.urlChangeParams[this.curTabState.fourthMenu] = value this.urlChangeParams[this.curTabState.fourthMenu] = value
} }
} else if (!this.$_.isEmpty(menu.children)) { } else if (!this.$_.isEmpty(menu.children)) {
menu.children.forEach(child => { menu.children.forEach(child => {
@@ -375,7 +373,6 @@ export default {
this.urlChangeParams[this.curTabState.thirdMenu] = tabType this.urlChangeParams[this.curTabState.thirdMenu] = tabType
this.urlChangeParams[this.curTabState.dimensionType] = tabGroup[0] ? tabGroup[0].prop : '' this.urlChangeParams[this.curTabState.dimensionType] = tabGroup[0] ? tabGroup[0].prop : ''
this.urlChangeParams[this.curTabState.fourthMenu] = value this.urlChangeParams[this.curTabState.fourthMenu] = value
} }
}) })
} }

View File

@@ -70,6 +70,15 @@
<template v-else-if="item.columnType === tableColumnType.dillDown" > <template v-else-if="item.columnType === tableColumnType.dillDown" >
<div class="data-click" @click="handleTabValue(item.label,scope.row['tab'])">{{scope.row['tab']}}</div> <div class="data-click" @click="handleTabValue(item.label,scope.row['tab'])">{{scope.row['tab']}}</div>
</template> </template>
<template v-else-if="item.columnType === tableColumnType.percent" >
<div class="dns-in-ex">
<div class="dns-percent-pic" >
<div v-if="scope.row[item.prop][0] !== false && scope.row[item.prop][0]>0" class="div-green" id="green" :style="`width:${scope.row[item.prop][0]}`"></div>
<div v-if="scope.row[item.prop][0] !== false && scope.row[item.prop][1]>0" class="div-yellow" id="div-yellow" :style="`width:${scope.row[item.prop][1]}`"></div>
</div>
<div class="dns-percent" >{{scope.row[item.prop][2]}}</div>
</div>
</template>
<template v-else-if="item.prop === 'score'" > <template v-else-if="item.prop === 'score'" >
{{scope.row[item.prop] ? unitConvert(scope.row[item.prop], unitTypes.number).join(' ') : '0'}} {{scope.row[item.prop] ? unitConvert(scope.row[item.prop], unitTypes.number).join(' ') : '0'}}
</template> </template>
@@ -314,6 +323,7 @@ export default {
console.error(e) console.error(e)
} finally { } finally {
this.changeUrlTabState() this.changeUrlTabState()
this.toggleLoading(false)
} }
}, },
sortable (title) { sortable (title) {
@@ -516,7 +526,31 @@ export default {
tabList.push(item[curTab.prop]) tabList.push(item[curTab.prop])
const otherData = { tab: item[curTab.prop] } const otherData = { tab: item[curTab.prop] }
Object.keys(this.columnNameGroup).forEach(i => { Object.keys(this.columnNameGroup).forEach(i => {
otherData[i] = item[this.columnNameGroup[i]] const propName = this.columnNameGroup[i]
const column = this.customTableTitles.find(tableColumn => { return tableColumn.prop === i })
if (column && column.columnType === tableColumnType.percent) {
let sum = 0
const propGroup = propName.split(',')
propGroup.forEach(prop => {
sum = sum + Number(item[prop])
})
const resultGroup = []
propGroup.forEach(prop => {
resultGroup.push(unitConvert(Number(item[prop]) / sum, unitTypes.percent, null, null, 0).join(''))
})
otherData[i] = []
if (resultGroup[0] === '-') {
otherData[i][0] = false
otherData[i][1] = resultGroup[1]
otherData[i][2] = resultGroup.join(' / ')
} else {
otherData[i][0] = resultGroup[0]
otherData[i][1] = resultGroup[1]
otherData[i][2] = resultGroup.join(' / ')
}
} else {
otherData[i] = item[propName]
}
}) })
return otherData return otherData
}) })
@@ -1669,6 +1703,9 @@ export default {
this.curTable.sessionsCycleColumnNameGroup = this.curTableInCode ? this.curTableInCode.sessionsCycleColumnNameGroup : [] this.curTable.sessionsCycleColumnNameGroup = this.curTableInCode ? this.curTableInCode.sessionsCycleColumnNameGroup : []
this.columnNameGroup = this.curTable.bytesColumnNameGroup this.columnNameGroup = this.curTable.bytesColumnNameGroup
this.cycleColumnNameGroup = this.curTable.bytesCycleColumnNameGroup this.cycleColumnNameGroup = this.curTable.bytesCycleColumnNameGroup
if (this.curTableInCode.defaultOrderBy) {
this.orderBy = this.curTableInCode.defaultOrderBy
}
} }
} }
this.saveUserLocalConfig() this.saveUserLocalConfig()