2021-12-14 16:42:45 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="explorer-search">
|
|
|
|
|
<div class="explorer-search__title" v-show="!showList">{{$t('search.title')}}</div>
|
|
|
|
|
<div class="explorer-search__input-case" :class="{'explorer-search__input-case--question-mark-in-line': showList}">
|
|
|
|
|
<div class="explorer-search__input">
|
|
|
|
|
<advanced-search
|
2021-12-31 10:55:49 +08:00
|
|
|
ref="search"
|
2022-01-23 23:34:51 +08:00
|
|
|
:column-list="columnList"
|
|
|
|
|
:operator-list="operatorList"
|
|
|
|
|
:connection-list="connectionList"
|
|
|
|
|
:full-text="true"
|
|
|
|
|
:class="{'advanced-search--show-list': showList}"
|
2021-12-14 16:42:45 +08:00
|
|
|
@search="search"
|
|
|
|
|
></advanced-search>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="search-symbol-inline" v-if="showList">
|
|
|
|
|
<i class="cn-icon cn-icon-help"></i>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else class="explorer-search__foot">
|
2022-01-26 17:44:24 +08:00
|
|
|
<div class="foot__item" @click="triggerHistory">
|
|
|
|
|
<i class="el-icon-arrow-right" :class="{ 'arrow-rotate': showHistory }" style="padding-right: 5px;"></i>
|
2021-12-14 16:42:45 +08:00
|
|
|
<span>{{$t('search.searchHistory')}}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="foot__item">
|
2022-01-25 22:58:23 +08:00
|
|
|
<span @click="search">{{$t('overall.explore')}}</span>
|
2021-12-14 16:42:45 +08:00
|
|
|
<el-divider direction="vertical"></el-divider>
|
|
|
|
|
<span>{{$t('overall.help')}}</span>
|
|
|
|
|
</div>
|
2022-01-26 17:44:24 +08:00
|
|
|
<transition name="el-zoom-in-top">
|
|
|
|
|
<div class="search__history" v-show="showHistory" v-ele-click-outside="esc">
|
|
|
|
|
<div class="history__item" v-for="(h, i) in history" :key="i" @click="selectHistory(h.sql)">
|
|
|
|
|
<span class="item-date">{{h.date}}</span>
|
|
|
|
|
<div class="item-value" :title="h.sql">{{h.sql}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="history__item clear-all">
|
|
|
|
|
<span @click="clearHistory" v-if="!$_.isEmpty(history)">{{$t('overall.clear')}}</span>
|
|
|
|
|
<div v-else>暂无记录</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</transition>
|
2021-12-14 16:42:45 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-01-23 23:34:51 +08:00
|
|
|
import AdvancedSearch from '@/components/advancedSearch/Index'
|
2022-01-25 22:58:23 +08:00
|
|
|
import { columnType } from '@/components/advancedSearch/meta/meta'
|
|
|
|
|
import SqlParser from '@/components/advancedSearch/meta/sql-parser'
|
2022-01-26 17:44:24 +08:00
|
|
|
import {storageKey} from "@/utils/constants";
|
2021-12-14 16:42:45 +08:00
|
|
|
export default {
|
|
|
|
|
name: 'CnSearch',
|
|
|
|
|
components: {
|
|
|
|
|
AdvancedSearch
|
|
|
|
|
},
|
|
|
|
|
props: {
|
|
|
|
|
showList: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: true
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-01-23 23:34:51 +08:00
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
columnList: [
|
|
|
|
|
{
|
|
|
|
|
name: 'entity_type',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: this.$t('overall.type')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'ip_addr',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: 'IP'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'ip_location_country',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: this.$t('overall.country')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'ip_location_province',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: this.$t('overall.province')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'ip_location_city',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: this.$t('overall.city')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'ip_asn',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: this.$t('entities.asn')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'ip_os',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: 'OS'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'domain_name',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: 'Domain'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'domain_category',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: this.$t('entities.domainCategory')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'domain_category_group',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: this.$t('entities.domainDetail.categoryGroup')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'domain_reputation_score',
|
|
|
|
|
type: 'long',
|
|
|
|
|
label: this.$t('entities.domainDetail.reputationValue')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'domain_reputation_level',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: this.$t('entities.reputationLevel')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'domain_whois_email',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: 'Domain whois email'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'domain_whois_name_servers',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: 'Domain whois ns'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'domain_whois_registrar',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: 'Domain whois registrar'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'domain_whois_org',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: 'Domain whois organization'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'domain_whois_city',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: 'Domain whois city'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'domain_whois_state',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: 'Domain whois state'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'domain_whois_country',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: 'Domain whois country'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'app_name',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: 'App'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'app_category',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: this.$t('trafficSummary.appCategory')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'app_subcategory',
|
|
|
|
|
type: 'string',
|
|
|
|
|
label: this.$t('entities.domainDetail.appSubcategory')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'app_risk',
|
|
|
|
|
type: 'long',
|
|
|
|
|
label: this.$t('trafficSummary.appRisk')
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
operatorList: ['=', '!=', '>', '<', '>=', '<='/* , 'IN', 'NOT IN', 'LIKE', 'NOT LIKE' */],
|
|
|
|
|
connectionList: [
|
|
|
|
|
{
|
|
|
|
|
value: 'AND',
|
|
|
|
|
label: 'AND'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 'OR',
|
|
|
|
|
label: 'OR'
|
|
|
|
|
}
|
2022-01-26 17:44:24 +08:00
|
|
|
],
|
|
|
|
|
showHistory: false,
|
|
|
|
|
history: []
|
2022-01-23 23:34:51 +08:00
|
|
|
}
|
|
|
|
|
},
|
2021-12-14 16:42:45 +08:00
|
|
|
methods: {
|
2022-01-25 19:47:08 +08:00
|
|
|
search (metaList, formatSql) {
|
2022-01-25 22:58:23 +08:00
|
|
|
let sql = formatSql
|
|
|
|
|
if (metaList) {
|
|
|
|
|
// 全文搜索处理
|
|
|
|
|
const hasFullText = metaList.some(meta => {
|
|
|
|
|
return meta.column && meta.column.type === columnType.fullText
|
|
|
|
|
})
|
|
|
|
|
if (hasFullText) {
|
|
|
|
|
const parser = new SqlParser(metaList, this.columnList)
|
|
|
|
|
sql = parser.parseMetaToSql(metaList, true)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.$emit('search', metaList, sql)
|
2022-01-26 17:44:24 +08:00
|
|
|
// 加入搜索记录
|
|
|
|
|
if (sql) {
|
|
|
|
|
const oldHistory = localStorage.getItem(storageKey.entitySearchHistory)
|
|
|
|
|
let arr = []
|
|
|
|
|
const newItem = { sql, date: window.$dayJs.tz(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss') }
|
|
|
|
|
if (!this.$_.isEmpty(oldHistory)) {
|
|
|
|
|
const oldArr = JSON.parse(oldHistory)
|
|
|
|
|
oldArr.unshift(newItem)
|
|
|
|
|
arr = [...oldArr]
|
|
|
|
|
} else {
|
|
|
|
|
arr.push(newItem)
|
|
|
|
|
}
|
|
|
|
|
localStorage.setItem(storageKey.entitySearchHistory, JSON.stringify(arr))
|
|
|
|
|
}
|
2021-12-31 10:55:49 +08:00
|
|
|
},
|
|
|
|
|
addParams (params) {
|
|
|
|
|
this.$refs.search.addParams(params)
|
2022-01-26 17:44:24 +08:00
|
|
|
},
|
|
|
|
|
selectHistory (sql) {
|
|
|
|
|
this.$refs.search.setSql(sql)
|
|
|
|
|
this.showHistory = false
|
|
|
|
|
},
|
|
|
|
|
clearHistory () {
|
|
|
|
|
localStorage.setItem(storageKey.entitySearchHistory, '')
|
|
|
|
|
this.history = []
|
|
|
|
|
},
|
|
|
|
|
triggerHistory () {
|
|
|
|
|
this.showHistory = !this.showHistory
|
|
|
|
|
if (this.showHistory) {
|
|
|
|
|
const history = localStorage.getItem(storageKey.entitySearchHistory)
|
|
|
|
|
if (!this.$_.isEmpty(history)) {
|
|
|
|
|
this.history = JSON.parse(history)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
esc () {
|
|
|
|
|
this.showHistory = false
|
2021-12-14 16:42:45 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|