2022-02-14 22:22:31 +08:00
|
|
|
|
<template>
|
2022-02-15 23:27:55 +08:00
|
|
|
|
<div class="explorer-search explorer-search--show-list">
|
2023-11-15 15:26:37 +08:00
|
|
|
|
<div class="explorer-search__input-case explorer-search__input-case--question-mark-in-line" style="position: relative">
|
|
|
|
|
|
<div class="explorer-search__input entity__search">
|
2022-02-14 22:22:31 +08:00
|
|
|
|
<advanced-search
|
|
|
|
|
|
ref="search"
|
2022-05-11 17:50:40 +08:00
|
|
|
|
:column-list="columnList[pageType]"
|
2022-02-14 22:22:31 +08:00
|
|
|
|
:connection-list="connectionList"
|
2023-10-24 18:11:17 +08:00
|
|
|
|
:default-mode="defaultMode"
|
2022-02-14 22:22:31 +08:00
|
|
|
|
class="advanced-search--show-list"
|
2023-10-20 15:45:11 +08:00
|
|
|
|
:full-text="true"
|
|
|
|
|
|
:show-list="showList"
|
2022-02-14 22:22:31 +08:00
|
|
|
|
@search="search"
|
|
|
|
|
|
></advanced-search>
|
|
|
|
|
|
</div>
|
2023-11-15 15:26:37 +08:00
|
|
|
|
<div class="explorer-search__foot-list" style="margin-top: -2px;" v-ele-click-outside="esc">
|
|
|
|
|
|
<div style="position: absolute;" class="explorer-search__block" @click="triggerHistory">
|
|
|
|
|
|
<i class="cn-icon cn-icon-time"></i>
|
|
|
|
|
|
<div class="search-dividing-line"></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<transition name="el-zoom-in-top">
|
|
|
|
|
|
<div class="search__history" v-if="showHistory">
|
|
|
|
|
|
<div class="history__items-new">
|
|
|
|
|
|
<el-table
|
|
|
|
|
|
:data="history"
|
|
|
|
|
|
scrollbar-always-on="false"
|
|
|
|
|
|
@row-click="selectHistory"
|
|
|
|
|
|
style="overflow-x: unset"
|
2023-11-16 17:29:54 +08:00
|
|
|
|
empty-text=""
|
2023-11-15 15:26:37 +08:00
|
|
|
|
>
|
2023-11-16 17:29:54 +08:00
|
|
|
|
<el-table-column prop="str" :label="$t('overall.expression')" min-width="560" />
|
|
|
|
|
|
<el-table-column prop="date" :label="$t('overall.time')" sortable width="200">
|
2023-11-15 15:26:37 +08:00
|
|
|
|
<template #default="scope">
|
|
|
|
|
|
<span>{{ changeTimeByDate(scope.row.date) }}</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="clear-all">
|
|
|
|
|
|
<span @click="clearHistory" v-if="!$_.isEmpty(history)">{{$t('entity.clearAll')}}</span>
|
|
|
|
|
|
<div v-else>{{$t('overall.noRecords')}}</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
</div>
|
2023-10-20 15:45:11 +08:00
|
|
|
|
<!-- <div class="search-symbol-inline">-->
|
|
|
|
|
|
<!-- <i class="cn-icon cn-icon-help"></i>-->
|
|
|
|
|
|
<!-- </div>-->
|
2022-02-14 22:22:31 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import AdvancedSearch from '@/components/advancedSearch/Index'
|
2023-10-20 15:45:11 +08:00
|
|
|
|
import { schemaDetectionSecurity } from '@/utils/static-data'
|
2023-10-24 18:11:17 +08:00
|
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
|
import { ref } from 'vue'
|
2023-11-15 15:26:37 +08:00
|
|
|
|
import { storageKey } from '@/utils/constants'
|
|
|
|
|
|
import _ from 'lodash'
|
|
|
|
|
|
import { changeTimeByDate } from '@/utils/tools'
|
2022-02-14 22:22:31 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'DetectionSearch',
|
2022-05-11 17:50:40 +08:00
|
|
|
|
props: {
|
|
|
|
|
|
pageType: String
|
|
|
|
|
|
},
|
2022-02-14 22:22:31 +08:00
|
|
|
|
components: {
|
|
|
|
|
|
AdvancedSearch
|
|
|
|
|
|
},
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
2022-05-11 17:50:40 +08:00
|
|
|
|
columnList: {
|
2023-10-20 15:45:11 +08:00
|
|
|
|
securityEvent: schemaDetectionSecurity,
|
2022-05-11 17:50:40 +08:00
|
|
|
|
performanceEvent: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'event_severity',
|
|
|
|
|
|
type: 'string',
|
2023-09-08 11:15:42 +08:00
|
|
|
|
// label: 'Event severity'
|
|
|
|
|
|
label: 'event_severity',
|
|
|
|
|
|
doc: {
|
|
|
|
|
|
constraints: {
|
|
|
|
|
|
operator_functions: '=,in'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-05-11 17:50:40 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'app_name',
|
|
|
|
|
|
type: 'string',
|
2023-09-08 11:15:42 +08:00
|
|
|
|
// label: 'APP name'
|
|
|
|
|
|
label: 'app_name',
|
|
|
|
|
|
doc: {
|
|
|
|
|
|
constraints: {
|
|
|
|
|
|
operator_functions: '=,in'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-05-11 17:50:40 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'domain',
|
|
|
|
|
|
type: 'string',
|
2023-09-08 11:15:42 +08:00
|
|
|
|
// label: 'Domain'
|
|
|
|
|
|
label: 'domain',
|
|
|
|
|
|
doc: {
|
|
|
|
|
|
constraints: {
|
|
|
|
|
|
operator_functions: '=,in'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-05-11 17:50:40 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'server_ip',
|
|
|
|
|
|
type: 'string',
|
2023-09-08 11:15:42 +08:00
|
|
|
|
// label: 'IP'
|
|
|
|
|
|
label: 'server_ip',
|
|
|
|
|
|
doc: {
|
|
|
|
|
|
constraints: {
|
|
|
|
|
|
operator_functions: '=,in'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-05-11 17:50:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
2023-06-07 15:58:59 +08:00
|
|
|
|
operatorList: ['=', '!=', /* '>', '<', '>=', '<=', */'IN', 'NOT IN', 'LIKE', 'NOT LIKE'],
|
2022-02-15 23:27:55 +08:00
|
|
|
|
connectionList: [
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'AND',
|
|
|
|
|
|
label: 'AND'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'OR',
|
|
|
|
|
|
label: 'OR'
|
|
|
|
|
|
}
|
2023-10-20 15:45:11 +08:00
|
|
|
|
],
|
2023-11-15 15:26:37 +08:00
|
|
|
|
showList: true,
|
|
|
|
|
|
showHistory: false,
|
|
|
|
|
|
history: []
|
2022-02-14 22:22:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-12-14 15:01:48 +08:00
|
|
|
|
emits: ['search'],
|
2023-10-24 18:11:17 +08:00
|
|
|
|
setup () {
|
|
|
|
|
|
// 根据地址栏添加mode,即text和tag模式,默认text
|
|
|
|
|
|
const { query } = useRoute()
|
|
|
|
|
|
const defaultMode = ref(query.mode || 'text')
|
|
|
|
|
|
return {
|
|
|
|
|
|
defaultMode
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-02-14 22:22:31 +08:00
|
|
|
|
methods: {
|
2022-12-08 16:09:46 +08:00
|
|
|
|
/* search (metaList, formatSql) {
|
2022-05-11 17:50:40 +08:00
|
|
|
|
let sql = formatSql
|
|
|
|
|
|
// 全文搜索处理
|
|
|
|
|
|
if (metaList && this.$_.isArray(metaList)) {
|
|
|
|
|
|
const hasFullText = metaList.some(meta => {
|
|
|
|
|
|
return meta.column && meta.column.type === columnType.fullText
|
|
|
|
|
|
})
|
|
|
|
|
|
if (hasFullText) {
|
|
|
|
|
|
const parser = new SqlParser(metaList, this.columnList[this.pageType])
|
|
|
|
|
|
sql = parser.parseMetaToSql(metaList, true)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$emit('search', metaList, sql)
|
2022-12-08 16:09:46 +08:00
|
|
|
|
}, */
|
2023-11-15 15:26:37 +08:00
|
|
|
|
changeTimeByDate,
|
|
|
|
|
|
search ({ str, q, metaList }) {
|
|
|
|
|
|
if (str) {
|
|
|
|
|
|
// 加入搜索记录,将记录数量控制在30以内
|
|
|
|
|
|
const oldHistory = localStorage.getItem(storageKey.detectionSearchHistory)
|
|
|
|
|
|
let arr = []
|
|
|
|
|
|
const newItem = { str, date: this.dateFormatByAppearance(new Date()) }
|
|
|
|
|
|
if (!_.isEmpty(oldHistory)) {
|
|
|
|
|
|
const oldArr = JSON.parse(oldHistory)
|
|
|
|
|
|
if (str === oldArr[0].str) {
|
|
|
|
|
|
oldArr[0].date = this.dateFormatByAppearance(new Date())
|
|
|
|
|
|
} else {
|
|
|
|
|
|
oldArr.unshift(newItem)
|
|
|
|
|
|
}
|
|
|
|
|
|
arr = [...oldArr]
|
|
|
|
|
|
if (arr.length > 30) {
|
|
|
|
|
|
arr = arr.slice(0, 30)
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
arr.push(newItem)
|
|
|
|
|
|
}
|
|
|
|
|
|
localStorage.setItem(storageKey.detectionSearchHistory, JSON.stringify(arr))
|
|
|
|
|
|
}
|
2022-06-06 17:34:55 +08:00
|
|
|
|
this.$emit('search', { q, metaList })
|
2022-02-18 10:07:43 +08:00
|
|
|
|
},
|
2023-11-10 14:11:46 +08:00
|
|
|
|
changeParams (params) {
|
|
|
|
|
|
this.$refs.search.addParams(params)
|
2023-11-15 15:26:37 +08:00
|
|
|
|
},
|
|
|
|
|
|
selectHistory (row) {
|
|
|
|
|
|
this.$refs.search.setStr(row.str)
|
|
|
|
|
|
this.showHistory = false
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
if (this.$refs.search.$refs.textMode) {
|
|
|
|
|
|
this.$refs.search.$refs.textMode.focus()
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
if (this.showList) {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.emitter.emit('advanced-search')
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
clearHistory () {
|
|
|
|
|
|
localStorage.setItem(storageKey.detectionSearchHistory, '')
|
|
|
|
|
|
this.history = []
|
|
|
|
|
|
},
|
|
|
|
|
|
triggerHistory () {
|
|
|
|
|
|
this.showHistory = !this.showHistory
|
|
|
|
|
|
if (this.showHistory) {
|
|
|
|
|
|
const history = localStorage.getItem(storageKey.detectionSearchHistory)
|
|
|
|
|
|
if (!_.isEmpty(history)) {
|
|
|
|
|
|
this.history = JSON.parse(history)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
esc () {
|
|
|
|
|
|
const timer = setTimeout(() => {
|
|
|
|
|
|
this.showHistory = false
|
|
|
|
|
|
clearTimeout(timer)
|
|
|
|
|
|
}, 100)
|
2022-02-14 22:22:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|