Skip to content

Commit

Permalink
perf: cloud privider
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuler committed Jul 3, 2024
1 parent 38aadbd commit a976948
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
v-if="iVisible"
:show-cancel="false"
:show-confirm="false"
:title="$tc('SelectPlatforms')"
:title="$tc('SelectProvider')"
:visible.sync="iVisible"
top="1vh"
width="60%"
Expand Down
32 changes: 22 additions & 10 deletions src/views/assets/Cloud/Account/AccountCreateUpdate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
<el-col :md="4" :sm="24">
<IBox style="height: 490px;">
<el-steps
direction="vertical"
:active="activeStep"
direction="vertical"
space="400px"
>
<el-step :title="$tc('Config')" :description="description" />
<el-step :description="description" :title="$tc('Config')" />
<el-step :title="$tc('Strategy')" />
</el-steps>
</IBox>
Expand Down Expand Up @@ -53,7 +53,10 @@ export default {
function setFieldAttrs() {
const fieldsObject = {}
const updateNotRequiredFields = ['access_key_secret', 'client_secret', 'password', 'sc_password', 'oc_password', 'cert_file', 'key_file', 'public_key', 'private_key']
const updateNotRequiredFields = [
'access_key_secret', 'client_secret', 'password', 'sc_password',
'oc_password', 'cert_file', 'key_file', 'public_key', 'private_key'
]
for (const item of accountProviderAttrs?.attrs) {
fieldsObject[item] = {
rules: updateNotRequiredFields.includes(item) && vm.$route.params.id ? [] : [RequiredChange]
Expand Down Expand Up @@ -160,7 +163,9 @@ export default {
}
return `${url}?provider=${accountProvider}`
},
submitMethod: () => { return vm.$route.params?.id || vm.accountId ? 'put' : 'post' },
submitMethod: () => {
return vm.$route.params?.id || vm.accountId ? 'put' : 'post'
},
cleanFormValue(values) {
const encryptedFields = [
'access_key_secret', 'password', 'client_secret',
Expand Down Expand Up @@ -257,12 +262,18 @@ export default {
},
hasSaveContinue: false,
hasReset: false,
getUrl: () => { return this.strategySettings.url },
submitMethod: () => { return this.$refs.baseForm.form.task?.id ? 'put' : 'post' },
getUrl: () => {
return this.strategySettings.url
},
submitMethod: () => {
return this.$refs.baseForm.form.task?.id ? 'put' : 'post'
},
moreButtons: [
{
title: this.$t('Previous'),
callback: () => { this.activeStep = this.activeStep === 1 ? 0 : 1 }
callback: () => {
this.activeStep = this.activeStep === 1 ? 0 : 1
}
}
],
updateSuccessNextRoute: { name: 'CloudAccountList' },
Expand All @@ -273,7 +284,9 @@ export default {
if (!Array.isArray(ipNetworkSegments)) {
value.ip_network_segment_group = ipNetworkSegments ? ipNetworkSegments.split(',') : []
}
value.strategy = strategy.map(item => { return item.id })
value.strategy = strategy.map(item => {
return item.id
})
const accountId = this.$route.params?.id || this.accountId
if (accountId) {
value.account = { pk: accountId }
Expand All @@ -283,8 +296,7 @@ export default {
}
}
},
methods: {
}
methods: {}
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default {
excludes: ['attrs', 'task'],
quickEditActions: [
{
title: this.$t('IpType'),
title: this.$t('IPType'),
type: 'updateSelect',
attrs: {
model: this.object.task.sync_ip_type,
Expand Down Expand Up @@ -177,7 +177,7 @@ export default {
formatter(row, value) {
return (<div>{
value?.map((content) => {
return <div>{ content }</div>
return <div>{content}</div>
})}
</div>)
}
Expand Down
59 changes: 22 additions & 37 deletions src/views/assets/Cloud/Account/components/AccountPanel.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<template>
<div class="account-panel">
<el-row :gutter="20">
<el-col :span="22">
<div class="line">
<el-col :span="21">
<div class="title">
<span>{{ object.name }}</span>
</div>
</el-col>
<el-col :span="2" @click.native="handleClick($event)">
<el-col :span="3" @click.native="handleClick($event)">
<el-dropdown>
<el-link :underline="false" type="primary">
<i class="el-icon-more el-icon--right" style="color: var(--color-text-primary)" />
Expand All @@ -25,15 +25,13 @@
</el-col>
</el-row>
<el-divider />
<el-row :gutter="20">
<el-col :span="6" class="image">
<el-row :gutter="20" class="panel-content">
<el-col :span="6" class="panel-image">
<el-image :src="cloudImage" fit="contain" />
</el-col>
<el-col :span="18">
<el-col :span="18" class="panel-info">
<InfoPanel :content="iTask.regions.length" :title="$tc('TotalSyncRegion')" />
<InfoPanel :content="iTask.instance_count || 0" :title="$tc('TotalSyncAsset')" />
<!-- <InfoPanel :content="iTask.strategy.length" :title="$tc('TotalSyncStrategy')" /> -->
<!-- <InfoPanel :content="toSafeLocalDateStr(object.date_created)" :title="$tc('DateJoined')" /> -->
<InfoPanel :content="toSafeLocalDateStr(iTask.date_last_sync)" :title="$tc('DateLastSync')" />
</el-col>
</el-row>
Expand Down Expand Up @@ -71,8 +69,8 @@
<script>
import Dialog from '@/components/Dialog/index.vue'
import AuthPanel from './AuthPanel'
import AssetPanel from './AssetPanel'
import InfoPanel from './InfoPanel'
import AssetPanel from './AssetPanel'
import { toSafeLocalDateStr } from '@/utils/time'
import { ACCOUNT_PROVIDER_ATTRS_MAP } from '@/views/assets/Cloud/const'
Expand Down Expand Up @@ -174,43 +172,30 @@ export default {
}
</script>
<style scoped lang="scss">
<style lang="scss" scoped>
.account-panel {
display: flex;
flex-direction: column;
//height: 100%;
cursor: pointer;
& .el-row:first-of-type {
height: 30px !important;
padding: 0;
.el-col-22 {
padding-left: 0 !important;
.line {
line-height: 30px;
text-align: left;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-weight: bold;
}
}
.el-col-2 {
display: flex;
justify-content: center;
align-items: center;
line-height: 30px;
}
.title {
text-align: left;
font-weight: 500;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.el-row {
.panel-content {
display: flex;
align-items: center;
margin: 0 !important;
padding: 25px 0;
height: 100px;
padding: 10px 0;
.panel-image {
margin: auto 5px;
}
}
.el-divider--horizontal {
Expand Down
14 changes: 9 additions & 5 deletions src/views/assets/Cloud/Account/components/AssetPanel.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<template>
<div>
<el-alert
:closable="false"
:center="false"
:closable="true"
style="margin-bottom: 6px"
>
<el-link :type="linkType" :icon="linkIcon" :underline="false"> {{ tip }} </el-link>
<el-link :icon="linkIcon" :type="linkType" :underline="false"> {{ tip }}</el-link>
</el-alert>
<ImportTable
ref="importTable"
Expand Down Expand Up @@ -60,15 +60,17 @@ export default {
title: this.$t('Next'),
type: 'primary',
hidden: !this.active,
callback: () => { this.$emit('update:active', 3) }
callback: () => {
this.$emit('update:active', 3)
}
}
],
config: {
hasSelection: true,
persistSelection: false,
hasPagination: false,
tableAttrs: {
maxHeight: '200px'
height: '300px'
}
},
jsonData: {
Expand Down Expand Up @@ -102,7 +104,9 @@ export default {
},
methods: {
enableWS() {
if (this.ws) { return }
if (this.ws) {
return
}
const scheme = document.location.protocol === 'https:' ? 'wss' : 'ws'
const port = document.location.port ? ':' + document.location.port : ''
const url = '/ws/xpack/cloud/'
Expand Down
19 changes: 16 additions & 3 deletions src/views/assets/Cloud/Account/components/AuthPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
ref="form"
class="form"
v-bind="settings"
@submitSuccess="handleSubmitSuccess"
@performFinished="handlePerformFinished"
@submitSuccess="handleSubmitSuccess"
/>
</template>

Expand All @@ -28,7 +28,8 @@ export default {
},
object: {
type: Object,
default: () => {}
default: () => {
}
},
origin: {
type: String,
Expand All @@ -37,9 +38,13 @@ export default {
},
data() {
const vm = this
function setFieldAttrs(provider) {
const fieldsObject = {}
const updateNotRequiredFields = ['access_key_secret', 'client_secret', 'password', 'sc_password', 'oc_password', 'cert_file', 'key_file', 'public_key', 'private_key']
const updateNotRequiredFields = [
'access_key_secret', 'client_secret', 'password', 'sc_password',
'oc_password', 'cert_file', 'key_file', 'public_key', 'private_key'
]
for (const item of ACCOUNT_PROVIDER_ATTRS_MAP[provider].attrs) {
fieldsObject[item] = {
rules: updateNotRequiredFields.includes(item) && vm.object?.id ? [] : [RequiredChange]
Expand Down Expand Up @@ -202,7 +207,15 @@ export default {
::v-deep .el-form-item.form-buttons {
text-align: right;
}
.form {
margin-right: 0;
::v-deep {
form {
margin-right: 0;
padding-right: 0;
}
}
}
</style>
18 changes: 12 additions & 6 deletions src/views/assets/Cloud/Account/components/CreateDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
width="1051px"
v-on="$listeners"
>
<el-row style="padding: 10px">
<el-col :span="4" style="height: 300px;">
<el-row :gutter="5" style="padding: 10px">
<el-col :span="4" class="left-step-zone">
<el-steps :active="active" direction="vertical">
<el-step :description="firstStepDesc" />
<el-step :description="$tc('Authentication')" />
Expand Down Expand Up @@ -67,7 +67,7 @@ export default {
activeMenuMap: { 0: 'ProviderPanel', 1: 'AuthPanel', 2: 'AssetPanel', 3: 'ResultPanel' },
activeMenu: 'ProviderPanel',
selected: '',
firstStepDesc: this.$tc('SelectPlatforms'),
firstStepDesc: this.$tc('SelectProvider'),
active: 0,
account: {}
}
Expand Down Expand Up @@ -102,11 +102,17 @@ export default {
}
</script>
<style scoped lang="scss">
<style lang="scss" scoped>
::v-deep .el-dialog {
min-width: 1051px !important;
max-width: 1051px !important;
max-width: 1056px !important;
}
.left-step-zone {
border-right: solid 1px var(--color-border);
height: 350px;
}
::v-deep .el-step {
.el-step__head {
&.is-process {
Expand All @@ -131,7 +137,7 @@ export default {
.el-step__main {
.el-step__description.is-process,
.el-step__description.is-finish{
.el-step__description.is-finish {
color: var(--color-primary);
}
}
Expand Down
Loading

0 comments on commit a976948

Please sign in to comment.