From 0144ee65087a6db72933d125387e509ad0074165 Mon Sep 17 00:00:00 2001 From: LH_R Date: Fri, 15 Aug 2025 16:06:23 +0800 Subject: [PATCH] feat(ui): add automatic subscription #285 --- cmdb-ui/src/modules/cmdb/api/preference.js | 15 ++ cmdb-ui/src/modules/cmdb/lang/en.js | 19 +- cmdb-ui/src/modules/cmdb/lang/zh.js | 19 +- .../preference/components/autoSubscribe.vue | 177 ++++++++++++++++++ .../modules/cmdb/views/preference/index.vue | 171 ++++++++++++----- 5 files changed, 347 insertions(+), 54 deletions(-) create mode 100644 cmdb-ui/src/modules/cmdb/views/preference/components/autoSubscribe.vue diff --git a/cmdb-ui/src/modules/cmdb/api/preference.js b/cmdb-ui/src/modules/cmdb/api/preference.js index 08a1eed..463eab2 100644 --- a/cmdb-ui/src/modules/cmdb/api/preference.js +++ b/cmdb-ui/src/modules/cmdb/api/preference.js @@ -157,3 +157,18 @@ export function preferenceCitypeOrder(data) { data: data }) } + +export function getAutoSubscription() { + return axios({ + url: '/v0.1/preference/auto_subscription', + method: 'get', + }) +} + +export function putAutoSubscription(data) { + return axios({ + url: '/v0.1/preference/auto_subscription', + method: 'put', + data + }) +} diff --git a/cmdb-ui/src/modules/cmdb/lang/en.js b/cmdb-ui/src/modules/cmdb/lang/en.js index e276967..3b087f8 100644 --- a/cmdb-ui/src/modules/cmdb/lang/en.js +++ b/cmdb-ui/src/modules/cmdb/lang/en.js @@ -222,12 +222,14 @@ const cmdb_en = { otherGroupTips: 'Non sortable within the other group', filterTips: 'click to show {name}', attributeAssociation: 'Attribute Association', - attributeAssociationTip1: 'Automatically establish relationships through attribute values (except password, json, multi-value, long text, boolean, reference) of two models', + attributeAssociationTip1: 'Automatically establish relationships through attribute values (except password, json, long text, boolean, reference) of two models', attributeAssociationTip2: 'Double click to edit', attributeAssociationTip3: 'Two Attributes must be selected', attributeAssociationTip4: 'Please select a attribute from Source CIType', attributeAssociationTip5: 'Please select a attribute from Target CIType', attributeAssociationTip6: 'Cannot be deleted again.', + attributeAssociationTip7: '1. The attribute value types of the source model and target model must be consistent.', + attributeAssociationTip8: '2. One To Many: Source model can select multiple value attributes', show: 'show attribute', setAsShow: 'Set as show attribute', cancelSetAsShow: 'Cancel show attribute', @@ -460,6 +462,20 @@ const cmdb_en = { searchPlaceholder: 'Please search CIType', subCITable: 'Data', subCITree: 'Tree', + autoSub: 'Auto Subscription', + autoSub2: 'Click To Enable Auto Subscribe', + autoSubScope: 'Auto Subscription Scope', + subscribeAllModel: 'Subscribe All Models', + selectiveSubscription: 'Selective Subscription', + excludeGroup: 'Exclude Group', + excludeModel: 'Exclude Model', + selectGroup: 'Select Group', + selectModel: 'Select Model', + isEnable: 'Is Enable', + enableAutoSubTip: 'After enabling automatic subscription, the model list in the resource data menu will only be based on the results of automatic subscription.', + tips1: 'Please go to', + tips2: ' Preference ', + tips3: 'page first to complete your subscription!' }, custom_dashboard: { charts: 'Chart', @@ -748,7 +764,6 @@ if __name__ == "__main__": searchTips: 'Search in service tree' }, tree: { - tips1: 'Please go to Preference page first to complete your subscription!', subSettings: 'Settings', }, topo: { diff --git a/cmdb-ui/src/modules/cmdb/lang/zh.js b/cmdb-ui/src/modules/cmdb/lang/zh.js index e6df5a2..70845e1 100644 --- a/cmdb-ui/src/modules/cmdb/lang/zh.js +++ b/cmdb-ui/src/modules/cmdb/lang/zh.js @@ -222,12 +222,14 @@ const cmdb_zh = { otherGroupTips: '其他分组属性不可排序', filterTips: '点击可仅查看{name}属性', attributeAssociation: '属性关联', - attributeAssociationTip1: '通过2个模型的属性值(除密码、json、多值、长文本、布尔、引用)来自动建立关系', + attributeAssociationTip1: '通过2个模型的属性值(除密码、json、长文本、布尔、引用)来自动建立关系', attributeAssociationTip2: '双击可编辑', attributeAssociationTip3: '属性关联必须选择两个属性', attributeAssociationTip4: '请选择原模型属性', attributeAssociationTip5: '请选择目标模型属性', attributeAssociationTip6: '不可再删除', + attributeAssociationTip7: '1. 源模型和目标模型的属性值类型必须保持一致', + attributeAssociationTip8: '2. 一对多:源模型可选多值属性', show: '展示属性', setAsShow: '设置为展示属性', cancelSetAsShow: '取消设置为展示属性', @@ -459,6 +461,20 @@ const cmdb_zh = { searchPlaceholder: '请搜索模型', subCITable: '数据订阅', subCITree: '层级订阅', + autoSub: '自动订阅', + autoSub2: '点击开启自动订阅', + autoSubScope: '自动订阅范围', + subscribeAllModel: '订阅所有模型', + selectiveSubscription: '选择性订阅', + excludeGroup: '排除分组', + excludeModel: '排除模型', + selectGroup: '选择分组', + selectModel: '选择模型', + isEnable: '是否启用', + enableAutoSubTip: '开启自动订阅后,资源数据菜单的模型列表只以自动订阅的结果为准', + tips1: '请先到', + tips2: ' 我的订阅 ', + tips3: '页面完成订阅!', }, custom_dashboard: { charts: '图表', @@ -747,7 +763,6 @@ if __name__ == "__main__": searchTips: '在服务树中筛选' }, tree: { - tips1: '请先到 我的订阅 页面完成订阅!', subSettings: '订阅设置', }, topo: { diff --git a/cmdb-ui/src/modules/cmdb/views/preference/components/autoSubscribe.vue b/cmdb-ui/src/modules/cmdb/views/preference/components/autoSubscribe.vue new file mode 100644 index 0000000..4f19416 --- /dev/null +++ b/cmdb-ui/src/modules/cmdb/views/preference/components/autoSubscribe.vue @@ -0,0 +1,177 @@ + + + + + diff --git a/cmdb-ui/src/modules/cmdb/views/preference/index.vue b/cmdb-ui/src/modules/cmdb/views/preference/index.vue index 4bec9ac..715262b 100644 --- a/cmdb-ui/src/modules/cmdb/views/preference/index.vue +++ b/cmdb-ui/src/modules/cmdb/views/preference/index.vue @@ -86,13 +86,15 @@ {{ ciType.alias || ciType.name }} - - - - - +
- +
+ +
+ + {{ enableAutoSub ? $t('cmdb.preference.autoSub') : $t('cmdb.preference.autoSub2') }} +
+

-
- {{ type_id2users[item.id].length > 99 ? '99+' : type_id2users[item.id].length - }}{{ $t('cmdb.preference.peopleSub') }} - {{ $t('cmdb.preference.noSub') }} -
{{ $t('cmdb.menu.ad') }} @@ -173,11 +179,20 @@
- {{ getsubscribedDays(item) }} + + {{ getsubscribedDays(item) }} + - - - + @@ -185,13 +200,15 @@
@@ -629,6 +661,45 @@ export default { height: 100%; padding-top: 24px; + &-header { + margin-bottom: 20px; + display: flex; + align-items: center; + + &-search { + width: 300px; + margin-right: 14px; + } + + &-auto { + background: linear-gradient(90deg, #16D9E3 0%, #30C7EC 47%, #46AEF7 100%); + height: 32px; + display: flex; + align-items: center; + justify-content: center; + border-radius: 4px; + color: #FFFFFF; + cursor: pointer; + padding: 0 12px; + opacity: 0.5; + transition: opacity 0.2s; + + span { + margin-left: 4px; + font-size: 14px; + font-weight: 600; + } + + &_enable { + opacity: 1; + } + + &:hover { + opacity: 1; + } + } + } + &-group-title { width: 300px; margin-bottom: 20px; @@ -651,7 +722,7 @@ export default { .cmdb-preference-type { display: inline-block; width: 195px; - height: 155px; + height: 127px; border-radius: @border-radius-box; background-color: #fff; box-shadow: ~'0px 2px 8px @{primary-color}15';