mirror of
https://github.com/jumpserver/lina.git
synced 2025-08-16 22:07:21 +00:00
Merge pull request #4931 from jumpserver/pr@dev@feat_ad_domain
feat: ad domain as asset
This commit is contained in:
commit
a3f17ea4d3
@ -52,7 +52,7 @@ export default {
|
|||||||
height: 200,
|
height: 200,
|
||||||
rotate: 45,
|
rotate: 45,
|
||||||
fontWeight: 'normal',
|
fontWeight: 'normal',
|
||||||
fontColor: 'rgba(128, 128, 128, 0.3)'
|
fontColor: 'rgba(128, 128, 128, 0.2)'
|
||||||
})
|
})
|
||||||
|
|
||||||
this.watermark.create()
|
this.watermark.create()
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.7 KiB |
BIN
src/assets/img/icons/windows_ad.png
Normal file
BIN
src/assets/img/icons/windows_ad.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
@ -6,6 +6,13 @@ import AutomationParamsForm from '@/views/assets/Platform/AutomationParamsSettin
|
|||||||
export const accountFieldsMeta = (vm) => {
|
export const accountFieldsMeta = (vm) => {
|
||||||
const defaultPrivilegedAccounts = ['root', 'administrator']
|
const defaultPrivilegedAccounts = ['root', 'administrator']
|
||||||
|
|
||||||
|
function onPrivilegedUser(value, updateForm) {
|
||||||
|
const maybePrivileged = defaultPrivilegedAccounts.includes(value)
|
||||||
|
if (maybePrivileged) {
|
||||||
|
updateForm({ privileged: true, secret_reset: false, push_now: false })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
assets: {
|
assets: {
|
||||||
component: Select2,
|
component: Select2,
|
||||||
@ -70,11 +77,8 @@ export const accountFieldsMeta = (vm) => {
|
|||||||
if (!vm.account?.name) {
|
if (!vm.account?.name) {
|
||||||
updateForm({ username: value })
|
updateForm({ username: value })
|
||||||
}
|
}
|
||||||
const maybePrivileged = defaultPrivilegedAccounts.includes(value)
|
|
||||||
if (maybePrivileged) {
|
|
||||||
updateForm({ privileged: true })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
onPrivilegedUser(value, updateForm)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hidden: () => {
|
hidden: () => {
|
||||||
@ -92,10 +96,7 @@ export const accountFieldsMeta = (vm) => {
|
|||||||
vm.usernameChanged = true
|
vm.usernameChanged = true
|
||||||
},
|
},
|
||||||
change: ([value], updateForm) => {
|
change: ([value], updateForm) => {
|
||||||
const maybePrivileged = defaultPrivilegedAccounts.includes(value)
|
onPrivilegedUser(value, updateForm)
|
||||||
if (maybePrivileged) {
|
|
||||||
updateForm({ privileged: true })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hidden: () => {
|
hidden: () => {
|
||||||
|
@ -182,13 +182,21 @@ export default {
|
|||||||
},
|
},
|
||||||
columnsMeta: {
|
columnsMeta: {
|
||||||
name: {
|
name: {
|
||||||
width: '120px',
|
minWidth: '60px',
|
||||||
formatterArgs: {
|
formatterArgs: {
|
||||||
can: () => vm.$hasPerm('accounts.view_account'),
|
can: () => vm.$hasPerm('accounts.view_account'),
|
||||||
getRoute: ({ row }) => ({
|
getRoute: ({ row }) => ({
|
||||||
name: 'AccountDetail',
|
name: 'AccountDetail',
|
||||||
params: { id: row.id }
|
params: { id: row.id }
|
||||||
}),
|
}),
|
||||||
|
getTitle: ({ row }) => {
|
||||||
|
let title = row.name
|
||||||
|
if (row.ds && this.asset && this.asset.id !== row.asset.id) {
|
||||||
|
const dsID = row.ds.id.split('-')[0]
|
||||||
|
title = `${row.name}@${dsID}`
|
||||||
|
}
|
||||||
|
return title
|
||||||
|
},
|
||||||
getDrawerTitle({ row }) {
|
getDrawerTitle({ row }) {
|
||||||
return `${row.username}@${row.asset.name}`
|
return `${row.username}@${row.asset.name}`
|
||||||
}
|
}
|
||||||
@ -208,15 +216,18 @@ export default {
|
|||||||
width: '80px',
|
width: '80px',
|
||||||
formatter: AccountConnectFormatter,
|
formatter: AccountConnectFormatter,
|
||||||
formatterArgs: {
|
formatterArgs: {
|
||||||
buttonIcon: 'fa fa-desktop',
|
can: ({ row }) => {
|
||||||
url: '/api/v1/assets/assets/{id}',
|
return this.currentUserIsSuperAdmin
|
||||||
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', {
|
ds: {
|
||||||
key: id,
|
width: '100px',
|
||||||
value: protocol
|
formatter: (row) => {
|
||||||
})
|
if (row.ds && row.ds['domain_name']) {
|
||||||
|
return row.ds['domain_name']
|
||||||
|
} else {
|
||||||
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -229,12 +240,20 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
asset: {
|
asset: {
|
||||||
|
minWidth: '100px',
|
||||||
formatter: function(row) {
|
formatter: function(row) {
|
||||||
return row.asset.name
|
return row.asset.name
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
username: {
|
username: {
|
||||||
width: '120px'
|
minWidth: '60px',
|
||||||
|
formatter: function(row) {
|
||||||
|
if (row.ds && row.ds['domain_name']) {
|
||||||
|
return `${row.username}@${row.ds['domain_name']}`
|
||||||
|
} else {
|
||||||
|
return row.username
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
secret_type: {
|
secret_type: {
|
||||||
formatter: function(row) {
|
formatter: function(row) {
|
||||||
|
@ -1,24 +1,32 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<el-dropdown
|
<el-dropdown
|
||||||
v-if="hasPerm"
|
:disabled="!hasPerm"
|
||||||
|
:show-timeout="500"
|
||||||
|
class="action-connect"
|
||||||
size="small"
|
size="small"
|
||||||
trigger="hover"
|
trigger="hover"
|
||||||
:show-timeout="500"
|
type="primary"
|
||||||
@command="handleCommand"
|
@command="handleProtocolConnect"
|
||||||
@visible-change="visibleChange"
|
@visible-change="visibleChange"
|
||||||
>
|
>
|
||||||
<el-button
|
<el-button
|
||||||
plain
|
plain
|
||||||
size="mini"
|
size="mini"
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="handlePamConnect"
|
@click="handleBtnConnect"
|
||||||
>
|
>
|
||||||
<i :class="IButtonIcon" />
|
<i :class="iButtonIcon" />
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-dropdown-menu slot="dropdown">
|
|
||||||
<el-dropdown-item command="Title" disabled>
|
<el-dropdown-menu v-if="!isClick" slot="dropdown">
|
||||||
{{ ITitleText }}
|
<el-dropdown-item command="title" disabled>
|
||||||
|
<div v-if="getProtocolsLoading">
|
||||||
|
{{ $t('Loading') }}
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
{{ dropdownTitle }}
|
||||||
|
</div>
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
<el-dropdown-item divided />
|
<el-dropdown-item divided />
|
||||||
<el-dropdown-item
|
<el-dropdown-item
|
||||||
@ -30,16 +38,6 @@
|
|||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
|
|
||||||
<el-button
|
|
||||||
v-else
|
|
||||||
plain
|
|
||||||
size="mini"
|
|
||||||
type="primary"
|
|
||||||
:disabled="!hasPerm"
|
|
||||||
>
|
|
||||||
<i :class="IButtonIcon" style="color: #fff" />
|
|
||||||
</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -50,85 +48,70 @@ export default {
|
|||||||
name: 'AccountConnectFormatter',
|
name: 'AccountConnectFormatter',
|
||||||
extends: BaseFormatter,
|
extends: BaseFormatter,
|
||||||
props: {
|
props: {
|
||||||
buttonIcon: {
|
formatterArgsDefault: {
|
||||||
type: String,
|
type: Object,
|
||||||
default: 'fa fa-desktop'
|
default() {
|
||||||
|
return {
|
||||||
|
can: () => true,
|
||||||
|
getConnectUrl: (row, protocol) => {
|
||||||
|
return `/luna/admin-connect/?
|
||||||
|
asset=${row.asset.id}
|
||||||
|
&account=${row.id}
|
||||||
|
&protocol=${protocol}
|
||||||
|
`.replace(/\s+/g, '')
|
||||||
},
|
},
|
||||||
titleText: {
|
assetUrl: '/api/v1/assets/assets/{id}/',
|
||||||
type: String,
|
buttonIcon: 'fa fa-desktop'
|
||||||
default: ''
|
}
|
||||||
},
|
}
|
||||||
url: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
hasPerm: false,
|
formatterArgs: Object.assign(this.formatterArgsDefault, this.col.formatterArgs),
|
||||||
protocols: []
|
protocols: [],
|
||||||
|
isClick: false,
|
||||||
|
getProtocolsLoading: false,
|
||||||
|
dropdownTitle: this.$t('Protocols')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
IButtonIcon() {
|
iButtonIcon() {
|
||||||
return this.buttonIcon
|
return this.formatterArgs.buttonIcon
|
||||||
},
|
},
|
||||||
ITitleText() {
|
hasPerm() {
|
||||||
return this.titleText || this.$t('SelectProtocol')
|
return this.formatterArgs.can({ row: this.row, cellValue: this.cellValue })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
this.hasPerm = this.formatterArgs.can()
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
handleCommand(protocol) {
|
handleProtocolConnect(protocol) {
|
||||||
if (protocol === 'Title') return
|
const url = this.formatterArgs.getConnectUrl(this.row, protocol)
|
||||||
|
window.open(url, '_blank')
|
||||||
this.formatterArgs.setMapItem(this.row.id, protocol)
|
|
||||||
this.handleWindowOpen(this.row, protocol)
|
|
||||||
},
|
},
|
||||||
visibleChange(visible) {
|
visibleChange(visible) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
this.getProtocols(this.row.asset.id)
|
this.getProtocols(this.row.asset.id)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleWindowOpen(row, protocol) {
|
async handleBtnConnect() {
|
||||||
const url = this.formatterArgs.connectUrlTemplate(row) + `${protocol}`
|
this.isClick = true
|
||||||
|
if (this.protocols === 0) {
|
||||||
this.$nextTick(() => {
|
await this.getProtocols(this.row.asset.id)
|
||||||
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.filter(protocol => protocol.name !== 'sftp')[0]
|
|
||||||
|
|
||||||
this.formatterArgs.setMapItem(this.row.id, protocol.name)
|
|
||||||
this.handleWindowOpen(this.row, protocol.name)
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error(`Error getting protocols: ${e}`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.protocols.length > 0) {
|
||||||
|
this.handleProtocolConnect(this.protocols[0].name)
|
||||||
}
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
this.isClick = false
|
||||||
|
}, 1000)
|
||||||
},
|
},
|
||||||
async getProtocols(assetId) {
|
async getProtocols(assetId) {
|
||||||
|
if (this.protocols.length > 0) return
|
||||||
try {
|
try {
|
||||||
const url = this.formatterArgs.url.replace('{id}', assetId)
|
const url = this.formatterArgs.assetUrl.replace('{id}', assetId)
|
||||||
const res = await this.$axios.get(url)
|
const res = await this.$axios.get(url)
|
||||||
|
this.protocols = res.protocols || []
|
||||||
// 暂将 SFTP 过滤
|
|
||||||
if (res) this.protocols = res.protocols.filter(protocol => protocol.name !== 'sftp')
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(`Error getting protocols: ${e}`)
|
throw new Error(`Error getting protocols: ${e}`)
|
||||||
}
|
}
|
||||||
@ -137,7 +120,7 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style lang="scss" scoped>
|
||||||
.el-dropdown-menu__item.is-disabled {
|
.el-dropdown-menu__item.is-disabled {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: var(--el-text-color-secondary);
|
color: var(--el-text-color-secondary);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<span>{{ $t('No accounts') }}</span>
|
<span>{{ $t('No accounts') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-for="account of accountData" :key="account.id" class="detail-item">
|
<div v-for="account of accountData" :key="account.id" class="detail-item">
|
||||||
<span>{{ account.name }}({{ account.username }})</span>
|
<span>{{ getDisplay(account) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<el-button slot="reference" class="link-btn" plain size="mini" type="primary">
|
<el-button slot="reference" class="link-btn" plain size="mini" type="primary">
|
||||||
@ -39,10 +39,20 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getDisplay(account) {
|
||||||
|
const { username, name } = account
|
||||||
|
if (username.startsWith('@')) {
|
||||||
|
return name
|
||||||
|
} else if (name === username) {
|
||||||
|
return username
|
||||||
|
} else {
|
||||||
|
return `${name}(${username})`
|
||||||
|
}
|
||||||
|
},
|
||||||
async getAsyncItems() {
|
async getAsyncItems() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
const userId = this.$route.params.id || 'self'
|
const userId = this.$route.params.id || 'self'
|
||||||
const url = `/api/v1/perms/users/${userId}/assets/${this.row.id}`
|
const url = `/api/v1/perms/users/${userId}/assets/${this.row.id}/`
|
||||||
this.$axios.get(url).then(res => {
|
this.$axios.get(url).then(res => {
|
||||||
this.accountData = res?.permed_accounts || []
|
this.accountData = res?.permed_accounts || []
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
|
@ -45,7 +45,7 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style lang="scss" scoped>
|
||||||
.platform-td {
|
.platform-td {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
@ -55,6 +55,7 @@ export default {
|
|||||||
.icon-zone {
|
.icon-zone {
|
||||||
width: 1.5em;
|
width: 1.5em;
|
||||||
height: 1.5em;
|
height: 1.5em;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
.asset-icon {
|
.asset-icon {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@ -66,6 +67,10 @@ export default {
|
|||||||
|
|
||||||
.platform-name {
|
.platform-name {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +89,9 @@ const actions = {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
cleanPlatforms({ commit, dispatch, state }) {
|
||||||
|
state.platforms = []
|
||||||
|
},
|
||||||
addToRecentPlatforms({ commit, display, state }, platform) {
|
addToRecentPlatforms({ commit, display, state }, platform) {
|
||||||
const recentPlatformIds = state.recentPlatformIds.filter(i => i !== platform.id)
|
const recentPlatformIds = state.recentPlatformIds.filter(i => i !== platform.id)
|
||||||
recentPlatformIds.unshift(platform.id)
|
recentPlatformIds.unshift(platform.id)
|
||||||
|
@ -114,7 +114,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async genConfig() {
|
async genConfig() {
|
||||||
const { addFields, addFieldsMeta, defaultConfig } = this
|
const { addFields, addFieldsMeta, defaultConfig } = this
|
||||||
defaultConfig.fieldsMeta = assetFieldsMeta(this, this.$route.query.type)
|
defaultConfig.fieldsMeta = assetFieldsMeta(this)
|
||||||
let url = this.url
|
let url = this.url
|
||||||
const id = this.$route.params.id
|
const id = this.$route.params.id
|
||||||
if (!id) {
|
if (!id) {
|
||||||
|
23
src/views/assets/Asset/AssetCreateUpdate/DSCreateUpdate.vue
Normal file
23
src/views/assets/Asset/AssetCreateUpdate/DSCreateUpdate.vue
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<template>
|
||||||
|
<BaseAssetCreateUpdate v-bind="$data" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import BaseAssetCreateUpdate from './BaseAssetCreateUpdate'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'DSCreateUpdate',
|
||||||
|
components: { BaseAssetCreateUpdate },
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
url: '/api/v1/assets/directories/',
|
||||||
|
addFields: [
|
||||||
|
[this.$t('IdentityDomain'), ['domain_name'], 1]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
@ -59,7 +59,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
title: this.$t('Test'),
|
title: this.$t('Test'),
|
||||||
templateDialogVisible: false,
|
templateDialogVisible: false,
|
||||||
columnsDefault: ['name', 'username', 'asset', 'connect'],
|
columnsDefault: ['name', 'username', 'connect'],
|
||||||
headerExtraActions: [
|
headerExtraActions: [
|
||||||
{
|
{
|
||||||
name: this.$t('AccountTemplate'),
|
name: this.$t('AccountTemplate'),
|
||||||
@ -96,7 +96,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
iUrl() {
|
iUrl() {
|
||||||
return this.url || `/api/v1/accounts/accounts/?asset=${this.object.id}`
|
return this.url || `/api/v1/assets/assets/${this.object.id}/accounts/`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
21
src/views/assets/Asset/AssetList/DSList.vue
Normal file
21
src/views/assets/Asset/AssetList/DSList.vue
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<template>
|
||||||
|
<BaseList v-bind="tableConfig" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import BaseList from './components/BaseList'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
BaseList
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
tableConfig: {
|
||||||
|
category: 'ds',
|
||||||
|
url: '/api/v1/assets/directories/'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@ -143,7 +143,8 @@ export default {
|
|||||||
'custom': () => import('@/views/assets/Asset/AssetCreateUpdate/CustomCreateUpdate.vue'),
|
'custom': () => import('@/views/assets/Asset/AssetCreateUpdate/CustomCreateUpdate.vue'),
|
||||||
'cloud': () => import('@/views/assets/Asset/AssetCreateUpdate/CloudCreateUpdate.vue'),
|
'cloud': () => import('@/views/assets/Asset/AssetCreateUpdate/CloudCreateUpdate.vue'),
|
||||||
'device': () => import('@/views/assets/Asset/AssetCreateUpdate/DeviceCreateUpdate.vue'),
|
'device': () => import('@/views/assets/Asset/AssetCreateUpdate/DeviceCreateUpdate.vue'),
|
||||||
'database': () => import('@/views/assets/Asset/AssetCreateUpdate/DatabaseCreateUpdate.vue')
|
'database': () => import('@/views/assets/Asset/AssetCreateUpdate/DatabaseCreateUpdate.vue'),
|
||||||
|
'ds': () => import('@/views/assets/Asset/AssetCreateUpdate/DSCreateUpdate.vue')
|
||||||
},
|
},
|
||||||
createProps: {},
|
createProps: {},
|
||||||
showPlatform: false,
|
showPlatform: false,
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
:show-confirm="false"
|
:show-confirm="false"
|
||||||
:title="$tc('SelectPlatform')"
|
:title="$tc('SelectPlatform')"
|
||||||
:visible.sync="iVisible"
|
:visible.sync="iVisible"
|
||||||
size="600px"
|
size="700px"
|
||||||
top="1vh"
|
top="1vh"
|
||||||
>
|
>
|
||||||
<template #title>
|
<template #title>
|
||||||
@ -61,6 +61,7 @@ import { loadPlatformIcon } from '@/utils/jms'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'PlatformDrawer',
|
name: 'PlatformDrawer',
|
||||||
|
components: {},
|
||||||
props: {
|
props: {
|
||||||
visible: {
|
visible: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@ -76,7 +77,7 @@ export default {
|
|||||||
platforms: [],
|
platforms: [],
|
||||||
recentPlatformIds: [],
|
recentPlatformIds: [],
|
||||||
loading: true,
|
loading: true,
|
||||||
activeType: 'host',
|
activeType: [],
|
||||||
recentUsedLabel: this.$t('RecentlyUsed'),
|
recentUsedLabel: this.$t('RecentlyUsed'),
|
||||||
typeIconMapper: {
|
typeIconMapper: {
|
||||||
linux: 'fa-linux',
|
linux: 'fa-linux',
|
||||||
@ -130,9 +131,7 @@ export default {
|
|||||||
async created() {
|
async created() {
|
||||||
this.platforms = await this.$store.dispatch('assets/getPlatforms')
|
this.platforms = await this.$store.dispatch('assets/getPlatforms')
|
||||||
this.allRecentPlatforms = await this.$store.dispatch('assets/getRecentPlatforms')
|
this.allRecentPlatforms = await this.$store.dispatch('assets/getRecentPlatforms')
|
||||||
if (this.allRecentPlatforms.length > 0) {
|
this.activeType = Object.keys(this.iPlatforms)[0]
|
||||||
this.activeType = this.recentUsedLabel
|
|
||||||
}
|
|
||||||
this.loading = false
|
this.loading = false
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -56,6 +56,12 @@ export default {
|
|||||||
hidden: true,
|
hidden: true,
|
||||||
component: () => import('@/views/assets/Asset/AssetList/WebList.vue')
|
component: () => import('@/views/assets/Asset/AssetList/WebList.vue')
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
icon: 'fa-id-card-o',
|
||||||
|
name: 'ds',
|
||||||
|
hidden: true,
|
||||||
|
component: () => import('@/views/assets/Asset/AssetList/DSList.vue')
|
||||||
|
},
|
||||||
{
|
{
|
||||||
icon: 'fa-comment',
|
icon: 'fa-comment',
|
||||||
name: 'gpt',
|
name: 'gpt',
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
:has-reset="false"
|
:has-reset="false"
|
||||||
:initial="initial"
|
:initial="initial"
|
||||||
:url="url"
|
:url="url"
|
||||||
|
@submitSuccess="onSubmitSuccess"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -49,7 +50,8 @@ export default {
|
|||||||
]],
|
]],
|
||||||
[this.$t('Config'), [
|
[this.$t('Config'), [
|
||||||
'protocols', 'su_enabled', 'su_method',
|
'protocols', 'su_enabled', 'su_method',
|
||||||
'domain_enabled', 'charset'
|
'domain_enabled', 'ds_enabled', 'ds',
|
||||||
|
'charset'
|
||||||
]],
|
]],
|
||||||
[this.$t('Automations'), ['automation']],
|
[this.$t('Automations'), ['automation']],
|
||||||
[this.$t('Other'), ['comment']]
|
[this.$t('Other'), ['comment']]
|
||||||
@ -105,6 +107,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
onSubmitSuccess() {
|
||||||
|
this.$store.dispatch('assets/cleanPlatforms')
|
||||||
|
},
|
||||||
updateSuMethodOptions() {
|
updateSuMethodOptions() {
|
||||||
const options = this.suMethods.filter(i => {
|
const options = this.suMethods.filter(i => {
|
||||||
return this.suMethodLimits.includes(i.value)
|
return this.suMethodLimits.includes(i.value)
|
||||||
@ -141,7 +146,6 @@ export default {
|
|||||||
const constraints = await this.$axios.get(url)
|
const constraints = await this.$axios.get(url)
|
||||||
this.defaultOptions = constraints
|
this.defaultOptions = constraints
|
||||||
|
|
||||||
const fieldsCheck = ['domain_enabled', 'su_enabled']
|
|
||||||
let protocols = constraints?.protocols || []
|
let protocols = constraints?.protocols || []
|
||||||
protocols = protocols?.map(i => {
|
protocols = protocols?.map(i => {
|
||||||
if (i.name === 'http') {
|
if (i.name === 'http') {
|
||||||
@ -151,15 +155,20 @@ export default {
|
|||||||
})
|
})
|
||||||
this.fieldsMeta.protocols.el.choices = protocols
|
this.fieldsMeta.protocols.el.choices = protocols
|
||||||
|
|
||||||
|
const fieldsCheck = ['domain_enabled', 'su_enabled']
|
||||||
for (const field of fieldsCheck) {
|
for (const field of fieldsCheck) {
|
||||||
const disabled = constraints[field] === false
|
const disabled = constraints[field] === false
|
||||||
this.initial[field] = !disabled
|
this.initial[field] = !disabled
|
||||||
_.set(this.fieldsMeta, `${field}.el.disabled`, disabled)
|
_.set(this.fieldsMeta, `${field}.el.disabled`, disabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constraints['charset_enabled'] === false) {
|
const fieldsHidden = ['charset_enabled', 'ds_enabled']
|
||||||
this.fieldsMeta.charset.hidden = () => true
|
for (const field of fieldsHidden) {
|
||||||
|
if (constraints[field] === false) {
|
||||||
|
this.fieldsMeta[field].hidden = () => true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await setAutomations(this)
|
await setAutomations(this)
|
||||||
await this.updateSuMethods(constraints)
|
await this.updateSuMethods(constraints)
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,11 @@ export default {
|
|||||||
canUpdate: ({ row }) => !row.internal && vm.$hasPerm('assets.change_platform'),
|
canUpdate: ({ row }) => !row.internal && vm.$hasPerm('assets.change_platform'),
|
||||||
canDelete: ({ row }) => !row.internal && vm.$hasPerm('assets.delete_platform'),
|
canDelete: ({ row }) => !row.internal && vm.$hasPerm('assets.delete_platform'),
|
||||||
onUpdate({ row, col }) {
|
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 }
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,14 +153,7 @@ export default {
|
|||||||
return `/api/v1/assets/platforms/?category=${this.tab.activeMenu}`
|
return `/api/v1/assets/platforms/?category=${this.tab.activeMenu}`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deactivated() {
|
|
||||||
window.localStorage.setItem('lastTab', this.tab.activeMenu)
|
|
||||||
},
|
|
||||||
activated() {
|
activated() {
|
||||||
setTimeout(() => {
|
|
||||||
this.tab.activeMenu = window.localStorage.getItem('lastTab') || 'host'
|
|
||||||
this.$refs.genericListTable?.reloadTable()
|
|
||||||
}, 300)
|
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
try {
|
try {
|
||||||
@ -173,9 +170,15 @@ export default {
|
|||||||
this.tableConfig.url = this.url
|
this.tableConfig.url = this.url
|
||||||
this.headerActions.importOptions.url = this.url
|
this.headerActions.importOptions.url = this.url
|
||||||
this.headerActions.exportOptions.url = this.url
|
this.headerActions.exportOptions.url = this.url
|
||||||
this.headerActions.moreCreates.dropdown = this.$store.state.assets.assetCategoriesDropdown.filter(item => {
|
const types = this.$store.state.assets.assetCategoriesDropdown.filter(item => {
|
||||||
return item.category === this.tab.activeMenu
|
return item.category === this.tab.activeMenu
|
||||||
|
}).map(item => {
|
||||||
|
if (item.group && !item.group.includes(this.$t('Type'))) {
|
||||||
|
item.group += this.$t('WordSep') + this.$t('Type')
|
||||||
|
}
|
||||||
|
return item
|
||||||
})
|
})
|
||||||
|
this.headerActions.moreCreates.dropdown = types
|
||||||
},
|
},
|
||||||
async setCategoriesTab() {
|
async setCategoriesTab() {
|
||||||
const categoryIcon = {
|
const categoryIcon = {
|
||||||
@ -185,6 +188,7 @@ export default {
|
|||||||
cloud: 'fa-cloud',
|
cloud: 'fa-cloud',
|
||||||
web: 'fa-globe',
|
web: 'fa-globe',
|
||||||
gpt: 'fa-comment',
|
gpt: 'fa-comment',
|
||||||
|
ds: 'fa-id-card-o',
|
||||||
custom: 'fa-cube'
|
custom: 'fa-cube'
|
||||||
}
|
}
|
||||||
const state = await this.$store.dispatch('assets/getAssetCategories')
|
const state = await this.$store.dispatch('assets/getAssetCategories')
|
||||||
|
@ -81,6 +81,19 @@ export const platformFieldsMeta = (vm) => {
|
|||||||
disabled: false
|
disabled: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
ds_enabled: {
|
||||||
|
el: {
|
||||||
|
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,
|
||||||
|
@ -48,7 +48,9 @@ function updatePlatformProtocols(vm, platformType, updateForm, platformChanged =
|
|||||||
}), 100)
|
}), 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 platformProtocols = []
|
||||||
const secretTypes = []
|
const secretTypes = []
|
||||||
const asset = { address: 'https://jumpserver:330' }
|
const asset = { address: 'https://jumpserver:330' }
|
||||||
@ -92,7 +94,7 @@ export const assetFieldsMeta = (vm, platformType) => {
|
|||||||
el: {
|
el: {
|
||||||
multiple: false,
|
multiple: false,
|
||||||
ajax: {
|
ajax: {
|
||||||
url: `/api/v1/assets/platforms/?type=${platformType}`,
|
url: `/api/v1/assets/platforms/?category=${platformCategory}&type=${platformType}`,
|
||||||
transformOption: (item) => {
|
transformOption: (item) => {
|
||||||
return { label: item.name, value: item.id }
|
return { label: item.name, value: item.id }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user