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

This commit is contained in:
ibuler
2020-05-11 10:39:52 +08:00
33 changed files with 168 additions and 392 deletions

View File

@@ -1,63 +0,0 @@
<template>
<IBox :fa="icon" :type="type" :title="title" v-bind="$attrs">
<el-table class="el-table" :data="content" :show-header="false">
<el-table-column prop="name" />
<el-table-column prop="is_active" align="right">
<template slot-scope="scope">
<el-switch
v-model="scope.row.is_active"
active-color="#1ab394"
inactive-color="#ff4949"
@change="HandleChangeAction(scope.$index, scope.row)"
/>
</template>
</el-table-column>
</el-table>
</IBox>
</template>
<script>
import IBox from '@/components/IBox'
export default {
name: 'ActiveCard',
components: {
IBox
},
props: {
title: {
type: String,
default: ''
},
icon: {
type: String,
default: ''
},
content: {
type: Array,
default: () => []
},
url: {
type: String,
default: ''
},
type: {
type: String,
default: 'primary'
}
},
methods: {
HandleChangeAction(index, row) {
this.$axios.patch(this.url, { is_active: row.is_active }
).then(res => {
this.$message.success(this.$ttc('updateSuccessMsg'))
}).catch(err => {
this.$message.error(this.$ttc('updateFailedMsg' + ' ' + err))
})
}
}
}
</script>
<style scoped>
</style>

View File

@@ -12,7 +12,6 @@ export { default as FormGroupHeader } from './FormGroupHeader'
export { default as Hamburger } from './Hamburger'
export { default as ListTable } from './ListTable'
export { default as RelationCard } from './RelationCard'
export { default as ActiveCard } from './ActiveCard'
export { default as Select2 } from './Select2'
export { default as AssetSelect } from './AssetSelect'
export { default as SvgIcon } from './SvgIcon'

View File

@@ -24,14 +24,7 @@ import Layout from '@/layout'
activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
}
*/
import UsersRoute from '@/views/users'
import AssetsRoute from '@/views/assets'
import ApplicationsRoute from '@/views/applications'
import PermsRoute from '@/views/perms'
import SessionsRoute from '@/views/sessions'
import OpsRoutes from '@/views/jobcenter'
import TicketsRoutes from '@/views/tickets'
import AuditsRoutes from '@/views/audits'
const requireContext = require.context('@/views/', true, /\.js$/)
/**
* constantRoutes
@@ -59,71 +52,6 @@ export const constantRoutes = [
}
]
},
{
path: '/users',
component: Layout,
redirect: '/users/users/',
name: 'Users',
meta: {
title: 'Users',
icon: 'users'
},
children: UsersRoute
},
{
path: '/assets',
component: Layout,
redirect: '/assets/assets/',
name: 'assets',
meta: { title: 'Assets', icon: 'inbox' },
children: AssetsRoute
},
{
path: '/applications/',
component: Layout,
redirect: '/applications/remote-apps/',
name: 'applications',
meta: { title: 'Applications', icon: 'th' },
children: ApplicationsRoute
},
{
path: '/perms/',
component: Layout,
redirect: '/perms/asset-permissions/',
name: 'Perms',
meta: { title: 'Perms', icon: 'edit' },
children: PermsRoute
},
{
path: '/terminal/',
component: Layout,
redirect: '/terminal/session-online/',
name: 'Sessions',
meta: { title: 'Sessions', icon: 'rocket' },
children: SessionsRoute
},
{
path: '/ops/',
component: Layout,
redirect: '/ops/tasks/',
name: 'JobCenter',
meta: { title: 'JobCenter', icon: 'coffee' },
children: OpsRoutes
},
{
path: '/tickets/',
component: Layout,
redirect: '/tickets/tickets/',
children: TicketsRoutes
},
{
path: '/audits/',
component: Layout,
redirect: '/audits/login-log/',
name: 'Audits',
meta: { title: 'Audits', icon: 'history' },
children: AuditsRoutes
},
{
path: '/settings',
component: Layout,
@@ -141,7 +69,8 @@ export const constantRoutes = [
name: 'CeleryTaskLog',
hidden: true,
meta: { title: 'CeleryTaskLog' }
}
},
...requireContext.keys().map(key => requireContext(key).default)
]
/**
@@ -150,99 +79,6 @@ export const constantRoutes = [
*/
// 权限路由
export const asyncRoutes = [
// {
// path: '/nested',
// component: Layout,
// redirect: '/nested/menu1',
// name: 'Nested',
// meta: {
// title: 'Nested',
// icon: 'nested'
// },
// children: [
// {
// path: 'menu1',
// component: () => import('@/views/nested/menu1/index'), // Parent router-view
// name: 'Menu1',
// meta: { title: 'Menu1' },
// children: [
// {
// path: 'menu1-1',
// component: () => import('@/views/nested/menu1/menu1-1'),
// name: 'Menu1-1',
// meta: { title: 'Menu1-1' }
// },
// {
// path: 'menu1-2',
// component: () => import('@/views/nested/menu1/menu1-2'),
// name: 'Menu1-2',
// meta: { title: 'Menu1-2' },
// children: [
// {
// path: 'menu1-2-1',
// component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
// name: 'Menu1-2-1',
// meta: { title: 'Menu1-2-1' }
// },
// {
// path: 'menu1-2-2',
// component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
// name: 'Menu1-2-2',
// meta: { title: 'Menu1-2-2' }
// }
// ]
// },
// {
// path: 'menu1-3',
// component: () => import('@/views/nested/menu1/menu1-3'),
// name: 'Menu1-3',
// meta: { title: 'Menu1-3' }
// }
// ]
// },
// {
// path: 'menu2',
// component: () => import('@/views/nested/menu2/index'),
// meta: { title: 'menu2' }
// }
// ]
// },
// {
// path: '/users',
// component: Layout,
// redirect: '/users/list',
// name: 'Users',
// meta: {
// title: 'Users',
// icon: 'nested'
// },
// children: [
// {
// path: 'user/list',
// component: () => import('@/views/users/UserList.vue'), // Parent router-view
// name: 'UserList',
// meta: { title: 'List' }
// },
// {
// path: 'user/:id',
// component: () => import('@/views/users/UserCreate.vue'), // Parent router-view
// name: 'UserEdit',
// meta: { title: 'Edit' },
// hidden: true
// }
// ]
// },
// {
// path: 'external-link',
// component: Layout,
// children: [
// {
// path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
// meta: { title: 'External Link', icon: 'link' }
// }
// ]
// },
// 404 page must be placed at the end !!!
{ path: '*', redirect: '/404', hidden: true }
]

View File

@@ -1,4 +1,6 @@
export default [
import Layout from '@/layout'
const ApplicationsRoute = [
{
path: 'remote-apps',
name: 'RemoteAppList',
@@ -18,3 +20,12 @@ export default [
meta: { title: 'DatabaseApp' }
}
]
export default {
path: '/applications/',
component: Layout,
redirect: '/applications/remote-apps/',
name: 'applications',
meta: { title: 'Applications', icon: 'th' },
children: ApplicationsRoute
}

View File

@@ -1,4 +1,6 @@
export default [
import Layout from '@/layout'
const AssetsRoute = [
{
path: 'assets',
name: 'AssetList',
@@ -167,3 +169,11 @@ export default [
meta: { title: 'PlatformList' }
}
]
export default {
path: '/assets',
component: Layout,
redirect: '/assets/assets/',
name: 'assets',
meta: { title: 'Assets', icon: 'inbox' },
children: AssetsRoute
}

View File

@@ -1,4 +1,5 @@
export default [
import Layout from '@/layout'
const AuditsRoutes = [
{
path: 'login-log',
name: 'LoginLog',
@@ -30,3 +31,12 @@ export default [
meta: { title: 'BatchCommand' }
}
]
export default {
path: '/audits/',
component: Layout,
redirect: '/audits/login-log/',
name: 'Audits',
meta: { title: 'Audits', icon: 'history' },
children: AuditsRoutes
}

View File

@@ -1,4 +1,5 @@
export default [
import Layout from '@/layout'
const OpsRoutes = [
{
path: 'tasks',
name: 'TaskList',
@@ -33,3 +34,11 @@ export default [
meta: { title: 'BatchCommand' }
}
]
export default {
path: '/ops/',
component: Layout,
redirect: '/ops/tasks/',
name: 'JobCenter',
meta: { title: 'JobCenter', icon: 'coffee' },
children: OpsRoutes
}

View File

@@ -15,7 +15,7 @@
import ListTable from '@/components/ListTable'
import { RelationCard } from '@/components'
import { DeleteActionFormatter } from '@/components/ListTable/formatters/index'
import AssetRelationCard from '../AssetRelationCard'
import AssetRelationCard from './AssetRelationCard/index'
export default {
name: 'AssetPermissionAsset',

View File

@@ -4,20 +4,20 @@
<DetailCard :title="cardTitle" :items="detailCardItems" />
</el-col>
<el-col :md="10" :sm="24">
<ActiveCard type="primary" v-bind="activeConfig" />
<QuickActions type="primary" :actions="quickActions" />
</el-col>
</el-row>
</template>
<script>
import { DetailCard, ActiveCard } from '@/components'
import { DetailCard, QuickActions } from '@/components'
// import { toSafeLocalDateStr } from '@/utils/common'
export default {
name: 'AssetPermissionDetail',
components: {
DetailCard,
ActiveCard
QuickActions
},
props: {
object: {
@@ -26,18 +26,26 @@ export default {
}
},
data() {
const vm = this
return {
activeConfig: {
icon: 'fa-edit',
title: this.$t('perms.QuickModify'),
content: [
{
name: this.$t('perms.Active'),
is_active: this.object.is_active
quickActions: [
{
title: this.$ttc('active'),
type: 'switcher',
attrs: {
model: this.object.is_active
},
callbacks: {
change: function(v, item) {
const url = `/api/v1/perms/asset-permissions/${vm.object.id}/`
const data = { is_active: v }
vm.$axios.patch(url, data).catch(() => {
item.attrs.model = !v
})
}
}
],
url: `/api/v1/perms/asset-permissions/${this.$route.params.id}/`
}
}
]
}
},
computed: {

View File

@@ -1,98 +0,0 @@
<template>
<GenericTreeListPage :table-config="tableConfig" :header-actions="headerActions" :tree-setting="treeSetting" />
</template>
<script>
import GenericTreeListPage from '@/layout/components/GenericTreeListPage'
import { ExpandAssetPermissionFormatter } from '@/components/ListTable/formatters/index'
export default {
components: {
GenericTreeListPage
},
data() {
return {
treeSetting: {
showMenu: false,
showRefresh: true,
showAssets: true,
url: '/api/v1/perms/asset-permissions/',
nodeUrl: '/api/v1/perms/asset-permissions/',
treeUrl: '/api/v1/assets/nodes/children/tree/?assets=1'
},
tableConfig: {
url: '/api/v1/perms/asset-permissions/',
hasSelection: false,
hasTree: true,
tagSearch: [
{ label: this.$tco('Name'), key: 'name' },
{ label: this.$t('perms.IsValid'), key: 'is_valid' },
{ label: this.$tco('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' }
],
columns: ['expand', 'name', 'users_amount', 'user_groups_amount', 'assets_amount', 'nodes_amount', 'system_users_amount', 'is_active', 'actions'],
columnsMeta: {
expand: {
type: 'expand',
formatter: ExpandAssetPermissionFormatter
},
users_amount: {
label: this.$t('perms.User')
},
user_groups_amount: {
label: this.$t('perms.UserGroups')
},
assets_amount: {
label: this.$t('perms.Asset')
},
nodes_amount: {
label: this.$t('perms.Node')
},
system_users_amount: {
label: this.$t('perms.SystemUser')
}
},
actions: {
updateRoute: 'AssetPermissionUpdate',
detailRoute: 'AssetPermissionDetail'
}
},
headerActions: {
hasExport: false,
hasImport: false,
hasRefresh: false,
hasBulkDelete: false,
hasBulkUpdate: false,
extraMoreActions: [
{
name: 'RefreshPermissionCache',
title: this.$t('perms.RefreshPermissionCache'),
type: 'primary',
has: true,
callback: this.HandleRefreshPermissionCache
}
]
}
}
},
methods: {
HandleRefreshPermissionCache() {
const url = '/api/v1/perms/asset-permissions/cache/refresh/'
this.$axios.get(url).then(res => {
this.$message.success(this.$t('perms.ReFreshSuccess'))
}).catch(err => {
this.$message.error(this.$t('perms.ReFreshFail') + ':' + err)
})
}
}
}
</script>
<style>
</style>

View File

@@ -4,20 +4,20 @@
<DetailCard :title="cardTitle" :items="detailCardItems" />
</el-col>
<el-col :md="10" :sm="24">
<ActiveCard type="primary" v-bind="activeConfig" />
<QuickActions type="primary" :actions="quickActions" />
</el-col>
</el-row>
</template>
<script>
import { DetailCard, ActiveCard } from '@/components'
import { DetailCard, QuickActions } from '@/components'
import { toSafeLocalDateStr } from '@/utils/common'
export default {
name: 'DatabaseAppPermissionDetail',
components: {
DetailCard,
ActiveCard
QuickActions
},
props: {
object: {
@@ -26,18 +26,26 @@ export default {
}
},
data() {
const vm = this
return {
activeConfig: {
icon: 'fa-edit',
title: this.$t('perms.QuickModify'),
content: [
{
name: this.$t('perms.Active'),
is_active: this.object.is_active
quickActions: [
{
title: this.$ttc('active'),
type: 'switcher',
attrs: {
model: this.object.is_active
},
callbacks: {
change: function(v, item) {
const url = `/api/v1/perms/database-app-permissions/${vm.object.id}/`
const data = { is_active: v }
vm.$axios.patch(url, data).catch(() => {
item.attrs.model = !v
})
}
}
],
url: `/api/v1/perms/database-app-permissions/${this.object.id}/`
}
}
]
}
},
computed: {

View File

@@ -4,20 +4,20 @@
<DetailCard :title="cardTitle" :items="detailCardItems" />
</el-col>
<el-col :span="10">
<ActiveCard type="primary" v-bind="activeConfig" />
<QuickActions type="primary" :actions="quickActions" />
</el-col>
</el-row>
</template>
<script>
import { DetailCard, ActiveCard } from '@/components'
import { DetailCard, QuickActions } from '@/components'
import { toSafeLocalDateStr } from '@/utils/common'
export default {
name: 'RemoteAppPermissionDetail',
components: {
DetailCard,
ActiveCard
QuickActions
},
props: {
object: {
@@ -26,18 +26,26 @@ export default {
}
},
data() {
const vm = this
return {
activeConfig: {
icon: 'fa-edit',
title: this.$t('perms.QuickModify'),
content: [
{
name: this.$t('perms.Active'),
is_active: this.object.is_active
quickActions: [
{
title: this.$ttc('active'),
type: 'switcher',
attrs: {
model: this.object.is_active
},
callbacks: {
change: function(v, item) {
const url = `/api/v1/perms/remote-app-permissions/${vm.object.id}/`
const data = { is_active: v }
vm.$axios.patch(url, data).catch(() => {
item.attrs.model = !v
})
}
}
],
url: `/api/v1/perms/remote-app-permissions/${this.object.id}/`
}
}
]
}
},
computed: {

View File

@@ -1,29 +1,28 @@
export default [
import Layout from '@/layout'
const PermsRoute = [
{
path: 'asset-permissions',
name: 'AssetPermissionList',
// component: () => import('@/views/perms/AssetPermissionList'),
component: () => import('@/views/perms/AssetPermissionList/index'),
component: () => import('@/views/perms/AssetPermission/AssetPermissionList/index'),
meta: { title: 'AssetPermission' }
},
{
path: 'asset-permissions/create',
component: () => import('@/views/perms/AssetPermissionCreateUpdate'),
component: () => import('@/views/perms/AssetPermission/AssetPermissionCreateUpdate'),
name: 'AssetPermissionCreate',
hidden: true,
meta: { title: 'AssetPermissionCreate', activeMenu: '/perms/asset-permissions', action: 'create' }
},
{
path: 'users/:id/update',
component: () => import('@/views/perms/AssetPermissionCreateUpdate.vue'),
component: () => import('@/views/perms/AssetPermission/AssetPermissionCreateUpdate.vue'),
name: 'AssetPermissionUpdate',
hidden: true,
meta: { title: 'AssetPermissionUpdate', activeMenu: '/perms/asset-permissions', action: 'update' }
},
{
path: 'asset-permissions/:id',
component: () => import('@/views/perms/AssetPermissionDetail/index'),
component: () => import('@/views/perms/AssetPermission/AssetPermissionDetail/index'),
name: 'AssetPermissionDetail',
hidden: true,
meta: { title: 'AssetPermissionDetail', activeMenu: '/perms/asset-permissions' }
@@ -31,26 +30,26 @@ export default [
{
path: 'remote-app-permissions',
name: 'RemoteAppPermissionList',
component: () => import('@/views/perms/RemoteAppPermissionList'),
component: () => import('@/views/perms/RemoteAppPermission/RemoteAppPermissionList'),
meta: { title: 'RemoteAppPermission' }
},
{
path: 'remote-app-permissions/create',
component: () => import('@/views/perms/RemoteAppPermissionCreateUpdate'),
component: () => import('@/views/perms/RemoteAppPermission/RemoteAppPermissionCreateUpdate'),
name: 'RemoteAppPermissionCreate',
hidden: true,
meta: { title: 'RemoteAppPermissionCreate', activeMenu: '/perms/remote-app-permissions', action: 'create' }
},
{
path: 'remote-app-permissions/update',
component: () => import('@/views/perms/RemoteAppPermissionCreateUpdate'),
component: () => import('@/views/perms/RemoteAppPermission/RemoteAppPermissionCreateUpdate'),
name: 'RemoteAppPermissionUpdate',
hidden: true,
meta: { title: 'RemoteAppPermissionUpdate', activeMenu: '/perms/remote-app-permissions', action: 'update' }
},
{
path: 'remote-app-permissions/:id',
component: () => import('@/views/perms/RemoteAppPermissionDetail/index'),
component: () => import('@/views/perms/RemoteAppPermission/RemoteAppPermissionDetail/index'),
name: 'RemoteAppPermissionDetail',
hidden: true,
meta: { title: 'RemoteAppPermissionDetail', activeMenu: '/perms/remote-app-permissions' }
@@ -58,28 +57,37 @@ export default [
{
path: 'database-app-permissions',
name: 'DatabaseAppPermissionList',
component: () => import('@/views/perms/DatabaseAppPermissionList'),
component: () => import('@/views/perms/DatabaseAppPermission/DatabaseAppPermissionList'),
meta: { title: 'DatabaseAppPermission' }
},
{
path: 'database-app-permissions/create',
component: () => import('@/views/perms/DatabaseAppPermissionCreateUpdate'), // Parent router-view
component: () => import('@/views/perms/DatabaseAppPermission/DatabaseAppPermissionCreateUpdate'), // Parent router-view
name: 'DatabaseAppPermissionCreate',
hidden: true,
meta: { title: 'DatabaseAppPermissionCreate', activeMenu: '/perms/database-app-permissions' }
},
{
path: 'database-app-permissions/update',
component: () => import('@/views/perms/DatabaseAppPermissionCreateUpdate'), // Parent router-view
component: () => import('@/views/perms/DatabaseAppPermission/DatabaseAppPermissionCreateUpdate'), // Parent router-view
name: 'DatabaseAppPermissionUpdate',
hidden: true,
meta: { title: 'DatabaseAppPermissionUpdate', activeMenu: '/perms/database-app-permissions', action: 'update' }
},
{
path: 'database-app-permissions/:id',
component: () => import('@/views/perms/DatabaseAppPermissionDetail/index'),
component: () => import('@/views/perms/DatabaseAppPermission/DatabaseAppPermissionDetail/index'),
name: 'DatabaseAppPermissionDetail',
hidden: true,
meta: { title: 'DatabaseAppPermissionDetail', activeMenu: '/perms/database-app-permissions' }
}
]
export default {
path: '/perms/',
component: Layout,
redirect: '/perms/asset-permissions/',
name: 'Perms',
meta: { title: 'Perms', icon: 'edit' },
children: PermsRoute
}

View File

@@ -1,5 +1,5 @@
export default [
import Layout from '@/layout'
const SessionsRoute = [
{
path: 'session-online',
name: 'SessionOnlineList',
@@ -92,3 +92,11 @@ export default [
hidden: true
}
]
export default {
path: '/terminal/',
component: Layout,
redirect: '/terminal/session-online/',
name: 'Sessions',
meta: { title: 'Sessions', icon: 'rocket' },
children: SessionsRoute
}

View File

@@ -1,4 +1,5 @@
export default [
import Layout from '@/layout'
const TicketsRoutes = [
{
path: 'tickets',
name: 'TicketsList',
@@ -6,3 +7,10 @@ export default [
meta: { title: 'Tickets', icon: 'check-square-o' }
}
]
export default {
path: '/tickets/',
component: Layout,
redirect: '/tickets/tickets/',
children: TicketsRoutes
}

View File

@@ -1,4 +1,5 @@
export default [
import Layout from '@/layout'
const UsersRoute = [
{
path: 'users',
component: () => import('./users/UserList.vue'), // Parent router-view
@@ -54,3 +55,16 @@ export default [
meta: { title: 'UserGroupDetail', activeMenu: '/users/groups' }
}
]
export default {
path: '/users',
component: Layout,
redirect: '/users/users/',
name: 'Users',
meta: {
title: 'Users',
icon: 'users'
},
children: UsersRoute
}