2021-04-20 14:38:24 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="full-width-height">
|
2021-10-11 14:05:07 +08:00
|
|
|
|
<nz-bottom-data-list
|
|
|
|
|
|
:showTitle='showTitle'
|
2021-04-20 14:38:24 +08:00
|
|
|
|
:api="url"
|
|
|
|
|
|
:custom-table-title.sync="tools.customTableTitle"
|
|
|
|
|
|
:layout="['searchInput', 'elementSet']"
|
|
|
|
|
|
:search-msg="searchMsg"
|
|
|
|
|
|
:tabs="tabs"
|
2021-04-20 15:31:57 +08:00
|
|
|
|
:targetTab="targetTab"
|
2021-06-07 17:31:17 +08:00
|
|
|
|
@search="search"
|
2021-04-20 14:38:24 +08:00
|
|
|
|
@changeTab="changeTab"
|
|
|
|
|
|
class="full-width-height"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template v-slot:title><span :title="obj.name">{{obj.name}}</span></template>
|
|
|
|
|
|
<template v-slot>
|
|
|
|
|
|
<endpoint-table
|
|
|
|
|
|
ref="dataTable"
|
|
|
|
|
|
v-loading="tools.loading"
|
|
|
|
|
|
:api="url"
|
|
|
|
|
|
:custom-table-title="tools.customTableTitle"
|
|
|
|
|
|
:height="subTableHeight"
|
|
|
|
|
|
:now-time="nowTime"
|
|
|
|
|
|
:table-data="tableData"
|
2021-06-25 14:09:18 +08:00
|
|
|
|
:endpointTab="true"
|
2021-04-20 14:38:24 +08:00
|
|
|
|
@del="del"
|
|
|
|
|
|
@edit="edit"
|
2021-08-26 15:38:45 +08:00
|
|
|
|
@copy="copy"
|
2021-04-20 14:38:24 +08:00
|
|
|
|
@orderBy="tableDataSort"
|
2021-07-01 17:56:01 +08:00
|
|
|
|
@addSilence="addSilence"
|
2021-04-20 14:38:24 +08:00
|
|
|
|
@reload="getTableData"
|
|
|
|
|
|
@selectionChange="selectionChange"
|
|
|
|
|
|
></endpoint-table>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:pagination>
|
|
|
|
|
|
<Pagination ref="Pagination" :pageObj="pageObj" :tableId="tableId" @pageNo='pageNo' @pageSize='pageSize'></Pagination>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</nz-bottom-data-list>
|
|
|
|
|
|
<transition name="right-box">
|
2021-05-14 17:09:57 +08:00
|
|
|
|
<edit-endpoint-box-new v-if="rightBox.editShow" :module="object" @close="closeRightEditBox" :disabled="true" :optionType="'edit'"></edit-endpoint-box-new>
|
2021-04-20 14:38:24 +08:00
|
|
|
|
</transition>
|
2021-08-26 15:38:45 +08:00
|
|
|
|
<transition name="right-box">
|
|
|
|
|
|
<edit-endpoint-box-new v-if="rightBox.show" :module="object" @close="closeRightEditBox" :disabled="false" :optionType="'add'"></edit-endpoint-box-new>
|
|
|
|
|
|
</transition>
|
2021-07-01 17:56:01 +08:00
|
|
|
|
<transition name="right-box"><alert-silence-box v-if='silenceBoxShow' :alert-silence="objectSilence" @close="closeSilenceBox"></alert-silence-box></transition>
|
2021-04-20 14:38:24 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import dataListMixin from '@/components/common/mixin/dataList'
|
|
|
|
|
|
import subDataListMixin from '@/components/common/mixin/subDataList'
|
|
|
|
|
|
import nzBottomDataList from '@/components/common/bottomBox/nzBottomDataList'
|
|
|
|
|
|
import endpointTable from '@/components/common/table/settings/endpointTable'
|
|
|
|
|
|
import EditEndpointBoxNew from '@/components/common/rightBox/editEndpointBoxNew'
|
2021-07-23 15:49:18 +08:00
|
|
|
|
import { fromRoute } from '@/components/common/js/constants'
|
2021-07-01 17:56:01 +08:00
|
|
|
|
import alertSilenceBox from '@/components/common/rightBox/alertSilenceBox'
|
2021-10-11 14:05:07 +08:00
|
|
|
|
import detailViewRightMixin from '@/components/common/mixin/detailViewRightMixin'
|
2021-04-20 14:38:24 +08:00
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: 'terminalLogTab',
|
2021-10-11 14:05:07 +08:00
|
|
|
|
mixins: [dataListMixin, subDataListMixin, detailViewRightMixin],
|
2021-04-20 14:38:24 +08:00
|
|
|
|
components: {
|
|
|
|
|
|
nzBottomDataList,
|
|
|
|
|
|
endpointTable,
|
2021-07-01 17:56:01 +08:00
|
|
|
|
EditEndpointBoxNew,
|
|
|
|
|
|
alertSilenceBox
|
2021-04-20 14:38:24 +08:00
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
obj: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler (n) {
|
|
|
|
|
|
if (n) {
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
url: 'monitor/endpoint',
|
|
|
|
|
|
tableId: 'endpointTab', // 需要分页的table的id,用于记录每页数量
|
|
|
|
|
|
searchMsg: { // 给搜索框子组件传递的信息
|
|
|
|
|
|
zheze_none: true,
|
|
|
|
|
|
searchLabelList: [{
|
2021-07-01 17:56:01 +08:00
|
|
|
|
id: 13,
|
|
|
|
|
|
name: this.$t('project.endpoint.endpointId'),
|
|
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'ids',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 12,
|
|
|
|
|
|
name: this.$t('project.endpoint.endpointName'),
|
|
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'name',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}
|
2021-06-08 10:31:05 +08:00
|
|
|
|
]
|
2021-04-20 14:38:24 +08:00
|
|
|
|
},
|
2021-07-01 17:56:01 +08:00
|
|
|
|
blankSilenceObject: {
|
|
|
|
|
|
startAt: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
objectSilence: {},
|
|
|
|
|
|
silenceBoxShow: false,
|
2021-04-20 14:38:24 +08:00
|
|
|
|
nowTime: '',
|
|
|
|
|
|
rightBox: {
|
|
|
|
|
|
editShow: false,
|
|
|
|
|
|
show: false
|
|
|
|
|
|
},
|
|
|
|
|
|
fromBottom: true
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
getTableData () {
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
...this.searchLabel,
|
|
|
|
|
|
pageNo: this.pageObj.pageNo,
|
|
|
|
|
|
pageSize: this.pageObj.pageSize
|
|
|
|
|
|
}
|
2021-04-30 11:45:22 +08:00
|
|
|
|
if (this.from === fromRoute.module) {
|
|
|
|
|
|
params.moduleIds = this.obj.id
|
|
|
|
|
|
} else if (this.from === fromRoute.asset) {
|
|
|
|
|
|
params.assetIds = this.obj.id
|
|
|
|
|
|
}
|
2021-04-20 14:38:24 +08:00
|
|
|
|
this.$get(this.url, params).then(response => {
|
|
|
|
|
|
this.tools.loading = false
|
|
|
|
|
|
if (response.code === 200) {
|
2021-08-05 15:07:45 +08:00
|
|
|
|
for (let i = 0; i < response.data.list.length; i++) {
|
|
|
|
|
|
response.data.list[i].configs.forEach(item => {
|
|
|
|
|
|
item.config = JSON.parse(item.config)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2021-04-20 14:38:24 +08:00
|
|
|
|
this.tableData = response.data.list
|
|
|
|
|
|
this.nowTime = this.utcTimeToTimezoneStr(response.time)
|
|
|
|
|
|
this.pageObj.total = response.data.total
|
|
|
|
|
|
if (!this.scrollbarWrap) {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.scrollbarWrap = this.$refs.dataTable.$refs.dataTable.bodyWrapper
|
|
|
|
|
|
this.toTopBtnHandler(this.scrollbarWrap)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-08-26 15:38:45 +08:00
|
|
|
|
edit (row, copyFlag) {
|
2021-04-20 14:38:24 +08:00
|
|
|
|
this.$get('monitor/endpoint/' + row.id).then(res => {
|
2021-08-26 15:38:45 +08:00
|
|
|
|
this.object = JSON.parse(JSON.stringify(res.data))
|
|
|
|
|
|
if (copyFlag) {
|
|
|
|
|
|
this.object.id = ''
|
|
|
|
|
|
this.object.name = this.object.name + '-copy'
|
|
|
|
|
|
if (this.object.name.length > 64) {
|
|
|
|
|
|
const length = this.object.name.length - 64
|
|
|
|
|
|
this.object.name = row.name.substring(0, row.name.length - length) + '-copy'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.object.configs.forEach(item => {
|
|
|
|
|
|
item.config = JSON.parse(item.config)
|
|
|
|
|
|
})
|
2021-04-20 14:38:24 +08:00
|
|
|
|
this.object.paramObj = []
|
|
|
|
|
|
this.object.labelModule = []
|
2021-08-26 15:38:45 +08:00
|
|
|
|
if (!this.object.configs[0].config.relabel_config) {
|
|
|
|
|
|
this.object.configs[0].config.relabel_config = []
|
|
|
|
|
|
}
|
|
|
|
|
|
this.object.configs[0].config.relabel_config && this.object.configs[0].config.relabel_config.forEach(item => {
|
|
|
|
|
|
item.showAllRelabelOption = false
|
|
|
|
|
|
item.tags = ''
|
|
|
|
|
|
})
|
|
|
|
|
|
this.object.configs[1].config.forEach(item => {
|
|
|
|
|
|
item.labelModule = []
|
|
|
|
|
|
if (JSON.stringify(item.labels) !== '{}' && item.labels) {
|
|
|
|
|
|
Object.keys(item.labels).forEach(key => {
|
|
|
|
|
|
item.labelModule.push({ key, value: item.labels[key] })
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
item.labelModule.push({ key: '', value: '' })
|
|
|
|
|
|
}
|
|
|
|
|
|
item.pipeline && item.pipeline.forEach((pipeline) => {
|
|
|
|
|
|
if (pipeline.type === 'labels') {
|
|
|
|
|
|
const labelsArr = []
|
|
|
|
|
|
if (JSON.stringify(pipeline.labels) !== '{}' && pipeline.labels) {
|
|
|
|
|
|
Object.keys(pipeline.labels).forEach(key => {
|
|
|
|
|
|
labelsArr.push({ key, value: pipeline.labels[key] })
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
labelsArr.push({ key: '', value: '' })
|
|
|
|
|
|
}
|
|
|
|
|
|
pipeline.labels = labelsArr
|
|
|
|
|
|
}
|
|
|
|
|
|
if (pipeline.type === 'json') {
|
|
|
|
|
|
const expressionsArr = []
|
|
|
|
|
|
if (JSON.stringify(pipeline.expressions) !== '{}' && pipeline.expressions) {
|
|
|
|
|
|
Object.keys(pipeline.expressions).forEach(key => {
|
|
|
|
|
|
expressionsArr.push({ key, value: pipeline.expressions[key] })
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
expressionsArr.push({ key: '', value: '' })
|
|
|
|
|
|
}
|
|
|
|
|
|
pipeline.expressions = expressionsArr
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
if (item.type === 'file') {
|
|
|
|
|
|
item.unit = ''
|
|
|
|
|
|
item.appName = ''
|
|
|
|
|
|
item.listenAddress = ''
|
|
|
|
|
|
} else if (item.type === 'journal') {
|
|
|
|
|
|
item.fileName = ''
|
|
|
|
|
|
item.appName = ''
|
|
|
|
|
|
item.listenAddress = ''
|
|
|
|
|
|
} else if (item.type === 'syslog') {
|
|
|
|
|
|
item.fileName = ''
|
|
|
|
|
|
item.unit = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
if (JSON.stringify(this.object.configs[0].config.labels) !== '{}' && this.object.configs[0].config.labels) {
|
|
|
|
|
|
Object.keys(this.object.configs[0].config.labels).forEach(key => {
|
|
|
|
|
|
this.object.labelModule.push({ key, value: this.object.configs[0].config.labels[key] })
|
2021-04-20 14:38:24 +08:00
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.object.labelModule.push({ key: '', value: '' })
|
|
|
|
|
|
}
|
2021-08-26 15:38:45 +08:00
|
|
|
|
if (JSON.stringify(this.object.configs[0].config.params) !== '{}' && this.object.configs[0].config.params) {
|
|
|
|
|
|
Object.keys(this.object.configs[0].config.params).forEach(key => {
|
|
|
|
|
|
this.object.paramObj.push({ key, value: this.object.configs[0].config.params[key] })
|
2021-04-20 14:38:24 +08:00
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.object.paramObj.push({ key: '', value: [] })
|
|
|
|
|
|
}
|
|
|
|
|
|
this.object.assetName = this.object.asset ? this.object.asset.name : ''
|
2021-08-26 15:38:45 +08:00
|
|
|
|
this.object.assetId = this.object.asset ? this.object.asset.id + '' : ''
|
2021-04-20 14:38:24 +08:00
|
|
|
|
this.object.projectId = this.object.project.id
|
|
|
|
|
|
this.object.moduleId = this.object.module.id
|
|
|
|
|
|
this.object.type = this.object.module.type
|
2021-08-26 15:38:45 +08:00
|
|
|
|
if (copyFlag) {
|
|
|
|
|
|
this.rightBox.show = true
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.rightBox.editShow = true
|
|
|
|
|
|
}
|
2021-04-20 14:38:24 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-08-26 15:38:45 +08:00
|
|
|
|
copy (row) {
|
|
|
|
|
|
this.edit(row, true)
|
|
|
|
|
|
},
|
2021-04-20 14:38:24 +08:00
|
|
|
|
closeRightEditBox (refresh) {
|
|
|
|
|
|
this.rightBox.editShow = false
|
2021-08-26 15:38:45 +08:00
|
|
|
|
this.rightBox.show = false
|
2021-04-20 14:38:24 +08:00
|
|
|
|
if (refresh) {
|
|
|
|
|
|
this.delFlag = true
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.full-width-height{
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|