mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-17 07:42:41 +00:00
perf: 优化账号模版同步更新账号信息
This commit is contained in:
@@ -116,6 +116,8 @@
|
||||
"AccountExportTips": "The exported information contains account secret, which involves sensitive information. The exported format is an encrypted zip file (if no encryption password is set, please go to personal information to set the file encryption password).",
|
||||
"TaskID": "Task ID",
|
||||
"AccountTemplate": "Account template",
|
||||
"Sync": "Sync",
|
||||
"SyncUpdateAccountInfo": "Sync update account info",
|
||||
"AddAccountResult": "Add account result",
|
||||
"AutoPush": "Auto Push",
|
||||
"GeneralAccounts": "General Accounts",
|
||||
|
@@ -116,6 +116,8 @@
|
||||
"AccountExportTips": "エクスポート情報には機密情報を含むアカウント暗号文が含まれており、エクスポートされたフォーマットは暗号化されたzipファイルです(暗号化パスワードが設定されていない場合は、個人情報にファイル暗号化パスワードを設定してください)。",
|
||||
"TaskID": "タスク ID",
|
||||
"AccountTemplate": "账号模版",
|
||||
"Sync": "同期",
|
||||
"SyncUpdateAccountInfo": "アカウント情報の同期更新",
|
||||
"AddAccountResult": "账号批量添加结果",
|
||||
"AutoPush": "自動プッシュ",
|
||||
"GeneralAccounts": "一般アカウント",
|
||||
|
@@ -10,6 +10,8 @@
|
||||
"GenerateSuccessMsg": "账号生成成功",
|
||||
"GenerateAccounts": "重新生成账号",
|
||||
"UpdateSecret": "更新密文",
|
||||
"Sync": "同步",
|
||||
"SyncUpdateAccountInfo": "同步更新账号信息",
|
||||
"AddAccountResult": "账号批量添加结果",
|
||||
"AccountPolicy": "账号策略",
|
||||
"BulkCreateStrategy": "创建时对于不符合要求的账号,如:密钥类型不合规,唯一键约束,可选择以上策略。",
|
||||
|
@@ -14,6 +14,14 @@ export default {
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
const isUpdate = vm.$route.path.indexOf('/update') > -1 && vm.$route.params?.id
|
||||
const formFields = templateFields(vm)
|
||||
for (const [key, value] of formFields) {
|
||||
if (key === vm.$t('assets.Secret')) {
|
||||
isUpdate && value.push('is_sync_account')
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
initial: {
|
||||
secret_type: 'password',
|
||||
@@ -21,11 +29,28 @@ export default {
|
||||
},
|
||||
url: '/api/v1/accounts/account-templates/',
|
||||
hasDetailInMsg: false,
|
||||
fields: [
|
||||
...templateFields(vm)
|
||||
],
|
||||
fields: formFields,
|
||||
fieldsMeta: {
|
||||
...templateFieldsMeta(vm)
|
||||
...templateFieldsMeta(vm),
|
||||
is_sync_account: {
|
||||
label: this.$t('accounts.SyncUpdateAccountInfo'),
|
||||
el: {
|
||||
icon: 'fa fa-external-link',
|
||||
type: 'primary',
|
||||
size: 'mini'
|
||||
},
|
||||
component: 'el-button',
|
||||
on: {
|
||||
click: () => {
|
||||
vm.$router.push({
|
||||
name: 'AccountTemplateDetail',
|
||||
query: {
|
||||
activeTab: 'Account'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
cleanFormValue(value) {
|
||||
Object.keys(value).forEach((item, index, arr) => {
|
||||
@@ -35,6 +60,7 @@ export default {
|
||||
}
|
||||
})
|
||||
value['secret'] = encryptPassword(value['secret'])
|
||||
delete value.is_sync_account
|
||||
return value
|
||||
},
|
||||
createSuccessNextRoute: { name: 'AccountTemplateList' },
|
||||
|
@@ -20,10 +20,6 @@
|
||||
:url="secretUrl"
|
||||
:visible.sync="showViewSecretDialog"
|
||||
/>
|
||||
<AccountTemplateChangeSecretDialog
|
||||
:object="object"
|
||||
:visible.sync="visible"
|
||||
/>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
@@ -31,17 +27,16 @@
|
||||
<script>
|
||||
import GenericListTable from '@/layout/components/GenericListTable'
|
||||
import QuickActions from '@/components/QuickActions'
|
||||
import AccountTemplateChangeSecretDialog from './AccountTemplateChangeSecretDialog'
|
||||
import { ActionsFormatter, DetailFormatter } from '@/components/Table/TableFormatters'
|
||||
import ViewSecret from '@/components/Apps/AccountListTable/ViewSecret'
|
||||
import { openTaskPage } from '@/utils/jms'
|
||||
|
||||
export default {
|
||||
name: 'AccountTemplateChangeSecret',
|
||||
components: {
|
||||
ViewSecret,
|
||||
QuickActions,
|
||||
GenericListTable,
|
||||
AccountTemplateChangeSecretDialog
|
||||
GenericListTable
|
||||
},
|
||||
props: {
|
||||
object: {
|
||||
@@ -58,14 +53,18 @@ export default {
|
||||
showViewSecretDialog: false,
|
||||
quickActions: [
|
||||
{
|
||||
title: this.$t('accounts.UpdateSecret'),
|
||||
title: this.$t('accounts.SyncUpdateAccountInfo'),
|
||||
attrs: {
|
||||
type: 'primary',
|
||||
label: this.$t('common.Update')
|
||||
label: this.$t('accounts.Sync')
|
||||
},
|
||||
callbacks: Object.freeze({
|
||||
click: () => {
|
||||
vm.visible = true
|
||||
this.$axios.patch(
|
||||
`/api/v1/accounts/account-templates/${this.object.id}/sync-related-accounts/`
|
||||
).then(res => {
|
||||
openTaskPage(res['task'])
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@@ -1,93 +0,0 @@
|
||||
<template>
|
||||
<Dialog
|
||||
v-if="iVisible"
|
||||
:destroy-on-close="true"
|
||||
:show-cancel="false"
|
||||
:show-confirm="false"
|
||||
:title="$tc('accounts.UpdateSecret')"
|
||||
:visible.sync="iVisible"
|
||||
width="50%"
|
||||
>
|
||||
<AutoDataForm
|
||||
:form="form"
|
||||
v-bind="config"
|
||||
@submit="onSubmit"
|
||||
/>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { AutoDataForm, Dialog } from '@/components'
|
||||
import { templateFieldsMeta } from '../const.js'
|
||||
import { encryptPassword } from '@/utils/crypto'
|
||||
|
||||
export default {
|
||||
name: 'AccountTemplateChangeSecretDialog',
|
||||
components: {
|
||||
Dialog,
|
||||
AutoDataForm
|
||||
},
|
||||
props: {
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
object: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
form: this.object,
|
||||
secretType: this.object?.secret_type?.value,
|
||||
config: {
|
||||
hasSaveContinue: false,
|
||||
url: '/api/v1/accounts/account-templates/',
|
||||
fields: [
|
||||
['', [
|
||||
'secret_type', 'secret', 'ssh_key', 'token',
|
||||
'access_key', 'passphrase', 'api_key'
|
||||
]]
|
||||
],
|
||||
fieldsMeta: {
|
||||
...templateFieldsMeta(this),
|
||||
secret_type: {
|
||||
disabled: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
iVisible: {
|
||||
get() {
|
||||
return this.visible
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('update:visible', val)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSubmit(form) {
|
||||
const { object, secretType } = this
|
||||
const currentSecretType = secretType === 'password' ? form?.['secret'] : form?.[secretType]
|
||||
const params = {
|
||||
secret: currentSecretType ? encryptPassword(currentSecretType) : '',
|
||||
is_sync_account: true,
|
||||
...(secretType === 'ssh_key' && { passphrase: encryptPassword(form?.['passphrase']) })
|
||||
}
|
||||
|
||||
this.$axios.patch(
|
||||
`/api/v1/accounts/account-templates/${object.id}/`,
|
||||
params
|
||||
).then(() => {
|
||||
this.$message.success(this.$tc('common.updateSuccessMsg'))
|
||||
}).finally(() => {
|
||||
this.iVisible = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
Reference in New Issue
Block a user