feat: ad domain as asset

This commit is contained in:
ibuler
2025-04-02 19:14:40 +08:00
parent 9af896898e
commit a45d86c568
14 changed files with 126 additions and 31 deletions

View File

@@ -45,7 +45,6 @@ export default {
},
methods: {
createWatermark() {
console.log('currentUser', this.currentUser)
if (this.currentUser?.username && this.publicSettings?.SECURITY_WATERMARK_ENABLED) {
this.watermark = new Watermark({
content: `${this.currentUser.username}(${this.currentUser.name})`,
@@ -53,7 +52,7 @@ export default {
height: 200,
rotate: 45,
fontWeight: 'normal',
fontColor: 'rgba(128, 128, 128, 0.3)'
fontColor: 'rgba(128, 128, 128, 0.2)'
})
this.watermark.create()

View File

@@ -6,6 +6,13 @@ import AutomationParamsForm from '@/views/assets/Platform/AutomationParamsSettin
export const accountFieldsMeta = (vm) => {
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 {
assets: {
component: Select2,
@@ -70,11 +77,8 @@ export const accountFieldsMeta = (vm) => {
if (!vm.account?.name) {
updateForm({ username: value })
}
const maybePrivileged = defaultPrivilegedAccounts.includes(value)
if (maybePrivileged) {
updateForm({ privileged: true })
}
}
onPrivilegedUser(value, updateForm)
}
},
hidden: () => {
@@ -92,10 +96,7 @@ export const accountFieldsMeta = (vm) => {
vm.usernameChanged = true
},
change: ([value], updateForm) => {
const maybePrivileged = defaultPrivilegedAccounts.includes(value)
if (maybePrivileged) {
updateForm({ privileged: true })
}
onPrivilegedUser(value, updateForm)
}
},
hidden: () => {

View File

@@ -147,6 +147,10 @@ export default {
showActions: {
type: Boolean,
default: true
},
target: {
type: Object,
default: null
}
},
data() {
@@ -182,7 +186,7 @@ export default {
},
columnsMeta: {
name: {
width: '120px',
minWidth: '120px',
formatterArgs: {
can: () => vm.$hasPerm('accounts.view_account'),
getRoute: ({ row }) => ({
@@ -234,7 +238,14 @@ export default {
}
},
username: {
width: '120px'
minWidth: '120px',
formatter: function(row) {
if (row.ad_domain) {
return `${row.username}@${row.ad_domain}`
} else {
return row.username
}
}
},
secret_type: {
formatter: function(row) {

View File

@@ -10,7 +10,7 @@
<span>{{ $t('No accounts') }}</span>
</div>
<div v-for="account of accountData" :key="account.id" class="detail-item">
<span>{{ account.name }}({{ account.username }})</span>
<span>{{ getDisplay(account) }}</span>
</div>
</div>
<el-button slot="reference" class="link-btn" plain size="mini" type="primary">
@@ -39,10 +39,20 @@ export default {
}
},
methods: {
getDisplay(account) {
const { username, name } = account
if (username.startsWith('@')) {
return name
} else if (name === username) {
return username
} else {
return `${name}(${username})`
}
},
async getAsyncItems() {
this.loading = true
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.accountData = res?.permed_accounts || []
}).finally(() => {

View File

@@ -89,6 +89,9 @@ const actions = {
})
})
},
cleanPlatforms({ commit, dispatch, state }) {
state.platforms = []
},
addToRecentPlatforms({ commit, display, state }, platform) {
const recentPlatformIds = state.recentPlatformIds.filter(i => i !== platform.id)
recentPlatformIds.unshift(platform.id)

View File

@@ -0,0 +1,23 @@
<template>
<BaseAssetCreateUpdate v-bind="$data" />
</template>
<script>
import BaseAssetCreateUpdate from './BaseAssetCreateUpdate'
export default {
name: 'ADCreateUpdate',
components: { BaseAssetCreateUpdate },
data() {
return {
url: '/api/v1/assets/directories/',
addFields: [
[this.$t('Domain name'), ['domain_name'], 1]
]
}
}
}
</script>
<style>
</style>

View File

@@ -59,7 +59,7 @@ export default {
return {
title: this.$t('Test'),
templateDialogVisible: false,
columnsDefault: ['name', 'username', 'asset', 'connect'],
columnsDefault: ['name', 'username', 'connect'],
headerExtraActions: [
{
name: this.$t('AccountTemplate'),
@@ -96,7 +96,7 @@ export default {
},
computed: {
iUrl() {
return this.url || `/api/v1/accounts/accounts/?asset=${this.object.id}`
return this.url || `/api/v1/assets/assets/${this.object.id}/accounts/`
}
},
methods: {

View 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: 'ad',
url: '/api/v1/assets/directories/'
}
}
}
}
</script>

View File

@@ -143,7 +143,8 @@ export default {
'custom': () => import('@/views/assets/Asset/AssetCreateUpdate/CustomCreateUpdate.vue'),
'cloud': () => import('@/views/assets/Asset/AssetCreateUpdate/CloudCreateUpdate.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'),
'ad': () => import('@/views/assets/Asset/AssetCreateUpdate/ADCreateUpdate.vue')
},
createProps: {},
showPlatform: false,

View File

@@ -76,7 +76,7 @@ export default {
platforms: [],
recentPlatformIds: [],
loading: true,
activeType: 'host',
activeType: [],
recentUsedLabel: this.$t('RecentlyUsed'),
typeIconMapper: {
linux: 'fa-linux',
@@ -130,9 +130,7 @@ export default {
async created() {
this.platforms = await this.$store.dispatch('assets/getPlatforms')
this.allRecentPlatforms = await this.$store.dispatch('assets/getRecentPlatforms')
if (this.allRecentPlatforms.length > 0) {
this.activeType = this.recentUsedLabel
}
this.activeType = Object.keys(this.iPlatforms)[0]
this.loading = false
},
methods: {

View File

@@ -56,6 +56,12 @@ export default {
hidden: true,
component: () => import('@/views/assets/Asset/AssetList/WebList.vue')
},
{
icon: 'fa-comment',
name: 'ad',
hidden: true,
component: () => import('@/views/assets/Asset/AssetList/ADList.vue')
},
{
icon: 'fa-comment',
name: 'gpt',

View File

@@ -11,6 +11,7 @@
:has-reset="false"
:initial="initial"
:url="url"
@submitSuccess="onSubmitSuccess"
/>
</div>
</template>
@@ -49,7 +50,8 @@ export default {
]],
[this.$t('Config'), [
'protocols', 'su_enabled', 'su_method',
'domain_enabled', 'charset'
'domain_enabled', 'ad_enabled', 'ad',
'charset'
]],
[this.$t('Automations'), ['automation']],
[this.$t('Other'), ['comment']]
@@ -105,6 +107,9 @@ export default {
}
},
methods: {
onSubmitSuccess() {
this.$store.dispatch('assets/cleanPlatforms')
},
updateSuMethodOptions() {
const options = this.suMethods.filter(i => {
return this.suMethodLimits.includes(i.value)
@@ -141,7 +146,6 @@ export default {
const constraints = await this.$axios.get(url)
this.defaultOptions = constraints
const fieldsCheck = ['domain_enabled', 'su_enabled']
let protocols = constraints?.protocols || []
protocols = protocols?.map(i => {
if (i.name === 'http') {
@@ -151,6 +155,7 @@ export default {
})
this.fieldsMeta.protocols.el.choices = protocols
const fieldsCheck = ['domain_enabled', 'su_enabled', 'ad_enabled']
for (const field of fieldsCheck) {
const disabled = constraints[field] === false
this.initial[field] = !disabled

View File

@@ -149,14 +149,7 @@ export default {
return `/api/v1/assets/platforms/?category=${this.tab.activeMenu}`
}
},
deactivated() {
window.localStorage.setItem('lastTab', this.tab.activeMenu)
},
activated() {
setTimeout(() => {
this.tab.activeMenu = window.localStorage.getItem('lastTab') || 'host'
this.$refs.genericListTable?.reloadTable()
}, 300)
},
async mounted() {
try {
@@ -173,9 +166,19 @@ export default {
this.tableConfig.url = this.url
this.headerActions.importOptions.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
}).map(item => {
if (!item.group) {
return item
} else {
return {
...item,
group: item.group + this.$t('WordSep') + this.$t('Type')
}
}
})
this.headerActions.moreCreates.dropdown = types
},
async setCategoriesTab() {
const categoryIcon = {
@@ -185,6 +188,7 @@ export default {
cloud: 'fa-cloud',
web: 'fa-globe',
gpt: 'fa-comment',
ad: 'fa-comment',
custom: 'fa-cube'
}
const state = await this.$store.dispatch('assets/getAssetCategories')

View File

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