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

127 lines
3.7 KiB
Vue
Raw Normal View History

2022-02-14 22:22:31 +08:00
<template>
2022-02-18 17:54:22 +08:00
<div class="detection-list" id="detectionList">
<loading :loading="loading"></loading>
2022-02-18 17:54:22 +08:00
<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>
2022-02-14 22:22:31 +08:00
<detection-row
style="margin-bottom: 10px"
class="detection-border"
v-for="(data, index) in myListData"
2022-02-14 22:22:31 +08:00
:detection="data"
:page-type="pageType"
2022-02-14 22:22:31 +08:00
:timeFilter="timeFilter"
:key="index"
:pageObj="pageObj"
2022-02-14 22:22:31 +08:00
:ref="`detectionRow${index}`"
:index="index"
@switchCollapse="switchCollapse"
></detection-row>
</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'
2022-02-14 22:22:31 +08:00
export default {
name: 'DetectionList',
components: {
Loading,
2022-02-14 22:22:31 +08:00
DetectionRow
},
props: {
listData: Array,
from: String,
pageObj: Object,
loading: Boolean,
timeFilter: Object,
pageType: String // 安全事件、服务质量
2022-02-14 22:22:31 +08:00
},
data () {
return {
showDetail: false,
typeName: '',
detectionList: [],
isCollapse: true,
collapseIndex: 0,
tableId: 'detectionList',
listDataCopy: [],
noData: true,
myListData: [] // listData的克隆避免因为修改listData里的malWareName而触发watch监听
2022-02-14 22:22:31 +08:00
}
},
mounted () {
// 监听⿏标滚动事件
window.addEventListener('mousewheel', this.handleScroll)
},
unmounted () {
window.removeEventListener('mousewheel', this.handleScroll)
},
2022-02-14 22:22:31 +08:00
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 => {
2023-10-22 18:29:34 +08:00
console.error(e)
})
}
})
},
2022-02-14 22:22:31 +08:00
switchCollapse (isCollapse, index) {
this.isCollapse = isCollapse
this.collapseIndex = index
if (isCollapse) {
this.emitter.emit('switch-collapse')
}
2022-02-14 22:22:31 +08:00
},
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
}
2022-02-14 22:22:31 +08:00
}
},
watch: {
listData: {
immediate: true,
2022-02-14 22:22:31 +08:00
deep: true,
handler (n) {
if (!n || n.length === 0) {
this.timeout = setTimeout(() => {
this.noData = true
2023-10-22 18:29:34 +08:00
this.myListData = []
2022-02-14 22:22:31 +08:00
}, 500)
} else {
clearTimeout(this.timeout)
this.noData = false
this.initData()
2022-02-14 22:22:31 +08:00
}
}
}
}
}
</script>