diff --git a/cmdb-ui/.env b/cmdb-ui/.env index 1be71b7..f9596a2 100644 --- a/cmdb-ui/.env +++ b/cmdb-ui/.env @@ -3,3 +3,4 @@ VUE_APP_PREVIEW=false VUE_APP_API_BASE_URL=http://127.0.0.1:5000/api VUE_APP_BUILD_PACKAGES="ticket,calendar,acl" VUE_APP_IS_OUTER=true +VUE_APP_IS_OPEN_SOURCE=true diff --git a/cmdb-ui/src/core/use.js b/cmdb-ui/src/core/use.js index 283889a..c8c90f7 100644 --- a/cmdb-ui/src/core/use.js +++ b/cmdb-ui/src/core/use.js @@ -69,6 +69,8 @@ Vue.prototype.$httpError = function (err, describe) { window.$message = Vue.prototype.$message +Vue.prototype.isOpenSource = process.env.VUE_APP_IS_OPEN_SOURCE === 'true' + Vue.use(Antd) Vue.use(Viser) diff --git a/cmdb-ui/src/modules/cmdb/api/CIType.js b/cmdb-ui/src/modules/cmdb/api/CIType.js index 6e60735..bab02c7 100644 --- a/cmdb-ui/src/modules/cmdb/api/CIType.js +++ b/cmdb-ui/src/modules/cmdb/api/CIType.js @@ -1,232 +1,257 @@ -import { axios } from '@/utils/request' - -/** - * 获取 所有的 ci_types - * @param parameter - * @returns {AxiosPromise} - */ -export function getCITypes(parameter) { - return axios({ - url: '/v0.1/ci_types', - method: 'GET', - params: parameter - }) -} - -/** - * 获取 某个 ci_types - * @param CITypeName - * @param parameter - * @returns {AxiosPromise} - */ -export function getCIType(CITypeName, parameter) { - return axios({ - url: `/v0.1/ci_types/${CITypeName}`, - method: 'GET', - params: parameter - }) -} - -/** - * 创建 ci_type - * @param data - * @returns {AxiosPromise} - */ -export function createCIType(data) { - return axios({ - url: '/v0.1/ci_types', - method: 'POST', - data: data - }) -} - -/** - * 更新 ci_type - * @param CITypeId - * @param data - * @returns {AxiosPromise} - */ -export function updateCIType(CITypeId, data) { - return axios({ - url: `/v0.1/ci_types/${CITypeId}`, - method: 'PUT', - data: data - }) -} - -/** - * 删除 ci_type - * @param CITypeId - * @returns {AxiosPromise} - */ -export function deleteCIType(CITypeId) { - return axios({ - url: `/v0.1/ci_types/${CITypeId}`, - method: 'DELETE' - }) -} - -/** - * 获取 某个 ci_type 的分组 - * @param CITypeId - * @param data - * @returns {AxiosPromise} - */ -export function getCITypeGroupById(CITypeId, data) { - return axios({ - url: `/v0.1/ci_types/${CITypeId}/attribute_groups`, - method: 'GET', - params: data - }) -} - -/** - * 保存 某个 ci_type 的分组 - * @param CITypeId - * @param data - * @returns {AxiosPromise} - */ -export function createCITypeGroupById(CITypeId, data) { - return axios({ - url: `/v0.1/ci_types/${CITypeId}/attribute_groups`, - method: 'POST', - data: data - }) -} - -/** - * 修改 某个 ci_type 的分组 - * @param groupId - * @param data - * @returns {AxiosPromise} - */ -export function updateCITypeGroupById(groupId, data) { - return axios({ - url: `/v0.1/ci_types/attribute_groups/${groupId}`, - method: 'PUT', - data: data - }) -} - -/** - * 删除 某个 ci_type 的分组 - * @param groupId - * @param data - * @returns {AxiosPromise} - */ -export function deleteCITypeGroupById(groupId, data) { - return axios({ - url: `/v0.1/ci_types/attribute_groups/${groupId}`, - method: 'delete', - data: data - }) -} - -export function getUniqueConstraintList(type_id) { - return axios({ - url: `/v0.1/ci_types/${type_id}/unique_constraint`, - method: 'get', - }) -} - -export function addUniqueConstraint(type_id, data) { - return axios({ - url: `/v0.1/ci_types/${type_id}/unique_constraint`, - method: 'post', - data: data - }) -} - -export function updateUniqueConstraint(type_id, id, data) { - return axios({ - url: `/v0.1/ci_types/${type_id}/unique_constraint/${id}`, - method: 'put', - data: data - }) -} - -export function deleteUniqueConstraint(type_id, id) { - return axios({ - url: `/v0.1/ci_types/${type_id}/unique_constraint/${id}`, - method: 'delete', - }) -} - -export function getTriggerList(type_id) { - return axios({ - url: `/v0.1/ci_types/${type_id}/triggers`, - method: 'get', - }) -} - -export function addTrigger(type_id, data) { - return axios({ - url: `/v0.1/ci_types/${type_id}/triggers`, - method: 'post', - data: data - }) -} - -export function updateTrigger(type_id, id, data) { - return axios({ - url: `/v0.1/ci_types/${type_id}/triggers/${id}`, - method: 'put', - data: data - }) -} - -export function deleteTrigger(type_id, id) { - return axios({ - url: `/v0.1/ci_types/${type_id}/triggers/${id}`, - method: 'delete', - }) -} - -// CMDB的模型和实例的授权接口 -export function grantCiType(type_id, rid, data) { - return axios({ - url: `/v0.1/ci_types/${type_id}/roles/${rid}/grant`, - method: 'post', - data - }) -} -// CMDB的模型和实例的删除授权接口 -export function revokeCiType(type_id, rid, data) { - return axios({ - url: `/v0.1/ci_types/${type_id}/roles/${rid}/revoke`, - method: 'post', - data - }) -} -// CMDB的模型和实例的过滤的权限 -export function ciTypeFilterPermissions(type_id) { - return axios({ - url: `/v0.1/ci_types/${type_id}/filters/permissions`, - method: 'get', - }) -} - -// parent_ids, child_id -export function postCiTypeInheritance(data) { - return axios({ - url: `/v0.1/ci_types/inheritance`, - method: 'post', - data - }) -} - -// parent_id, child_id -export function deleteCiTypeInheritance(data) { - return axios({ - url: `/v0.1/ci_types/inheritance`, - method: 'delete', - data - }) -} - -export function getCITypeIcons() { - return axios({ - url: '/v0.1/ci_types/icons', - method: 'GET', - }) -} +import { axios } from '@/utils/request' + +/** + * 获取 所有的 ci_types + * @param parameter + * @returns {AxiosPromise} + */ +export function getCITypes(parameter) { + return axios({ + url: '/v0.1/ci_types', + method: 'GET', + params: parameter + }) +} + +/** + * 获取 某个 ci_types + * @param CITypeName + * @param parameter + * @returns {AxiosPromise} + */ +export function getCIType(CITypeName, parameter) { + return axios({ + url: `/v0.1/ci_types/${CITypeName}`, + method: 'GET', + params: parameter + }) +} + +/** + * 创建 ci_type + * @param data + * @returns {AxiosPromise} + */ +export function createCIType(data) { + return axios({ + url: '/v0.1/ci_types', + method: 'POST', + data: data + }) +} + +/** + * 更新 ci_type + * @param CITypeId + * @param data + * @returns {AxiosPromise} + */ +export function updateCIType(CITypeId, data) { + return axios({ + url: `/v0.1/ci_types/${CITypeId}`, + method: 'PUT', + data: data + }) +} + +/** + * 删除 ci_type + * @param CITypeId + * @returns {AxiosPromise} + */ +export function deleteCIType(CITypeId) { + return axios({ + url: `/v0.1/ci_types/${CITypeId}`, + method: 'DELETE' + }) +} + +/** + * 获取 某个 ci_type 的分组 + * @param CITypeId + * @param data + * @returns {AxiosPromise} + */ +export function getCITypeGroupById(CITypeId, data) { + return axios({ + url: `/v0.1/ci_types/${CITypeId}/attribute_groups`, + method: 'GET', + params: data + }) +} + +/** + * 保存 某个 ci_type 的分组 + * @param CITypeId + * @param data + * @returns {AxiosPromise} + */ +export function createCITypeGroupById(CITypeId, data) { + return axios({ + url: `/v0.1/ci_types/${CITypeId}/attribute_groups`, + method: 'POST', + data: data + }) +} + +/** + * 修改 某个 ci_type 的分组 + * @param groupId + * @param data + * @returns {AxiosPromise} + */ +export function updateCITypeGroupById(groupId, data) { + return axios({ + url: `/v0.1/ci_types/attribute_groups/${groupId}`, + method: 'PUT', + data: data + }) +} + +/** + * 删除 某个 ci_type 的分组 + * @param groupId + * @param data + * @returns {AxiosPromise} + */ +export function deleteCITypeGroupById(groupId, data) { + return axios({ + url: `/v0.1/ci_types/attribute_groups/${groupId}`, + method: 'delete', + data: data + }) +} + +/** + * 获取级联属性配置 + * @param {*} typeId + * @returns + */ +export function getCITypeCascadeAttributes(typeId) { + return axios({ + url: `/v0.1/cascade_attributes/ci_types/${typeId}`, + method: 'get' + }) +} + +/** + * 获取级联属性数据 + * @param {*} typeId + * @returns + */ +export function postCITypeCascadeAttributesValues(attrId, data) { + return axios({ + url: `/v0.1/cascade_attributes/${attrId}/values`, + method: 'post', + data + }) +} + +export function getUniqueConstraintList(type_id) { + return axios({ + url: `/v0.1/ci_types/${type_id}/unique_constraint`, + method: 'get', + }) +} + +export function addUniqueConstraint(type_id, data) { + return axios({ + url: `/v0.1/ci_types/${type_id}/unique_constraint`, + method: 'post', + data: data + }) +} + +export function updateUniqueConstraint(type_id, id, data) { + return axios({ + url: `/v0.1/ci_types/${type_id}/unique_constraint/${id}`, + method: 'put', + data: data + }) +} + +export function deleteUniqueConstraint(type_id, id) { + return axios({ + url: `/v0.1/ci_types/${type_id}/unique_constraint/${id}`, + method: 'delete', + }) +} + +export function getTriggerList(type_id) { + return axios({ + url: `/v0.1/ci_types/${type_id}/triggers`, + method: 'get', + }) +} + +export function addTrigger(type_id, data) { + return axios({ + url: `/v0.1/ci_types/${type_id}/triggers`, + method: 'post', + data: data + }) +} + +export function updateTrigger(type_id, id, data) { + return axios({ + url: `/v0.1/ci_types/${type_id}/triggers/${id}`, + method: 'put', + data: data + }) +} + +export function deleteTrigger(type_id, id) { + return axios({ + url: `/v0.1/ci_types/${type_id}/triggers/${id}`, + method: 'delete', + }) +} + +// CMDB的模型和实例的授权接口 +export function grantCiType(type_id, rid, data) { + return axios({ + url: `/v0.1/ci_types/${type_id}/roles/${rid}/grant`, + method: 'post', + data + }) +} +// CMDB的模型和实例的删除授权接口 +export function revokeCiType(type_id, rid, data) { + return axios({ + url: `/v0.1/ci_types/${type_id}/roles/${rid}/revoke`, + method: 'post', + data + }) +} +// CMDB的模型和实例的过滤的权限 +export function ciTypeFilterPermissions(type_id) { + return axios({ + url: `/v0.1/ci_types/${type_id}/filters/permissions`, + method: 'get', + }) +} + +// parent_ids, child_id +export function postCiTypeInheritance(data) { + return axios({ + url: `/v0.1/ci_types/inheritance`, + method: 'post', + data + }) +} + +// parent_id, child_id +export function deleteCiTypeInheritance(data) { + return axios({ + url: `/v0.1/ci_types/inheritance`, + method: 'delete', + data + }) +} + +export function getCITypeIcons() { + return axios({ + url: '/v0.1/ci_types/icons', + method: 'GET', + }) +} diff --git a/cmdb-ui/src/modules/cmdb/components/httpSnmpAD/httpADCategory.vue b/cmdb-ui/src/modules/cmdb/components/httpSnmpAD/httpADCategory.vue index 5a30752..fb57c20 100644 --- a/cmdb-ui/src/modules/cmdb/components/httpSnmpAD/httpADCategory.vue +++ b/cmdb-ui/src/modules/cmdb/components/httpSnmpAD/httpADCategory.vue @@ -29,7 +29,7 @@ class="category-side-children-item-corporate" v-if="ruleType === 'private_cloud' || (ruleType === 'http' && (categoryIndex !== 0 || itemIndex !== 0))" > - 企 + {{ $t('cmdb.enterpriseVersionFlag') }} @@ -67,7 +67,7 @@ class="corporate-flag" v-if="ruleType === 'private_cloud' || (ruleType === 'http' && (categoryIndex !== 0 || itemIndex !== 0))" > - + {{ $t('cmdb.enterpriseVersionFlag') }} diff --git a/cmdb-ui/src/modules/cmdb/lang/en.js b/cmdb-ui/src/modules/cmdb/lang/en.js index c95d8c4..e5fbb69 100644 --- a/cmdb-ui/src/modules/cmdb/lang/en.js +++ b/cmdb-ui/src/modules/cmdb/lang/en.js @@ -2,6 +2,8 @@ const cmdb_en = { relation: 'Relation', attribute: 'Attributes', configTable: 'Config Table', + enterpriseVersionFlag: 'Pro', + enterpriseVersionTip: 'Enterprise version only', menu: { views: 'Views', topologyView: 'Topology Views', @@ -274,8 +276,12 @@ const cmdb_en = { attrAlias: 'Attr Alias', attrCode: 'Attr Code', computedAttrTip1: 'Reference attributes follow jinja2 syntax', - computedAttrTip2: `Multi-valued attributes (lists) are rendered with [ ] included by default, if you want to remove it, the reference method is: ‘’‘{{ attr_name | join(’,‘)}}}’‘’ where commas are separators`, - example: 'Example' + computedAttrTip2: `Multi-valued attributes (lists) are rendered with [ ] included by default, if you want to remove it, the reference method is: """{{ attr_name | join(',') }}""" where commas are separators`, + example: 'Example', + attrFilterTip: `The third column of values allows you to select attributes of this model to cascade attributes`, + rule: 'Rule', + cascadeAttr: 'Cascade', + cascadeAttrTip: 'Cascading attributes note the order', }, components: { unselectAttributes: 'Unselected', @@ -325,6 +331,7 @@ const cmdb_en = { sub: 'subscription', selectBelow: 'Please select below', subSuccess: 'Subscription successful', + subFailed: 'Subscription failed, please try again later', selectMethods: 'Please select a method', noAuthRequest: 'No certification requested yet', noParamRequest: 'No parameter certification yet', @@ -380,6 +387,8 @@ const cmdb_en = { yearsAgo: 'years ago', just: 'just now', searchPlaceholder: 'Please search CIType', + subCITable: 'Data', + subCITree: 'Tree', }, custom_dashboard: { charts: 'Chart', @@ -639,6 +648,7 @@ if __name__ == "__main__": rollbackingTips: 'Rollbacking', batchRollbacking: 'Deleting {total} items in total, {successNum} items successful, {errorNum} items failed', baselineTips: 'Changes at this point in time will also be rollbacked, Unique ID, password and dynamic attributes do not support', + cover: 'Cover', }, serviceTree: { remove: 'Remove', diff --git a/cmdb-ui/src/modules/cmdb/lang/zh.js b/cmdb-ui/src/modules/cmdb/lang/zh.js index 99e0aa4..40fdc00 100644 --- a/cmdb-ui/src/modules/cmdb/lang/zh.js +++ b/cmdb-ui/src/modules/cmdb/lang/zh.js @@ -2,6 +2,8 @@ const cmdb_zh = { relation: '关系', attribute: '属性', configTable: '配置表格', + enterpriseVersionFlag: '企', + enterpriseVersionTip: '仅限企业版', menu: { views: '视图', topologyView: '拓扑视图', @@ -274,8 +276,12 @@ const cmdb_zh = { attrAlias: '属性别名', attrCode: '属性代码', computedAttrTip1: '引用属性遵循jinja2语法', - computedAttrTip2: `多值属性(列表)默认呈现包括[ ], 如果要去掉, 引用方法为: """{{ attr_name | join(',')}}""" 其中逗号为分隔符`, - example: '例如' + computedAttrTip2: `多值属性(列表)默认呈现包括[ ], 如果要去掉, 引用方法为: """{{ attr_name | join(',') }}""" 其中逗号为分隔符`, + example: '例如', + attrFilterTip: '第三列值可选择本模型的属性,来实现级联属性的功能', + rule: '规则', + cascadeAttr: '级联', + cascadeAttrTip: '级联属性注意顺序', }, components: { unselectAttributes: '未选属性', @@ -325,6 +331,7 @@ const cmdb_zh = { sub: '订阅', selectBelow: '请在下方进行选择', subSuccess: '订阅成功', + subFailed: '订阅失败,请稍后再试', selectMethods: '请选择方式', noAuthRequest: '暂无请求认证', noParamRequest: '暂无参数认证', @@ -379,6 +386,8 @@ const cmdb_zh = { yearsAgo: '年前', just: '刚刚', searchPlaceholder: '请搜索模型', + subCITable: '数据订阅', + subCITree: '层级订阅', }, custom_dashboard: { charts: '图表', @@ -638,6 +647,7 @@ if __name__ == "__main__": rollbackingTips: '正在批量回滚中', batchRollbacking: '正在回滚,共{total}个,成功{successNum}个,失败{errorNum}个', baselineTips: '该时间点的变更也会被回滚, 唯一标识、密码属性、动态属性不支持回滚', + cover: '覆盖', }, serviceTree: { remove: '移除', diff --git a/cmdb-ui/src/modules/cmdb/views/ci/modules/CreateInstanceForm.vue b/cmdb-ui/src/modules/cmdb/views/ci/modules/CreateInstanceForm.vue index 4fc5254..2ae66a5 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci/modules/CreateInstanceForm.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci/modules/CreateInstanceForm.vue @@ -1,431 +1,504 @@ - - - - + + + + diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/allAttrDrawer.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/allAttrDrawer.vue index 339c945..93cdcdb 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci_types/allAttrDrawer.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci_types/allAttrDrawer.vue @@ -92,7 +92,7 @@ export default { } attr.groupId = -1 - attr.groupName = '其他' + attr.groupName = this.$t('other') attr.code = `{{ ${attr.name} }}` attr.typeText = typeMap?.[attr.value_type] ?? '' }) diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/attrADTabpane.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/attrADTabpane.vue index 6f67d95..dff970d 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci_types/attrADTabpane.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci_types/attrADTabpane.vue @@ -454,10 +454,15 @@ export default { query_expr: _findADT.query_expr || '', enabled: _findADT?.enabled ?? true, } + + const allMachineIndex = this.agentTypeRadioList.findIndex((item) => item.value === 'all') + if (_findADT.query_expr) { this.agent_type = 'query_expr' } else if (_findADT.agent_id) { this.agent_type = _findADT.agent_id === '0x0000' ? 'master' : 'agent_id' + } else if (_findADT.agent_id === '' && allMachineIndex !== -1) { + this.agent_type = 'all' } else { this.agent_type = this.agentTypeRadioList[0].value } diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/attributeEditForm.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/attributeEditForm.vue index 29dabbc..de5065c 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci_types/attributeEditForm.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci_types/attributeEditForm.vue @@ -345,6 +345,7 @@ :canDefineScript="canDefineScript" ref="preValueArea" :disabled="isShowComputedArea" + :CITypeId="CITypeId" /> diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/attributesTable.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/attributesTable.vue index 9101b88..6e28ac1 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci_types/attributesTable.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci_types/attributesTable.vue @@ -18,19 +18,19 @@ {{ $t('cmdb.ciType.uniqueConstraint') }}
- - {{ valueTypeMap[type] }} + + {{ valueTypeMap[typeKey] }}
diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/ceateNewAttribute.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/ceateNewAttribute.vue index 3643cc9..0b5a66b 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci_types/ceateNewAttribute.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci_types/ceateNewAttribute.vue @@ -333,7 +333,12 @@ - + @@ -402,6 +407,10 @@ export default { type: Boolean, default: true, }, + CITypeId: { + type: Number, + default: null + } }, data() { return { diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/ciTypedetail.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/ciTypedetail.vue index 981e132..67de7a1 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci_types/ciTypedetail.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci_types/ciTypedetail.vue @@ -32,6 +32,8 @@ import TriggerTable from './triggerTable.vue' import ADTab from './adTab.vue' import GrantComp from '../../components/cmdbGrant/grantComp.vue' +const ACTIVE_KEY_STORAGE_KEY = 'ops_model_config_tab_key' + export default { name: 'CITypeDetail', components: { @@ -53,11 +55,24 @@ export default { }, data() { return { - activeKey: '1', + activeKey: localStorage.getItem(ACTIVE_KEY_STORAGE_KEY) || '1', } }, beforeCreate() {}, - mounted() {}, + mounted() { + this.$nextTick(() => { + switch (this.activeKey) { + case '6': + this.$refs.triggerTable.getTableData() + break + case '5': + this.$refs.reconciliationTable.getTableData() + break + default: + break + } + }) + }, computed: { ...mapState({ windowHeight: (state) => state.windowHeight, @@ -66,15 +81,23 @@ export default { methods: { changeTab(activeKey) { this.activeKey = activeKey + localStorage.setItem(ACTIVE_KEY_STORAGE_KEY, activeKey) this.$nextTick(() => { - if (activeKey === '1') { - this.$refs.attributesTable.getCITypeGroupData() - } - if (activeKey === '5') { - this.$refs.triggerTable.getTableData() + switch (activeKey) { + case '1': + this.$refs.attributesTable.getCITypeGroupData() + break + case '6': + this.$refs.triggerTable.getTableData() + break + case '5': + this.$refs.reconciliationTable.getTableData() + break + default: + break } }) - }, + } }, } diff --git a/cmdb-ui/src/modules/cmdb/views/ci_types/computedArea.vue b/cmdb-ui/src/modules/cmdb/views/ci_types/computedArea.vue index 696055b..ce02b90 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci_types/computedArea.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci_types/computedArea.vue @@ -1,17 +1,16 @@