mirror of https://github.com/veops/cmdb.git
pref(cmdb-ui):change adt key & add adt alias (#314)
This commit is contained in:
parent
092a8b9b92
commit
6e9ce08e2c
|
@ -53,8 +53,8 @@ export default {
|
||||||
return postCITypeDiscovery(this.CITypeId, { adr_id: id, interval: type === 'agent' ? 300 : 3600 })
|
return postCITypeDiscovery(this.CITypeId, { adr_id: id, interval: type === 'agent' ? 300 : 3600 })
|
||||||
})
|
})
|
||||||
await Promise.all(promises)
|
await Promise.all(promises)
|
||||||
.then(() => {
|
.then((res) => {
|
||||||
this.getCITypeDiscovery(this.selectedIds[0].id)
|
this.getCITypeDiscovery(res[0].id)
|
||||||
this.$message.success('添加成功')
|
this.$message.success('添加成功')
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|
|
@ -2,20 +2,22 @@
|
||||||
<div class="attr-ad" :style="{ height: `${windowHeight - 104}px` }">
|
<div class="attr-ad" :style="{ height: `${windowHeight - 104}px` }">
|
||||||
<div v-if="adCITypeList && adCITypeList.length">
|
<div v-if="adCITypeList && adCITypeList.length">
|
||||||
<a-tabs size="small" v-model="currentTab">
|
<a-tabs size="small" v-model="currentTab">
|
||||||
<a-tab-pane v-for="item in adCITypeList" :key="item.adr_id">
|
<a-tab-pane v-for="item in adCITypeList" :key="item.id">
|
||||||
<a-space slot="tab">
|
<a-space slot="tab">
|
||||||
<span>{{ getADCITypeParam(item.adr_id) }}</span>
|
<span v-if="item.extra_option && item.extra_option.alias">{{ item.extra_option.alias }}</span>
|
||||||
|
<span v-else>{{ getADCITypeParam(item.adr_id) }}</span>
|
||||||
<a-icon type="close-circle" @click="(e) => deleteADT(e, item)" />
|
<a-icon type="close-circle" @click="(e) => deleteADT(e, item)" />
|
||||||
</a-space>
|
</a-space>
|
||||||
<AttrADTabpane
|
<AttrADTabpane
|
||||||
:ref="`attrAdTabpane_${item.adr_id}`"
|
:ref="`attrAdTabpane_${item.id}`"
|
||||||
:currentTab="item.adr_id"
|
:adr_id="item.adr_id"
|
||||||
:adrList="adrList"
|
:adrList="adrList"
|
||||||
:adCITypeList="adCITypeList"
|
:adCITypeList="adCITypeList"
|
||||||
:currentAdt="item"
|
:currentAdt="item"
|
||||||
:ciTypeAttributes="ciTypeAttributes"
|
:ciTypeAttributes="ciTypeAttributes"
|
||||||
:currentAdr="getADCITypeParam(item.adr_id, undefined, true)"
|
:currentAdr="getADCITypeParam(item.adr_id, undefined, true)"
|
||||||
@openEditDrawer="(data, type, adType) => openEditDrawer(data, type, adType)"
|
@openEditDrawer="(data, type, adType) => openEditDrawer(data, type, adType)"
|
||||||
|
@handleSave="getCITypeDiscovery"
|
||||||
/>
|
/>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-space
|
<a-space
|
||||||
|
@ -135,7 +137,7 @@ export default {
|
||||||
await getCITypeDiscovery(this.CITypeId).then((res) => {
|
await getCITypeDiscovery(this.CITypeId).then((res) => {
|
||||||
this.adCITypeList = res.filter((item) => item.adr_id)
|
this.adCITypeList = res.filter((item) => item.adr_id)
|
||||||
if (res && res.length && !this.currentTab) {
|
if (res && res.length && !this.currentTab) {
|
||||||
this.currentTab = res[0].adr_id
|
this.currentTab = res[0].id
|
||||||
}
|
}
|
||||||
if (currentTab) {
|
if (currentTab) {
|
||||||
this.currentTab = currentTab
|
this.currentTab = currentTab
|
||||||
|
@ -156,7 +158,7 @@ export default {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
const that = this
|
const that = this
|
||||||
this.$confirm({
|
this.$confirm({
|
||||||
title: `确认删除 【${this.getADCITypeParam(item.adr_id)}】`,
|
title: `确认删除 【${item?.extra_option?.alias || this.getADCITypeParam(item.adr_id)}】`,
|
||||||
content: (h) => (
|
content: (h) => (
|
||||||
<div>
|
<div>
|
||||||
<a-checkbox v-model={that.deletePlugin}>删除插件</a-checkbox>
|
<a-checkbox v-model={that.deletePlugin}>删除插件</a-checkbox>
|
||||||
|
@ -164,18 +166,22 @@ export default {
|
||||||
),
|
),
|
||||||
onOk() {
|
onOk() {
|
||||||
deleteCITypeDiscovery(item.id).then(async () => {
|
deleteCITypeDiscovery(item.id).then(async () => {
|
||||||
if (that.currentTab === item.adr_id) {
|
if (that.currentTab === item.id) {
|
||||||
that.currentTab = ''
|
that.currentTab = ''
|
||||||
}
|
}
|
||||||
that.deletePlugin = false
|
|
||||||
that.$message.success('删除成功!')
|
that.$message.success('删除成功!')
|
||||||
that.getCITypeDiscovery()
|
that.getCITypeDiscovery()
|
||||||
if (that.deletePlugin) {
|
if (that.deletePlugin) {
|
||||||
await deleteDiscovery(item.adr_id)
|
await deleteDiscovery(item.adr_id).finally(() => {
|
||||||
|
that.deletePlugin = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
that.deletePlugin = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onCancel() {},
|
onCancel() {
|
||||||
|
that.deletePlugin = false
|
||||||
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
openEditDrawer(data, type, adType) {
|
openEditDrawer(data, type, adType) {
|
||||||
|
@ -183,12 +189,12 @@ export default {
|
||||||
},
|
},
|
||||||
async updateNotInner(adr) {
|
async updateNotInner(adr) {
|
||||||
const _idx = this.adCITypeList.findIndex((item) => item.adr_id === adr.id)
|
const _idx = this.adCITypeList.findIndex((item) => item.adr_id === adr.id)
|
||||||
|
let res
|
||||||
if (_idx < 0) {
|
if (_idx < 0) {
|
||||||
await postCITypeDiscovery(this.CITypeId, { adr_id: adr.id, interval: 300 })
|
res = await postCITypeDiscovery(this.CITypeId, { adr_id: adr.id, interval: 300 })
|
||||||
}
|
}
|
||||||
await this.getDiscovery()
|
await this.getDiscovery()
|
||||||
await this.getCITypeDiscovery()
|
await this.getCITypeDiscovery(res?.id ?? undefined)
|
||||||
this.currentTab = adr.id
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs[`attrAdTabpane_${this.currentTab}`][0].init()
|
this.$refs[`attrAdTabpane_${this.currentTab}`][0].init()
|
||||||
})
|
})
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
<span>编辑</span>
|
<span>编辑</span>
|
||||||
</a-space>
|
</a-space>
|
||||||
</a>
|
</a>
|
||||||
|
<div>别名:<a-input v-model="alias" style="width:200px;" /></div>
|
||||||
<div class="attr-ad-header">字段映射</div>
|
<div class="attr-ad-header">字段映射</div>
|
||||||
<vxe-table
|
<vxe-table
|
||||||
v-if="adrType === 'agent'"
|
v-if="adrType === 'agent'"
|
||||||
|
@ -56,7 +57,7 @@
|
||||||
:ruleName="adrName"
|
:ruleName="adrName"
|
||||||
:ciTypeAttributes="ciTypeAttributes"
|
:ciTypeAttributes="ciTypeAttributes"
|
||||||
:adCITypeList="adCITypeList"
|
:adCITypeList="adCITypeList"
|
||||||
:currentTab="currentTab"
|
:currentTab="adr_id"
|
||||||
:style="{ marginBottom: '20px' }"
|
:style="{ marginBottom: '20px' }"
|
||||||
/>
|
/>
|
||||||
<a-form-model
|
<a-form-model
|
||||||
|
@ -133,7 +134,7 @@ export default {
|
||||||
name: 'AttrADTabpane',
|
name: 'AttrADTabpane',
|
||||||
components: { Vcrontab, HttpSnmpAD, CMDBExprDrawer, MonitorNodeSetting },
|
components: { Vcrontab, HttpSnmpAD, CMDBExprDrawer, MonitorNodeSetting },
|
||||||
props: {
|
props: {
|
||||||
currentTab: {
|
adr_id: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
|
@ -187,6 +188,7 @@ export default {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
form3: this.$form.createForm(this, { name: 'snmp_form' }),
|
form3: this.$form.createForm(this, { name: 'snmp_form' }),
|
||||||
|
alias: '',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -205,7 +207,7 @@ export default {
|
||||||
},
|
},
|
||||||
agentTypeRadioList() {
|
agentTypeRadioList() {
|
||||||
const { permissions = [] } = this.userRoles
|
const { permissions = [] } = this.userRoles
|
||||||
if (permissions.includes('cmdb_admin') || permissions.includes('admin')) {
|
if ((permissions.includes('cmdb_admin') || permissions.includes('admin')) && this.adrType !== 'http') {
|
||||||
return [
|
return [
|
||||||
{ value: 'all', label: '所有节点' },
|
{ value: 'all', label: '所有节点' },
|
||||||
{ value: 'agent_id', label: '指定节点' },
|
{ value: 'agent_id', label: '指定节点' },
|
||||||
|
@ -221,8 +223,9 @@ export default {
|
||||||
mounted() {},
|
mounted() {},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
const _find = this.adrList.find((item) => Number(item.id) === Number(this.currentTab))
|
const _find = this.adrList.find((item) => Number(item.id) === Number(this.adr_id))
|
||||||
const _findADT = this.adCITypeList.find((item) => Number(item.adr_id) === Number(this.currentTab))
|
const _findADT = this.adCITypeList.find((item) => Number(item.id) === Number(this.currentAdt.id))
|
||||||
|
this.alias = _findADT?.extra_option?.alias ?? ''
|
||||||
if (this.adrType === 'http') {
|
if (this.adrType === 'http') {
|
||||||
const { category = undefined, key = '', secret = '' } = _findADT?.extra_option ?? {}
|
const { category = undefined, key = '', secret = '' } = _findADT?.extra_option ?? {}
|
||||||
this.form2 = {
|
this.form2 = {
|
||||||
|
@ -294,7 +297,7 @@ export default {
|
||||||
this.cron = cron
|
this.cron = cron
|
||||||
},
|
},
|
||||||
handleSave() {
|
handleSave() {
|
||||||
const { currentAdt } = this
|
const { currentAdt, alias } = this
|
||||||
let params
|
let params
|
||||||
if (this.adrType === 'http') {
|
if (this.adrType === 'http') {
|
||||||
params = {
|
params = {
|
||||||
|
@ -360,9 +363,15 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (params.extra_option) {
|
||||||
|
params.extra_option.alias = alias
|
||||||
|
} else {
|
||||||
|
params.extra_option = {}
|
||||||
|
params.extra_option.alias = alias
|
||||||
|
}
|
||||||
putCITypeDiscovery(currentAdt.id, params).then((res) => {
|
putCITypeDiscovery(currentAdt.id, params).then((res) => {
|
||||||
this.$message.success('保存成功')
|
this.$message.success('保存成功')
|
||||||
|
this.$emit('handleSave')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleOpenCmdb() {
|
handleOpenCmdb() {
|
||||||
|
|
Loading…
Reference in New Issue