mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-13 11:24:17 +00:00
perf: 修改 hostname 为 name
This commit is contained in:
@@ -61,7 +61,7 @@ export default {
|
||||
ajax: {
|
||||
url: '/api/v1/assets/assets/?fields_size=mini',
|
||||
transformOption: (item) => {
|
||||
return { label: item.hostname + '(' + item.ip + ')', value: item.id }
|
||||
return { label: item.name + '(' + item.ip + ')', value: item.id }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,8 +88,8 @@ export default {
|
||||
canSelect: this.canSelect,
|
||||
columns: [
|
||||
{
|
||||
prop: 'hostname',
|
||||
label: this.$t('assets.Hostname'),
|
||||
prop: 'name',
|
||||
label: this.$t('assets.Name'),
|
||||
sortable: true,
|
||||
showOverflowTooltip: true,
|
||||
formatter: DetailFormatter,
|
||||
|
||||
@@ -160,8 +160,6 @@ export default {
|
||||
let msgLinkName = ''
|
||||
if (res.name) {
|
||||
msgLinkName = res.name
|
||||
} else if (res.hostname) {
|
||||
msgLinkName = res.hostname
|
||||
}
|
||||
const h = this.$createElement
|
||||
const detailRoute = this.objectDetailRoute
|
||||
@@ -323,8 +321,6 @@ export default {
|
||||
object = await this.getObjectDetail(url)
|
||||
if (object['name']) {
|
||||
object.name = this.$t('common.cloneFrom') + '' + object.name
|
||||
} else if (object['hostname']) {
|
||||
object.hostname = this.$t('common.cloneFrom') + '' + object.hostname
|
||||
}
|
||||
} else {
|
||||
object = await this.getObjectDetail(this.iUrl)
|
||||
|
||||
@@ -33,10 +33,10 @@ export default {
|
||||
tableConfig: {
|
||||
url: `/api/v1/xpack/change-auth-plan/plan/${this.object.id}/assets/`,
|
||||
columns: [
|
||||
'hostname', 'ip', 'delete_action'
|
||||
'name', 'ip', 'delete_action'
|
||||
],
|
||||
columnsMeta: {
|
||||
hostname: {
|
||||
name: {
|
||||
formatter: DetailFormatter,
|
||||
formatterArgs: {
|
||||
route: 'AssetDetail'
|
||||
|
||||
@@ -33,7 +33,7 @@ export default {
|
||||
formatterArgs: {
|
||||
can: this.$hasPerm('assets.view_asset'),
|
||||
getTitle({ row }) {
|
||||
return row.asset_info.hostname
|
||||
return row.asset_info.name
|
||||
},
|
||||
getRoute({ row }) {
|
||||
return {
|
||||
|
||||
@@ -23,10 +23,11 @@ export default {
|
||||
url: '/api/v1/assets/gathered-users/',
|
||||
hasTree: true,
|
||||
columns: [
|
||||
'hostname', 'ip', 'username', 'date_last_login', 'present', 'ip_last_login', 'date_updated'
|
||||
'name', 'ip', 'username', 'date_last_login', 'present',
|
||||
'ip_last_login', 'date_updated'
|
||||
],
|
||||
columnsMeta: {
|
||||
hostname: {
|
||||
name: {
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
ip: {
|
||||
@@ -51,8 +52,8 @@ export default {
|
||||
exclude: ['asset', 'present'],
|
||||
options: [
|
||||
{
|
||||
label: this.$t('assets.Hostname'),
|
||||
value: 'asset__hostname'
|
||||
label: this.$t('assets.Name'),
|
||||
value: 'asset__name'
|
||||
},
|
||||
{
|
||||
label: 'IP',
|
||||
|
||||
@@ -33,7 +33,7 @@ export default {
|
||||
showOverflowTooltip: true,
|
||||
formatter: function(row, column, cellValue, index) {
|
||||
const route = { to: { name: 'AssetDetail', params: { id: cellValue }}}
|
||||
const hostname = row.attrs['asset_info'].hostname
|
||||
const hostname = row.attrs['asset_info'].name
|
||||
if (vm.$hasPerm('assets.view_asset')) {
|
||||
return <router-link{...{ attrs: route }} >{ hostname }</router-link>
|
||||
} else {
|
||||
|
||||
@@ -142,8 +142,8 @@ export default {
|
||||
detailCardItems() {
|
||||
return [
|
||||
{
|
||||
key: this.$t('assets.Hostname'),
|
||||
value: this.object.hostname
|
||||
key: this.$t('assets.Name'),
|
||||
value: this.object.name
|
||||
},
|
||||
{
|
||||
key: this.$t('assets.ip'),
|
||||
|
||||
@@ -51,7 +51,7 @@ export default {
|
||||
],
|
||||
hasRightSide: true,
|
||||
getObjectName: function(obj) {
|
||||
return obj.hostname + '(' + obj.ip + ')'
|
||||
return obj.name + '(' + obj.ip + ')'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,8 +62,8 @@ export default {
|
||||
hasTree: true,
|
||||
columns: [
|
||||
{
|
||||
prop: 'hostname',
|
||||
label: this.$t('assets.Hostname'),
|
||||
prop: 'name',
|
||||
label: this.$t('assets.Name'),
|
||||
sortable: true,
|
||||
formatter: DetailFormatter,
|
||||
formatterArgs: {
|
||||
|
||||
@@ -88,16 +88,16 @@ export default {
|
||||
'actions'
|
||||
],
|
||||
columnsShow: {
|
||||
min: ['hostname', 'ip', 'actions'],
|
||||
min: ['name', 'ip', 'actions'],
|
||||
default: [
|
||||
'hostname', 'ip', 'platform', 'category', 'type',
|
||||
'name', 'ip', 'platform', 'category', 'type',
|
||||
'connectivity', 'actions'
|
||||
]
|
||||
},
|
||||
columnsMeta: {
|
||||
type: { formatter: ChoicesDisplayFormatter },
|
||||
category: { formatter: ChoicesDisplayFormatter },
|
||||
hostname: {
|
||||
name: {
|
||||
formatter: DetailFormatter,
|
||||
formatterArgs: {
|
||||
route: 'AssetDetail'
|
||||
|
||||
@@ -24,7 +24,7 @@ export default {
|
||||
},
|
||||
fields: [
|
||||
[this.$t('common.Basic'), [
|
||||
'hostname', 'ip', 'platform', 'number'
|
||||
'name', 'ip', 'platform', 'number'
|
||||
]],
|
||||
[this.$t('assets.Hardware'), [
|
||||
'vendor', 'model', 'sn', 'cpu_model', 'cpu_count', 'cpu_cores',
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
<template>
|
||||
<component :is="systemUserProtocolComponent" :title="iTitle" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import SSH from './ssh'
|
||||
import RDP from './rdp'
|
||||
import VNC from './vnc'
|
||||
import Database from './database'
|
||||
import K8S from './k8s'
|
||||
import TELNET from './telnet'
|
||||
|
||||
export default {
|
||||
name: 'SystemUserCreateUpdate',
|
||||
components: { SSH, RDP, VNC, Database },
|
||||
data() {
|
||||
return {
|
||||
}
|
||||
},
|
||||
method: {
|
||||
},
|
||||
computed: {
|
||||
iTitle() {
|
||||
const params = this.$route.params
|
||||
let title = ''
|
||||
if (params.id) {
|
||||
title = this.$t('route.SystemUserUpdate')
|
||||
} else {
|
||||
title = this.$t('route.SystemUserCreate')
|
||||
}
|
||||
return title + '-' + this.$t('assets.CommonUser')
|
||||
},
|
||||
systemUserProtocolComponent() {
|
||||
const query = this.$route.query
|
||||
const protocol = query.protocol
|
||||
switch (protocol) {
|
||||
case 'ssh':
|
||||
return SSH
|
||||
case 'rdp':
|
||||
return RDP
|
||||
case 'vnc':
|
||||
return VNC
|
||||
case 'telnet':
|
||||
return TELNET
|
||||
case 'mysql':
|
||||
case 'oracle':
|
||||
case 'postgresql':
|
||||
case 'mariadb':
|
||||
case 'sqlserver':
|
||||
case 'redis':
|
||||
case 'mongodb':
|
||||
return Database
|
||||
case 'k8s':
|
||||
return K8S
|
||||
default:
|
||||
return SSH
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='less' scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,115 +0,0 @@
|
||||
<template>
|
||||
<GenericCreateUpdatePage
|
||||
:fields="fields"
|
||||
:initial="initial"
|
||||
:fields-meta="fieldsMeta"
|
||||
:url="url"
|
||||
v-bind="$attrs"
|
||||
@getObjectDone="onGetObjectDone($event)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import GenericCreateUpdatePage from '@/layout/components/GenericCreateUpdatePage'
|
||||
import { Required } from '@/components/DataForm/rules'
|
||||
|
||||
export default {
|
||||
name: 'CommonUserSSH',
|
||||
components: { GenericCreateUpdatePage },
|
||||
data() {
|
||||
return {
|
||||
initial: {
|
||||
login_mode: 'auto',
|
||||
username_same_with_user: false
|
||||
},
|
||||
fields: [
|
||||
[this.$t('common.Basic'), ['name', 'protocol']],
|
||||
[this.$t('assets.Account'), [
|
||||
'login_mode', 'username', 'username_same_with_user',
|
||||
'su_enabled', 'su_from'
|
||||
]],
|
||||
[this.$t('common.Other'), ['comment']]
|
||||
],
|
||||
fieldsMeta: {
|
||||
login_mode: {
|
||||
on: {
|
||||
input: ([value], updateForm) => {
|
||||
if (value === 'manual') {
|
||||
updateForm({ auto_push_account: false })
|
||||
updateForm({ auto_generate_key: false })
|
||||
}
|
||||
}
|
||||
},
|
||||
helpText: '使用资产上已添加的账号登录,或者手动输入密码登录'
|
||||
},
|
||||
username: {
|
||||
el: {
|
||||
disabled: false
|
||||
},
|
||||
rules: [Object.assign({}, Required)],
|
||||
hidden: (form) => {
|
||||
if (['vnc', 'redis', 'telnet'].includes(form.protocol)) {
|
||||
this.fieldsMeta.username.rules[0].required = false
|
||||
} else if (form.login_mode === 'manual') {
|
||||
this.fieldsMeta.username.rules[0].required = false
|
||||
} else if (form.username_same_with_user) {
|
||||
this.fieldsMeta.username.rules[0].required = false
|
||||
} else {
|
||||
this.fieldsMeta.username.rules[0].required = true
|
||||
}
|
||||
|
||||
if (form.username_same_with_user) {
|
||||
this.fieldsMeta.username.el.disabled = true
|
||||
form.username = ''
|
||||
} else {
|
||||
this.fieldsMeta.username.el.disabled = false
|
||||
}
|
||||
}
|
||||
},
|
||||
username_same_with_user: {
|
||||
type: 'switch',
|
||||
label: this.$t('assets.DynamicUsername'),
|
||||
helpText: this.$t('assets.UsernameHelpMessage'),
|
||||
el: {
|
||||
disabled: false
|
||||
}
|
||||
},
|
||||
protocol: {
|
||||
rules: [Required],
|
||||
el: {
|
||||
style: 'width:100%',
|
||||
disabled: true
|
||||
}
|
||||
},
|
||||
su_enabled: {
|
||||
type: 'switch'
|
||||
},
|
||||
su_from: {
|
||||
hidden: (item) => !item.su_enabled,
|
||||
rules: [Required],
|
||||
el: {
|
||||
multiple: false,
|
||||
clearable: true,
|
||||
ajax: {
|
||||
url: '/api/v1/assets/system-users/su-from/',
|
||||
transformOption: (item) => {
|
||||
return { label: item.name + '(' + item.username + ')', value: item.id }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
url: '/api/v1/assets/system-users/'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onGetObjectDone(obj) {
|
||||
this.fieldsMeta.private_key.el.fingerprint = obj.ssh_key_fingerprint
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='less' scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,37 +0,0 @@
|
||||
<template>
|
||||
<el-row :gutter="20">
|
||||
<el-col :md="20" :sm="24">
|
||||
<AccountListTable ref="ListTable" :url="accountUrl" :has-import="false" :has-clone="false" />
|
||||
</el-col>
|
||||
<el-col :md="4" :sm="24" />
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import { AccountListTable } from '@/components'
|
||||
|
||||
export default {
|
||||
name: 'AccountList',
|
||||
components: {
|
||||
AccountListTable
|
||||
},
|
||||
props: {
|
||||
object: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
accountUrl: `/api/v1/assets/accounts/?systemuser=${this.object.id}`
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='less' scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,42 +0,0 @@
|
||||
<template>
|
||||
<el-row :gutter="20">
|
||||
<el-col :md="20" :sm="24">
|
||||
<AppAccountListTable
|
||||
ref="ListTable"
|
||||
:url="accountUrl"
|
||||
:has-import="false"
|
||||
:has-clone="false"
|
||||
:system-user-disabled="systemUserDisabled"
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :md="4" :sm="24" />
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import { AppAccountListTable } from '@/components'
|
||||
|
||||
export default {
|
||||
name: 'AccountList',
|
||||
components: {
|
||||
AppAccountListTable
|
||||
},
|
||||
props: {
|
||||
object: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
accountUrl: `/api/v1/applications/accounts/?systemuser=${this.object.id}`,
|
||||
systemUserDisabled: false
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='less' scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,126 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-row :gutter="20">
|
||||
<el-col :md="16" :sm="24">
|
||||
<ListTable ref="ListTable" :table-config="tableConfig" :header-actions="headerActions" />
|
||||
</el-col>
|
||||
<el-col :md="8" :sm="24">
|
||||
<RelationCard ref="assetSelect" type="primary" style="margin-top: 15px" v-bind="appRelationConfig" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ListTable from '@/components/ListTable'
|
||||
import { DetailFormatter } from '@/components/TableFormatters'
|
||||
import RelationCard from '@/components/RelationCard'
|
||||
|
||||
export default {
|
||||
name: 'AssetList',
|
||||
components: {
|
||||
RelationCard,
|
||||
ListTable
|
||||
},
|
||||
props: {
|
||||
object: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
return {
|
||||
tableConfig: {
|
||||
name: 'AppList',
|
||||
url: `/api/v1/applications/system-users-apps-relations/?systemuser=${this.object.id}`,
|
||||
columns: ['app_display', 'actions'],
|
||||
columnsMeta: {
|
||||
app_display: {
|
||||
label: this.$t('applications.App'),
|
||||
showOverflowTooltip: true,
|
||||
formatter: DetailFormatter,
|
||||
formatterArgs: {
|
||||
getRoute({ row }) {
|
||||
const categoryRouteMapper = {
|
||||
'remote_app': 'RemoteAppDetail',
|
||||
'db': 'DatabaseAppDetail',
|
||||
'cloud': 'KubernetesAppDetail'
|
||||
}
|
||||
const name = categoryRouteMapper[row.category]
|
||||
return {
|
||||
name: name,
|
||||
params: { id: row.app }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
formatterArgs: {
|
||||
hasUpdate: false, // can set function(row, value)
|
||||
hasDelete: false, // can set function(row, value)
|
||||
hasClone: false,
|
||||
moreActionsTitle: this.$t('common.More'),
|
||||
extraActions: [
|
||||
{
|
||||
name: 'Delete',
|
||||
title: this.$t('common.Delete'),
|
||||
type: 'danger',
|
||||
can: !this.$store.getters.currentOrgIsRoot,
|
||||
callback: (val) => {
|
||||
this.$axios.delete(`/api/v1/applications/system-users-apps-relations/${val.row.id}/`).then(() => {
|
||||
this.$message.success(this.$t('common.deleteSuccessMsg'))
|
||||
this.$refs.ListTable.reloadTable()
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasLeftActions: false,
|
||||
hasBulkDelete: false,
|
||||
hasImport: false,
|
||||
hasCreate: false
|
||||
},
|
||||
appRelationConfig: {
|
||||
icon: 'fa-edit',
|
||||
title: this.$t('applications.associateApplication'),
|
||||
disabled: this.$store.getters.currentOrgIsRoot,
|
||||
objectsAjax: {
|
||||
url: `/api/v1/applications/applications/?type=${vm.object.protocol}`,
|
||||
transformOption: (item) => {
|
||||
return { label: item.name + ' (' + item.type_display + ')', value: item.id }
|
||||
}
|
||||
},
|
||||
showHasObjects: false,
|
||||
performAdd: (items) => {
|
||||
const objectId = this.object.id
|
||||
const relationUrl = `/api/v1/applications/system-users-apps-relations/`
|
||||
const appsId = items.map(v => v.value)
|
||||
const data = []
|
||||
for (const appId of appsId) {
|
||||
data.push({ systemuser: objectId, app: appId })
|
||||
}
|
||||
return this.$axios.post(relationUrl, data)
|
||||
},
|
||||
onAddSuccess: (objects, that) => {
|
||||
this.$log.debug('Select value', that.select2.value)
|
||||
that.iHasObjects = [...that.iHasObjects, ...objects]
|
||||
that.$refs.select2.clearSelected()
|
||||
this.$message.success(this.$t('common.updateSuccessMsg'))
|
||||
this.$refs.ListTable.reloadTable()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='less' scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,247 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-row :gutter="20">
|
||||
<el-col :md="16" :sm="24">
|
||||
<ListTable ref="ListTable" :table-config="tableConfig" :header-actions="headerActions" />
|
||||
</el-col>
|
||||
<el-col :md="8" :sm="24">
|
||||
<QuickActions type="primary" :actions="quickActions" />
|
||||
<AssetRelationCard ref="assetSelect" type="primary" style="margin-top: 15px" v-bind="assetRelationConfig" />
|
||||
<RelationCard ref="nodeRelation" type="info" style="margin-top: 15px" v-bind="nodeRelationConfig" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import QuickActions from '@/components/QuickActions/index'
|
||||
import RelationCard from '@/components/RelationCard'
|
||||
import AssetRelationCard from '@/components/AssetRelationCard'
|
||||
import ListTable from '@/components/ListTable'
|
||||
import { DetailFormatter } from '@/components/TableFormatters'
|
||||
import { connectivityMeta } from '@/components/AccountListTable/const'
|
||||
import { openTaskPage } from '@/utils/jms'
|
||||
|
||||
export default {
|
||||
name: 'AssetList',
|
||||
components: {
|
||||
QuickActions,
|
||||
RelationCard,
|
||||
AssetRelationCard,
|
||||
ListTable
|
||||
},
|
||||
props: {
|
||||
object: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
return {
|
||||
tableConfig: {
|
||||
url: `/api/v1/assets/system-users-assets-relations/?systemuser=${this.object.id}`,
|
||||
columns: ['asset_display', 'connectivity', 'actions'],
|
||||
columnsMeta: {
|
||||
asset_display: {
|
||||
label: this.$t('assets.Hostname'),
|
||||
showOverflowTooltip: true,
|
||||
formatter: DetailFormatter,
|
||||
formatterArgs: {
|
||||
getRoute({ row }) {
|
||||
return {
|
||||
name: 'AssetDetail',
|
||||
params: { id: row.asset }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
connectivity: connectivityMeta,
|
||||
actions: {
|
||||
formatterArgs: {
|
||||
hasUpdate: false, // can set function(row, value)
|
||||
hasDelete: false, // can set function(row, value)
|
||||
hasClone: false,
|
||||
moreActionsTitle: this.$t('common.More'),
|
||||
extraActions: [
|
||||
{
|
||||
name: 'Push',
|
||||
title: this.$t('common.Push'),
|
||||
type: 'primary',
|
||||
can: this.object.auto_push_account && vm.$hasPerm('assets.push_assetsystemuser'),
|
||||
callback: ({ row }) => {
|
||||
const theUrl = `/api/v1/assets/system-users/${vm.object.id}/tasks/`
|
||||
const data = { action: 'push', assets: [row.asset] }
|
||||
this.$axios.post(theUrl, data).then(resp => {
|
||||
openTaskPage(resp['task'])
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
title: this.$t('common.Delete'),
|
||||
type: 'danger',
|
||||
can: !this.$store.getters.currentOrgIsRoot && vm.$hasPerm('assets.delete_authbook'),
|
||||
callback: (val) => {
|
||||
this.$axios.delete(`/api/v1/assets/system-users-assets-relations/${val.row.id}/`).then(() => {
|
||||
this.$message.success(this.$t('common.deleteSuccessMsg'))
|
||||
this.$refs.ListTable.reloadTable()
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasBulkDelete: false,
|
||||
hasImport: false,
|
||||
hasCreate: false,
|
||||
extraMoreActions: [
|
||||
{
|
||||
title: this.$t('common.PushSelected'),
|
||||
name: 'PushSelected',
|
||||
can({ selectedRows }) {
|
||||
return selectedRows.length > 0 && vm.object.auto_push_account && vm.$hasPerm('assets.push_assetsystemuser')
|
||||
},
|
||||
callback: this.bulkPushCallback.bind(this)
|
||||
},
|
||||
{
|
||||
title: this.$t('assets.TestAssetsConnective'),
|
||||
name: 'TestSelected',
|
||||
can({ selectedRows }) {
|
||||
return selectedRows.length > 0 && vm.$hasPerm('assets.test_assetconnectivity')
|
||||
},
|
||||
callback: this.bulkTestCallback.bind(this)
|
||||
}
|
||||
]
|
||||
},
|
||||
quickActions: [
|
||||
{
|
||||
title: this.$t('assets.TestAssetsConnective'),
|
||||
attrs: {
|
||||
type: 'primary',
|
||||
label: this.$t('common.Test'),
|
||||
disabled: !vm.$hasPerm('assets.test_assetconnectivity')
|
||||
},
|
||||
callbacks: {
|
||||
click: function() {
|
||||
this.$axios.post(
|
||||
`/api/v1/assets/system-users/${this.object.id}/tasks/`,
|
||||
{ action: 'test' }
|
||||
).then(res => {
|
||||
openTaskPage(res['task'])
|
||||
})
|
||||
}.bind(this)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: this.$t('assets.PushSystemUserNow'),
|
||||
attrs: {
|
||||
type: 'primary',
|
||||
disabled: !vm.object.auto_push_account,
|
||||
label: this.$t('common.Push')
|
||||
},
|
||||
callbacks: {
|
||||
click: function({ row }) {
|
||||
const theUrl = `/api/v1/assets/system-users/${vm.object.id}/tasks/`
|
||||
const data = { action: 'push' }
|
||||
this.$axios.post(theUrl, data).then(resp => {
|
||||
openTaskPage(resp['task'])
|
||||
})
|
||||
}.bind(this)
|
||||
}
|
||||
}
|
||||
],
|
||||
nodeRelationConfig: {
|
||||
icon: 'fa-link',
|
||||
title: this.$t('assets.AssociateNodes'),
|
||||
objectsAjax: {
|
||||
url: '/api/v1/assets/nodes/',
|
||||
transformOption: (item) => {
|
||||
return { label: item.full_value, value: item.id }
|
||||
}
|
||||
},
|
||||
hasObjectsId: this.object.nodes,
|
||||
performAdd: (items) => {
|
||||
const relationUrl = `/api/v1/assets/system-users-nodes-relations/`
|
||||
const objectId = this.object.id
|
||||
const data = items.map(v => {
|
||||
return {
|
||||
systemuser: objectId,
|
||||
node: v.value
|
||||
}
|
||||
})
|
||||
if (data.length === 0) {
|
||||
return this.$message.error(this.$t('assets.UnselectedNodes'))
|
||||
}
|
||||
return this.$axios.post(relationUrl, data)
|
||||
},
|
||||
performDelete: (item) => {
|
||||
const itemId = item.value
|
||||
const objectId = this.object.id
|
||||
const relationUrl = `/api/v1/assets/system-users-nodes-relations/?systemuser=${objectId}&node=${itemId}`
|
||||
return this.$axios.delete(relationUrl)
|
||||
},
|
||||
onAddSuccess: (objects, that) => {
|
||||
that.iHasObjects = [...that.iHasObjects, ...objects]
|
||||
vm.$refs.nodeRelation.$refs.select2.clearSelected()
|
||||
this.$message.success(this.$t('common.updateSuccessMsg'))
|
||||
vm.$refs.ListTable.reloadTable()
|
||||
}
|
||||
},
|
||||
assetRelationConfig: {
|
||||
icon: 'fa-link',
|
||||
title: this.$t('assets.AssociateAssets'),
|
||||
disabled: this.$store.getters.currentOrgIsRoot,
|
||||
performAdd: (items, that) => {
|
||||
const relationUrl = `/api/v1/assets/system-users-assets-relations/`
|
||||
const data = items.map((i) => {
|
||||
return {
|
||||
'asset': i,
|
||||
'systemuser': this.object.id
|
||||
}
|
||||
})
|
||||
if (data.length === 0) {
|
||||
return this.$message.error(this.$tc('assets.UnselectedAssets'))
|
||||
}
|
||||
return this.$axios.post(relationUrl, data)
|
||||
},
|
||||
onAddSuccess: (items, that) => {
|
||||
this.$log.debug('AssetSelect value', that.assets)
|
||||
this.$message.success(this.$t('common.updateSuccessMsg'))
|
||||
vm.$refs.ListTable.reloadTable()
|
||||
that.$refs.assetSelect.$refs.select2.clearSelected()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
bulkPushCallback({ selectedRows }) {
|
||||
const theUrl = `/api/v1/assets/system-users/${this.object.id}/tasks/`
|
||||
const assets = selectedRows.map((v) => {
|
||||
return v.asset
|
||||
})
|
||||
const data = { action: 'push', assets: assets }
|
||||
this.$axios.post(theUrl, data).then(resp => {
|
||||
openTaskPage(resp['task'])
|
||||
})
|
||||
},
|
||||
bulkTestCallback({ selectedRows }) {
|
||||
const theUrl = `/api/v1/assets/system-users/${this.object.id}/tasks/`
|
||||
const assets = selectedRows.map((v) => {
|
||||
return v.asset
|
||||
})
|
||||
const data = { action: 'test', assets: assets }
|
||||
this.$axios.post(theUrl, data).then(resp => {
|
||||
openTaskPage(resp['task'])
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='less' scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,160 +0,0 @@
|
||||
<template>
|
||||
<el-row :gutter="20">
|
||||
<el-col :md="14" :sm="24">
|
||||
<DetailCard :items="detailCardItems" />
|
||||
</el-col>
|
||||
<el-col :md="10" :sm="24">
|
||||
<QuickActions type="primary" :actions="quickActions" />
|
||||
<RelationCard
|
||||
v-if="!(object.protocol === 'rdp' || object.protocol === 'vnc')"
|
||||
ref="RelationCard"
|
||||
v-bind="nodeRelationConfig"
|
||||
type="info"
|
||||
style="margin-top: 15px"
|
||||
/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DetailCard from '@/components/DetailCard'
|
||||
import QuickActions from '@/components/QuickActions'
|
||||
import RelationCard from '@/components/RelationCard/index'
|
||||
import { toSafeLocalDateStr } from '@/utils/common'
|
||||
|
||||
export default {
|
||||
name: 'Detail',
|
||||
components: {
|
||||
DetailCard,
|
||||
QuickActions,
|
||||
RelationCard
|
||||
},
|
||||
props: {
|
||||
object: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
return {
|
||||
quickActions: [
|
||||
{
|
||||
title: this.$t('assets.AutoPush'),
|
||||
type: 'switcher',
|
||||
attrs: {
|
||||
label: this.$t('assets.AutoPush'),
|
||||
model: this.object.auto_push_account,
|
||||
disabled: (['rdp', 'ssh'].indexOf(this.object.protocol) === -1 || this.object.type === 'admin') ||
|
||||
!vm.$hasPerm('assets.change_systemuser')
|
||||
},
|
||||
callbacks: {
|
||||
change: function(val) {
|
||||
this.$axios.patch(
|
||||
`/api/v1/assets/system-users/${this.object.id}/`,
|
||||
{ auto_push_account: val }
|
||||
).then(res => {
|
||||
this.$message.success(this.$t('common.updateSuccessMsg'))
|
||||
}).catch(err => {
|
||||
this.$message.error(this.$t('common.updateErrorMsg' + ' ' + err))
|
||||
})
|
||||
}.bind(this)
|
||||
}
|
||||
}
|
||||
],
|
||||
nodeRelationConfig: {
|
||||
icon: 'fa-info',
|
||||
hasObjectsId: this.object.cmd_filters,
|
||||
title: this.$t('assets.CmdFilter'),
|
||||
objectsAjax: {
|
||||
url: '/api/v1/assets/cmd-filters/'
|
||||
},
|
||||
performAdd: (items) => {
|
||||
const objectId = this.object.id
|
||||
const relationUrl = `/api/v1/assets/system-users/${objectId}/`
|
||||
const objectOldRelationCmdFilters = this.object.cmd_filters
|
||||
items.map(v => objectOldRelationCmdFilters.push(v.value))
|
||||
const data = { cmd_filters: objectOldRelationCmdFilters }
|
||||
return this.$axios.patch(relationUrl, data)
|
||||
},
|
||||
performDelete: (item) => {
|
||||
const objectId = this.object.id
|
||||
const relationUrl = `/api/v1/assets/system-users/${objectId}/`
|
||||
const objectOldRelationCmdFilters = this.object.cmd_filters
|
||||
const objectNewRelationCmdFilters = objectOldRelationCmdFilters.filter(v => v !== item.value)
|
||||
const data = { cmd_filters: objectNewRelationCmdFilters }
|
||||
return this.$axios.patch(relationUrl, data)
|
||||
},
|
||||
onAddSuccess: (objects, that) => {
|
||||
this.$log.debug('Select value', that.select2.value)
|
||||
that.iHasObjects = [...that.iHasObjects, ...objects]
|
||||
that.$refs.select2.clearSelected()
|
||||
// setTimeout(() => location.reload(), 300)
|
||||
this.$message.success(this.$t('common.updateSuccessMsg'))
|
||||
},
|
||||
onDeleteSuccess: (obj, that) => {
|
||||
const theRemoveIndex = that.iHasObjects.findIndex((v) => v.value === obj.value)
|
||||
that.iHasObjects.splice(theRemoveIndex, 1)
|
||||
while (that.select2.disabledValues.indexOf(obj.value) !== -1) {
|
||||
const i = that.select2.disabledValues.indexOf(obj.value)
|
||||
this.$log.debug('disabled values remove index: ', i)
|
||||
that.select2.disabledValues.splice(i, 1)
|
||||
}
|
||||
this.$message.success(this.$t('common.deleteSuccessMsg'))
|
||||
// setTimeout(() => location.reload(), 300)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
detailCardItems() {
|
||||
return [
|
||||
{
|
||||
key: this.$t('assets.Name'),
|
||||
value: this.object.name
|
||||
},
|
||||
{
|
||||
key: this.$t('assets.Type'),
|
||||
value: this.object.type_display
|
||||
},
|
||||
{
|
||||
key: this.$t('assets.Username'),
|
||||
value: this.object.username
|
||||
},
|
||||
{
|
||||
key: this.$t('assets.sshKeyFingerprint'),
|
||||
value: this.object['ssh_key_fingerprint']
|
||||
},
|
||||
{
|
||||
key: this.$t('assets.Protocol'),
|
||||
value: this.object.protocol
|
||||
},
|
||||
{
|
||||
key: this.$t('assets.LoginModel'),
|
||||
value: this.object['login_mode_display']
|
||||
},
|
||||
{
|
||||
key: 'Sudo',
|
||||
value: this.object.sudo
|
||||
},
|
||||
{
|
||||
key: 'Shell',
|
||||
value: this.object.shell
|
||||
},
|
||||
{
|
||||
key: this.$t('assets.date_joined'),
|
||||
value: toSafeLocalDateStr(this.object.date_created)
|
||||
},
|
||||
{
|
||||
key: this.$t('assets.CreatedBy'),
|
||||
value: this.object.created_by
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='less' scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,80 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-alert type="success">
|
||||
<b>{{ Tips.title }}</b>: <span>{{ Tips.body }}</span>
|
||||
</el-alert>
|
||||
<el-row :gutter="20">
|
||||
<el-col :md="20" :sm="24">
|
||||
<ListTable ref="ListTable" :table-config="tableConfig" :header-actions="headerActions" />
|
||||
</el-col>
|
||||
<el-col :md="4" :sm="24" />
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ListTable from '@/components/ListTable'
|
||||
|
||||
export default {
|
||||
name: 'SwitchToUserList',
|
||||
components: {
|
||||
ListTable
|
||||
},
|
||||
props: {
|
||||
object: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
Tips: {
|
||||
title: this.$t('common.Info'),
|
||||
body: this.$t('assets.SwitchToUserListTips')
|
||||
},
|
||||
tableConfig: {
|
||||
url: `/api/v1/assets/system-users/${this.object.id}/su-to/`,
|
||||
columns: [
|
||||
'name', 'username', 'username_same_with_user', 'protocol', 'login_mode',
|
||||
'assets_amount', 'applications_amount', 'priority',
|
||||
'created_by', 'date_created', 'date_updated', 'comment', 'org_name', 'actions'
|
||||
],
|
||||
columnsShow: {
|
||||
min: ['name', 'actions'],
|
||||
default: [
|
||||
'name', 'username', 'protocol', 'login_mode', 'comment', 'actions'
|
||||
]
|
||||
},
|
||||
columnsMeta: {
|
||||
actions: {
|
||||
formatterArgs: {
|
||||
updateRoute: { name: 'SystemUserUpdate', query: { id: this.$route.params.id }},
|
||||
hasUpdate: true, // can set function(row, value)
|
||||
hasDelete: false, // can set function(row, value)
|
||||
hasClone: false,
|
||||
moreActionsTitle: this.$t('common.More'),
|
||||
extraActions: [
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasLeftActions: false,
|
||||
hasBulkDelete: false,
|
||||
hasImport: false,
|
||||
hasCreate: false,
|
||||
searchConfig: {
|
||||
exclude: ['type', 'protocol']
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='less' scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,99 +0,0 @@
|
||||
<template>
|
||||
<GenericDetailPage :object.sync="systemUser" :active-menu.sync="config.activeMenu" v-bind="config" v-on="$listeners">
|
||||
<keep-alive>
|
||||
<component :is="config.activeMenu" :object="systemUser" />
|
||||
</keep-alive>
|
||||
</GenericDetailPage>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { GenericDetailPage, TabPage } from '@/layout/components'
|
||||
import Detail from './Detail.vue'
|
||||
import AssetList from './AssetList.vue'
|
||||
import AccountList from './AccountList.vue'
|
||||
import AppList from './AppList'
|
||||
import AppAccountList from './AppAccountList'
|
||||
import SwitchToUserList from './SwitchToUserList'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
GenericDetailPage,
|
||||
TabPage,
|
||||
Detail,
|
||||
AssetList,
|
||||
AccountList,
|
||||
AppList,
|
||||
AppAccountList,
|
||||
SwitchToUserList
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
return {
|
||||
systemUser: {},
|
||||
config: {
|
||||
activeMenu: 'Detail',
|
||||
submenu: [
|
||||
{
|
||||
title: this.$t('assets.SystemUserDetail'),
|
||||
name: 'Detail'
|
||||
},
|
||||
{
|
||||
title: this.$t('assets.AssetList'),
|
||||
name: 'AssetList',
|
||||
hidden: () => {
|
||||
return !(vm.systemUser['is_asset_protocol'] && vm.$hasPerm('assets.view_authbook'))
|
||||
}
|
||||
},
|
||||
{
|
||||
title: this.$t('assets.AccountList'),
|
||||
name: 'AccountList',
|
||||
hidden: () => {
|
||||
return !(vm.systemUser['is_asset_protocol'] && vm.$hasPerm('assets.view_authbook'))
|
||||
}
|
||||
},
|
||||
{
|
||||
title: this.$t('assets.AppList'),
|
||||
name: 'AppList',
|
||||
hidden: () => {
|
||||
return !(!vm.systemUser['is_asset_protocol'] && vm.$hasPerm('applications.view_account'))
|
||||
}
|
||||
},
|
||||
{
|
||||
title: this.$t('assets.AccountList'),
|
||||
name: 'AppAccountList',
|
||||
hidden: () => {
|
||||
return !(!vm.systemUser['is_asset_protocol'] && vm.$hasPerm('applications.view_account'))
|
||||
}
|
||||
},
|
||||
{
|
||||
title: this.$t('assets.SwitchToUser'),
|
||||
name: 'SwitchToUserList',
|
||||
hidden: () => {
|
||||
return vm.systemUser['protocol'] !== 'ssh'
|
||||
}
|
||||
}
|
||||
],
|
||||
hasRightSide: true,
|
||||
actions: {
|
||||
updateCallback: () => {
|
||||
const id = this.$route.params.id
|
||||
const routeName = 'SystemUserUpdate'
|
||||
this.$router.push({
|
||||
name: routeName,
|
||||
params: { id: id },
|
||||
query: {
|
||||
type: vm.systemUser.type,
|
||||
protocol: vm.systemUser.protocol
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,96 +0,0 @@
|
||||
<template>
|
||||
<GenericListPage
|
||||
:table-config="tableConfig"
|
||||
:header-actions="headerActions"
|
||||
:help-message="helpMessage"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { GenericListPage } from '@/layout/components'
|
||||
import { ApplicationSystemUserTypes } from '@/views/applications/const'
|
||||
import { AssetProtocols } from '@/views/assets/const'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
GenericListPage
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
return {
|
||||
tableConfig: {
|
||||
url: '/api/v1/assets/system-users/?type=common',
|
||||
columns: [
|
||||
'name', 'username', 'username_same_with_user', 'protocol', 'login_mode',
|
||||
'created_by', 'date_created', 'date_updated', 'comment', 'org_name', 'actions'
|
||||
],
|
||||
columnsShow: {
|
||||
min: ['name', 'actions'],
|
||||
default: [
|
||||
'name', 'username', 'protocol', 'login_mode',
|
||||
'comment', 'actions'
|
||||
]
|
||||
},
|
||||
columnsMeta: {
|
||||
username: {
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
protocol: {
|
||||
width: '100px'
|
||||
},
|
||||
username_same_with_user: {
|
||||
width: '150px',
|
||||
formatterArgs: {
|
||||
showFalse: false
|
||||
}
|
||||
},
|
||||
login_mode: {
|
||||
width: '120px'
|
||||
},
|
||||
assets_amount: {
|
||||
width: '80px'
|
||||
},
|
||||
applications_amount: {
|
||||
width: '80px'
|
||||
},
|
||||
actions: {
|
||||
formatterArgs: {
|
||||
onUpdate: ({ row }) => {
|
||||
vm.$router.push({
|
||||
name: 'SystemUserUpdate', params: { id: row.id }, query: { protocol: row.protocol }
|
||||
})
|
||||
},
|
||||
onClone: ({ row }) => {
|
||||
vm.$router.push({
|
||||
name: 'SystemUserCreate', query: { protocol: row.protocol, clone_from: row.id }
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasCreate: false,
|
||||
createRoute: 'SystemUserCreate',
|
||||
searchConfig: {
|
||||
exclude: ['type', 'protocol']
|
||||
},
|
||||
moreCreates: {
|
||||
callback: (option) => {
|
||||
vm.$router.push({ name: 'SystemUserCreate', query: { protocol: option.name.toLowerCase() }})
|
||||
},
|
||||
dropdown: [
|
||||
...AssetProtocols,
|
||||
...ApplicationSystemUserTypes
|
||||
]
|
||||
}
|
||||
},
|
||||
helpMessage: this.$t('assets.SystemUserListHelpMessage')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -80,7 +80,7 @@ export const Categories = [
|
||||
},
|
||||
{
|
||||
title: '网络设备',
|
||||
name: 'network'
|
||||
name: 'networking'
|
||||
},
|
||||
{
|
||||
title: '数据库',
|
||||
|
||||
Reference in New Issue
Block a user