1
0
mirror of https://github.com/jumpserver/lina.git synced 2025-05-10 17:16:25 +00:00

perf: change diretory service account

This commit is contained in:
ibuler 2025-04-15 20:19:04 +08:00
parent a3f17ea4d3
commit af3030752b
8 changed files with 201 additions and 168 deletions
src
components
Apps/AccountListTable
Table/TableFormatters
const.js
views/assets

View File

@ -51,7 +51,7 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { accountOtherActions, accountQuickFilters, connectivityMeta } from './const' import { accountOtherActions, accountQuickFilters, connectivityMeta, isDirectoryServiceAccount } from './const'
import { openTaskPage } from '@/utils/jms' import { openTaskPage } from '@/utils/jms'
import { import {
AccountConnectFormatter, AccountConnectFormatter,
@ -216,6 +216,7 @@ export default {
width: '80px', width: '80px',
formatter: AccountConnectFormatter, formatter: AccountConnectFormatter,
formatterArgs: { formatterArgs: {
asset: this.asset,
can: ({ row }) => { can: ({ row }) => {
return this.currentUserIsSuperAdmin return this.currentUserIsSuperAdmin
} }
@ -286,7 +287,7 @@ export default {
hasUpdate: false, // can set function(row, value) hasUpdate: false, // can set function(row, value)
hasDelete: true, // can set function(row, value) hasDelete: true, // can set function(row, value)
hasClone: false, hasClone: false,
canDelete: () => vm.$hasPerm('accounts.delete_account'), canDelete: ({ row }) => vm.$hasPerm('accounts.delete_account') && !isDirectoryServiceAccount(row, this),
moreActionsTitle: this.$t('More'), moreActionsTitle: this.$t('More'),
extraActions: accountOtherActions(this) extraActions: accountOtherActions(this)
} }

View File

@ -24,162 +24,191 @@ export const connectivityMeta = {
width: '130px' width: '130px'
} }
export const accountOtherActions = (vm) => [ export function isDirectoryServiceAccount(account, vm) {
{ return vm.asset && vm.asset.id !== account.asset.id
name: 'View', }
title: vm.$t('View'),
can: vm.$hasPerm('accounts.view_accountsecret'),
type: 'primary',
order: 1,
callback: ({ row }) => {
// debugger
vm.secretUrl = `/api/v1/accounts/account-secrets/${row.id}/`
vm.account = row
vm.showViewSecretDialog = false
setTimeout(() => {
vm.showViewSecretDialog = true
})
}
},
{
name: 'Update',
title: vm.$t('Edit'),
can: vm.$hasPerm('accounts.change_account') && !vm.$store.getters.currentOrgIsRoot,
callback: ({ row }) => {
vm.isUpdateAccount = true
const data = {
...vm.asset,
...row.asset
}
vm.iAsset = data
vm.account = row
vm.addTemplate = false
vm.showAddDialog = false
setTimeout(() => {
vm.showAddDialog = true
})
}
},
{
name: 'UpdateSecret',
title: vm.$t('EditSecret'),
can: vm.$hasPerm('accounts.change_account') && !vm.$store.getters.currentOrgIsRoot,
callback: ({ row }) => {
const data = {
...vm.asset,
...row.asset
}
vm.account = row
vm.iAsset = data
vm.showUpdateSecretDialog = false
vm.accountCreateUpdateTitle = vm.$t('UpdateAccount')
setTimeout(() => {
vm.showUpdateSecretDialog = true
})
}
},
{
name: 'Clone',
title: vm.$t('Duplicate'),
has: () => {
return !vm.asset
},
can: vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot,
callback: ({ row }) => {
vm.account = {
name: `${row.name} - ${vm.$t('Duplicate').toLowerCase()}`,
username: `${row.username} - ${vm.$t('Duplicate').toLowerCase()}`,
payload: 'pam_account_clone'
}
vm.iAsset = vm.asset
vm.showAddDialog = false export const accountOtherActions = (vm) => {
setTimeout(() => { return [
{
name: 'View',
title: vm.$t('View'),
can: vm.$hasPerm('accounts.view_accountsecret'),
type: 'primary',
order: 1,
callback: ({ row }) => {
// debugger
vm.secretUrl = `/api/v1/accounts/account-secrets/${row.id}/`
vm.account = row
vm.showViewSecretDialog = false
setTimeout(() => {
vm.showViewSecretDialog = true
})
}
},
{
name: 'Update',
title: vm.$t('Edit'),
can: ({ row }) => {
return vm.$hasPerm('accounts.change_account') &&
!vm.$store.getters.currentOrgIsRoot &&
!isDirectoryServiceAccount(row, vm)
},
callback: ({ row }) => {
vm.isUpdateAccount = true
const data = {
...vm.asset,
...row.asset
}
vm.iAsset = data
vm.account = row
vm.addTemplate = false
vm.showAddDialog = false
setTimeout(() => {
vm.showAddDialog = true
})
}
},
{
name: 'UpdateSecret',
title: vm.$t('EditSecret'),
can: ({ row }) => {
return vm.$hasPerm('accounts.change_account') &&
!vm.$store.getters.currentOrgIsRoot &&
!isDirectoryServiceAccount(row, vm)
},
callback: ({ row }) => {
const data = {
...vm.asset,
...row.asset
}
vm.account = row
vm.iAsset = data
vm.showUpdateSecretDialog = false
vm.accountCreateUpdateTitle = vm.$t('UpdateAccount')
setTimeout(() => {
vm.showUpdateSecretDialog = true
})
}
},
{
name: 'Clone',
title: vm.$t('Duplicate'),
has: () => {
return !vm.asset
},
can: ({ row }) => {
return vm.$hasPerm('accounts.add_account') &&
!vm.$store.getters.currentOrgIsRoot &&
!isDirectoryServiceAccount(row, vm)
},
callback: ({ row }) => {
vm.account = {
name: `${row.name} - ${vm.$t('Duplicate').toLowerCase()}`,
username: `${row.username} - ${vm.$t('Duplicate').toLowerCase()}`,
payload: 'pam_account_clone'
}
vm.iAsset = vm.asset
vm.showAddDialog = false
setTimeout(() => {
vm.showAddDialog = true
})
}
},
{
name: 'Test',
title: vm.$t('VerifySecret'),
divided: true,
can: ({ row }) =>
!vm.$store.getters.currentOrgIsRoot &&
vm.$hasPerm('accounts.verify_account') &&
row.asset['auto_config'].ansible_enabled &&
row.asset['auto_config'].ping_enabled,
callback: ({ row }) => {
vm.$axios.post(
`/api/v1/accounts/accounts/tasks/`,
{ action: 'verify', accounts: [row.id] }
).then(res => {
openTaskPage(res['task'])
})
}
},
{
name: 'ClearSecret',
title: vm.$t('ClearSecret'),
can: ({ row }) => {
return vm.$hasPerm('accounts.change_account') &&
!isDirectoryServiceAccount(row, vm)
},
type: 'primary',
callback: ({ row }) => {
vm.$axios.patch(
`/api/v1/accounts/accounts/clear-secret/`,
{ account_ids: [row.id] }
).then(() => {
vm.$message.success(vm.$tc('ClearSuccessMsg'))
})
}
},
{
name: 'SecretHistory',
title: vm.$t('HistoryPassword'),
can: () => vm.$hasPerm('accounts.view_accountsecret'),
type: 'primary',
callback: ({ row }) => {
vm.account = row
vm.currentAccountColumn = row
vm.showViewSecretDialog = false
vm.secretUrl = `/api/v1/accounts/account-secrets/${row.id}/`
setTimeout(() => {
vm.showViewSecretDialog = true
})
}
},
{
name: 'CopyToOther',
title: vm.$t('CopyToAsset'),
type: 'primary',
divided: true,
can: ({ row }) => {
return vm.$hasPerm('accounts.add_account') &&
!vm.$store.getters.currentOrgIsRoot &&
!isDirectoryServiceAccount(row, vm)
},
has: () => {
return !vm.asset
},
callback: ({ row }) => {
vm.accountCreateUpdateTitle = vm.$t('CopyToOther')
vm.$route.query.flag = 'copy'
vm.iAsset = vm.asset
vm.account = row
vm.showAddDialog = true vm.showAddDialog = true
}) }
}
},
{
name: 'Test',
title: vm.$t('VerifySecret'),
divided: true,
can: ({ row }) =>
!vm.$store.getters.currentOrgIsRoot &&
vm.$hasPerm('accounts.verify_account') &&
row.asset['auto_config'].ansible_enabled &&
row.asset['auto_config'].ping_enabled,
callback: ({ row }) => {
vm.$axios.post(
`/api/v1/accounts/accounts/tasks/`,
{ action: 'verify', accounts: [row.id] }
).then(res => {
openTaskPage(res['task'])
})
}
},
{
name: 'ClearSecret',
title: vm.$t('ClearSecret'),
can: vm.$hasPerm('accounts.change_account'),
type: 'primary',
callback: ({ row }) => {
vm.$axios.patch(
`/api/v1/accounts/accounts/clear-secret/`,
{ account_ids: [row.id] }
).then(() => {
vm.$message.success(vm.$tc('ClearSuccessMsg'))
})
}
},
{
name: 'SecretHistory',
title: vm.$t('HistoryPassword'),
can: () => vm.$hasPerm('accounts.view_accountsecret'),
type: 'primary',
callback: ({ row }) => {
vm.account = row
vm.currentAccountColumn = row
vm.showViewSecretDialog = false
vm.secretUrl = `/api/v1/accounts/account-secrets/${row.id}/`
setTimeout(() => {
vm.showViewSecretDialog = true
})
}
},
{
name: 'CopyToOther',
title: vm.$t('CopyToAsset'),
type: 'primary',
divided: true,
can: () => vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot,
has: () => {
return !vm.asset
}, },
callback: ({ row }) => { {
vm.accountCreateUpdateTitle = vm.$t('CopyToOther') name: 'MoveToOther',
vm.$route.query.flag = 'copy' title: vm.$t('MoveToAsset'),
vm.iAsset = vm.asset type: 'primary',
vm.account = row can: ({ row }) => {
vm.showAddDialog = true return vm.$hasPerm('accounts.add_account') &&
!vm.$store.getters.currentOrgIsRoot &&
!isDirectoryServiceAccount(row, vm)
},
has: () => {
return !vm.asset
},
callback: ({ row }) => {
vm.accountCreateUpdateTitle = vm.$t('MoveToOther')
vm.$route.query.flag = 'move'
vm.iAsset = vm.asset
vm.account = row
vm.showAddDialog = true
}
} }
}, ]
{ }
name: 'MoveToOther',
title: vm.$t('MoveToAsset'),
type: 'primary',
can: () => vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot,
has: () => {
return !vm.asset
},
callback: ({ row }) => {
vm.accountCreateUpdateTitle = vm.$t('MoveToOther')
vm.$route.query.flag = 'move'
vm.iAsset = vm.asset
vm.account = row
vm.showAddDialog = true
}
}
]
export const accountQuickFilters = (vm) => [ export const accountQuickFilters = (vm) => [
{ {

View File

@ -53,13 +53,15 @@ export default {
default() { default() {
return { return {
can: () => true, can: () => true,
getConnectUrl: (row, protocol) => { getConnectUrl: (row, protocol, asset) => {
const assetId = asset ? asset.id : row.asset.id
return `/luna/admin-connect/? return `/luna/admin-connect/?
asset=${row.asset.id} asset=${assetId}
&account=${row.id} &account=${row.id}
&protocol=${protocol} &protocol=${protocol}
`.replace(/\s+/g, '') `.replace(/\s+/g, '')
}, },
asset: null,
assetUrl: '/api/v1/assets/assets/{id}/', assetUrl: '/api/v1/assets/assets/{id}/',
buttonIcon: 'fa fa-desktop' buttonIcon: 'fa fa-desktop'
} }
@ -85,7 +87,7 @@ export default {
}, },
methods: { methods: {
handleProtocolConnect(protocol) { handleProtocolConnect(protocol) {
const url = this.formatterArgs.getConnectUrl(this.row, protocol) const url = this.formatterArgs.getConnectUrl(this.row, protocol, this.formatterArgs.asset)
window.open(url, '_blank') window.open(url, '_blank')
}, },
visibleChange(visible) { visibleChange(visible) {

View File

@ -72,7 +72,6 @@ export const interval = {
], ],
on: { on: {
input: (val, updateForm) => { input: (val, updateForm) => {
console.log('interval input', val)
updateForm({ updateForm({
crontab: '' crontab: ''
}) })

View File

@ -64,7 +64,7 @@ export default {
[this.$t('Basic'), ['name', 'address', 'platform', 'nodes']], [this.$t('Basic'), ['name', 'address', 'platform', 'nodes']],
[this.$t('Protocol'), ['protocols']], [this.$t('Protocol'), ['protocols']],
[this.$t('Account'), ['accounts']], [this.$t('Account'), ['accounts']],
[this.$t('Other'), ['domain', 'labels', 'is_active', 'comment']] [this.$t('Other'), ['directory_services', 'domain', 'labels', 'is_active', 'comment']]
], ],
fieldsMeta: {}, fieldsMeta: {},
performSubmit(validValues) { performSubmit(validValues) {

View File

@ -50,7 +50,7 @@ export default {
]], ]],
[this.$t('Config'), [ [this.$t('Config'), [
'protocols', 'su_enabled', 'su_method', 'protocols', 'su_enabled', 'su_method',
'domain_enabled', 'ds_enabled', 'ds', 'domain_enabled', 'ds_enabled',
'charset' 'charset'
]], ]],
[this.$t('Automations'), ['automation']], [this.$t('Automations'), ['automation']],

View File

@ -86,14 +86,7 @@ export const platformFieldsMeta = (vm) => {
disabled: false disabled: false
} }
}, },
ds: {
el: {
multiple: false,
url: '/api/v1/assets/directories/',
disabled: false
},
hidden: (formValue) => !formValue['ds_enabled']
},
protocols: { protocols: {
label: i18n.t('SupportedProtocol'), label: i18n.t('SupportedProtocol'),
...assetMeta.protocols, ...assetMeta.protocols,

View File

@ -133,6 +133,15 @@ export const assetFieldsMeta = (vm, category, type) => {
default: [] default: []
} }
}, },
directory_services: {
el: {
url: '/api/v1/assets/directories/',
disabled: false
},
hidden: () => {
return vm.platform.ds_enabled === false
}
},
nodes: { nodes: {
rules: [rules.RequiredChange], rules: [rules.RequiredChange],
el: { el: {