2022-08-08 22:13:31 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="npm-app-event">
|
|
|
|
|
|
<div class="metric-select" >
|
|
|
|
|
|
<el-select v-model="metric"
|
|
|
|
|
|
class="option__select select-column"
|
2022-08-24 09:40:05 +08:00
|
|
|
|
popper-class="option-popper common-select"
|
2022-08-08 22:13:31 +08:00
|
|
|
|
:popper-append-to-body="false"
|
|
|
|
|
|
key="tabMetric"
|
|
|
|
|
|
@change="changeMetric"
|
|
|
|
|
|
size="mini"
|
|
|
|
|
|
width="100">
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in options"
|
|
|
|
|
|
:key="item.label"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
:value="item.value"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
<span>{{$t('network.metric')}}:</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-table
|
|
|
|
|
|
:id="`tabTable_${index}`"
|
|
|
|
|
|
:ref="`dataTable_${index}`"
|
|
|
|
|
|
:data="tableData"
|
|
|
|
|
|
class="npm-app-event-table"
|
|
|
|
|
|
height="100%"
|
2022-08-24 09:40:05 +08:00
|
|
|
|
empty-text=" "
|
2022-08-08 22:13:31 +08:00
|
|
|
|
>
|
|
|
|
|
|
<template v-for="(item, index) in customTableTitles" :key="index">
|
2022-08-09 11:46:48 +08:00
|
|
|
|
<el-table-column class="data-column" :min-width="columnWidth(index)">
|
2022-08-08 22:13:31 +08:00
|
|
|
|
<template #header>
|
|
|
|
|
|
<span class="data-column__span">{{$t(item.label)}}</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #default="scope" :column="item">
|
|
|
|
|
|
<div class="data-app-event-table">
|
2022-08-24 11:54:09 +08:00
|
|
|
|
<template v-if="item.prop === 'domain' ||item.prop === 'appName' ||item.prop === 'serverIp' ">
|
2022-08-08 22:13:31 +08:00
|
|
|
|
<span class="data-applications">{{$t(scope.row[item.prop])}}</span>
|
|
|
|
|
|
</template>
|
2022-08-24 11:54:09 +08:00
|
|
|
|
<template v-else-if="item.prop === 'eventSeverity'">
|
|
|
|
|
|
<template v-if="scope.row[item.prop]==='critical'">
|
2022-08-08 22:13:31 +08:00
|
|
|
|
<div v-for="item in 5" class="red-dot"></div>
|
|
|
|
|
|
</template>
|
2022-08-24 11:54:09 +08:00
|
|
|
|
<template v-else-if="scope.row[item.prop]==='high'">
|
2022-08-08 22:13:31 +08:00
|
|
|
|
<div v-for="item in 4" class="red-dot"></div>
|
|
|
|
|
|
<div class="grey-dot"></div>
|
|
|
|
|
|
</template>
|
2022-08-24 11:54:09 +08:00
|
|
|
|
<template v-else-if="scope.row[item.prop]==='medium'">
|
2022-08-08 22:13:31 +08:00
|
|
|
|
<div v-for="item in 3" class="red-dot"></div>
|
|
|
|
|
|
<div v-for="item in 2" class="grey-dot"></div>
|
|
|
|
|
|
</template>
|
2022-08-24 11:54:09 +08:00
|
|
|
|
<template v-else-if="scope.row[item.prop]==='low'">
|
2022-08-08 22:13:31 +08:00
|
|
|
|
<div v-for="item in 2" class="red-dot"></div>
|
|
|
|
|
|
<div v-for="item in 3" class="grey-dot"></div>
|
|
|
|
|
|
</template>
|
2022-08-24 11:54:09 +08:00
|
|
|
|
<template v-else-if="scope.row[item.prop]==='info'">
|
2022-08-08 22:13:31 +08:00
|
|
|
|
<div v-for="item in 1" class="red-dot"></div>
|
|
|
|
|
|
<div v-for="item in 4" class="grey-dot"></div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<span class="data-severity" >{{$t(scope.row[item.prop])}}</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="item.prop === 'eventType'">
|
2022-08-24 11:54:09 +08:00
|
|
|
|
<!-- <span class="data-eventType" v-for="type in scope.row[item.prop]">{{type}}</span>-->
|
|
|
|
|
|
<span class="data-eventType" >{{$t(scope.row[item.prop])}}</span>
|
2022-08-08 22:13:31 +08:00
|
|
|
|
</template>
|
2022-08-24 11:54:09 +08:00
|
|
|
|
<template v-else-if="item.prop === 'count'">
|
2022-08-08 22:13:31 +08:00
|
|
|
|
<span class="data-eventCount">{{scope.row[item.prop]}}</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<span v-else>-</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</template>
|
2022-08-24 16:50:18 +08:00
|
|
|
|
<template v-slot:empty>
|
|
|
|
|
|
<div class="table-no-data" v-show="isNoData">
|
|
|
|
|
|
<div class="table-no-data__title">{{ $t('npm.noData') }}</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2022-08-08 22:13:31 +08:00
|
|
|
|
</el-table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-08-24 11:54:09 +08:00
|
|
|
|
import { unitTypes, npmCategoryInfoMapping } from '@/utils/constants'
|
|
|
|
|
|
import unitConvert from '@/utils/unit-convert'
|
|
|
|
|
|
import { api } from '@/utils/api'
|
|
|
|
|
|
import { getSecond } from '@/utils/date-util'
|
|
|
|
|
|
import { get } from '@/utils/http'
|
|
|
|
|
|
import { getChainRatio, computeScore } from '@/utils/tools'
|
2022-08-24 09:40:05 +08:00
|
|
|
|
import chartMixin from '@/views/charts2/chart-mixin'
|
|
|
|
|
|
|
2022-08-08 22:13:31 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'NpmAppEventTable',
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
2022-08-24 11:54:09 +08:00
|
|
|
|
metric: 'appLabel',
|
|
|
|
|
|
dataProp: 'appLabel',
|
2022-08-08 22:13:31 +08:00
|
|
|
|
options: [
|
|
|
|
|
|
{
|
2022-08-24 11:54:09 +08:00
|
|
|
|
value: 'appLabel',
|
2022-08-08 22:13:31 +08:00
|
|
|
|
label: 'Application'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-08-24 11:54:09 +08:00
|
|
|
|
value: 'idcRenter',
|
2022-08-08 22:13:31 +08:00
|
|
|
|
label: 'Provider'
|
|
|
|
|
|
}
|
|
|
|
|
|
],
|
2022-08-24 11:54:09 +08:00
|
|
|
|
typePropMap: {
|
|
|
|
|
|
appLabel: 'appName',
|
|
|
|
|
|
idcRenter: 'domain'
|
|
|
|
|
|
},
|
|
|
|
|
|
typeLabelMap: {
|
|
|
|
|
|
appLabel: 'network.applications',
|
|
|
|
|
|
idcRenter: 'network.idcRenter'
|
|
|
|
|
|
},
|
2022-08-08 22:13:31 +08:00
|
|
|
|
dotList: ['grey-dot', 'grey-dot', 'grey-dot', 'grey-dot', 'grey-dot'],
|
2022-08-24 11:54:09 +08:00
|
|
|
|
tableData: [],
|
2022-08-08 22:13:31 +08:00
|
|
|
|
customTableTitles: [
|
2022-08-24 11:54:09 +08:00
|
|
|
|
{ label: 'network.applications', prop: 'serverIp' },
|
|
|
|
|
|
{ label: 'network.severity', prop: 'eventSeverity' },
|
2022-08-08 22:13:31 +08:00
|
|
|
|
{ label: 'network.eventType', prop: 'eventType' },
|
2022-08-24 11:54:09 +08:00
|
|
|
|
{ label: 'network.eventCount', prop: 'count' }
|
2022-08-24 16:50:18 +08:00
|
|
|
|
],
|
|
|
|
|
|
isNoData: false,
|
2022-08-08 22:13:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-08-24 11:54:09 +08:00
|
|
|
|
mixins: [chartMixin],
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
timeFilter: {
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler (n) {
|
|
|
|
|
|
this.init()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
this.init()
|
|
|
|
|
|
},
|
2022-08-09 15:35:36 +08:00
|
|
|
|
methods: {
|
2022-08-24 11:54:09 +08:00
|
|
|
|
init () {
|
|
|
|
|
|
this.toggleLoading(true)
|
2022-08-24 16:50:18 +08:00
|
|
|
|
this.isNoData = false
|
2022-08-24 11:54:09 +08:00
|
|
|
|
this.customTableTitles[0].prop = this.typePropMap[this.metric]
|
|
|
|
|
|
this.customTableTitles[0].label = this.typeLabelMap[this.metric]
|
|
|
|
|
|
this.tableData = []
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
startTime: getSecond(this.timeFilter.startTime),
|
|
|
|
|
|
endTime: getSecond(this.timeFilter.endTime),
|
|
|
|
|
|
limit: 10,
|
|
|
|
|
|
type: this.metric
|
|
|
|
|
|
}
|
|
|
|
|
|
get(api.npm.events.dimensionEvents, params).then(res => {
|
|
|
|
|
|
if (res.code === 200) {
|
2022-08-24 16:50:18 +08:00
|
|
|
|
if (!res.data.result || res.data.result.length === 0) {
|
|
|
|
|
|
this.isNoData = true
|
|
|
|
|
|
}
|
2022-08-24 11:54:09 +08:00
|
|
|
|
this.tableData = res.data.result
|
|
|
|
|
|
console.log(res.data.result)
|
2022-08-24 16:50:18 +08:00
|
|
|
|
}else {
|
|
|
|
|
|
this.isNoData = true
|
2022-08-24 11:54:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.toggleLoading(false)
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
changeMetric () {
|
|
|
|
|
|
this.init()
|
|
|
|
|
|
},
|
2022-08-09 15:35:36 +08:00
|
|
|
|
columnWidth (index) {
|
|
|
|
|
|
if (index === 0 || index === 1) {
|
|
|
|
|
|
return '20%'
|
|
|
|
|
|
} else if (index === 2) {
|
|
|
|
|
|
return '35%'
|
|
|
|
|
|
} else if (index === 3) {
|
|
|
|
|
|
return '15%'
|
2022-08-09 11:46:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-08-24 11:54:09 +08:00
|
|
|
|
|
2022-08-09 11:46:48 +08:00
|
|
|
|
},
|
2022-08-08 22:13:31 +08:00
|
|
|
|
computed: {
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|