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/entityExplorer/entityList/Row.vue

327 lines
13 KiB
Vue
Raw Normal View History

<template>
<div class="cn-entity--list" :style="{ zIndex: !isCollapse ? 1 : 'unset' }">
2021-12-16 18:22:47 +08:00
<!-- 左侧下拉按钮 -->
<div class="cn-entity__collapse">
2023-04-27 16:53:12 +08:00
<span @click="switchCollapse" :class="{ 'reg-down': !isCollapse }">
<i class="cn-icon cn-icon-arrow-right"></i>
</span>
2021-12-16 18:22:47 +08:00
</div>
<div class="cn-entity__case">
<div class="cn-entity__icon"><i :class="iconClass"></i></div>
<div class="cn-entity__row">
2023-07-07 17:22:51 +08:00
<!--标签-->
<div class="cn-entity__header" style="display: flex;">
2023-07-07 17:22:51 +08:00
<span class="cn-entity__header-title">{{ entityData.entityValue || 'Unknown' }}</span>
<span class="entity-detail" style="display: flex;margin-left: 6px;margin-top: 1px;flex-wrap: wrap;margin-bottom: -10px;">
<span v-for="(item, index) in levelTwoTags" :key="index" class="entity-tag entity-tag--small margin-r-10 margin-b-10" :class="`entity-tag--level-two-${item.type}`">
2023-07-07 17:22:51 +08:00
{{ item.value }}
</span>
</span>
</div>
2023-07-07 17:22:51 +08:00
2021-12-16 18:22:47 +08:00
<div class="cn-entity__body">
<div class="body__basic-info">
<div class="basic-info">
<template v-if="entityData.entityType === 'ip'">
<div class="basic-info__item">
<i class="cn-icon cn-icon-country"></i>
2023-07-07 17:22:51 +08:00
<span class="row-item-label">{{ $t('overall.country') }}&nbsp;:&nbsp;&nbsp;</span>
<span class="row-item-value">{{ $_.get(entityData, 'location.country', '-') || '-' }}</span>
2021-12-16 18:22:47 +08:00
</div>
<div class="basic-info__item">
<i class="cn-icon cn-icon-position"></i>
2023-08-18 09:32:58 +08:00
<span class="row-item-label">{{ $t('overall.city') }}&nbsp;:&nbsp;&nbsp;</span>
2023-07-07 17:22:51 +08:00
<span class="row-item-value">{{ entityData.location ? ipLocationRegion(entityData.location) : '-' }}</span>
2021-12-16 18:22:47 +08:00
</div>
<div class="basic-info__item">
<i class="cn-icon cn-icon-cloud"></i>
2023-07-07 17:22:51 +08:00
<span class="row-item-label">{{ $t('entities.asn') }}&nbsp;:&nbsp;&nbsp;</span>
<span class="row-item-value">{{ $_.get(entityData, 'asn.asn', '-') || '-' }}</span>
2021-12-16 18:22:47 +08:00
</div>
</template>
<template v-else-if="entityData.entityType === 'domain'">
<div class="basic-info__item">
<i class="cn-icon cn-icon-category-group"></i>
2023-07-07 17:22:51 +08:00
<span class="row-item-label">{{ $t('entities.category') }}&nbsp;:&nbsp;&nbsp;</span>
<span class="row-item-value">{{ $_.get(entityData, 'category.categoryGroup', '-') || '-' }}</span>
2021-12-16 18:22:47 +08:00
</div>
<div class="basic-info__item">
<i class="cn-icon cn-icon-sub-category"></i>
2023-07-07 17:22:51 +08:00
<span class="row-item-label">{{ $t('entities.subcategory') }}&nbsp;:&nbsp;&nbsp;</span>
<span class="row-item-value">{{ $_.get(entityData, 'category.categoryName', '-') || '-' }}</span>
2021-12-16 18:22:47 +08:00
</div>
<div class="basic-info__item">
<i class="cn-icon cn-icon-credit-rating"></i>
2023-07-07 17:22:51 +08:00
<span class="row-item-label">{{ $t('entities.reputationLevel') }}&nbsp;:&nbsp;&nbsp;</span>
<span class="row-item-value">{{ $_.get(entityData, 'category.reputationLevel', '-') || '-' }}</span>
2021-12-16 18:22:47 +08:00
</div>
</template>
<template v-else-if="entityData.entityType === 'app'">
<div class="basic-info__item">
<i class="cn-icon cn-icon-category2"></i>
2023-07-07 17:22:51 +08:00
<span class="row-item-label">{{ $t('entities.category') }}&nbsp;:&nbsp;&nbsp;</span>
<span class="row-item-value">{{ $_.get(entityData, 'category.appCategory', '-') || '-' }}</span>
2021-12-16 18:22:47 +08:00
</div>
<div class="basic-info__item">
<i class="cn-icon cn-icon-sub-category"></i>
2023-07-07 17:22:51 +08:00
<span class="row-item-label">{{ $t('entities.subcategory') }}&nbsp;:&nbsp;&nbsp;</span>
<span class="row-item-value">{{ $_.get(entityData, 'category.appSubcategory', '-') || '-' }}</span>
2021-12-16 18:22:47 +08:00
</div>
<div class="basic-info__item">
<i class="cn-icon cn-icon-credit-rating"></i>
2023-07-07 17:22:51 +08:00
<span class="row-item-label">{{ $t('entities.risk') }}&nbsp;:&nbsp;&nbsp;</span>
<span class="row-item-value">{{ entityData.category ? appRisk(entityData.category.appRisk) : '-' }}</span>
2021-12-16 18:22:47 +08:00
</div>
</template>
<!-- 通用字段 -->
<div class="basic-info__item">
<div class="item__box">
<i class="cn-icon cn-icon-rise"></i>
2023-07-07 17:22:51 +08:00
<span class="row-item-label">{{ $t('entities.sentThroughput') }}&nbsp;:&nbsp;&nbsp;</span>
<span class="row-item-value">
2023-04-27 16:53:12 +08:00
{{
valueToRangeValue(entityData.bytesSentRate, unitTypes.bps).join(' ') !=='- ' ? valueToRangeValue(entityData.bytesSentRate, unitTypes.bps).join(' ') : '-'
2023-04-27 16:53:12 +08:00
}}
</span>
<!-- 曲线-->
<div class="item-box-loading">
2022-05-26 17:14:00 +08:00
<loading :loading="loading" size="small"></loading>
<div
class="row__charts"
:id="`entityDetailSend${entityType}${listMode}`"
2023-04-27 16:53:12 +08:00
v-if="entityData.entityType === 'domain'">
</div>
<div
class="row__charts"
:id="`entityDetailSend${entityType}${listMode}`"
2023-04-27 16:53:12 +08:00
v-if="entityData.entityType === 'app'">
</div>
<div
class="row__charts"
:id="`entityDetailSend${entityType}${listMode}`"
2023-04-27 16:53:12 +08:00
v-if="entityData.entityType === 'ip'">
</div>
</div>
</div>
2021-12-16 18:22:47 +08:00
</div>
2021-12-16 18:22:47 +08:00
<div class="basic-info__item">
<div class="item__box">
<i class="cn-icon cn-icon-fall"></i>
2023-07-07 17:22:51 +08:00
<span class="row-item-label">{{ $t('entities.receivedThroughput') }}&nbsp;:&nbsp;&nbsp;</span>
<span class="row-item-value">
{{ valueToRangeValue(entityData.bytesReceivedRate, unitTypes.bps).join(' ') !== '- ' ? valueToRangeValue(entityData.bytesReceivedRate, unitTypes.bps).join(' ') : '-' }}
2023-04-27 16:53:12 +08:00
</span>
<div class="item-box-loading">
2022-05-26 17:14:00 +08:00
<loading :loading="loading" size="small"></loading>
<div
2023-04-27 16:53:12 +08:00
class="row__charts"
:id="`entityDetailReceived${entityType}${listMode}`"
v-if="entityData.entityType === 'domain'">
</div>
<div
2023-04-27 16:53:12 +08:00
class="row__charts"
:id="`entityDetailReceived${entityType}${listMode}`"
v-if="entityData.entityType === 'app'">
</div>
<div
2023-04-27 16:53:12 +08:00
class="row__charts"
:id="`entityDetailReceived${entityType}${listMode}`"
v-if="entityData.entityType === 'ip'">
</div>
</div>
</div>
2021-12-16 18:22:47 +08:00
</div>
<!--score分数-->
<div class="basic-info__item" style="display: flex;align-items: center;">
<i class="cn-icon cn-icon-Score"></i>
<div class="row-item-label">
<span class="row-item-label">{{ $t('network.score') }}&nbsp;:&nbsp;&nbsp;</span>
<span class="row-item-value" style="position: relative;">
<span v-if="!loadingNetworkQuality">{{ score }}</span>
<loading :loading="loadingNetworkQuality" size="small"></loading>
</span>
</div>
</div>
<!--事件数量即Performance和security事件总和-->
<div class="basic-info__item" style="position: relative">
<div v-if="eventNum>0 && !loadingEvent" style="display: flex;align-items: center;">
<i class="cn-icon cn-icon-Event1"></i>
<div class="row-item-label">
<span class="row-item-label">{{ $t('dnsInsight.event') }}&nbsp;:&nbsp;&nbsp;</span>
<span class="row-item-value">{{ eventNum }}</span>
</div>
</div>
<!-- <loading :loading="loadingEvent" size="small" style="width: 90px"></loading>-->
</div>
2021-12-16 18:22:47 +08:00
</div>
</div>
</div>
</div>
<div class="new-show-detail">
<div @click="showDetail"><i class="cn-icon cn-icon-detail"></i>{{ $t('overall.detail') }} ></div>
<div @click="showGraph"><i class="cn-icon cn-icon-graph"></i>{{ $t('entities.graph') }} ></div>
</div>
<el-collapse-transition>
2022-01-11 11:20:17 +08:00
<div class="cn-entity__detail-overview" v-if="!isCollapse">
<el-divider></el-divider>
<detail-overview :entity="entityData" :time-filter="timeFilter" @reloadEntity="getEntity" />
</div>
</el-collapse-transition>
2021-12-16 18:22:47 +08:00
</div>
</div>
</template>
<script>
import DetailOverview from '@/views/entityExplorer/entityList/detailOverview/DetailOverview'
2022-03-27 13:04:47 +08:00
import entityListMixin from './entityListMixin'
import relatedServer from '@/mixins/relatedServer'
import Loading from '@/components/common/Loading'
2023-07-07 17:22:51 +08:00
import axios from 'axios'
import { api } from '@/utils/api'
import { entityDetailTags, psiphon3IpType } from '@/utils/constants'
import _ from 'lodash'
export default {
2021-12-16 18:22:47 +08:00
name: 'Row',
2021-12-17 20:56:25 +08:00
props: {
2021-12-31 10:40:37 +08:00
index: Number,
2022-03-27 13:04:47 +08:00
timeFilter: Object,
listMode: String
2021-12-17 20:56:25 +08:00
},
components: {
Loading,
DetailOverview
},
2022-03-27 13:04:47 +08:00
mixins: [entityListMixin, relatedServer],
data () {
2021-12-16 23:03:39 +08:00
return {
loading: false,
2023-07-07 17:22:51 +08:00
isCollapse: true, // 是否是折叠状态
levelTwoTags: [],
loadingNetworkQuality: false // 分数的loading
2021-12-16 23:03:39 +08:00
}
},
computed: {
ipLocationRegion () {
return function (entityData) {
const hasProvinceAndCity =
2023-07-07 17:22:51 +08:00
entityData.province &&
entityData.city &&
entityData.province !== 'null' &&
entityData.city !== 'null'
const hasProvince =
2023-07-07 17:22:51 +08:00
entityData.province &&
entityData.province !== 'null'
const hasCity =
2023-07-07 17:22:51 +08:00
entityData.city && entityData.city !== 'null'
if (hasProvinceAndCity) {
2023-07-07 17:22:51 +08:00
return `${entityData.province}, ${entityData.city}`
} else if (hasProvince) {
2023-07-07 17:22:51 +08:00
return entityData.province
} else if (hasCity) {
2023-07-07 17:22:51 +08:00
return entityData.city
} else {
return '-'
}
}
}
},
2023-07-07 17:22:51 +08:00
mounted () {
setTimeout(() => {
this.initData()
}, 1000)
setTimeout(() => {
this.initTagsData()
})
2023-07-07 17:22:51 +08:00
},
2021-12-16 23:03:39 +08:00
methods: {
2023-07-07 17:22:51 +08:00
initData () {
let url = ''
switch (this.entity.entityType) {
case ('domain'): {
url = api.entity.entityList.domainBasicInfo
break
}
case ('ip'): {
url = api.entity.entityList.ipBasicInfo
break
}
case ('app'): {
url = api.entity.entityList.appBasicInfo
break
}
}
axios.get(`${url}?resource=${this.entity.entityValue}`).then(response => {
this.$nextTick(() => {
this.entityData = { ...this.entityData, ...response.data.data, ...this.entity }
2023-07-07 17:22:51 +08:00
})
})
},
initTagsData () {
let url = ''
switch (this.entity.entityType) {
case ('domain'): {
url = api.entity.entityList.domainTags
break
}
case ('ip'): {
url = api.entity.entityList.ipTags
break
}
case ('app'): {
url = api.entity.entityList.appTags
break
}
}
axios.get(`${url}?resource=${this.entity.entityValue}`).then(responese => {
const res = responese.data
if (responese.status === 200) {
2023-07-07 17:22:51 +08:00
Object.keys(res.data).forEach(k => {
if (k !== 'userDefinedTags' && res.data[k]) {
Object.keys(res.data[k]).forEach(k2 => {
const find = entityDetailTags[this.entity.entityType].find(t => t.name === k2)
if (find) {
this.levelTwoTags.push({ key: k2, value: this.tagValueHandler(k, k2, res.data[k][k2]), type: find.type })
}
})
}
})
if (_.isArray(res.data.userDefinedTags)) {
this.levelTwoTags = _.concat(this.levelTwoTags, res.data.userDefinedTags.map(tag => ({ value: tag.tagValue, type: 'normal' })))
}
this.hideTagArea = _.isEmpty(this.levelTwoTags)
}
})
},
tagValueHandler (k, k2, value) {
if (k === 'psiphon3Ip') {
if (k2 === 'type') {
const find = psiphon3IpType.find(t => t.value === value)
if (find) {
return find.name
}
}
}
return value
},
/* 切换折叠状态 */
switchCollapse () {
2021-12-16 23:03:39 +08:00
this.isCollapse = !this.isCollapse
this.$emit('switchCollapse', this.isCollapse, this.index)
2021-12-17 20:56:25 +08:00
},
/* 设为折叠状态 */
collapse () {
this.isCollapse = true
},
getEntity (data) {
this.entityData = { ...data }
}
}
}
</script>