mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-26 06:58:53 +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() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
selectedTemplate: false,
|
||||||
loading: true,
|
loading: true,
|
||||||
usernameChanged: false,
|
usernameChanged: false,
|
||||||
defaultPrivilegedAccounts: ['root', 'administrator'],
|
defaultPrivilegedAccounts: ['root', 'administrator'],
|
||||||
@@ -59,6 +60,7 @@ export default {
|
|||||||
encryptedFields: ['secret'],
|
encryptedFields: ['secret'],
|
||||||
fields: [
|
fields: [
|
||||||
[this.$t('assets.Asset'), ['assets']],
|
[this.$t('assets.Asset'), ['assets']],
|
||||||
|
[this.$t('accounts.AccountTemplate'), ['template']],
|
||||||
[this.$t('common.Basic'), ['name', 'username', 'privileged', 'su_from']],
|
[this.$t('common.Basic'), ['name', 'username', 'privileged', 'su_from']],
|
||||||
[this.$t('assets.Secret'), [
|
[this.$t('assets.Secret'), [
|
||||||
'secret_type', 'secret', 'ssh_key',
|
'secret_type', 'secret', 'ssh_key',
|
||||||
@@ -78,6 +80,26 @@ export default {
|
|||||||
return this.platform || this.asset
|
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: {
|
on_invalid: {
|
||||||
rules: [Required],
|
rules: [Required],
|
||||||
label: this.$t('ops.RunasPolicy'),
|
label: this.$t('ops.RunasPolicy'),
|
||||||
@@ -100,6 +122,9 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
hidden: () => {
|
||||||
|
return this.selectedTemplate
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
username: {
|
username: {
|
||||||
@@ -116,6 +141,14 @@ export default {
|
|||||||
updateForm({ privileged: true })
|
updateForm({ privileged: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
hidden: () => {
|
||||||
|
return this.selectedTemplate
|
||||||
|
}
|
||||||
|
},
|
||||||
|
privileged: {
|
||||||
|
hidden: () => {
|
||||||
|
return this.selectedTemplate
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
su_from: {
|
su_from: {
|
||||||
@@ -137,32 +170,35 @@ export default {
|
|||||||
secret: {
|
secret: {
|
||||||
label: this.$t('assets.Password'),
|
label: this.$t('assets.Password'),
|
||||||
component: UpdateToken,
|
component: UpdateToken,
|
||||||
hidden: (formValue) => formValue.secret_type !== 'password'
|
hidden: (formValue) => formValue.secret_type !== 'password' || this.selectedTemplate
|
||||||
},
|
},
|
||||||
ssh_key: {
|
ssh_key: {
|
||||||
label: this.$t('assets.PrivateKey'),
|
label: this.$t('assets.PrivateKey'),
|
||||||
component: UploadSecret,
|
component: UploadSecret,
|
||||||
hidden: (formValue) => formValue.secret_type !== 'ssh_key'
|
hidden: (formValue) => formValue.secret_type !== 'ssh_key' || this.selectedTemplate
|
||||||
},
|
},
|
||||||
passphrase: {
|
passphrase: {
|
||||||
label: this.$t('assets.Passphrase'),
|
label: this.$t('assets.Passphrase'),
|
||||||
component: UpdateToken,
|
component: UpdateToken,
|
||||||
hidden: (formValue) => formValue.secret_type !== 'ssh_key'
|
hidden: (formValue) => formValue.secret_type !== 'ssh_key' || this.selectedTemplate
|
||||||
},
|
},
|
||||||
token: {
|
token: {
|
||||||
label: this.$t('assets.Token'),
|
label: this.$t('assets.Token'),
|
||||||
component: UploadSecret,
|
component: UploadSecret,
|
||||||
hidden: (formValue) => formValue.secret_type !== 'token'
|
hidden: (formValue) => formValue.secret_type !== 'token' || this.selectedTemplate
|
||||||
},
|
},
|
||||||
access_key: {
|
access_key: {
|
||||||
id: 'access_key',
|
id: 'access_key',
|
||||||
label: this.$t('assets.AccessKey'),
|
label: this.$t('assets.AccessKey'),
|
||||||
component: UploadSecret,
|
component: UploadSecret,
|
||||||
hidden: (formValue) => formValue.secret_type !== 'access_key'
|
hidden: (formValue) => formValue.secret_type !== 'access_key' || this.selectedTemplate
|
||||||
},
|
},
|
||||||
secret_type: {
|
secret_type: {
|
||||||
type: 'radio-group',
|
type: 'radio-group',
|
||||||
options: []
|
options: [],
|
||||||
|
hidden: () => {
|
||||||
|
return this.selectedTemplate
|
||||||
|
}
|
||||||
},
|
},
|
||||||
push_now: {
|
push_now: {
|
||||||
helpText: this.$t('accounts.AccountPush.WindowsPushHelpText'),
|
helpText: this.$t('accounts.AccountPush.WindowsPushHelpText'),
|
||||||
@@ -170,6 +206,16 @@ export default {
|
|||||||
const automation = this.iPlatform.automation || {}
|
const automation = this.iPlatform.automation || {}
|
||||||
return !automation.push_account_enabled || !automation.ansible_enabled || !this.$hasPerm('accounts.push_account')
|
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
|
hasSaveContinue: false
|
||||||
|
@@ -74,14 +74,16 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
addAccount(form) {
|
addAccount(form) {
|
||||||
const formValue = Object.assign({}, form)
|
const formValue = Object.assign({}, form)
|
||||||
let data, url
|
let data, url, iVisible
|
||||||
if (this.asset) {
|
if (this.asset) {
|
||||||
data = {
|
data = {
|
||||||
asset: this.asset.id,
|
asset: this.asset.id,
|
||||||
...formValue
|
...formValue
|
||||||
}
|
}
|
||||||
|
iVisible = false
|
||||||
url = `/api/v1/accounts/accounts/`
|
url = `/api/v1/accounts/accounts/`
|
||||||
} else {
|
} else {
|
||||||
|
iVisible = true
|
||||||
data = formValue
|
data = formValue
|
||||||
url = `/api/v1/accounts/accounts/bulk/`
|
url = `/api/v1/accounts/accounts/bulk/`
|
||||||
if (data.assets.length === 0) {
|
if (data.assets.length === 0) {
|
||||||
@@ -89,11 +91,17 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.$axios.post(url, data).then((data) => {
|
this.$axios.post(url, data, {
|
||||||
|
disableFlashErrorMsg: true
|
||||||
|
}).then((data) => {
|
||||||
this.handleResult(data, null)
|
this.handleResult(data, null)
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.handleResult(null, error)
|
this.handleResult(null, error)
|
||||||
})
|
})
|
||||||
|
this.iVisible = iVisible
|
||||||
|
if (!iVisible) {
|
||||||
|
this.$store.commit('common/reload')
|
||||||
|
}
|
||||||
},
|
},
|
||||||
editAccount(form) {
|
editAccount(form) {
|
||||||
const data = { ...form }
|
const data = { ...form }
|
||||||
|
Reference in New Issue
Block a user