diff --git a/.gitignore b/.gitignore index 460951e..54bb2f7 100755 --- a/.gitignore +++ b/.gitignore @@ -73,4 +73,4 @@ ui/npm-debug.log* ui/yarn-debug.log* ui/yarn-error.log* ui/yarn.lock - +ui/package-lock.json diff --git a/api/views/cmdb/preference.py b/api/views/cmdb/preference.py index 685b3fd..3a39717 100644 --- a/api/views/cmdb/preference.py +++ b/api/views/cmdb/preference.py @@ -80,9 +80,9 @@ class PreferenceRelationApiView(APIView): def post(self): name = request.values.get("name") cr_ids = request.values.get("cr_ids") - res = PreferenceManager.create_or_update_relation_view(name, cr_ids) + views, id2type = PreferenceManager.create_or_update_relation_view(name, cr_ids) - return self.jsonify(res) + return self.jsonify(views, id2type) def put(self): return self.post() diff --git a/ui/.env b/ui/.env index 580d9f3..f98cf96 100644 --- a/ui/.env +++ b/ui/.env @@ -1,3 +1,3 @@ NODE_ENV=production VUE_APP_PREVIEW=false -VUE_APP_API_BASE_URL=http://127.0.0.1:5000/api +VUE_APP_API_BASE_URL=http://127.0.0.1:5001/api diff --git a/ui/.env.preview b/ui/.env.preview index 60abf39..196e0da 100644 --- a/ui/.env.preview +++ b/ui/.env.preview @@ -1,3 +1,3 @@ NODE_ENV=production VUE_APP_PREVIEW=true -VUE_APP_API_BASE_URL=http://127.0.0.1:5000/api +VUE_APP_API_BASE_URL=http://127.0.0.1:5001/api diff --git a/ui/babel.config.js b/ui/babel.config.js index 1d98106..46e423b 100644 --- a/ui/babel.config.js +++ b/ui/babel.config.js @@ -2,13 +2,13 @@ module.exports = { presets: [ '@vue/app', [ - "@babel/preset-env", + '@babel/preset-env', { - "useBuiltIns": "usage", // "usage" | "entry" | false, defaults to false. - "corejs": "3.1.2", - "targets": { - "esmodules": true, - "ie": "11" + 'useBuiltIns': 'usage', // "usage" | "entry" | false, defaults to false. + 'corejs': '3.1.2', + 'targets': { + 'esmodules': true, + 'ie': '11' } } ] diff --git a/ui/package.json b/ui/package.json index 0f71589..9c5dcba 100644 --- a/ui/package.json +++ b/ui/package.json @@ -28,6 +28,7 @@ "md5": "^2.2.1", "moment": "^2.24.0", "nprogress": "^0.2.0", + "vis-network": "^6.4.4", "viser-vue": "^2.3.3", "vue": "^2.6.10", "vue-clipboard2": "^0.2.1", diff --git a/ui/src/api/cmdb/CITypeRelation.js b/ui/src/api/cmdb/CITypeRelation.js index 8bb934c..cc64572 100644 --- a/ui/src/api/cmdb/CITypeRelation.js +++ b/ui/src/api/cmdb/CITypeRelation.js @@ -3,7 +3,7 @@ import { axios } from '@/utils/request' export function getCITypeChildren (CITypeID, parameter) { return axios({ url: '/v0.1/ci_type_relations/' + CITypeID + '/children', - method: 'get', + method: 'GET', params: parameter }) } @@ -11,14 +11,21 @@ export function getCITypeChildren (CITypeID, parameter) { export function getCITypeParent (CITypeID) { return axios({ url: '/v0.1/ci_type_relations/' + CITypeID + '/parents', - method: 'get' + method: 'GET' + }) +} + +export function getCITypeRelations () { + return axios({ + url: '/v0.1/ci_type_relations', + method: 'GET' }) } export function createRelation (parentId, childrenId, relationTypeId) { return axios({ url: `/v0.1/ci_type_relations/${parentId}/${childrenId}`, - method: 'post', + method: 'POST', data: { relation_type_id: relationTypeId } }) } @@ -26,7 +33,7 @@ export function createRelation (parentId, childrenId, relationTypeId) { export function deleteRelation (parentId, childrenId) { return axios({ url: `/v0.1/ci_type_relations/${parentId}/${childrenId}`, - method: 'delete' + method: 'DELETE' }) } diff --git a/ui/src/api/cmdb/preference.js b/ui/src/api/cmdb/preference.js index 739b120..ba24c73 100644 --- a/ui/src/api/cmdb/preference.js +++ b/ui/src/api/cmdb/preference.js @@ -39,3 +39,26 @@ export function subscribeTreeView (ciTypeId, levels) { data: { type_id: ciTypeId, levels: levels } }) } + +export function getRelationView () { + return axios({ + url: `/v0.1/preference/relation/view`, + method: 'GET' + }) +} + +export function deleteRelationView (viewName) { + return axios({ + url: `/v0.1/preference/relation/view`, + method: 'DELETE', + data: { name: viewName } + }) +} + +export function subscribeRelationView (payload) { + return axios({ + url: `/v0.1/preference/relation/view`, + method: 'POST', + data: payload + }) +} diff --git a/ui/src/config/router.config.js b/ui/src/config/router.config.js index 72a8829..1408881 100644 --- a/ui/src/config/router.config.js +++ b/ui/src/config/router.config.js @@ -62,14 +62,14 @@ const cmdbRouter = [ path: '/config/ci_types', name: 'ci_type', hideChildrenInMenu: true, - component: () => import('@/views/cmdb/model_config/ci_type/list'), + component: () => import('@/views/cmdb/modeling/ci_type/list'), meta: { title: '模型管理', keepAlive: true } }, { path: '/config/ci_types/:CITypeName/detail/:CITypeId', name: 'ci_type_detail', hideChildrenInMenu: true, - component: () => import('@/views/cmdb/model_config/ci_type/detail'), + component: () => import('@/views/cmdb/modeling/ci_type/detail'), meta: { title: '模型管理', keepAlive: true, hidden: true }, hidden: true }, @@ -77,22 +77,22 @@ const cmdbRouter = [ path: '/config/attributes', name: 'attributes', hideChildrenInMenu: true, - component: () => import('@/views/cmdb/model_config/attributes/index'), + component: () => import('@/views/cmdb/modeling/attributes/index'), meta: { title: '属性库', keepAlive: true } }, { path: '/config/relation_type', name: 'relation_type', hideChildrenInMenu: true, - component: () => import('@/views/cmdb/model_config/relation_type/index'), + component: () => import('@/views/cmdb/modeling/relation_type/index'), meta: { title: '关系类型', keepAlive: true } }, { path: '/config/preference_relation', name: 'preference_relation', hideChildrenInMenu: true, - component: () => import('@/views/cmdb/model_config/preference_relation/index'), - meta: { title: '关系视图配置', keepAlive: true } + component: () => import('@/views/cmdb/modeling/preference_relation/index'), + meta: { title: '关系视图定义', keepAlive: true } } ] }, @@ -107,28 +107,28 @@ const cmdbRouter = [ path: '/acl/users', name: 'acl_users', hideChildrenInMenu: true, - component: () => import('@/views/cmdb/acl/users'), + component: () => import('@/views/acl/users'), meta: { title: '用户管理', keepAlive: true } }, { path: '/acl/roles', name: 'acl_roles', hideChildrenInMenu: true, - component: () => import('@/views/cmdb/acl/roles'), + component: () => import('@/views/acl/roles'), meta: { title: '角色管理', keepAlive: true } }, { path: '/acl/resources', name: 'acl_resources', hideChildrenInMenu: true, - component: () => import('@/views/cmdb/acl/resources'), + component: () => import('@/views/acl/resources'), meta: { title: '资源管理', keepAlive: true } }, { path: '/acl/resource_types', name: 'acl_resource_types', hideChildrenInMenu: true, - component: () => import('@/views/cmdb/acl/resource_types'), + component: () => import('@/views/acl/resource_types'), meta: { title: '资源类型', keepAlive: true } } ] diff --git a/ui/src/views/cmdb/acl/module/addRoleRelationForm.vue b/ui/src/views/acl/module/addRoleRelationForm.vue similarity index 100% rename from ui/src/views/cmdb/acl/module/addRoleRelationForm.vue rename to ui/src/views/acl/module/addRoleRelationForm.vue diff --git a/ui/src/views/cmdb/acl/module/permissionForm.vue b/ui/src/views/acl/module/permissionForm.vue similarity index 100% rename from ui/src/views/cmdb/acl/module/permissionForm.vue rename to ui/src/views/acl/module/permissionForm.vue diff --git a/ui/src/views/cmdb/acl/module/resourceForm.vue b/ui/src/views/acl/module/resourceForm.vue similarity index 100% rename from ui/src/views/cmdb/acl/module/resourceForm.vue rename to ui/src/views/acl/module/resourceForm.vue diff --git a/ui/src/views/cmdb/acl/module/resourcePermForm.vue b/ui/src/views/acl/module/resourcePermForm.vue similarity index 100% rename from ui/src/views/cmdb/acl/module/resourcePermForm.vue rename to ui/src/views/acl/module/resourcePermForm.vue diff --git a/ui/src/views/cmdb/acl/module/resourceTypeForm.vue b/ui/src/views/acl/module/resourceTypeForm.vue similarity index 100% rename from ui/src/views/cmdb/acl/module/resourceTypeForm.vue rename to ui/src/views/acl/module/resourceTypeForm.vue diff --git a/ui/src/views/cmdb/acl/module/roleForm.vue b/ui/src/views/acl/module/roleForm.vue similarity index 100% rename from ui/src/views/cmdb/acl/module/roleForm.vue rename to ui/src/views/acl/module/roleForm.vue diff --git a/ui/src/views/cmdb/acl/module/userForm.vue b/ui/src/views/acl/module/userForm.vue similarity index 100% rename from ui/src/views/cmdb/acl/module/userForm.vue rename to ui/src/views/acl/module/userForm.vue diff --git a/ui/src/views/cmdb/acl/permissions.vue b/ui/src/views/acl/permissions.vue similarity index 100% rename from ui/src/views/cmdb/acl/permissions.vue rename to ui/src/views/acl/permissions.vue diff --git a/ui/src/views/cmdb/acl/resource_types.vue b/ui/src/views/acl/resource_types.vue similarity index 100% rename from ui/src/views/cmdb/acl/resource_types.vue rename to ui/src/views/acl/resource_types.vue diff --git a/ui/src/views/cmdb/acl/resources.vue b/ui/src/views/acl/resources.vue similarity index 100% rename from ui/src/views/cmdb/acl/resources.vue rename to ui/src/views/acl/resources.vue diff --git a/ui/src/views/cmdb/acl/roles.vue b/ui/src/views/acl/roles.vue similarity index 100% rename from ui/src/views/cmdb/acl/roles.vue rename to ui/src/views/acl/roles.vue diff --git a/ui/src/views/cmdb/acl/users.vue b/ui/src/views/acl/users.vue similarity index 100% rename from ui/src/views/cmdb/acl/users.vue rename to ui/src/views/acl/users.vue diff --git a/ui/src/views/cmdb/model_config/preference_relation/index.vue b/ui/src/views/cmdb/model_config/preference_relation/index.vue deleted file mode 100644 index 5679305..0000000 --- a/ui/src/views/cmdb/model_config/preference_relation/index.vue +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/ui/src/views/cmdb/model_config/attributes/index.vue b/ui/src/views/cmdb/modeling/attributes/index.vue similarity index 100% rename from ui/src/views/cmdb/model_config/attributes/index.vue rename to ui/src/views/cmdb/modeling/attributes/index.vue diff --git a/ui/src/views/cmdb/model_config/attributes/module/attributeForm.vue b/ui/src/views/cmdb/modeling/attributes/module/attributeForm.vue similarity index 100% rename from ui/src/views/cmdb/model_config/attributes/module/attributeForm.vue rename to ui/src/views/cmdb/modeling/attributes/module/attributeForm.vue diff --git a/ui/src/views/cmdb/model_config/attributes/module/const.js b/ui/src/views/cmdb/modeling/attributes/module/const.js similarity index 100% rename from ui/src/views/cmdb/model_config/attributes/module/const.js rename to ui/src/views/cmdb/modeling/attributes/module/const.js diff --git a/ui/src/views/cmdb/model_config/ci_type/attributesTable.vue b/ui/src/views/cmdb/modeling/ci_type/attributesTable.vue similarity index 98% rename from ui/src/views/cmdb/model_config/ci_type/attributesTable.vue rename to ui/src/views/cmdb/modeling/ci_type/attributesTable.vue index 2e484f3..8284105 100644 --- a/ui/src/views/cmdb/model_config/ci_type/attributesTable.vue +++ b/ui/src/views/cmdb/modeling/ci_type/attributesTable.vue @@ -143,8 +143,8 @@ import { } from '@/api/cmdb/CITypeAttr' import { STable } from '@/components' import { mixin, mixinDevice } from '@/utils/mixin' -import AttributeForm from '@/views/cmdb/model_config/attributes/module/attributeForm' -import { valueTypeMap } from '@/views/cmdb/model_config/attributes/module/const' +import AttributeForm from '@/views/cmdb/modeling/attributes/module/attributeForm' +import { valueTypeMap } from '@/views/cmdb/modeling/attributes/module/const' export default { name: 'AttributesTable', diff --git a/ui/src/views/cmdb/model_config/ci_type/checkTable.vue b/ui/src/views/cmdb/modeling/ci_type/checkTable.vue similarity index 100% rename from ui/src/views/cmdb/model_config/ci_type/checkTable.vue rename to ui/src/views/cmdb/modeling/ci_type/checkTable.vue diff --git a/ui/src/views/cmdb/model_config/ci_type/defaultShowTable.vue b/ui/src/views/cmdb/modeling/ci_type/defaultShowTable.vue similarity index 100% rename from ui/src/views/cmdb/model_config/ci_type/defaultShowTable.vue rename to ui/src/views/cmdb/modeling/ci_type/defaultShowTable.vue diff --git a/ui/src/views/cmdb/model_config/ci_type/detail.vue b/ui/src/views/cmdb/modeling/ci_type/detail.vue similarity index 100% rename from ui/src/views/cmdb/model_config/ci_type/detail.vue rename to ui/src/views/cmdb/modeling/ci_type/detail.vue diff --git a/ui/src/views/cmdb/model_config/ci_type/group.vue b/ui/src/views/cmdb/modeling/ci_type/group.vue similarity index 100% rename from ui/src/views/cmdb/model_config/ci_type/group.vue rename to ui/src/views/cmdb/modeling/ci_type/group.vue diff --git a/ui/src/views/cmdb/model_config/ci_type/list.vue b/ui/src/views/cmdb/modeling/ci_type/list.vue similarity index 100% rename from ui/src/views/cmdb/model_config/ci_type/list.vue rename to ui/src/views/cmdb/modeling/ci_type/list.vue diff --git a/ui/src/views/cmdb/model_config/ci_type/relationTable.vue b/ui/src/views/cmdb/modeling/ci_type/relationTable.vue similarity index 100% rename from ui/src/views/cmdb/model_config/ci_type/relationTable.vue rename to ui/src/views/cmdb/modeling/ci_type/relationTable.vue diff --git a/ui/src/views/cmdb/modeling/preference_relation/index.vue b/ui/src/views/cmdb/modeling/preference_relation/index.vue new file mode 100644 index 0000000..e2747b6 --- /dev/null +++ b/ui/src/views/cmdb/modeling/preference_relation/index.vue @@ -0,0 +1,312 @@ + + + diff --git a/ui/src/views/cmdb/modeling/preference_relation/modules/RelationViewForm.vue b/ui/src/views/cmdb/modeling/preference_relation/modules/RelationViewForm.vue new file mode 100644 index 0000000..36f859b --- /dev/null +++ b/ui/src/views/cmdb/modeling/preference_relation/modules/RelationViewForm.vue @@ -0,0 +1,159 @@ + + + + + diff --git a/ui/src/views/cmdb/model_config/relation_type/index.vue b/ui/src/views/cmdb/modeling/relation_type/index.vue similarity index 99% rename from ui/src/views/cmdb/model_config/relation_type/index.vue rename to ui/src/views/cmdb/modeling/relation_type/index.vue index 5e2681b..3b66b7e 100644 --- a/ui/src/views/cmdb/model_config/relation_type/index.vue +++ b/ui/src/views/cmdb/modeling/relation_type/index.vue @@ -80,7 +80,7 @@