Merge branch 'master' of github.com:jumpserver/lina

This commit is contained in:
ibuler
2020-04-26 15:46:30 +08:00
13 changed files with 153 additions and 77 deletions

View File

@@ -0,0 +1,29 @@
<template>
<el-button size="mini" type="danger" @click="handleDelete(col, row, cellValue, reload)">
<i class="fa fa-minus" />
</el-button>
</template>
<script>
import BaseFormatter from './base'
export default {
name: 'DeleteActionFormatter',
extends: BaseFormatter,
methods: {
handleDelete(col, row, cellValue, reload) {
const url = col.deleteUrl + cellValue
this.$axios.delete(url).then(res => {
this.$message.success(this.$tc('Delete success'))
reload()
}).catch(error => {
this.$message.error(this.$tc('Delete failed' + ' ' + error))
})
}
}
}
</script>
<style scoped>
</style>

View File

@@ -8,6 +8,7 @@ import RouterFormatter from './RouterFormatter'
import OutputExpandFormatter from './OutputExpandFormatter' import OutputExpandFormatter from './OutputExpandFormatter'
import ExpandAssetPermissionFormatter from './ExpandAssetPermissionFormatter' import ExpandAssetPermissionFormatter from './ExpandAssetPermissionFormatter'
import CustomActionsFormatter from './CustomActionsFormatter' import CustomActionsFormatter from './CustomActionsFormatter'
import DeleteActionFormatter from './DeleteActionFormatter'
export default { export default {
DetailFormatter, DetailFormatter,
@@ -19,7 +20,8 @@ export default {
RouterFormatter, RouterFormatter,
OutputExpandFormatter, OutputExpandFormatter,
ExpandAssetPermissionFormatter, ExpandAssetPermissionFormatter,
CustomActionsFormatter CustomActionsFormatter,
DeleteActionFormatter
} }
export { export {
@@ -32,5 +34,6 @@ export {
RouterFormatter, RouterFormatter,
OutputExpandFormatter, OutputExpandFormatter,
ExpandAssetPermissionFormatter, ExpandAssetPermissionFormatter,
CustomActionsFormatter CustomActionsFormatter,
DeleteActionFormatter
} }

View File

@@ -16,3 +16,4 @@ export { default as ActiveCard } from './ActiveCard'
export { default as Select2 } from './Select2' export { default as Select2 } from './Select2'
export { default as SvgIcon } from './SvgIcon' export { default as SvgIcon } from './SvgIcon'
export { default as TreeTable } from './TreeTable' export { default as TreeTable } from './TreeTable'

View File

@@ -349,6 +349,9 @@ const cn = {
'RefreshPermissionCache': '刷新授权缓存', 'RefreshPermissionCache': '刷新授权缓存',
'ReFreshSuccess': '刷新成功', 'ReFreshSuccess': '刷新成功',
'ReFreshFail': '刷新失败', 'ReFreshFail': '刷新失败',
'IsValid': '有效',
'IP': 'IP',
'Hostname': '主机名',
'All': '全部', 'All': '全部',
'Connect': '连接', 'Connect': '连接',
'UpDownload': '上传下载', 'UpDownload': '上传下载',

View File

@@ -14,6 +14,7 @@
<script> <script>
import ListTable from '@/components/ListTable' import ListTable from '@/components/ListTable'
import { RelationCard } from '@/components' import { RelationCard } from '@/components'
import { DeleteActionFormatter } from '@/components/ListTable/formatters/index'
export default { export default {
name: 'AssetPermissionAsset', name: 'AssetPermissionAsset',
@@ -26,12 +27,24 @@ export default {
tableConfig: { tableConfig: {
url: `/api/v1/perms/asset-permissions/${this.$route.params.id}/assets/all/`, url: `/api/v1/perms/asset-permissions/${this.$route.params.id}/assets/all/`,
columns: [ columns: [
'asset_display' 'asset_display', 'delete_action'
], ],
columnsMeta: { columnsMeta: {
asset_display: { asset_display: {
label: this.$t('perms.Asset') label: this.$t('perms.Asset'),
align: 'center'
},
delete_action: {
prop: 'asset',
label: this.$tc('Action'),
align: 'center',
width: 150,
formatter: DeleteActionFormatter,
deleteUrl: `/api/v1/perms/asset-permissions-assets-relations/?assetpermission=${this.$route.params.id}&asset=`
} }
},
tableAttrs: {
border: false
} }
}, },
headerActions: { headerActions: {

View File

@@ -1,5 +1,5 @@
<template> <template>
<GenericDetailPage :object.sync="assetPermissionData" v-bind="config"> <GenericDetailPage :object.sync="assetPermissionData" v-bind="config" @tab-click="TabClick">
<template #detail> <template #detail>
<div> <div>
<el-row :gutter="20"> <el-row :gutter="20">
@@ -111,7 +111,6 @@ export default {
}, },
{ {
key: this.$t('perms.DateExpired'), key: this.$t('perms.DateExpired'),
// value: toSafeLocalDateStr(this.assetData.date_expired),
value: toSafeLocalDateStr(this.assetPermissionData.date_expired) value: toSafeLocalDateStr(this.assetPermissionData.date_expired)
}, },
{ {
@@ -141,6 +140,13 @@ export default {
return data.length return data.length
} }
return data return data
},
TabClick(tab) {
if (tab.name !== 'detail') {
this.$set(this.config, 'hasRightSide', false)
} else {
this.$set(this.config, 'hasRightSide', true)
}
} }
} }
} }

View File

@@ -16,6 +16,17 @@ export default {
url: '/api/v1/perms/asset-permissions/', url: '/api/v1/perms/asset-permissions/',
hasSelection: false, hasSelection: false,
hasTree: true, hasTree: true,
tagSearch: [
{ label: this.$tc('Name'), key: 'name' },
{ label: this.$t('perms.IsValid'), key: 'is_valid' },
{ label: this.$tc('username'), key: 'username' },
{ label: this.$t('perms.UserGroups'), key: 'user_group' },
{ label: this.$t('perms.IP'), key: 'ip' },
{ label: this.$t('perms.Hostname'), key: 'hostname' },
{ label: this.$t('perms.Node'), key: 'node' },
{ label: this.$t('perms.SystemUser'), key: 'system_user' },
{ label: '继承(先占位)', key: 'all=0' }
],
treeSetting: { treeSetting: {
showMenu: false, showMenu: false,
showRefresh: true, showRefresh: true,
@@ -56,8 +67,12 @@ export default {
} }
}, },
headerActions: { headerActions: {
hasExport: false,
hasImport: false,
hasRefresh: false,
hasBulkDelete: false, hasBulkDelete: false,
extraActions: [ hasBulkUpdate: false,
extraMoreActions: [
{ {
name: 'RefreshPermissionCache', name: 'RefreshPermissionCache',
title: this.$t('perms.RefreshPermissionCache'), title: this.$t('perms.RefreshPermissionCache'),
@@ -73,9 +88,9 @@ export default {
HandleRefreshPermissionCache() { HandleRefreshPermissionCache() {
const url = '/api/v1/perms/asset-permissions/cache/refresh/' const url = '/api/v1/perms/asset-permissions/cache/refresh/'
this.$axios.get(url).then(res => { this.$axios.get(url).then(res => {
this.$message(this.$t('perms.ReFreshSuccess')) this.$message.success(this.$t('perms.ReFreshSuccess'))
}).catch(err => { }).catch(err => {
this.$message(this.$t('perms.ReFreshFail') + ':' + err) this.$message.error(this.$t('perms.ReFreshFail') + ':' + err)
}) })
} }
} }

View File

@@ -13,6 +13,7 @@
<script> <script>
import ListTable from '@/components/ListTable' import ListTable from '@/components/ListTable'
import { RelationCard } from '@/components' import { RelationCard } from '@/components'
import { DeleteActionFormatter } from '@/components/ListTable/formatters/index'
export default { export default {
name: 'AssetPermissionUser', name: 'AssetPermissionUser',
@@ -25,12 +26,24 @@ export default {
tableConfig: { tableConfig: {
url: `/api/v1/perms/asset-permissions/${this.$route.params.id}/users/all/`, url: `/api/v1/perms/asset-permissions/${this.$route.params.id}/users/all/`,
columns: [ columns: [
'user_display' 'user_display', 'delete_action'
], ],
columnsMeta: { columnsMeta: {
user_display: { user_display: {
label: this.$t('perms.User') label: this.$t('perms.User'),
align: 'center'
},
delete_action: {
prop: 'user',
label: this.$tc('Action'),
align: 'center',
width: 150,
formatter: DeleteActionFormatter,
deleteUrl: `/api/v1/perms/asset-permissions-users-relations/?assetpermission=${this.$route.params.id}&user=`
} }
},
tableAttrs: {
border: false
} }
}, },
headerActions: { headerActions: {

View File

@@ -13,6 +13,7 @@
<script> <script>
import ListTable from '@/components/ListTable' import ListTable from '@/components/ListTable'
import { RelationCard } from '@/components' import { RelationCard } from '@/components'
import { DeleteActionFormatter } from '@/components/ListTable/formatters/index'
export default { export default {
name: 'DatabaseAppPermissionDatabaseApp', name: 'DatabaseAppPermissionDatabaseApp',
@@ -25,11 +26,20 @@ export default {
tableConfig: { tableConfig: {
url: `/api/v1/perms/database-app-permissions/${this.$route.params.id}/database-apps/all/`, url: `/api/v1/perms/database-app-permissions/${this.$route.params.id}/database-apps/all/`,
columns: [ columns: [
'databaseapp_display' 'databaseapp_display', 'delete_action'
], ],
columnsMeta: { columnsMeta: {
databaseapp_display: { databaseapp_display: {
label: this.$t('perms.DatabaseApp') label: this.$t('perms.DatabaseApp'),
align: 'center'
},
delete_action: {
prop: 'databaseapp',
label: this.$tc('Action'),
align: 'center',
width: 150,
formatter: DeleteActionFormatter,
deleteUrl: `/api/v1/perms/database-app-permissions-database-apps-relations/?databaseapppermission=${this.$route.params.id}&databaseapp=`
} }
} }
}, },

View File

@@ -1,5 +1,5 @@
<template> <template>
<GenericDetailPage :object.sync="databaseAppData" v-bind="config"> <GenericDetailPage :object.sync="databaseAppData" v-bind="config" @tab-click="TabClick">
<div slot="detail"> <div slot="detail">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :md="14" :sm="24"> <el-col :md="14" :sm="24">
@@ -130,6 +130,13 @@ export default {
return data.length return data.length
} }
return data return data
},
TabClick(tab) {
if (tab.name !== 'detail') {
this.$set(this.config, 'hasRightSide', false)
} else {
this.$set(this.config, 'hasRightSide', true)
}
} }
} }
} }

View File

@@ -14,6 +14,8 @@
<script> <script>
import ListTable from '@/components/ListTable' import ListTable from '@/components/ListTable'
import { RelationCard } from '@/components' import { RelationCard } from '@/components'
import { DeleteActionFormatter } from '@/components/ListTable/formatters/index'
export default { export default {
name: 'DatabaseAppPermissionUser', name: 'DatabaseAppPermissionUser',
components: { components: {
@@ -25,11 +27,20 @@ export default {
tableConfig: { tableConfig: {
url: `/api/v1/perms/database-app-permissions/${this.$route.params.id}/users/all/`, url: `/api/v1/perms/database-app-permissions/${this.$route.params.id}/users/all/`,
columns: [ columns: [
'user_display' 'user_display', 'delete_action'
], ],
columnsMeta: { columnsMeta: {
user_display: { user_display: {
label: this.$t('perms.User') label: this.$t('perms.User'),
align: 'center'
},
delete_action: {
prop: 'user',
label: this.$tc('Action'),
align: 'center',
width: 150,
formatter: DeleteActionFormatter,
deleteUrl: `/api/v1/perms/database-app-permissions-users-relations/?databaseapppermission=${this.$route.params.id}&user=`
} }
} }
}, },

View File

@@ -1,5 +1,5 @@
<template> <template>
<GenericDetailPage :object.sync="remoteAppData" v-bind="config"> <GenericDetailPage :object.sync="remoteAppData" v-bind="config" @tab-click="TabClick">
<div slot="detail"> <div slot="detail">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="14"> <el-col :span="14">
@@ -130,6 +130,13 @@ export default {
return data.length return data.length
} }
return data return data
},
TabClick(tab) {
if (tab.name !== 'detail') {
this.$set(this.config, 'hasRightSide', false)
} else {
this.$set(this.config, 'hasRightSide', true)
}
} }
} }
} }

View File

@@ -16,7 +16,6 @@
import { TabPage } from '@/layout/components' import { TabPage } from '@/layout/components'
import { ListTable } from '@/components' import { ListTable } from '@/components'
import { TestCommandStorage, TestReplayStorage } from '@/api/sessions' import { TestCommandStorage, TestReplayStorage } from '@/api/sessions'
import { CustomActionsFormatter } from '@/components/ListTable/formatters'
export default { export default {
name: 'Storage', name: 'Storage',
@@ -90,7 +89,7 @@ export default {
}, },
replayTableConfig: { replayTableConfig: {
url: '/api/v1/terminal/replay-storages/', url: '/api/v1/terminal/replay-storages/',
columns: ['name', 'type', 'comment', 'cusActions'], columns: ['name', 'type', 'comment', 'actions'],
columnsMeta: { columnsMeta: {
name: { name: {
formatter: function(row) { formatter: function(row) {
@@ -105,36 +104,16 @@ export default {
comment: { comment: {
sortable: 'custom' sortable: 'custom'
}, },
cusActions: {
prop: 'id',
formatter: CustomActionsFormatter,
actions: { actions: {
actions: [ prop: 'id',
{ actions: {
name: 'update', canUpdate: function(row, cellValue) {
title: this.$tc('Update'), return (row.name !== 'default' && row.name !== 'null')
type: 'primary',
can: function(row, cellValue,) {
return row.name !== 'null' && row.name !== 'default'
}, },
callback: function({ row, col, cellValue, reload }) { canDelete: function(row, cellValue) {
} return (row.name !== 'default' && row.name !== 'null')
},
{
name: 'delete',
title: this.$tc('Delete'),
type: 'danger',
can: function(row, cellValue) {
return row.name !== 'null' && row.name !== 'default'
},
callback: function({ row, col, cellValue, reload }) {
const id = row.id
const url = `${this.url}${id}/`
this.$axios.delete(url).then(data => {
reload()
})
}
}, },
extraActions: [
{ {
name: 'test', name: 'test',
title: this.$t('sessions.test'), title: this.$t('sessions.test'),
@@ -179,7 +158,7 @@ export default {
commandTableConfig: { commandTableConfig: {
title: 'command', title: 'command',
url: '/api/v1/terminal/command-storages/', url: '/api/v1/terminal/command-storages/',
columns: ['name', 'type', 'comment', 'cusActions'], columns: ['name', 'type', 'comment', 'actions'],
columnsMeta: { columnsMeta: {
comment: { comment: {
sortable: 'custom' sortable: 'custom'
@@ -194,36 +173,15 @@ export default {
return row.type return row.type
} }
}, },
cusActions: {
prop: 'id',
formatter: CustomActionsFormatter,
actions: { actions: {
actions: [ actions: {
{ canUpdate: function(row, cellValue) {
name: 'update', return (row.name !== 'default' && row.name !== 'null')
title: this.$tc('Update'),
type: 'primary',
can: function(row, cellValue,) {
return row.name !== 'null' && row.name !== 'default'
}, },
callback: function({ row, col, cellValue, reload }) { canDelete: function(row, cellValue) {
} return (row.name !== 'default' && row.name !== 'null')
},
{
name: 'delete',
title: this.$tc('Delete'),
type: 'danger',
can: function(row, cellValue) {
return row.name !== 'null' && row.name !== 'default'
},
callback: function({ row, col, cellValue, reload }) {
const id = row.id
const url = `${this.url}${id}/`
this.$axios.delete(url).then(data => {
reload()
})
}
}, },
extraActions: [
{ {
name: 'test', name: 'test',
title: this.$t('sessions.test'), title: this.$t('sessions.test'),