1
0
mirror of https://github.com/jumpserver/lina.git synced 2025-05-12 01:58:51 +00:00

perf: rename ad to ds

This commit is contained in:
ibuler 2025-04-07 19:10:33 +08:00
parent a45d86c568
commit 0a7704c06c
12 changed files with 97 additions and 112 deletions

View File

@ -148,6 +148,7 @@ export default {
type: Boolean,
default: true
},
// target for ad connect btn, if not has, ad account should be select one
target: {
type: Object,
default: null
@ -186,7 +187,7 @@ export default {
},
columnsMeta: {
name: {
minWidth: '120px',
minWidth: '60px',
formatterArgs: {
can: () => vm.$hasPerm('accounts.view_account'),
getRoute: ({ row }) => ({
@ -212,15 +213,9 @@ export default {
width: '80px',
formatter: AccountConnectFormatter,
formatterArgs: {
buttonIcon: 'fa fa-desktop',
url: '/api/v1/assets/assets/{id}',
can: () => this.currentUserIsSuperAdmin,
connectUrlTemplate: (row) => `/luna/direct_connect/${row.id}/${row.username}/${row.asset.id}/${row.asset.name}/`,
setMapItem: (id, protocol) => {
this.$store.commit('table/SET_PROTOCOL_MAP_ITEM', {
key: id,
value: protocol
})
connectUrlTemplate: (row) => {
}
}
},
@ -238,7 +233,7 @@ export default {
}
},
username: {
minWidth: '120px',
minWidth: '60px',
formatter: function(row) {
if (row.ad_domain) {
return `${row.username}@${row.ad_domain}`

View File

@ -1,24 +1,32 @@
<template>
<div>
<el-dropdown
v-if="hasPerm"
:disabled="!hasPerm"
:show-timeout="500"
class="action-connect"
size="small"
trigger="hover"
:show-timeout="500"
@command="handleCommand"
type="primary"
@command="handleProtocolConnect"
@visible-change="visibleChange"
>
<el-button
plain
size="mini"
type="primary"
@click="handlePamConnect"
@click="handleBtnConnect"
>
<i :class="IButtonIcon" />
<i :class="iButtonIcon" />
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="Title" disabled>
{{ ITitleText }}
<el-dropdown-menu v-if="!isClick" slot="dropdown">
<el-dropdown-item command="title" disabled>
<div v-if="getProtocolsLoading">
{{ $t('Loading') }}
</div>
<div v-else>
{{ dropdownTitle }}
</div>
</el-dropdown-item>
<el-dropdown-item divided />
<el-dropdown-item
@ -30,16 +38,6 @@
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-button
v-else
plain
size="mini"
type="primary"
:disabled="!hasPerm"
>
<i :class="IButtonIcon" style="color: #fff" />
</el-button>
</div>
</template>
@ -50,85 +48,70 @@ export default {
name: 'AccountConnectFormatter',
extends: BaseFormatter,
props: {
buttonIcon: {
type: String,
default: 'fa fa-desktop'
},
titleText: {
type: String,
default: ''
},
url: {
type: String,
default: ''
formatterArgsDefault: {
type: Object,
default() {
return {
can: () => true,
getConnectUrl: (row, protocol) => {
return `/luna/admin-connect/?
asset=${row.asset.id}
&account=${row.id}
&protocol=${protocol}
`.replace(/\s+/g, '')
},
assetUrl: '/api/v1/assets/assets/{id}/',
buttonIcon: 'fa fa-desktop'
}
}
}
},
data() {
return {
hasPerm: false,
protocols: []
formatterArgs: Object.assign(this.formatterArgsDefault, this.col.formatterArgs),
protocols: [],
isClick: false,
getProtocolsLoading: false,
dropdownTitle: this.$t('Protocols')
}
},
computed: {
IButtonIcon() {
return this.buttonIcon
iButtonIcon() {
return this.formatterArgs.buttonIcon
},
ITitleText() {
return this.titleText || this.$t('SelectProtocol')
hasPerm() {
return this.formatterArgs.can(this.row, this.cellValue)
}
},
mounted() {
this.hasPerm = this.formatterArgs.can()
},
methods: {
handleCommand(protocol) {
if (protocol === 'Title') return
this.formatterArgs.setMapItem(this.row.id, protocol)
this.handleWindowOpen(this.row, protocol)
handleProtocolConnect(protocol) {
const url = this.formatterArgs.getConnectUrl(this.row, protocol)
window.open(url, '_blank')
},
visibleChange(visible) {
if (visible) {
this.getProtocols(this.row.asset.id)
}
},
handleWindowOpen(row, protocol) {
const url = this.formatterArgs.connectUrlTemplate(row) + `${protocol}`
this.$nextTick(() => {
window.open(url, '_blank')
})
},
async handlePamConnect() {
const protocolMap = this.$store.getters.protocolMap
if (protocolMap.has(this.row.id)) {
//
const protocol = protocolMap.get(this.row.id)
this.handleWindowOpen(this.row, protocol)
} else {
try {
const url = this.formatterArgs.url.replace('{id}', this.row.asset.id)
const res = await this.$axios.get(url)
if (res && res.protocols.length > 0) {
const protocol = res.protocols[0]
this.formatterArgs.setMapItem(this.row.id, protocol.name)
this.handleWindowOpen(this.row, protocol.name)
}
} catch (e) {
throw new Error(`Error getting protocols: ${e}`)
}
async handleBtnConnect() {
this.isClick = true
if (this.protocols === 0) {
await this.getProtocols(this.row.asset.id)
}
if (this.protocols.length > 0) {
this.handleProtocolConnect(this.protocols[0].name)
}
setTimeout(() => {
this.isClick = false
}, 1000)
},
async getProtocols(assetId) {
if (this.protocols.length > 0) return
try {
const url = this.formatterArgs.url.replace('{id}', assetId)
const url = this.formatterArgs.assetUrl.replace('{id}', assetId)
const res = await this.$axios.get(url)
// SFTP
if (res) this.protocols = res.protocols
this.protocols = res.protocols || []
} catch (e) {
throw new Error(`Error getting protocols: ${e}`)
}
@ -137,7 +120,7 @@ export default {
}
</script>
<style scoped lang="scss">
<style lang="scss" scoped>
.el-dropdown-menu__item.is-disabled {
font-weight: 500;
color: var(--el-text-color-secondary);

View File

@ -12,7 +12,7 @@ export default {
return {
url: '/api/v1/assets/directories/',
addFields: [
[this.$t('Domain name'), ['domain_name'], 1]
[this.$t('DomainName'), ['domain_name'], 1]
]
}
}

View File

@ -114,7 +114,7 @@ export default {
},
async genConfig() {
const { addFields, addFieldsMeta, defaultConfig } = this
defaultConfig.fieldsMeta = assetFieldsMeta(this, this.$route.query.type)
defaultConfig.fieldsMeta = assetFieldsMeta(this)
let url = this.url
const id = this.$route.params.id
if (!id) {

View File

@ -12,7 +12,7 @@ export default {
data() {
return {
tableConfig: {
category: 'ad',
category: 'ds',
url: '/api/v1/assets/directories/'
}
}

View File

@ -144,7 +144,7 @@ export default {
'cloud': () => import('@/views/assets/Asset/AssetCreateUpdate/CloudCreateUpdate.vue'),
'device': () => import('@/views/assets/Asset/AssetCreateUpdate/DeviceCreateUpdate.vue'),
'database': () => import('@/views/assets/Asset/AssetCreateUpdate/DatabaseCreateUpdate.vue'),
'ad': () => import('@/views/assets/Asset/AssetCreateUpdate/ADCreateUpdate.vue')
'ds': () => import('@/views/assets/Asset/AssetCreateUpdate/ADCreateUpdate.vue')
},
createProps: {},
showPlatform: false,

View File

@ -5,7 +5,7 @@
:show-confirm="false"
:title="$tc('SelectPlatform')"
:visible.sync="iVisible"
size="600px"
size="700px"
top="1vh"
>
<template #title>
@ -61,6 +61,7 @@ import { loadPlatformIcon } from '@/utils/jms'
export default {
name: 'PlatformDrawer',
components: {},
props: {
visible: {
type: Boolean,

View File

@ -57,10 +57,10 @@ export default {
component: () => import('@/views/assets/Asset/AssetList/WebList.vue')
},
{
icon: 'fa-comment',
name: 'ad',
icon: 'fa-vcard-o',
name: 'ds',
hidden: true,
component: () => import('@/views/assets/Asset/AssetList/ADList.vue')
component: () => import('@/views/assets/Asset/AssetList/DSList.vue')
},
{
icon: 'fa-comment',

View File

@ -50,7 +50,7 @@ export default {
]],
[this.$t('Config'), [
'protocols', 'su_enabled', 'su_method',
'domain_enabled', 'ad_enabled', 'ad',
'domain_enabled', 'ds_enabled', 'ds',
'charset'
]],
[this.$t('Automations'), ['automation']],
@ -155,16 +155,20 @@ export default {
})
this.fieldsMeta.protocols.el.choices = protocols
const fieldsCheck = ['domain_enabled', 'su_enabled', 'ad_enabled']
const fieldsCheck = ['domain_enabled', 'su_enabled']
for (const field of fieldsCheck) {
const disabled = constraints[field] === false
this.initial[field] = !disabled
_.set(this.fieldsMeta, `${field}.el.disabled`, disabled)
}
if (constraints['charset_enabled'] === false) {
this.fieldsMeta.charset.hidden = () => true
const fieldsHidden = ['charset_enabled', 'ds_enabled']
for (const field of fieldsHidden) {
if (constraints[field] === false) {
this.fieldsMeta[field].hidden = () => true
}
}
await setAutomations(this)
await this.updateSuMethods(constraints)
}

View File

@ -115,7 +115,11 @@ export default {
canUpdate: ({ row }) => !row.internal && vm.$hasPerm('assets.change_platform'),
canDelete: ({ row }) => !row.internal && vm.$hasPerm('assets.delete_platform'),
onUpdate({ row, col }) {
vm.$refs.genericListTable.onUpdate({ row, col, query: { type: row.type.value, category: row.category.value }})
vm.$refs.genericListTable.onUpdate({
row,
col,
query: { type: row.type.value, category: row.category.value }
})
}
}
}
@ -169,14 +173,10 @@ export default {
const types = this.$store.state.assets.assetCategoriesDropdown.filter(item => {
return item.category === this.tab.activeMenu
}).map(item => {
if (!item.group) {
return item
} else {
return {
...item,
group: item.group + this.$t('WordSep') + this.$t('Type')
}
if (item.group && !item.group.includes(this.$t('Type'))) {
item.group += this.$t('WordSep') + this.$t('Type')
}
return item
})
this.headerActions.moreCreates.dropdown = types
},
@ -188,7 +188,7 @@ export default {
cloud: 'fa-cloud',
web: 'fa-globe',
gpt: 'fa-comment',
ad: 'fa-comment',
ds: 'fa-id-card-o',
custom: 'fa-cube'
}
const state = await this.$store.dispatch('assets/getAssetCategories')

View File

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

View File

@ -48,7 +48,9 @@ function updatePlatformProtocols(vm, platformType, updateForm, platformChanged =
}), 100)
}
export const assetFieldsMeta = (vm, platformType) => {
export const assetFieldsMeta = (vm, category, type) => {
const platformCategory = category || vm.$route.query.category
const platformType = type || vm.$route.query.type
const platformProtocols = []
const secretTypes = []
const asset = { address: 'https://jumpserver:330' }
@ -92,7 +94,7 @@ export const assetFieldsMeta = (vm, platformType) => {
el: {
multiple: false,
ajax: {
url: `/api/v1/assets/platforms/?type=${platformType}`,
url: `/api/v1/assets/platforms/?category=${platformCategory}&type=${platformType}`,
transformOption: (item) => {
return { label: item.name, value: item.id }
}