Skip to content

Commit

Permalink
Merge pull request veops#574 from veops/dev_ui_240709
Browse files Browse the repository at this point in the history
feat: update auto discovery
  • Loading branch information
LHRUN committed Jul 9, 2024
2 parents 6776be4 + 586d820 commit d53288c
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 12 deletions.
27 changes: 18 additions & 9 deletions cmdb-ui/src/modules/cmdb/components/httpSnmpAD/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@clickCategory="setCurrentCate"
/>
<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>
<AttrMapTable
Expand Down Expand Up @@ -70,6 +70,10 @@ export default {
uniqueKey: {
type: String,
default: '',
},
currentAdt: {
type: Object,
default: () => {},
}
},
data() {
Expand Down Expand Up @@ -136,7 +140,7 @@ export default {
})
this.categoriesSelect = categoriesSelect
if (this.isEdit && categoriesSelect?.length) {
this.currentCate = categoriesSelect[0]
this.currentCate = this?.currentAdt?.extra_option?.category || categoriesSelect[0]
}
})
}
Expand All @@ -159,19 +163,24 @@ export default {

if (_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 (
this.isEdit &&
!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
Expand Down
5 changes: 5 additions & 0 deletions cmdb-ui/src/modules/cmdb/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ const cmdb_en = {
account: 'Account',
insecure: 'Certificate Validation',
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: {
unselectAttributes: 'Unselected',
Expand Down
5 changes: 5 additions & 0 deletions cmdb-ui/src/modules/cmdb/lang/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ const cmdb_zh = {
account: '账号',
insecure: '是否证书验证',
vcenterName: '虚拟平台名',
resourceSearchTip1: '请使用条件过滤进行CI筛选,并将过滤表达式复制粘贴到上一步填写框中。',
resourceSearchTip2: '注1:请使用表达式右侧的绿色按钮进行复制',
resourceSearchTip3: '注2:如不需要筛选,请直接点击灰色按钮进行复制粘贴,即可配置为所有节点',
enable: '开启',
enableTip: '确定切换开启状态吗',
},
components: {
unselectAttributes: '未选属性',
Expand Down
55 changes: 53 additions & 2 deletions cmdb-ui/src/modules/cmdb/views/ci_types/attrADTabpane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,22 @@
<span>{{ $t('edit') }}</span>
</a-space>
</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">
<AttrMapTable
v-if="adrType === 'agent'"
Expand All @@ -34,6 +49,7 @@
:adCITypeList="adCITypeList"
:currentTab="adr_id"
:uniqueKey="uniqueKey"
:currentAdt="currentAdt"
:style="{ marginBottom: '20px' }"
/>
</div>
Expand Down Expand Up @@ -234,6 +250,7 @@ export default {
agent_id: '',
auto_accept: false,
query_expr: '',
enabled: true,
},
form2: {
key: '',
Expand Down Expand Up @@ -263,7 +280,8 @@ export default {
uniqueKey: '',
isPrivateCloud: false,
privateCloudName: '',
PRIVATE_CLOUD_NAME
PRIVATE_CLOUD_NAME,
isClient: false, // 是否前端新增临时数据
}
},
computed: {
Expand Down Expand Up @@ -316,6 +334,7 @@ export default {
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))
this.uniqueKey = _find?.unique_key ?? ''
this.isClient = _findADT?.isClient ?? false

if (this.adrType === 'http') {
const {
Expand Down Expand Up @@ -391,6 +410,7 @@ export default {
auto_accept: _findADT?.auto_accept || false,
agent_id: _findADT?.agent_id && _findADT?.agent_id !== '0x0000' ? _findADT.agent_id : '',
query_expr: _findADT.query_expr || '',
enabled: _findADT?.enabled ?? true,
}
if (_findADT.query_expr) {
this.agent_type = 'query_expr'
Expand Down Expand Up @@ -562,6 +582,17 @@ export default {
hideCron() {
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>
Expand All @@ -572,6 +603,26 @@ export default {
overflow-x: hidden;
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 {
margin-left: 17px;
}
Expand Down
16 changes: 15 additions & 1 deletion cmdb-ui/src/modules/cmdb/views/resource_search/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
>{{ $t('download') }}</a-button
>
</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
ref="search"
:type="type"
Expand All @@ -44,7 +49,7 @@
size="small"
row-id="_id"
:loading="loading"
:height="fromCronJob ? windowHeight - 180 : windowHeight - 240"
:height="fromCronJob ? windowHeight - 280 : windowHeight - 240"
show-header-overflow
highlight-hover-row
:data="instanceList"
Expand Down Expand Up @@ -568,5 +573,14 @@ export default {
background-color: #fff;
padding: 20px;
border-radius: @border-radius-box;

&-tip {
margin-bottom: 16px;

&-item {
font-size: 12px;
color: @text-color_4
}
}
}
</style>

0 comments on commit d53288c

Please sign in to comment.