mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-25 06:19:51 +00:00
Merge pull request #2985 from jumpserver/pr@dev@bulk_account
perf: 批量创建账号添加模版
This commit is contained in:
@@ -41,6 +41,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
selectedTemplate: false,
|
||||
loading: true,
|
||||
usernameChanged: false,
|
||||
defaultPrivilegedAccounts: ['root', 'administrator'],
|
||||
@@ -59,6 +60,7 @@ export default {
|
||||
encryptedFields: ['secret'],
|
||||
fields: [
|
||||
[this.$t('assets.Asset'), ['assets']],
|
||||
[this.$t('accounts.AccountTemplate'), ['template']],
|
||||
[this.$t('common.Basic'), ['name', 'username', 'privileged', 'su_from']],
|
||||
[this.$t('assets.Secret'), [
|
||||
'secret_type', 'secret', 'ssh_key',
|
||||
@@ -78,6 +80,26 @@ export default {
|
||||
return this.platform || this.asset
|
||||
}
|
||||
},
|
||||
template: {
|
||||
component: Select2,
|
||||
el: {
|
||||
multiple: false,
|
||||
ajax: {
|
||||
url: '/api/v1/accounts/account-templates/',
|
||||
transformOption: (item) => {
|
||||
return { label: item.name, value: item.id }
|
||||
}
|
||||
}
|
||||
},
|
||||
hidden: () => {
|
||||
return this.platform || this.asset
|
||||
},
|
||||
on: {
|
||||
change: ([event]) => {
|
||||
this.selectedTemplate = !!event
|
||||
}
|
||||
}
|
||||
},
|
||||
on_invalid: {
|
||||
rules: [Required],
|
||||
label: this.$t('ops.RunasPolicy'),
|
||||
@@ -100,6 +122,9 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
hidden: () => {
|
||||
return this.selectedTemplate
|
||||
}
|
||||
},
|
||||
username: {
|
||||
@@ -116,6 +141,14 @@ export default {
|
||||
updateForm({ privileged: true })
|
||||
}
|
||||
}
|
||||
},
|
||||
hidden: () => {
|
||||
return this.selectedTemplate
|
||||
}
|
||||
},
|
||||
privileged: {
|
||||
hidden: () => {
|
||||
return this.selectedTemplate
|
||||
}
|
||||
},
|
||||
su_from: {
|
||||
@@ -137,32 +170,35 @@ export default {
|
||||
secret: {
|
||||
label: this.$t('assets.Password'),
|
||||
component: UpdateToken,
|
||||
hidden: (formValue) => formValue.secret_type !== 'password'
|
||||
hidden: (formValue) => formValue.secret_type !== 'password' || this.selectedTemplate
|
||||
},
|
||||
ssh_key: {
|
||||
label: this.$t('assets.PrivateKey'),
|
||||
component: UploadSecret,
|
||||
hidden: (formValue) => formValue.secret_type !== 'ssh_key'
|
||||
hidden: (formValue) => formValue.secret_type !== 'ssh_key' || this.selectedTemplate
|
||||
},
|
||||
passphrase: {
|
||||
label: this.$t('assets.Passphrase'),
|
||||
component: UpdateToken,
|
||||
hidden: (formValue) => formValue.secret_type !== 'ssh_key'
|
||||
hidden: (formValue) => formValue.secret_type !== 'ssh_key' || this.selectedTemplate
|
||||
},
|
||||
token: {
|
||||
label: this.$t('assets.Token'),
|
||||
component: UploadSecret,
|
||||
hidden: (formValue) => formValue.secret_type !== 'token'
|
||||
hidden: (formValue) => formValue.secret_type !== 'token' || this.selectedTemplate
|
||||
},
|
||||
access_key: {
|
||||
id: 'access_key',
|
||||
label: this.$t('assets.AccessKey'),
|
||||
component: UploadSecret,
|
||||
hidden: (formValue) => formValue.secret_type !== 'access_key'
|
||||
hidden: (formValue) => formValue.secret_type !== 'access_key' || this.selectedTemplate
|
||||
},
|
||||
secret_type: {
|
||||
type: 'radio-group',
|
||||
options: []
|
||||
options: [],
|
||||
hidden: () => {
|
||||
return this.selectedTemplate
|
||||
}
|
||||
},
|
||||
push_now: {
|
||||
helpText: this.$t('accounts.AccountPush.WindowsPushHelpText'),
|
||||
@@ -170,6 +206,16 @@ export default {
|
||||
const automation = this.iPlatform.automation || {}
|
||||
return !automation.push_account_enabled || !automation.ansible_enabled || !this.$hasPerm('accounts.push_account')
|
||||
}
|
||||
},
|
||||
is_active: {
|
||||
hidden: () => {
|
||||
return this.selectedTemplate
|
||||
}
|
||||
},
|
||||
comment: {
|
||||
hidden: () => {
|
||||
return this.selectedTemplate
|
||||
}
|
||||
}
|
||||
},
|
||||
hasSaveContinue: false
|
||||
|
@@ -74,14 +74,16 @@ export default {
|
||||
methods: {
|
||||
addAccount(form) {
|
||||
const formValue = Object.assign({}, form)
|
||||
let data, url
|
||||
let data, url, iVisible
|
||||
if (this.asset) {
|
||||
data = {
|
||||
asset: this.asset.id,
|
||||
...formValue
|
||||
}
|
||||
iVisible = false
|
||||
url = `/api/v1/accounts/accounts/`
|
||||
} else {
|
||||
iVisible = true
|
||||
data = formValue
|
||||
url = `/api/v1/accounts/accounts/bulk/`
|
||||
if (data.assets.length === 0) {
|
||||
@@ -89,11 +91,17 @@ export default {
|
||||
return
|
||||
}
|
||||
}
|
||||
this.$axios.post(url, data).then((data) => {
|
||||
this.$axios.post(url, data, {
|
||||
disableFlashErrorMsg: true
|
||||
}).then((data) => {
|
||||
this.handleResult(data, null)
|
||||
}).catch(error => {
|
||||
this.handleResult(null, error)
|
||||
})
|
||||
this.iVisible = iVisible
|
||||
if (!iVisible) {
|
||||
this.$store.commit('common/reload')
|
||||
}
|
||||
},
|
||||
editAccount(form) {
|
||||
const data = { ...form }
|
||||
|
Reference in New Issue
Block a user