From 3b074c7ac954e659f6db541125a836ed5e20ba0f Mon Sep 17 00:00:00 2001 From: jiangweidong <1053570670@qq.com> Date: Fri, 10 Jan 2025 10:36:17 +0800 Subject: [PATCH 1/2] perf: Cloud sync support ali rds --- src/components/Table/CardTable/index.vue | 3 ++- .../assets/Asset/AssetList/DatabaseList.vue | 15 ++++++++++++++- src/views/assets/Asset/AssetList/HostList.vue | 4 +++- .../assets/Cloud/Account/AccountList.vue | 19 ++++++++++++------- .../Cloud/Account/components/AuthPanel.vue | 1 + .../Account/components/ProviderPanel.vue | 4 ++-- src/views/assets/Cloud/const.js | 3 +-- 7 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/components/Table/CardTable/index.vue b/src/components/Table/CardTable/index.vue index 9915141b77..93c6bf1365 100644 --- a/src/components/Table/CardTable/index.vue +++ b/src/components/Table/CardTable/index.vue @@ -158,7 +158,8 @@ export default { const pageQuery = this.getPageQuery(this.page, this.paginationSize) const query = Object.assign(this.extraQuery, pageQuery) const queryString = Object.keys(query).map(key => key + '=' + query[key]).join('&') - const url = `${this.tableUrl}?${queryString}` + const connector = this.tableUrl.indexOf('?') === -1 ? '?' : '&' + const url = `${this.tableUrl}${connector}${queryString}` this.$axios .get(url, this.axiosConfig) diff --git a/src/views/assets/Asset/AssetList/DatabaseList.vue b/src/views/assets/Asset/AssetList/DatabaseList.vue index ab0c940cbb..fefc05c456 100644 --- a/src/views/assets/Asset/AssetList/DatabaseList.vue +++ b/src/views/assets/Asset/AssetList/DatabaseList.vue @@ -13,7 +13,20 @@ export default { return { config: { category: 'database', - url: '/api/v1/assets/databases/' + url: '/api/v1/assets/databases/', + headerActions: { + extraActions: [ + { + name: this.$t('CloudSync'), + title: this.$t('CloudSync'), + icon: 'cloud-provider', + has: () => this.$hasPerm('xpack.view_account') && this.$hasLicense(), + callback: () => this.$router.push( + { name: 'CloudAccountList', query: { category: 'database' }} + ) + } + ] + } } } } diff --git a/src/views/assets/Asset/AssetList/HostList.vue b/src/views/assets/Asset/AssetList/HostList.vue index 655990a9e2..ed3308104f 100644 --- a/src/views/assets/Asset/AssetList/HostList.vue +++ b/src/views/assets/Asset/AssetList/HostList.vue @@ -37,7 +37,9 @@ export default { title: this.$t('CloudSync'), icon: 'cloud-provider', has: () => vm.$hasPerm('xpack.view_account') && vm.$hasLicense(), - callback: () => this.$router.push({ name: 'CloudAccountList' }) + callback: () => this.$router.push( + { name: 'CloudAccountList', query: { category: 'host' }} + ) } ] }, diff --git a/src/views/assets/Cloud/Account/AccountList.vue b/src/views/assets/Cloud/Account/AccountList.vue index dcb03f09d0..ef32d42052 100644 --- a/src/views/assets/Cloud/Account/AccountList.vue +++ b/src/views/assets/Cloud/Account/AccountList.vue @@ -33,7 +33,7 @@ export default { colWidth: 6, subComponent: AccountPanel, tableConfig: { - url: '/api/v1/xpack/cloud/accounts/', + url: `/api/v1/xpack/cloud/accounts/?category=${this.$route.query.category}`, permissions: { app: 'xpack', resource: 'account' @@ -58,12 +58,15 @@ export default { title: this.$t('PublicCloud'), icon: 'public-cloud', callback: () => { - const providers = [ - aliyun, qcloud, qcloud_lighthouse, huaweicloud, - baiducloud, jdcloud, kingsoftcloud, aws_china, - aws_international, azure, azure_international, - gcp, ucloud, volcengine - ] + let providers = [aliyun] + if (this.$route.query.category === 'host') { + providers = providers.concat([ + aliyun, qcloud, qcloud_lighthouse, huaweicloud, + baiducloud, jdcloud, kingsoftcloud, aws_china, + aws_international, azure, azure_international, + gcp, ucloud, volcengine + ]) + } this.providerConfig.providers = providers.map( (item) => ACCOUNT_PROVIDER_ATTRS_MAP[item] ) @@ -74,6 +77,7 @@ export default { name: 'privateCloud', icon: 'private-cloud', title: this.$t('PrivateCloud'), + has: () => this.$route.query.category === 'host', callback: () => { const providers = [ vmware, qingcloud_private, huaweicloud_private, state_private, @@ -89,6 +93,7 @@ export default { name: 'LAN', title: this.$t('LAN'), icon: 'computer', + has: () => this.$route.query.category === 'host', callback: () => { const providers = [lan] this.providerConfig.providers = providers.map( diff --git a/src/views/assets/Cloud/Account/components/AuthPanel.vue b/src/views/assets/Cloud/Account/components/AuthPanel.vue index 63518c848b..90dbe7741e 100644 --- a/src/views/assets/Cloud/Account/components/AuthPanel.vue +++ b/src/views/assets/Cloud/Account/components/AuthPanel.vue @@ -164,6 +164,7 @@ export default { const newValues = JSON.parse(JSON.stringify(values)) newValues['attrs'] = encryptAttrsField(newValues.attrs) newValues['provider'] = vm.provider + newValues['category'] = this.$route.query.category || 'host' return newValues }, addContinue: true diff --git a/src/views/assets/Cloud/Account/components/ProviderPanel.vue b/src/views/assets/Cloud/Account/components/ProviderPanel.vue index 3d9d6d5da5..9939dda562 100644 --- a/src/views/assets/Cloud/Account/components/ProviderPanel.vue +++ b/src/views/assets/Cloud/Account/components/ProviderPanel.vue @@ -1,7 +1,7 @@