This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
cyber-narrator-cn-ui/src/views/detections/DetectionList.vue
2024-08-23 16:11:07 +08:00

152 lines
4.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="detection-list" id="detectionList">
<loading :loading="loading"></loading>
<div class="detection-list__content">
<div class="detection-list--list">
<div class="no-data" v-if="myListData.length===0">{{ $t('npm.noData') }}</div>
<div v-if="!isCollapse" @click="collapse" class="cn-detection__shadow new-cn-detection__shadow"></div>
<template v-if="eventFlag===detectionEventType.single">
<detection-row
class="detection-border margin-b-10"
v-for="(data, index) in myListData"
:detection="data"
:page-type="pageType"
:timeFilter="timeFilter"
:key="data.eventId"
:pageObj="pageObj"
:eventFlag="eventFlag"
:ref="`detectionRow${index}`"
:index="index"
@switchCollapse="switchCollapse"
:q="q"
></detection-row>
</template>
<template v-if="eventFlag===detectionEventType.aggregation">
<detection-row-events
class="detection-border margin-b-10"
v-for="(data, index) in myListData"
:detection="data"
:page-type="pageType"
:timeFilter="timeFilter"
:eventFlag="eventFlag"
:key="data.eventId"
:pageObj="pageObj"
:ref="`detectionRow${index}`"
:index="index"
:q="q"
@switchCollapse="switchCollapse"
></detection-row-events>
</template>
</div>
</div>
</div>
</template>
<script>
import DetectionRow from '@/views/detections/DetectionRow'
import Loading from '@/components/common/Loading'
import axios from 'axios'
import { api } from '@/utils/api'
import DetectionRowEvents from '@/views/detections/DetectionRowEvents'
import { detectionEventType } from '@/utils/constants'
export default {
name: 'DetectionList',
components: {
Loading,
DetectionRow,
DetectionRowEvents
},
props: {
listData: Array,
from: String,
pageObj: Object,
loading: Boolean,
timeFilter: Object,
pageType: String, // 安全事件、服务质量
eventFlag: String, // 事件标识,单独/聚合
q: String
},
data () {
return {
showDetail: false,
typeName: '',
detectionList: [],
isCollapse: true,
collapseIndex: 0,
tableId: 'detectionList',
listDataCopy: [],
noData: true,
myListData: [], // listData的克隆避免因为修改listData里的malWareName而触发watch监听
detectionEventType
}
},
mounted () {
// 监听⿏标滚动事件
window.addEventListener('mousewheel', this.handleScroll)
},
unmounted () {
window.removeEventListener('mousewheel', this.handleScroll)
},
methods: {
initData () {
this.myListData = []
this.listData.forEach((item, i) => {
this.myListData.push(this.$_.cloneDeep(item))
if (item.eventInfoObj && item.isBuiltin == 1) {
axios.get(`${api.detection.securityEvent.detail}/${item.eventInfoObj.ioc_type.toLowerCase()}?resource=${item.eventInfoObj.ioc_value}`).then(res => {
if (res.status === 200) {
if (item.eventType === 'Anonymity') {
this.myListData[i].darkweb = this.$_.get(res, 'data.data.darkweb', {}) || {}
} else if (item.eventType === 'Command and Control') {
this.myListData[i].malware = this.$_.get(res, 'data.data.malware', {}) || {}
}
}
}).catch(e => {
console.error(e)
})
}
})
},
switchCollapse (isCollapse, index) {
this.isCollapse = isCollapse
this.collapseIndex = index
if (isCollapse) {
this.emitter.emit('switch-collapse')
}
},
collapse () {
this.isCollapse = true
if (this.$refs[`detectionRow${this.collapseIndex}`] && this.$refs[`detectionRow${this.collapseIndex}`].collapse) {
this.$refs[`detectionRow${this.collapseIndex}`].collapse()
} else {
this.$refs[`detectionRow${this.collapseIndex}`][0].collapse()
}
},
handleScroll (e) {
if (e.target.className === 'cn-detection__shadow') {
const container = document.getElementById('cnContainer')
container.scrollTop += e.deltaY / 2
}
}
},
watch: {
listData: {
immediate: true,
deep: true,
handler (n) {
if (!n || n.length === 0) {
this.timeout = setTimeout(() => {
this.noData = true
this.myListData = []
}, 500)
} else {
clearTimeout(this.timeout)
this.noData = false
this.initData()
}
}
}
}
}
</script>