feat: update auto discovery

This commit is contained in:
songlh 2024-07-09 09:44:28 +08:00
parent 6776be4599
commit 586d820a08
5 changed files with 96 additions and 12 deletions

View File

@ -9,7 +9,7 @@
@clickCategory="setCurrentCate" @clickCategory="setCurrentCate"
/> />
<template v-else> <template v-else>
<a-select v-if="isCloud" :style="{ marginBottom: '10px', minWidth: '120px' }" v-model="currentCate"> <a-select v-if="isCloud" :style="{ marginBottom: '10px', minWidth: '200px' }" v-model="currentCate">
<a-select-option v-for="cate in categoriesSelect" :key="cate" :value="cate">{{ cate }}</a-select-option> <a-select-option v-for="cate in categoriesSelect" :key="cate" :value="cate">{{ cate }}</a-select-option>
</a-select> </a-select>
<AttrMapTable <AttrMapTable
@ -70,6 +70,10 @@ export default {
uniqueKey: { uniqueKey: {
type: String, type: String,
default: '', default: '',
},
currentAdt: {
type: Object,
default: () => {},
} }
}, },
data() { data() {
@ -136,7 +140,7 @@ export default {
}) })
this.categoriesSelect = categoriesSelect this.categoriesSelect = categoriesSelect
if (this.isEdit && categoriesSelect?.length) { if (this.isEdit && categoriesSelect?.length) {
this.currentCate = categoriesSelect[0] this.currentCate = this?.currentAdt?.extra_option?.category || categoriesSelect[0]
} }
}) })
} }
@ -159,19 +163,24 @@ export default {
if (_findADT?.attributes?.[item.name]) { if (_findADT?.attributes?.[item.name]) {
item.attr = _findADT.attributes[item.name] item.attr = _findADT.attributes[item.name]
} else {
const _find = this.ciTypeAttributes.find((ele) => ele.name === item.name)
if (_find) {
item.attr = _find.name
}
} }
const attrMapName = this.httpAttrMap?.[item?.name]
if ( if (
this.isEdit && this.isEdit &&
!item.attr && !item.attr &&
this.httpAttrMap?.[item.name] attrMapName &&
this.ciTypeAttributes.some((ele) => ele.name === attrMapName)
) { ) {
item.attr = this.httpAttrMap[item.name] item.attr = attrMapName
}
if (!item.attr) {
const _find = this.ciTypeAttributes.find((ele) => ele.name === item.name)
if (_find) {
item.attr = _find.name
}
} }
return item return item

View File

@ -259,6 +259,11 @@ const cmdb_en = {
account: 'Account', account: 'Account',
insecure: 'Certificate Validation', insecure: 'Certificate Validation',
vcenterName: 'Platform Name', vcenterName: 'Platform Name',
resourceSearchTip1: 'Please use conditional filtering for CI filtering and copy and paste the filter expression into the fill-in box in the previous step.',
resourceSearchTip2: 'Note 1: Please use the green button to the right of the expression to copy it',
resourceSearchTip3: 'Note 2: If you do not need to filter, please click the grey button to copy and paste directly to configure for all nodes',
enable: 'Enable',
enableTip: 'Confirm switching on?',
}, },
components: { components: {
unselectAttributes: 'Unselected', unselectAttributes: 'Unselected',

View File

@ -259,6 +259,11 @@ const cmdb_zh = {
account: '账号', account: '账号',
insecure: '是否证书验证', insecure: '是否证书验证',
vcenterName: '虚拟平台名', vcenterName: '虚拟平台名',
resourceSearchTip1: '请使用条件过滤进行CI筛选并将过滤表达式复制粘贴到上一步填写框中。',
resourceSearchTip2: '注1请使用表达式右侧的绿色按钮进行复制',
resourceSearchTip3: '注2如不需要筛选请直接点击灰色按钮进行复制粘贴即可配置为所有节点',
enable: '开启',
enableTip: '确定切换开启状态吗',
}, },
components: { components: {
unselectAttributes: '未选属性', unselectAttributes: '未选属性',

View File

@ -14,7 +14,22 @@
<span>{{ $t('edit') }}</span> <span>{{ $t('edit') }}</span>
</a-space> </a-space>
</a> </a>
<div class="attr-ad-header">{{ $t('cmdb.ciType.attributeMap') }}</div> <div class="attr-ad-header attr-ad-header_between">
{{ $t('cmdb.ciType.attributeMap') }}
<div class="attr-ad-open">
<span class="attr-ad-open-label">{{ $t('cmdb.ciType.enable') }}</span>
<a-switch v-model="form.enabled" v-if="isClient" />
<a-popconfirm
v-else
:title="$t('cmdb.ciType.enableTip')"
:ok-text="$t('confirm')"
:cancel-text="$t('cancel')"
@confirm="changeEnabled"
>
<a-switch :checked="form.enabled" />
</a-popconfirm>
</div>
</div>
<div class="attr-ad-attributemap-main"> <div class="attr-ad-attributemap-main">
<AttrMapTable <AttrMapTable
v-if="adrType === 'agent'" v-if="adrType === 'agent'"
@ -34,6 +49,7 @@
:adCITypeList="adCITypeList" :adCITypeList="adCITypeList"
:currentTab="adr_id" :currentTab="adr_id"
:uniqueKey="uniqueKey" :uniqueKey="uniqueKey"
:currentAdt="currentAdt"
:style="{ marginBottom: '20px' }" :style="{ marginBottom: '20px' }"
/> />
</div> </div>
@ -234,6 +250,7 @@ export default {
agent_id: '', agent_id: '',
auto_accept: false, auto_accept: false,
query_expr: '', query_expr: '',
enabled: true,
}, },
form2: { form2: {
key: '', key: '',
@ -263,7 +280,8 @@ export default {
uniqueKey: '', uniqueKey: '',
isPrivateCloud: false, isPrivateCloud: false,
privateCloudName: '', privateCloudName: '',
PRIVATE_CLOUD_NAME PRIVATE_CLOUD_NAME,
isClient: false, // 是否前端新增临时数据
} }
}, },
computed: { computed: {
@ -316,6 +334,7 @@ export default {
const _find = this.adrList.find((item) => Number(item.id) === Number(this.adr_id)) const _find = this.adrList.find((item) => Number(item.id) === Number(this.adr_id))
const _findADT = this.adCITypeList.find((item) => Number(item.id) === Number(this.currentAdt.id)) const _findADT = this.adCITypeList.find((item) => Number(item.id) === Number(this.currentAdt.id))
this.uniqueKey = _find?.unique_key ?? '' this.uniqueKey = _find?.unique_key ?? ''
this.isClient = _findADT?.isClient ?? false
if (this.adrType === 'http') { if (this.adrType === 'http') {
const { const {
@ -391,6 +410,7 @@ export default {
auto_accept: _findADT?.auto_accept || false, auto_accept: _findADT?.auto_accept || false,
agent_id: _findADT?.agent_id && _findADT?.agent_id !== '0x0000' ? _findADT.agent_id : '', agent_id: _findADT?.agent_id && _findADT?.agent_id !== '0x0000' ? _findADT.agent_id : '',
query_expr: _findADT.query_expr || '', query_expr: _findADT.query_expr || '',
enabled: _findADT?.enabled ?? true,
} }
if (_findADT.query_expr) { if (_findADT.query_expr) {
this.agent_type = 'query_expr' this.agent_type = 'query_expr'
@ -562,6 +582,17 @@ export default {
hideCron() { hideCron() {
this.cronVisible = false this.cronVisible = false
}, },
changeEnabled() {
if (!this.isClient) {
putCITypeDiscovery(this.currentAdt.id, {
enabled: !this.form.enabled
}).then((res) => {
this.form.enabled = !this.form.enabled
this.$message.success(this.$t('saveSuccess'))
this.$emit('handleSave', res.id)
})
}
}
}, },
} }
</script> </script>
@ -572,6 +603,26 @@ export default {
overflow-x: hidden; overflow-x: hidden;
position: relative; position: relative;
.attr-ad-header_between {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 20px;
}
.attr-ad-open {
display: flex;
align-items: center;
justify-content: flex-end;
padding: 0px 20px;
&-label {
font-size: 14px;
font-weight: 600;
margin-right: 6px;
}
}
.attr-ad-attributemap-main { .attr-ad-attributemap-main {
margin-left: 17px; margin-left: 17px;
} }

View File

@ -18,6 +18,11 @@
>{{ $t('download') }}</a-button >{{ $t('download') }}</a-button
> >
</div> </div>
<div v-if="fromCronJob" class="resource-search-tip">
<div class="resource-search-tip-item">{{ $t('cmdb.ciType.resourceSearchTip1') }}</div>
<div class="resource-search-tip-item">{{ $t('cmdb.ciType.resourceSearchTip2') }}</div>
<div class="resource-search-tip-item">{{ $t('cmdb.ciType.resourceSearchTip3') }}</div>
</div>
<SearchForm <SearchForm
ref="search" ref="search"
:type="type" :type="type"
@ -44,7 +49,7 @@
size="small" size="small"
row-id="_id" row-id="_id"
:loading="loading" :loading="loading"
:height="fromCronJob ? windowHeight - 180 : windowHeight - 240" :height="fromCronJob ? windowHeight - 280 : windowHeight - 240"
show-header-overflow show-header-overflow
highlight-hover-row highlight-hover-row
:data="instanceList" :data="instanceList"
@ -568,5 +573,14 @@ export default {
background-color: #fff; background-color: #fff;
padding: 20px; padding: 20px;
border-radius: @border-radius-box; border-radius: @border-radius-box;
&-tip {
margin-bottom: 16px;
&-item {
font-size: 12px;
color: @text-color_4
}
}
} }
</style> </style>