From b7c3cce83b97dad6031da4c4516a6bb613e49cf9 Mon Sep 17 00:00:00 2001 From: songlh Date: Thu, 5 Dec 2024 14:33:23 +0800 Subject: [PATCH 1/2] feat(ui): add trigger test send --- cmdb-ui/src/modules/cmdb/api/CIType.js | 7 +++++ cmdb-ui/src/modules/cmdb/lang/en.js | 3 ++ cmdb-ui/src/modules/cmdb/lang/zh.js | 3 ++ .../cmdb/views/ci_types/triggerForm.vue | 30 +++++++++++++++++-- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/cmdb-ui/src/modules/cmdb/api/CIType.js b/cmdb-ui/src/modules/cmdb/api/CIType.js index bab02c7..26088be 100644 --- a/cmdb-ui/src/modules/cmdb/api/CIType.js +++ b/cmdb-ui/src/modules/cmdb/api/CIType.js @@ -207,6 +207,13 @@ export function deleteTrigger(type_id, id) { }) } +export function testTrigger(type_id, id) { + return axios({ + url: `/v0.1/ci_types/${type_id}/triggers/${id}/test_notify`, + method: 'post', + }) +} + // CMDB的模型和实例的授权接口 export function grantCiType(type_id, rid, data) { return axios({ diff --git a/cmdb-ui/src/modules/cmdb/lang/en.js b/cmdb-ui/src/modules/cmdb/lang/en.js index 2da1cba..090d8ba 100644 --- a/cmdb-ui/src/modules/cmdb/lang/en.js +++ b/cmdb-ui/src/modules/cmdb/lang/en.js @@ -186,6 +186,9 @@ const cmdb_en = { botSelect: 'Please select a robot', refAttributeTips: 'The title and content can reference the attribute value of the CIType. The reference method is: {{ attr_name }}', webhookRefAttributeTips: 'Request parameters can reference the attribute value of the model. The reference method is: {{ attr_name }}', + testSend: 'Test Send', + testSendTip: 'Please save the trigger first', + testSendSuccess: 'Send Success', newTrigger: 'Add trigger', editTriggerTitle: 'Edit trigger {name}', newTriggerTitle: 'Add trigger {name}', diff --git a/cmdb-ui/src/modules/cmdb/lang/zh.js b/cmdb-ui/src/modules/cmdb/lang/zh.js index 1e98ce3..f55e392 100644 --- a/cmdb-ui/src/modules/cmdb/lang/zh.js +++ b/cmdb-ui/src/modules/cmdb/lang/zh.js @@ -186,6 +186,9 @@ const cmdb_zh = { botSelect: '请选择机器人', refAttributeTips: '标题、内容可以引用该模型的属性值,引用方法为: {{ attr_name }}', webhookRefAttributeTips: '请求参数可以引用该模型的属性值,引用方法为: {{ attr_name }}', + testSend: '测试发送', + testSendTip: '请先保存触发器', + testSendSuccess: '发送成功', newTrigger: '新增触发器', editTriggerTitle: '编辑触发器 {name}', newTriggerTitle: '新增触发器 {name}', diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/triggerForm.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/triggerForm.vue index ad871e6..fdfc22d 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci_types/triggerForm.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci_types/triggerForm.vue @@ -242,6 +242,18 @@ + + + + {{ $t('cmdb.ciType.testSend') }} + +
@@ -273,7 +285,7 @@ From 12743c20fe5fc0885f8dfae3d73491347dbb3df9 Mon Sep 17 00:00:00 2001 From: songlh Date: Thu, 5 Dec 2024 14:36:56 +0800 Subject: [PATCH 2/2] feat(ui): ipam - address table add view relation --- .../cmdb/views/ipam/modules/address/index.vue | 26 ++++++++++++++++--- .../views/ipam/modules/address/tableIP.vue | 23 ++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/index.vue b/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/index.vue index a726a5b..242dbf3 100644 --- a/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/index.vue +++ b/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/index.vue @@ -115,6 +115,7 @@ :referenceShowAttrNameMap="referenceShowAttrNameMap" :referenceCIIdMap="referenceCIIdMap" :columnWidth="columnWidth" + :addressCITypeId="addressCITypeId" @openAssign="openAssign" @recycle="handleRecycle" @selectChange="handleTableSelectChange" @@ -182,6 +183,7 @@ export default { currentSelectScope: '', columns: [], attrList: [], + attributes: {}, subnetData: {}, referenceShowAttrNameMap: {}, referenceCIIdMap: {}, @@ -212,6 +214,17 @@ export default { ], } }, + provide() { + return { + handleSearch: this.getIPList, + attrList: () => { + return this.attrList + }, + attributes: () => { + return this.attributes + } + } + }, computed: { addressNullTip() { if ( @@ -314,8 +327,10 @@ export default { async getColumns() { const getAttrRes = await getCITypeAttributesById(this.addressCITypeId) + this.attributes = _.cloneDeep(getAttrRes) + this.attrList = _.cloneDeep(getAttrRes.attributes) + const attrList = getAttrRes.attributes - this.attrList = _.cloneDeep(attrList) const filterAttrList = _.remove(attrList, (item) => { return ['ip', 'subnet_mask', 'assign_status', 'is_used', '_updated_by', '_updated_at'].includes(item.name) @@ -489,9 +504,14 @@ export default { const totalWidth = Object.values(columnWidth).reduce((acc, cur) => acc + cur, 0) if (totalWidth < wrapWidth) { - this.columnWidth = {} + this.columnWidth = { + ip: 130 + } } else { - this.columnWidth = columnWidth + this.columnWidth = { + ...columnWidth, + ip: 130 + } } }, diff --git a/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/tableIP.vue b/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/tableIP.vue index d9b2de0..02f05aa 100644 --- a/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/tableIP.vue +++ b/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/tableIP.vue @@ -111,6 +111,12 @@ + + + + + +
@@ -141,6 +147,8 @@ + + @@ -149,8 +157,13 @@ import _ from 'lodash' import { mapState } from 'vuex' import { STATUS_COLOR, STATUS_LABEL, ADDRESS_STATUS } from './constants.js' +import CIDetailDrawer from '@/modules/cmdb/views/ci/modules/ciDetailDrawer.vue' + export default { name: 'TableIP', + components: { + CIDetailDrawer + }, props: { columns: { type: Array, @@ -171,6 +184,10 @@ export default { columnWidth: { type: Object, default: () => {} + }, + addressCITypeId: { + type: Number, + default: 0 } }, data() { @@ -284,6 +301,12 @@ export default { const ips = records?.map?.((item) => item.ip) || [] this.$emit('selectChange', ips) }, + + openRelation(row) { + if (row._id) { + this.$refs.detail.create(row._id, 'tab_2', '2') + } + } } }