perf: 优化对自定义资产的支持

This commit is contained in:
ibuler
2023-04-07 11:32:33 +08:00
committed by Jiangjie.Bai
parent da69186239
commit d0b4b488b1
11 changed files with 34 additions and 29 deletions

View File

@@ -244,8 +244,8 @@ export default {
can: ({ row }) =>
!this.$store.getters.currentOrgIsRoot &&
this.$hasPerm('accounts.change_account') &&
row.asset['auto_info'].ansible_enabled &&
row.asset['auto_info'].ping_enabled,
row.asset['auto_config'].ansible_enabled &&
row.asset['auto_config'].ping_enabled,
callback: ({ row }) => {
this.$axios.post(
`/api/v1/accounts/accounts/tasks/`,

View File

@@ -208,6 +208,7 @@
},
"assets": {
"CustomHelpMessage": "自定义类型资产,需要 Applet 插件的支持",
"CustomFields": "自定义属性",
"CommentHelpText": "注意:备注信息会在 Luna 页面的用户授权资产树中进行悬停显示,普通用户可以查看,请不要填写敏感信息。",
"BulkUpdatePlatformHelpText": "只修改相同类型的资产",
"ImportMessage": "请前往对应类型的页面导入数据",

View File

@@ -85,8 +85,8 @@ export default {
label: this.$t('assets.Test'),
disabled: (
!vm.$hasPerm('accounts.verify_account') ||
!vm.object.asset.auto_info?.ansible_enabled ||
!vm.object.asset.auto_info?.ping_enabled ||
!vm.object.asset.auto_config?.ansible_enabled ||
!vm.object.asset.auto_config?.ping_enabled ||
this.$store.getters.currentOrgIsRoot
)
},
@@ -111,7 +111,7 @@ export default {
label: this.$t('assets.Push'),
disabled: (
!vm.$hasPerm('accounts.push_account') ||
!vm.object.asset.auto_info?.push_account_enabled ||
!vm.object.asset.auto_config?.push_account_enabled ||
this.$store.getters.currentOrgIsRoot
)
},

View File

@@ -6,6 +6,7 @@
import GenericCreateUpdatePage from '@/layout/components/GenericCreateUpdatePage'
import { assetFieldsMeta } from '@/views/assets/const'
import { encryptPassword } from '@/utils/crypto'
import { setUrlParam } from '@/utils/common'
export default {
components: { GenericCreateUpdatePage },
@@ -98,7 +99,11 @@ export default {
},
computed: {
iConfig() {
const { url, addFields, addFieldsMeta, defaultConfig } = this
const { addFields, addFieldsMeta, defaultConfig } = this
let url = this.url
if (this.$route.query.platform) {
url = setUrlParam(url, 'platform', this.$route.query.platform)
}
// 过滤类型为null, undefined 的元素
defaultConfig.fields = defaultConfig.fields.filter(Boolean)
const config = _.merge(defaultConfig, { url })

View File

@@ -12,20 +12,16 @@ export default {
return {
url: '/api/v1/assets/customs/',
addFields: [
[this.$t('assets.Secure'), ['info'], 1]
[this.$t('assets.CustomFields'), ['custom_info'], 1]
],
addFieldsMeta: {
info: {
custom_info: {
fields: '__all__'
}
}
}
},
mounted() {
const platform = this.$route.query.platform
if (platform) {
this.url += `?platform=${platform}`
}
}
}
</script>

View File

@@ -72,8 +72,8 @@ export default {
type: 'primary',
label: this.$t('assets.Refresh'),
disabled: !vm.$hasPerm('assets.refresh_assethardwareinfo') ||
!this.object['auto_info'].gather_facts_enabled ||
!this.object['auto_info'].ansible_enabled ||
!this.object['auto_config'].gather_facts_enabled ||
!this.object['auto_config'].ansible_enabled ||
this.$store.getters.currentOrgIsRoot
},
callbacks: {
@@ -94,8 +94,8 @@ export default {
type: 'primary',
label: this.$t('assets.Test'),
disabled: !vm.$hasPerm('assets.test_assetconnectivity') ||
!this.object['auto_info'].ansible_enabled ||
!this.object['auto_info']['ping_enabled'] ||
!this.object['auto_config'].ansible_enabled ||
!this.object['auto_config']['ping_enabled'] ||
this.$store.getters.currentOrgIsRoot
},
callbacks: {

View File

@@ -2,8 +2,8 @@
<div>
<BaseList v-bind="config" />
<GatewayDialog
:port="GatewayPort"
:cell="GatewayCell"
:port="GatewayPort"
:visible.sync="GatewayVisible"
/>
</div>
@@ -58,8 +58,8 @@ export default {
can: ({ row }) =>
this.$hasPerm('assets.test_assetconnectivity') &&
!this.$store.getters.currentOrgIsRoot &&
row['auto_info'].ansible_enabled &&
row['auto_info'].ping_enabled,
row['auto_config'].ansible_enabled &&
row['auto_config'].ping_enabled,
callback: ({ row }) => {
if (row.platform.name === 'Gateway') {
this.GatewayVisible = true

View File

@@ -20,7 +20,7 @@ export default {
tableConfig: {
columnsExclude: [
'username_selector', 'password_selector', 'submit_selector',
'script', 'spec_info', 'info', 'auto_info'
'script', 'spec_info', 'info', 'auto_config'
],
columnsMeta: {
autofill: {

View File

@@ -7,9 +7,9 @@
<PlatformDialog :category="category" :visible.sync="showPlatform" />
<AssetBulkUpdateDialog
v-if="updateSelectedDialogSetting.visible"
:category="category"
:visible.sync="updateSelectedDialogSetting.visible"
v-bind="updateSelectedDialogSetting"
:category="category"
@update="handleAssetBulkUpdate"
/>
<GatewayDialog
@@ -23,7 +23,12 @@
<script>
import { ListTable } from '@/components'
import {
ActionsFormatter, ArrayFormatter, ChoicesFormatter, DetailFormatter, ProtocolsFormatter, TagsFormatter
ActionsFormatter,
ArrayFormatter,
ChoicesFormatter,
DetailFormatter,
ProtocolsFormatter,
TagsFormatter
} from '@/components/TableFormatters'
import AssetBulkUpdateDialog from './AssetBulkUpdateDialog'
import { connectivityMeta } from '@/components/AccountListTable/const'
@@ -114,7 +119,7 @@ export default {
...extraQuery,
...this.extraQuery
},
columnsExclude: ['spec_info', 'auto_info'],
columnsExclude: ['spec_info', 'auto_config'],
columnsShow: {
min: ['name', 'address', 'actions'],
default: [
@@ -177,8 +182,8 @@ export default {
can: ({ row }) =>
this.$hasPerm('assets.test_assetconnectivity') &&
!this.$store.getters.currentOrgIsRoot &&
row['auto_info'].ansible_enabled &&
row['auto_info'].ping_enabled,
row['auto_config'].ansible_enabled &&
row['auto_config'].ping_enabled,
callback: ({ row }) => {
if (row.platform.name === 'Gateway') {
this.GatewayVisible = true

View File

@@ -37,7 +37,7 @@ export default {
tableConfig: {
url: `/api/v1/assets/gateways/?domain=${this.$route.params.id}`,
columnsExclude: [
'info', 'spec_info', 'auto_info'
'info', 'spec_info', 'auto_config'
],
columnsShow: {
min: ['name', 'actions'],

View File

@@ -6,7 +6,7 @@
@tab-click="changeMoreCreates"
>
<keep-alive>
<GenericListTable :table-config="tableConfig" :header-actions="headerActions" />
<GenericListTable :header-actions="headerActions" :table-config="tableConfig" />
</keep-alive>
</TabPage>
</template>
@@ -87,8 +87,6 @@ export default {
},
headerActions: {
hasRightActions: true,
hasMoreActions: false,
hasBulkDelete: false,
createRoute: 'PlatformCreate',
canCreate: () => {
return this.$hasPerm('assets.add_platform')