2022-07-29 09:55:58 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="npm-recent">
|
|
|
|
|
<div class="npm-recent-title">{{ $t('network.recentEvents') }}</div>
|
|
|
|
|
<el-table
|
|
|
|
|
:id="`tabTable_${index}`"
|
|
|
|
|
:ref="`dataTable_${index}`"
|
|
|
|
|
:data="tableData"
|
|
|
|
|
class="npm-recent-table"
|
|
|
|
|
height="100%"
|
|
|
|
|
>
|
|
|
|
|
<template v-for="(item, index) in customTableTitles" :key="index">
|
|
|
|
|
<el-table-column class="data-column">
|
|
|
|
|
<template #header>
|
|
|
|
|
<span class="data-column__span">{{$t(item.label)}}</span>
|
|
|
|
|
</template>
|
|
|
|
|
<template #default="scope" :column="item">
|
|
|
|
|
<div class="data-recent-table">
|
2022-08-11 16:45:48 +08:00
|
|
|
<template v-if="item.prop === 'eventSeverity'">
|
|
|
|
|
<span class="data-recent-table-severity" :class="scope.row[item.prop]">{{$t(scope.row[item.prop])}}</span>
|
2022-07-29 09:55:58 +08:00
|
|
|
</template>
|
2022-08-11 16:45:48 +08:00
|
|
|
<template v-else-if="item.prop === 'eventKey'">
|
2022-07-29 09:55:58 +08:00
|
|
|
<span class="data-recent-table-entity">{{$t(scope.row[item.prop])}}</span>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else-if="item.prop === 'eventType'">
|
|
|
|
|
<span class="data-recent-table-eventType">{{$t(scope.row[item.prop])}}</span>
|
|
|
|
|
</template>
|
|
|
|
|
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
|
|
|
|
|
<span v-else>-</span>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</template>
|
2022-08-12 15:25:54 +08:00
|
|
|
<template v-slot:empty>
|
2022-08-23 21:42:42 +08:00
|
|
|
<div class="table-no-data" v-show="isNoData">
|
2022-08-12 15:25:54 +08:00
|
|
|
<svg class="icon" aria-hidden="true">
|
|
|
|
|
<use xlink:href="#cn-icon-a-allclear"></use>
|
|
|
|
|
</svg>
|
|
|
|
|
<div class="table-no-data__title">{{ $t('npm.thereNoEvents') }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
2022-07-29 09:55:58 +08:00
|
|
|
</el-table>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-08-11 16:45:48 +08:00
|
|
|
import { get } from '@/utils/http'
|
|
|
|
|
import { api } from '@/utils/api'
|
|
|
|
|
import { getSecond } from '@/utils/date-util'
|
2022-08-21 22:11:53 +08:00
|
|
|
import chartMixin from '@/views/charts2/chart-mixin'
|
2022-08-24 16:58:34 +08:00
|
|
|
import _ from 'lodash'
|
2022-08-11 16:45:48 +08:00
|
|
|
|
2022-07-29 09:55:58 +08:00
|
|
|
export default {
|
|
|
|
|
name: 'NpmRecentEvents',
|
2022-08-21 22:11:53 +08:00
|
|
|
mixins: [chartMixin],
|
2022-07-29 09:55:58 +08:00
|
|
|
data () {
|
|
|
|
|
return {
|
2022-08-11 16:45:48 +08:00
|
|
|
tableData: [],
|
2022-07-29 09:55:58 +08:00
|
|
|
customTableTitles: [
|
2022-08-11 16:45:48 +08:00
|
|
|
{ label: 'network.severity', prop: 'eventSeverity' },
|
|
|
|
|
{ label: 'network.entity', prop: 'eventKey' },
|
2022-07-29 09:55:58 +08:00
|
|
|
{ label: 'detections.eventType', prop: 'eventType' }
|
2022-08-24 16:58:34 +08:00
|
|
|
]
|
2022-08-24 12:28:23 +08:00
|
|
|
}
|
|
|
|
|
},
|
2022-08-11 16:45:48 +08:00
|
|
|
methods: {
|
|
|
|
|
recentEventsListData () {
|
2022-08-24 16:58:34 +08:00
|
|
|
const condition = this.$store.getters.getQueryCondition.split(/["|'](.*?)["|']/)
|
|
|
|
|
const type = this.$store.getters.getDimensionType
|
|
|
|
|
let url = ''
|
2022-08-11 16:45:48 +08:00
|
|
|
const params = {
|
|
|
|
|
startTime: getSecond(this.timeFilter.startTime),
|
|
|
|
|
endTime: getSecond(this.timeFilter.endTime),
|
2022-08-12 15:25:54 +08:00
|
|
|
limit: 8
|
2022-07-29 09:55:58 +08:00
|
|
|
}
|
2022-08-24 16:58:34 +08:00
|
|
|
if (condition.length > 1 && type) {
|
|
|
|
|
params.param = condition[1]
|
|
|
|
|
params.type = type
|
|
|
|
|
params.limit = 10
|
|
|
|
|
url = api.npm.events.recentEventsD
|
|
|
|
|
} else {
|
|
|
|
|
url = api.npm.events.recentEvents
|
|
|
|
|
}
|
2022-08-21 22:11:53 +08:00
|
|
|
this.toggleLoading(true)
|
2022-08-24 16:58:34 +08:00
|
|
|
get(url, params).then(res => {
|
2022-08-11 16:45:48 +08:00
|
|
|
if (res.code === 200) {
|
2022-08-24 16:58:34 +08:00
|
|
|
if (res.data.result.length === 0) {
|
2022-08-21 22:11:53 +08:00
|
|
|
this.isNoData = true
|
|
|
|
|
}
|
2022-08-11 16:45:48 +08:00
|
|
|
this.tableData = res.data.result
|
2022-08-21 22:11:53 +08:00
|
|
|
} else {
|
|
|
|
|
this.isNoData = true
|
2022-08-11 16:45:48 +08:00
|
|
|
}
|
2022-08-21 22:11:53 +08:00
|
|
|
}).finally(() => {
|
|
|
|
|
this.toggleLoading(false)
|
2022-08-11 16:45:48 +08:00
|
|
|
})
|
2022-07-29 09:55:58 +08:00
|
|
|
}
|
2022-08-11 16:45:48 +08:00
|
|
|
},
|
|
|
|
|
mounted () {
|
|
|
|
|
this.recentEventsListData()
|
2022-07-29 09:55:58 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|