perf: change domain to zone

This commit is contained in:
ibuler
2025-04-18 18:41:52 +08:00
committed by 老广
parent deea38c704
commit 9a0158da3a
23 changed files with 71 additions and 67 deletions

View File

@@ -16,9 +16,9 @@ export function getSystemUserList(data) {
}) })
} }
export function getDomainList(data) { export function getZoneList(data) {
return request({ return request({
url: '/api/v1/assets/domains/', url: '/api/v1/assets/zones/',
method: 'get', method: 'get',
params: data params: data
}) })

View File

@@ -228,35 +228,35 @@ export default [
component: empty, component: empty,
redirect: '', redirect: '',
meta: { meta: {
resource: 'domain', resource: 'zone',
icon: 'zone', icon: 'zone',
permissions: ['assets.view_domain'] permissions: ['assets.view_zone']
}, },
children: [ children: [
{ {
path: '', path: '',
name: 'ZoneList', name: 'ZoneList',
component: () => import('@/views/assets/Domain/DomainList.vue'), component: () => import('@/views/assets/Zone/ZoneList.vue'),
meta: { title: i18n.t('ZoneList') } meta: { title: i18n.t('ZoneList') }
}, },
{ {
path: 'create', path: 'create',
name: 'ZoneCreate', name: 'ZoneCreate',
component: () => import('@/views/assets/Domain/DomainCreateUpdate.vue'), component: () => import('@/views/assets/Zone/ZoneCreateUpdate.vue'),
hidden: true, hidden: true,
meta: { title: i18n.t('ZoneCreate') } meta: { title: i18n.t('ZoneCreate') }
}, },
{ {
path: ':id/update', path: ':id/update',
name: 'ZoneUpdate', name: 'ZoneUpdate',
component: () => import('@/views/assets/Domain/DomainCreateUpdate.vue'), component: () => import('@/views/assets/Zone/ZoneCreateUpdate.vue'),
hidden: true, hidden: true,
meta: { title: i18n.t('ZoneUpdate') } meta: { title: i18n.t('ZoneUpdate') }
}, },
{ {
path: ':id', path: ':id',
name: 'ZoneDetail', name: 'ZoneDetail',
component: () => import('@/views/assets/Domain/DomainDetail'), component: () => import('@/views/assets/Zone/ZoneDetail'),
hidden: true, hidden: true,
meta: { title: i18n.t('Zone') } meta: { title: i18n.t('Zone') }
} }
@@ -274,7 +274,7 @@ export default [
{ {
path: 'create', path: 'create',
name: 'GatewayCreate', name: 'GatewayCreate',
component: () => import('@/views/assets/Domain/DomainDetail/GatewayCreateUpdate.vue'), component: () => import('@/views/assets/Zone/ZoneDetail/GatewayCreateUpdate.vue'),
meta: { meta: {
title: i18n.t('GatewayCreate'), title: i18n.t('GatewayCreate'),
permissions: ['assets.view_gateway'] permissions: ['assets.view_gateway']
@@ -283,7 +283,7 @@ export default [
{ {
path: ':id/update', path: ':id/update',
name: 'GatewayUpdate', name: 'GatewayUpdate',
component: () => import('@/views/assets/Domain/DomainDetail/GatewayCreateUpdate.vue'), component: () => import('@/views/assets/Zone/ZoneDetail/GatewayCreateUpdate.vue'),
meta: { meta: {
title: i18n.t('GatewayUpdate'), title: i18n.t('GatewayUpdate'),
permissions: ['assets.change_gateway'] permissions: ['assets.change_gateway']

View File

@@ -64,7 +64,7 @@ export default {
[this.$t('Basic'), ['name', 'address', 'platform', 'nodes']], [this.$t('Basic'), ['name', 'address', 'platform', 'nodes']],
[this.$t('Protocol'), ['protocols']], [this.$t('Protocol'), ['protocols']],
[this.$t('Account'), ['accounts']], [this.$t('Account'), ['accounts']],
[this.$t('Other'), ['directory_services', 'domain', 'labels', 'is_active', 'comment']] [this.$t('Other'), ['directory_services', 'zone', 'labels', 'is_active', 'comment']]
], ],
fieldsMeta: {}, fieldsMeta: {},
performSubmit(validValues) { performSubmit(validValues) {

View File

@@ -184,7 +184,7 @@ export default {
object: this.object, object: this.object,
fields: [ fields: [
'id', 'name', 'category', 'type', 'id', 'name', 'category', 'type',
'address', 'platform', 'protocols', 'domain', 'address', 'platform', 'protocols', 'zone',
'is_active', 'date_created', 'date_updated', 'is_active', 'date_created', 'date_updated',
'created_by', 'comment' 'created_by', 'comment'
], ],

View File

@@ -41,7 +41,7 @@ export default {
formSetting: { formSetting: {
url: '/api/v1/assets/assets/', url: '/api/v1/assets/assets/',
hasSaveContinue: false, hasSaveContinue: false,
fields: ['platform', 'nodes', 'domain', 'labels', 'is_active', 'comment'], fields: ['platform', 'nodes', 'zone', 'labels', 'is_active', 'comment'],
fieldsMeta: { fieldsMeta: {
platform: { platform: {
el: { el: {
@@ -63,8 +63,8 @@ export default {
...meta.nodes, ...meta.nodes,
label: this.$t('Node') label: this.$t('Node')
}, },
domain: { zone: {
...meta.domain, ...meta.zone,
label: this.$tc('Zone'), label: this.$tc('Zone'),
disabled: exclude.includes(this.category) disabled: exclude.includes(this.category)
}, },

View File

@@ -73,8 +73,8 @@ export default {
case 'node': case 'node':
url = '/api/v1/assets/nodes/' url = '/api/v1/assets/nodes/'
break break
case 'domain': case 'zone':
url = '/api/v1/assets/domains/' url = '/api/v1/assets/zones/'
break break
case 'account_template': case 'account_template':
url = '/api/v1/accounts/account-templates/' url = '/api/v1/accounts/account-templates/'
@@ -209,7 +209,7 @@ export default {
beforeSubmit(data) { beforeSubmit(data) {
let status = true let status = true
const labelMap = { const labelMap = {
platform: this.$tc('Platform'), domain: this.$tc('Zone'), platform: this.$tc('Platform'), zone: this.$tc('Zone'),
name_strategy: this.$tc('Strategy') name_strategy: this.$tc('Strategy')
} }
this.tableConfig.totalData.map(item => { this.tableConfig.totalData.map(item => {

View File

@@ -4,7 +4,7 @@ import { attrMatchOptions } from '@/components/const'
export const resourceTypeOptions = [ export const resourceTypeOptions = [
{ label: i18n.t('Platform'), value: 'platform' }, { label: i18n.t('Platform'), value: 'platform' },
{ label: i18n.t('Node'), value: 'node' }, { label: i18n.t('Node'), value: 'node' },
{ label: i18n.t('Zone'), value: 'domain' }, { label: i18n.t('Zone'), value: 'zone' },
{ label: i18n.t('AccountTemplate'), value: 'account_template' }, { label: i18n.t('AccountTemplate'), value: 'account_template' },
{ label: i18n.t('Tags'), value: 'label' }, { label: i18n.t('Tags'), value: 'label' },
{ label: i18n.t('Strategy'), value: 'name_strategy' } { label: i18n.t('Strategy'), value: 'name_strategy' }
@@ -20,7 +20,9 @@ export const tableFormatter = (colName, getResourceLabel) => {
return (row, col, cellValue) => { return (row, col, cellValue) => {
const globalResource = {} const globalResource = {}
const value = cellValue const value = cellValue
if (value?.label) { return value.label } if (value?.label) {
return value.label
}
switch (colName) { switch (colName) {
case 'attr': case 'attr':
return instanceAttrOptions.find(attr => attr.value === value)?.label || value return instanceAttrOptions.find(attr => attr.value === value)?.label || value
@@ -36,7 +38,9 @@ export const tableFormatter = (colName, getResourceLabel) => {
} }
return globalResource[value] || value return globalResource[value] || value
case 'protocols': case 'protocols':
return Array.isArray(value) ? value.map(p => { return `${p.name}/${p.port}` }).join(', ') : '' return Array.isArray(value) ? value.map(p => {
return `${p.name}/${p.port}`
}).join(', ') : ''
case 'count': case 'count':
return value?.length || 0 return value?.length || 0
default: default:

View File

@@ -50,7 +50,7 @@ export default {
]], ]],
[this.$t('Config'), [ [this.$t('Config'), [
'protocols', 'su_enabled', 'su_method', 'protocols', 'su_enabled', 'su_method',
'domain_enabled', 'ds_enabled', 'gateway_enabled', 'ds_enabled',
'charset' 'charset'
]], ]],
[this.$t('Automations'), ['automation']], [this.$t('Automations'), ['automation']],
@@ -152,7 +152,7 @@ export default {
}) })
this.fieldsMeta.protocols.el.choices = protocols this.fieldsMeta.protocols.el.choices = protocols
const fieldsCheck = ['domain_enabled', 'su_enabled'] const fieldsCheck = ['gateway_enabled', 'su_enabled']
for (const field of fieldsCheck) { for (const field of fieldsCheck) {
const disabled = constraints[field] === false const disabled = constraints[field] === false
this.initial[field] = !disabled this.initial[field] = !disabled

View File

@@ -59,7 +59,7 @@ export default {
data() { data() {
return { return {
visible: false, visible: false,
fields: ['domain_enabled'], fields: ['gateway_enabled'],
quickActions: [], quickActions: [],
url: `/api/v1/assets/platforms/${this.object.id}/`, url: `/api/v1/assets/platforms/${this.object.id}/`,
detailFields: [ detailFields: [
@@ -101,16 +101,16 @@ export default {
const { object } = this const { object } = this
const quickActions = [ const quickActions = [
{ {
title: this.$t('EnableDomain'), title: this.$t('EnableGateway'),
type: 'switch', type: 'switch',
attrs: { attrs: {
label: this.$t('Update'), label: this.$t('Update'),
model: object['domain_enabled'], model: object['gateway_enabled'],
disabled: !this.canEdit || this.constraints['domain_enabled'] === false disabled: !this.canEdit || this.constraints['gateway_enabled'] === false
}, },
callbacks: Object.freeze({ callbacks: Object.freeze({
change: (val) => { change: (val) => {
const data = { domain_enabled: val } const data = { gateway_enabled: val }
this.$axios.patch( this.$axios.patch(
`/api/v1/assets/platforms/${object.id}/`, data).then(res => { `/api/v1/assets/platforms/${object.id}/`, data).then(res => {
this.$message.success(this.$tc('UpdateSuccessMsg')) this.$message.success(this.$tc('UpdateSuccessMsg'))

View File

@@ -73,7 +73,7 @@ export default {
category: { category: {
formatter: ChoicesFormatter formatter: ChoicesFormatter
}, },
domain_enabled: { gateway_enabled: {
formatterArgs: { formatterArgs: {
showFalse: false showFalse: false
} }

View File

@@ -76,7 +76,7 @@ export const platformFieldsMeta = (vm) => {
} }
}, },
charset: {}, charset: {},
domain_enabled: { gateway_enabled: {
el: { el: {
disabled: false disabled: false
} }

View File

@@ -25,9 +25,9 @@ export default {
component: AssetSelect, component: AssetSelect,
el: { el: {
value: [], value: [],
baseUrl: '/api/v1/assets/assets/?domain_enabled=true', baseUrl: '/api/v1/assets/assets/?gateway_enabled=true',
treeUrlQuery: { treeUrlQuery: {
domain_enabled: true gateway_enabled: true
}, },
canSelect: (row) => { canSelect: (row) => {
return !row.platform?.name.startsWith('Gateway') return !row.platform?.name.startsWith('Gateway')
@@ -42,7 +42,7 @@ export default {
} }
} }
}, },
url: '/api/v1/assets/domains/' url: '/api/v1/assets/zones/'
} }
} }
} }

View File

@@ -14,7 +14,7 @@
<script> <script>
import BaseList from '@/views/assets/Asset/AssetList/components/BaseList' import BaseList from '@/views/assets/Asset/AssetList/components/BaseList'
import AddAssetDialog from '@/views/assets/Domain/components/AddAssetDialog.vue' import AddAssetDialog from '@/views/assets/Zone/components/AddAssetDialog.vue'
import TwoCol from '@/layout/components/Page/TwoColPage.vue' import TwoCol from '@/layout/components/Page/TwoColPage.vue'
export default { export default {
@@ -34,7 +34,7 @@ export default {
return { return {
config: { config: {
category: 'all', category: 'all',
url: `/api/v1/assets/assets/?domain=${this.object.id}&is_gateway=0`, url: `/api/v1/assets/assets/?zone=${this.object.id}&is_gateway=0`,
tableConfig: { tableConfig: {
columns: ['name', 'address', 'platform', 'actions'], columns: ['name', 'address', 'platform', 'actions'],
columnsMeta: { columnsMeta: {
@@ -114,14 +114,14 @@ export default {
patch_data = rows.selectedRows.map(row => { patch_data = rows.selectedRows.map(row => {
return { return {
id: row.id, id: row.id,
domain: null zone: null
} }
}) })
msg = patch_data.length + ' ' + this.$t('Rows') msg = patch_data.length + ' ' + this.$t('Rows')
} else { } else {
patch_data = [{ patch_data = [{
id: rows.row.id, id: rows.row.id,
domain: null zone: null
}] }]
msg = rows.row.name msg = rows.row.name
} }

View File

@@ -23,7 +23,7 @@ export default {
}, },
data() { data() {
return { return {
url: `/api/v1/assets/domains/${this.object.id}/`, url: `/api/v1/assets/zones/${this.object.id}/`,
detailFields: [ detailFields: [
'name', 'assets_amount', 'name', 'assets_amount',
{ {

View File

@@ -17,11 +17,11 @@ export default {
const url = `/api/v1/assets/platforms/?name__startswith=Gateway` const url = `/api/v1/assets/platforms/?name__startswith=Gateway`
const platform = await this.$axios.get(url) const platform = await this.$axios.get(url)
initial.platform = parseInt(platform[0].id) initial.platform = parseInt(platform[0].id)
initial.domain = this.$route.query.domain initial.zone = this.$route.query.zone
return initial return initial
}, },
addFieldsMeta: { addFieldsMeta: {
domain: { zone: {
disabled: true disabled: true
}, },
platform: { platform: {
@@ -40,7 +40,7 @@ export default {
createSuccessNextRoute: { createSuccessNextRoute: {
name: 'ZoneDetail', name: 'ZoneDetail',
params: { params: {
id: this.$route.query.domain id: this.$route.query.zone
}, },
query: { query: {
tab: 'GatewayList' tab: 'GatewayList'
@@ -49,7 +49,7 @@ export default {
updateSuccessNextRoute: { updateSuccessNextRoute: {
name: 'ZoneDetail', name: 'ZoneDetail',
params: { params: {
id: this.$route.query.domain id: this.$route.query.zone
}, },
query: { query: {
tab: 'GatewayList' tab: 'GatewayList'

View File

@@ -27,7 +27,7 @@ import { GenericListTable } from '@/layout/components'
import GatewayTestDialog from '@/components/Apps/GatewayTestDialog' import GatewayTestDialog from '@/components/Apps/GatewayTestDialog'
import { connectivityMeta } from '@/components/Apps/AccountListTable/const' import { connectivityMeta } from '@/components/Apps/AccountListTable/const'
import { ArrayFormatter, ChoicesFormatter, DetailFormatter, TagsFormatter } from '@/components/Table/TableFormatters' import { ArrayFormatter, ChoicesFormatter, DetailFormatter, TagsFormatter } from '@/components/Table/TableFormatters'
import AddGatewayDialog from '@/views/assets/Domain/components/AddGatewayDialog' import AddGatewayDialog from '@/views/assets/Zone/components/AddGatewayDialog'
import TwoCol from '@/layout/components/Page/TwoColPage.vue' import TwoCol from '@/layout/components/Page/TwoColPage.vue'
export default { export default {
@@ -48,7 +48,7 @@ export default {
const vm = this const vm = this
return { return {
createDrawer: () => import('@/views/assets/Domain/DomainDetail/GatewayCreateUpdate.vue'), createDrawer: () => import('@/views/assets/Zone/ZoneDetail/GatewayCreateUpdate.vue'),
detailDrawer: () => import('@/views/assets/Asset/AssetDetail'), detailDrawer: () => import('@/views/assets/Asset/AssetDetail'),
transObject: {}, transObject: {},
testConfig: { testConfig: {
@@ -57,7 +57,7 @@ export default {
cell: '' cell: ''
}, },
tableConfig: { tableConfig: {
url: `/api/v1/assets/gateways/?domain=${this.object.id}`, url: `/api/v1/assets/gateways/?zone=${this.object.id}`,
columnsExclude: [ columnsExclude: [
'info', 'spec_info', 'auto_config' 'info', 'spec_info', 'auto_config'
], ],
@@ -113,7 +113,7 @@ export default {
formatterArgs: { formatterArgs: {
updateRoute: { updateRoute: {
name: 'GatewayUpdate', name: 'GatewayUpdate',
query: { domain: this.object.id, platform_type: 'linux', 'category': 'host' } query: { zone: this.object.id, platform_type: 'linux', 'category': 'host' }
}, },
onClone: ({ row }) => { onClone: ({ row }) => {
this.$refs.ListTable.onClone({ row: { ...row, payload: 'pam_asset_clone' }}) this.$refs.ListTable.onClone({ row: { ...row, payload: 'pam_asset_clone' }})
@@ -203,7 +203,7 @@ export default {
} }
], ],
onCreate: () => { onCreate: () => {
vm.$refs.ListTable.onCreate({ query: { domain: vm.object.id, platform_type: 'linux', category: 'host' }}) vm.$refs.ListTable.onCreate({ query: { zone: vm.object.id, platform_type: 'linux', category: 'host' }})
} }
}, },
addGatewaySetting: { addGatewaySetting: {
@@ -222,14 +222,14 @@ export default {
patch_data = rows.selectedRows.map(row => { patch_data = rows.selectedRows.map(row => {
return { return {
id: row.id, id: row.id,
domain: null zone: null
} }
}) })
msg = patch_data.length + ' ' + this.$t('Rows') msg = patch_data.length + ' ' + this.$t('Rows')
} else { } else {
patch_data = [{ patch_data = [{
id: rows.row.id, id: rows.row.id,
domain: null zone: null
}] }]
msg = rows.row.name msg = rows.row.name
} }

View File

@@ -25,7 +25,7 @@ export default {
TaskDetail: {}, TaskDetail: {},
config: { config: {
activeMenu: 'Detail', activeMenu: 'Detail',
url: '/api/v1/assets/domains/', url: '/api/v1/assets/zones/',
submenu: [ submenu: [
{ {
title: this.$t('Basic'), title: this.$t('Basic'),

View File

@@ -18,10 +18,10 @@ export default {
}, },
data() { data() {
return { return {
createDrawer: () => import('./DomainCreateUpdate.vue'), createDrawer: () => import('./ZoneCreateUpdate.vue'),
detailDrawer: () => import('./DomainDetail/index.vue'), detailDrawer: () => import('@/views/assets/Zone/ZoneDetail/index.vue'),
tableConfig: { tableConfig: {
url: '/api/v1/assets/domains/', url: '/api/v1/assets/zones/',
columnsExclude: ['gateway'], columnsExclude: ['gateway'],
columnsExtra: ['gateways'], columnsExtra: ['gateways'],
columns: ['name', 'assets_amount', 'gateways', 'labels', 'comment', 'actions'], columns: ['name', 'assets_amount', 'gateways', 'labels', 'comment', 'actions'],

View File

@@ -5,7 +5,7 @@
:modal="false" :modal="false"
:show-cancel="false" :show-cancel="false"
:show-confirm="false" :show-confirm="false"
:title="$tc('AddAssetInDomain')" :title="$tc('AddAssetInZone')"
:visible.sync="setting.addAssetDialogVisible" :visible.sync="setting.addAssetDialogVisible"
after after
custom-class="asset-select-dialog" custom-class="asset-select-dialog"
@@ -62,9 +62,9 @@ export default {
type: 'select2', type: 'select2',
el: { el: {
value: [], value: [],
url: '/api/v1/assets/assets/?domain_enabled=true', url: '/api/v1/assets/assets/?gateway_enabled=true',
treeUrlQuery: { treeUrlQuery: {
domain_enabled: true gateway_enabled: true
}, },
canSelect: (row) => { canSelect: (row) => {
return !row.platform?.name.startsWith('Gateway') && this.object.assets.map(item => item.id).indexOf(row.id) === -1 return !row.platform?.name.startsWith('Gateway') && this.object.assets.map(item => item.id).indexOf(row.id) === -1
@@ -75,7 +75,7 @@ export default {
cleanFormValue(values) { cleanFormValue(values) {
const data = [] const data = []
values.assets.forEach(item => { values.assets.forEach(item => {
const d = { id: item, domain: vm.object.id } const d = { id: item, zone: vm.object.id }
data.push(d) data.push(d)
}) })
return data return data

View File

@@ -4,7 +4,7 @@
:destroy-on-close="true" :destroy-on-close="true"
:show-cancel="false" :show-cancel="false"
:show-confirm="false" :show-confirm="false"
:title="$tc('AddGatewayInDomain')" :title="$tc('AddGatewayInZone')"
:visible.sync="setting.addGatewayDialogVisible" :visible.sync="setting.addGatewayDialogVisible"
after after
custom-class="asset-select-dialog" custom-class="asset-select-dialog"
@@ -65,7 +65,7 @@ export default {
multiple: true, multiple: true,
clearable: true, clearable: true,
ajax: { ajax: {
url: '/api/v1/assets/assets/?domain_enabled=true&is_gateway=1' url: '/api/v1/assets/assets/?gateway_enabled=true&is_gateway=1'
}, },
disabledValues: this.object.gateways.map(item => item.id) disabledValues: this.object.gateways.map(item => item.id)
} }
@@ -74,7 +74,7 @@ export default {
cleanFormValue(values) { cleanFormValue(values) {
const data = [] const data = []
values.gateways.forEach(item => { values.gateways.forEach(item => {
const d = { id: item.pk, domain: vm.object.id } const d = { id: item.pk, zone: vm.object.id }
data.push(d) data.push(d)
}) })
return data return data

View File

@@ -112,18 +112,18 @@ export const assetFieldsMeta = (vm, category, type) => {
}, 200) }, 200)
} }
}, },
domain: { zone: {
component: Select2, component: Select2,
disabled: false, disabled: false,
el: { el: {
multiple: false, multiple: false,
clearable: true, clearable: true,
ajax: { ajax: {
url: '/api/v1/assets/domains/' url: '/api/v1/assets/zones/'
} }
}, },
hidden: () => { hidden: () => {
return vm.platform.domain_enabled === false return vm.platform.gateway_enabled === false
} }
}, },
accounts: { accounts: {

View File

@@ -56,7 +56,7 @@ export default {
platform: { platform: {
hidden: () => true hidden: () => true
}, },
domain: { zone: {
hidden: () => { hidden: () => {
return !this.$store.getters.hasValidLicense return !this.$store.getters.hasValidLicense
}, },

View File

@@ -110,9 +110,9 @@ export default {
'assets.view_asset': ['assets.view_platform'], 'assets.view_asset': ['assets.view_platform'],
'assets.view_node': ['assets.view_asset', 'assets.view_platform'], 'assets.view_node': ['assets.view_asset', 'assets.view_platform'],
'acls.commandgroup': ['acls.view_commandfilteracl'], 'acls.commandgroup': ['acls.view_commandfilteracl'],
'assets.gateway': ['assets.view_domain'], 'assets.gateway': ['assets.view_zone'],
'assets.add_gateway': ['assets.view_domain', 'assets.view_platform', 'assets.view_node'], 'assets.add_gateway': ['assets.view_zone', 'assets.view_platform', 'assets.view_node'],
'assets.change_gateway': ['assets.view_domain', 'assets.view_platform', 'assets.view_node'], 'assets.change_gateway': ['assets.view_zone', 'assets.view_platform', 'assets.view_node'],
'assets.add_asset': ['assets.view_platform'], 'assets.add_asset': ['assets.view_platform'],
'assets.change_asset': ['assets.view_platform'], 'assets.change_asset': ['assets.view_platform'],
'accounts.view_gatheredaccount': ['assets.view_asset', 'assets.view_node'], 'accounts.view_gatheredaccount': ['assets.view_asset', 'assets.view_node'],