mirror of
https://github.com/veops/cmdb.git
synced 2025-09-20 12:29:20 +08:00
feat(ui): add navigation buttons to the model configuration page and resource view page
This commit is contained in:
@@ -38,6 +38,7 @@ const cmdb_en = {
|
|||||||
attributeAD: 'Attributes AutoDiscovery',
|
attributeAD: 'Attributes AutoDiscovery',
|
||||||
relationAD: 'Relation AutoDiscovery',
|
relationAD: 'Relation AutoDiscovery',
|
||||||
grant: 'Grant',
|
grant: 'Grant',
|
||||||
|
resourceViewTip: 'Not subscribed yet. Please go to the Preference page to complete your subscription.',
|
||||||
addGroup: 'New Group',
|
addGroup: 'New Group',
|
||||||
editGroup: 'Edit Group',
|
editGroup: 'Edit Group',
|
||||||
group: 'Group',
|
group: 'Group',
|
||||||
|
@@ -38,6 +38,7 @@ const cmdb_zh = {
|
|||||||
attributeAD: '属性自动发现',
|
attributeAD: '属性自动发现',
|
||||||
relationAD: '关系自动发现',
|
relationAD: '关系自动发现',
|
||||||
grant: '权限配置',
|
grant: '权限配置',
|
||||||
|
resourceViewTip: '暂未订阅, 请先到我的订阅页面完成订阅',
|
||||||
addGroup: '新增分组',
|
addGroup: '新增分组',
|
||||||
editGroup: '修改分组',
|
editGroup: '修改分组',
|
||||||
group: '分组',
|
group: '分组',
|
||||||
|
@@ -47,6 +47,13 @@
|
|||||||
<a-icon type="star" />
|
<a-icon type="star" />
|
||||||
{{ $t('cmdb.preference.cancelSub') }}
|
{{ $t('cmdb.preference.cancelSub') }}
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
|
<a-menu-item
|
||||||
|
key="citypeConfig"
|
||||||
|
@click="handleCITypeConfig"
|
||||||
|
>
|
||||||
|
<ops-icon type="ops-cmdb-citype" />
|
||||||
|
{{ $t('cmdb.menu.citypeManage') }}
|
||||||
|
</a-menu-item>
|
||||||
</a-menu>
|
</a-menu>
|
||||||
</a-dropdown>
|
</a-dropdown>
|
||||||
</a-space>
|
</a-space>
|
||||||
@@ -782,6 +789,28 @@ export default {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleCITypeConfig() {
|
||||||
|
const { id, name } = this.CIType || {}
|
||||||
|
if (id && name) {
|
||||||
|
roleHasPermissionToGrant({
|
||||||
|
app_id: 'cmdb',
|
||||||
|
resource_type_name: 'CIType',
|
||||||
|
perm: 'config',
|
||||||
|
resource_name: name,
|
||||||
|
}).then((res) => {
|
||||||
|
if (res?.result) {
|
||||||
|
const storageId = `null%${id}%${name}`
|
||||||
|
localStorage.setItem('ops_cityps_currentId', storageId)
|
||||||
|
localStorage.setItem('ops_model_config_tab_key', '1')
|
||||||
|
window.open('/cmdb/ci_types', '_blank')
|
||||||
|
} else {
|
||||||
|
this.$message.error(this.$t('noPermission'))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
handlePerm() {
|
handlePerm() {
|
||||||
roleHasPermissionToGrant({
|
roleHasPermissionToGrant({
|
||||||
app_id: 'cmdb',
|
app_id: 'cmdb',
|
||||||
|
@@ -20,6 +20,18 @@
|
|||||||
<RelationTable isInGrantComp :CITypeId="CITypeId" :CITypeName="CITypeName"></RelationTable>
|
<RelationTable isInGrantComp :CITypeId="CITypeId" :CITypeName="CITypeName"></RelationTable>
|
||||||
</div>
|
</div>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
|
|
||||||
|
<a-button
|
||||||
|
slot="tabBarExtraContent"
|
||||||
|
type="primary"
|
||||||
|
ghost
|
||||||
|
size="small"
|
||||||
|
class="ops-button-ghost ops-tab-button"
|
||||||
|
@click="jumpResourceView"
|
||||||
|
>
|
||||||
|
<ops-icon type="ops-cmdb-resource" />
|
||||||
|
{{ $t('cmdb.menu.ciTable') }}
|
||||||
|
</a-button>
|
||||||
</a-tabs>
|
</a-tabs>
|
||||||
</a-card>
|
</a-card>
|
||||||
</template>
|
</template>
|
||||||
@@ -52,6 +64,10 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
|
preferenceData: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -91,6 +107,16 @@ export default {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
jumpResourceView() {
|
||||||
|
const isSub = this?.preferenceData?.type_ids?.includes(this.CITypeId)
|
||||||
|
|
||||||
|
if (!isSub) {
|
||||||
|
this.$message.error(this.$t('cmdb.ciType.resourceViewTip'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
localStorage.setItem('ops_ci_typeid', this.CITypeId)
|
||||||
|
window.open('/cmdb/instances/types', '_blank')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@@ -182,7 +182,12 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #two>
|
<template #two>
|
||||||
<div class="ci-types-right">
|
<div class="ci-types-right">
|
||||||
<CITypeDetail v-if="currentCId" :CITypeId="currentCId" :CITypeName="currentCName" />
|
<CITypeDetail
|
||||||
|
v-if="currentCId"
|
||||||
|
:CITypeId="currentCId"
|
||||||
|
:CITypeName="currentCName"
|
||||||
|
:preferenceData="preferenceData"
|
||||||
|
/>
|
||||||
<div v-else class="ci-types-right-empty">
|
<div v-else class="ci-types-right-empty">
|
||||||
<a-empty :image="emptyImage" description=""></a-empty>
|
<a-empty :image="emptyImage" description=""></a-empty>
|
||||||
<a-button icon="plus" size="small" type="primary" @click="handleCreateCiFromEmpty">{{
|
<a-button icon="plus" size="small" type="primary" @click="handleCreateCiFromEmpty">{{
|
||||||
@@ -413,6 +418,7 @@ import {
|
|||||||
exportCITypeGroups
|
exportCITypeGroups
|
||||||
} from '@/modules/cmdb/api/ciTypeGroup'
|
} from '@/modules/cmdb/api/ciTypeGroup'
|
||||||
import { searchAttributes, getCITypeAttributesById } from '@/modules/cmdb/api/CITypeAttr'
|
import { searchAttributes, getCITypeAttributesById } from '@/modules/cmdb/api/CITypeAttr'
|
||||||
|
import { getPreference } from '@/modules/cmdb/api/preference'
|
||||||
import CreateNewAttribute from './ceateNewAttribute.vue'
|
import CreateNewAttribute from './ceateNewAttribute.vue'
|
||||||
import CITypeDetail from './ciTypedetail.vue'
|
import CITypeDetail from './ciTypedetail.vue'
|
||||||
import emptyImage from '@/assets/data_empty.png'
|
import emptyImage from '@/assets/data_empty.png'
|
||||||
@@ -489,7 +495,9 @@ export default {
|
|||||||
|
|
||||||
searchValue: '',
|
searchValue: '',
|
||||||
modelExportVisible: false,
|
modelExportVisible: false,
|
||||||
pageLoading: false
|
pageLoading: false,
|
||||||
|
|
||||||
|
preferenceData: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -510,14 +518,19 @@ export default {
|
|||||||
},
|
},
|
||||||
currentGId() {
|
currentGId() {
|
||||||
if (this.currentId) {
|
if (this.currentId) {
|
||||||
return Number(this.currentId.split('%')[0])
|
const id = this?.currentId?.split?.('%')?.[0]
|
||||||
|
if (id !== 'null') {
|
||||||
|
return Number(id)
|
||||||
|
}
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
currentCId() {
|
currentCId() {
|
||||||
if (this.currentId) {
|
if (this.currentId) {
|
||||||
if (this.currentId.split('%')[1] !== 'null') {
|
const id = this?.currentId?.split?.('%')?.[1]
|
||||||
return Number(this.currentId.split('%')[1])
|
if (id !== 'null') {
|
||||||
|
return Number(id)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -525,8 +538,9 @@ export default {
|
|||||||
},
|
},
|
||||||
currentCName() {
|
currentCName() {
|
||||||
if (this.currentId) {
|
if (this.currentId) {
|
||||||
if (this.currentId.split('%')[2] !== 'null') {
|
const name = this?.currentId?.split?.('%')?.[2]
|
||||||
return this.currentId.split('%')[2]
|
if (name !== 'null') {
|
||||||
|
return name
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -598,6 +612,7 @@ export default {
|
|||||||
this.pageLoading = false
|
this.pageLoading = false
|
||||||
|
|
||||||
this.getAttributes()
|
this.getAttributes()
|
||||||
|
this.getPreference()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getAllDepAndEmployee() {
|
getAllDepAndEmployee() {
|
||||||
@@ -608,6 +623,13 @@ export default {
|
|||||||
handleSearch(e) {
|
handleSearch(e) {
|
||||||
this.searchValue = e.target.value
|
this.searchValue = e.target.value
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getPreference() {
|
||||||
|
getPreference().then((res) => {
|
||||||
|
this.preferenceData = res || {}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
async loadCITypes(isResetCurrentId = false, isInit = false) {
|
async loadCITypes(isResetCurrentId = false, isInit = false) {
|
||||||
const groups = await getCITypeGroupsConfig({ need_other: true })
|
const groups = await getCITypeGroupsConfig({ need_other: true })
|
||||||
let alreadyReset = false
|
let alreadyReset = false
|
||||||
@@ -632,8 +654,10 @@ export default {
|
|||||||
if (isInit) {
|
if (isInit) {
|
||||||
const isMatch = groups.some((g) => {
|
const isMatch = groups.some((g) => {
|
||||||
const matchGroup = `${g?.id}%null%null` === this.currentId
|
const matchGroup = `${g?.id}%null%null` === this.currentId
|
||||||
const matchCITypes = g?.ci_types?.some((item) => `${g?.id}%${item?.id}%${item?.name}` === this.currentId)
|
const matchCIType = g?.ci_types?.some((item) => {
|
||||||
return matchGroup || matchCITypes
|
return `${g?.id}%${item?.id}%${item?.name}` === this.currentId || `null%${item?.id}%${item?.name}` === this.currentId
|
||||||
|
})
|
||||||
|
return matchGroup || matchCIType
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!isMatch) {
|
if (!isMatch) {
|
||||||
|
Reference in New Issue
Block a user