Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Determine the asset connection opening method based on the settings #4379

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/api/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function testEmailSetting(data) {
data: data
})
}

export function importLicense(formData) {
return request({
url: '/api/v1/xpack/license/import',
Expand All @@ -25,6 +26,7 @@ export function importLicense(formData) {
data: formData
})
}

export function testLdapSetting(data, refresh = true) {
let url = '/api/v1/settings/ldap/testing/config/'
if (refresh) {
Expand Down Expand Up @@ -96,9 +98,17 @@ export function getPublicSettings(isOpen) {
method: 'get'
})
}

export function getLogo() {
return request({
url: '/api/v1/xpack/interface/setting/',
method: 'get'
})
}

export function getPreference() {
return request({
url: 'api/v1/users/preference/?category=luna',
method: 'get'
})
}
22 changes: 22 additions & 0 deletions src/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,26 @@ export function toSentenceCase(string) {
}).join(' ')
return s[0].toUpperCase() + s.slice(1)
}

export { BASE_URL }

export function openNewWindow(url) {
let count
let top = 50
count = parseInt(window.sessionStorage.getItem('newWindowCount'), 10)
if (isNaN(count)) {
count = 0
}
let left = 100 + count * 100
top = 50 + count * 50
if (left + screen.width / 3 > screen.width) {
// 支持两排足以
top = screen.height / 3
count = 1
left = 100
}
let params = 'toolbar=yes,scrollbars=yes,resizable=yes'
params = params + `,top=${top},left=${left},width=${screen.width / 3},height=${screen.height / 3}`
window.sessionStorage.setItem('newWindowCount', `${count + 1}`)
window.open(url, '_blank', params)
}
15 changes: 13 additions & 2 deletions src/views/workbench/myassets/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import GrantedAssets from '@/components/Apps/GrantedAssets/index.vue'
import Page from '@/layout/components/Page/index.vue'
import { EditableInputFormatter } from '@/components/Table/TableFormatters'
import { getPreference } from '@/api/settings'
import { openNewWindow } from '@/utils/common'

export default {
components: {
Expand All @@ -25,6 +27,7 @@ export default {
return {
treeUrl: `/api/v1/perms/users/self/nodes/children/tree/`,
tableUrl: `/api/v1/perms/users/self/assets/`,
preference: {},
actions: {
width: '88px',
align: 'center',
Expand All @@ -41,8 +44,13 @@ export default {
can: ({ row }) => row.is_active,
callback: ({ row }) => {
const oid = this.$store.getters.currentOrg ? this.$store.getters.currentOrg.id : ''
const url = `/luna/?login_to=${row.id}${oid ? `&oid=${oid}` : ''}`
window.open(url, '_blank')
const url = `/luna/connect?login_to=${row.id}`
if (this.preference?.basic?.connect_default_open_method === 'new') {
openNewWindow(url)
} else {
const url = `/luna/?login_to=${row.id}${oid ? `&oid=${oid}` : ''}`
window.open(url, '_blank')
}
}
},
{
Expand Down Expand Up @@ -81,6 +89,9 @@ export default {
},
mounted() {
this.refreshAllFavorites()
this.preference = getPreference().then((resp) => {
this.preference = resp
})
},
methods: {
refreshAllFavorites() {
Expand Down
14 changes: 13 additions & 1 deletion src/views/workbench/myhome/components/Session.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

<script>
import HomeCard from './HomeCard.vue'
import { getPreference } from '@/api/settings'
import { openNewWindow } from '@/utils/common'

export default {
name: 'Announcement',
Expand All @@ -13,6 +15,7 @@ export default {
data() {
const vm = this
return {
preference: {},
cardConfig: {
title: this.$t('RecentSession')
},
Expand Down Expand Up @@ -71,7 +74,11 @@ export default {
type: 'primary',
can: ({ row }) => row.is_active,
callback: ({ row }) => {
window.open(`/luna/?login_to=${row.asset_id}&login_account=${row.account_id}`, '_blank')
if (this.preference?.basic?.connect_default_open_method === 'new') {
openNewWindow(`/luna/connect?login_to=${row.asset_id}&login_account=${row.account_id}`)
} else {
window.open(`/luna/?login_to=${row.asset_id}&login_account=${row.account_id}`, '_blank')
}
}
}
]
Expand All @@ -82,6 +89,11 @@ export default {
paginationSize: 10
}
}
},
mounted() {
getPreference().then(resp => {
this.preference = resp
})
}
}
</script>
Expand Down