Merge branch 'fix_rbac' of github.com:jumpserver/lina into fix_rbac

This commit is contained in:
“怀磊” 2022-02-23 16:53:20 +08:00
commit 1824519d6c
14 changed files with 29 additions and 176 deletions

View File

@ -93,13 +93,19 @@ export default {
} }
.el-menu--horizontal .el-menu .el-menu-item { .el-menu--horizontal .el-menu .el-menu-item {
display: inline-block!important; display: inline-block!important;
padding: 10px 10px;
text-align: center; text-align: center;
padding: 6px 0px 6px 18px; height: 70px;
width: 70px;
&:hover { &:hover {
color: #303133; color: #303133;
//background-color: #e6e6e6;
}
&:first-child {
margin-left: 20px;
} }
&:last-child { &:last-child {
padding: 6px 18px 6px 18px; margin-right: 20px;
} }
} }
.el-submenu.is-opened { .el-submenu.is-opened {
@ -118,10 +124,12 @@ export default {
} }
.icons-title { .icons-title {
display: inline-block; display: inline-block;
padding-bottom: 10px;
font-size: 14px; font-size: 14px;
} }
.el-menu--popup-bottom-start { .el-menu--popup-bottom-start {
margin-top: 0px!important; margin-top: 0!important;
}
.el-menu-item.is-active {
font-weight: bold;
} }
</style> </style>

View File

@ -1,4 +1,3 @@
import Layout from '@/layout/index'
import i18n from '@/i18n/i18n' import i18n from '@/i18n/i18n'
/** /**
@ -6,26 +5,6 @@ import i18n from '@/i18n/i18n'
* the routes that need to be dynamically loaded based on admin or user roles * the routes that need to be dynamically loaded based on admin or user roles
*/ */
export default [ export default [
{
path: '/users/first-login',
component: Layout,
meta: { title: i18n.t('route.UserFirstLogin'), icon: 'user' },
children: [
{
path: 'personal-information-improvement/',
component: () => import('@/views/profile/UserFirstLogin/PersonalInformationImprovement/index'),
name: 'PersonalInformationImprovement',
meta: { title: i18n.t('route.PersonalInformationImprovement') }
},
{
path: 'guide/',
component: () => import('@/views/profile/UserFirstLogin/UserGuide/index'),
name: 'UserGuide',
meta: { title: i18n.t('route.UserGuide') }
}
],
hidden: true
},
{ {
path: '/ops/celery/task/:id/log/', path: '/ops/celery/task/:id/log/',
component: () => import('@/views/ops/CeleryTaskLog'), component: () => import('@/views/ops/CeleryTaskLog'),

View File

@ -17,7 +17,7 @@ export default {
{ {
path: '/profile/info', path: '/profile/info',
name: 'ProfileInfo', name: 'ProfileInfo',
component: () => import('@/views/profile/UserProfile/ProfileInfo'), component: () => import('@/views/profile/ProfileInfo'),
meta: { meta: {
title: i18n.t('users.AccountInformation'), title: i18n.t('users.AccountInformation'),
icon: 'adjust', icon: 'adjust',
@ -26,13 +26,20 @@ export default {
}, },
{ {
path: '/profile/setting', path: '/profile/setting',
name: 'profileSetting', name: 'ProfileSetting',
component: () => import('@/views/profile/UserProfile/index'), component: () => import('@/views/profile/ProfileUpdate/index'),
meta: { meta: {
title: i18n.t('users.PersonalSetting'), title: i18n.t('users.PersonalSetting'),
icon: 'user-circle', icon: 'user-circle',
permissions: [] permissions: []
} }
},
{
path: '/profile/improvement',
component: () => import('@/views/profile/ProfileImprovement'),
name: 'ProfileImprovement',
hidden: true,
meta: { title: i18n.t('route.PersonalInformationImprovement'), permissions: [] }
} }
] ]
} }

View File

@ -15,10 +15,6 @@ function reject(msg) {
return new Promise((resolve, reject) => reject(msg)) return new Promise((resolve, reject) => reject(msg))
} }
// function setHeadTitle({ to, from, next }) {
// document.title = getPageTitle(to.meta.title)
// }
async function checkLogin({ to, from, next }) { async function checkLogin({ to, from, next }) {
if (whiteList.indexOf(to.path) !== -1) { if (whiteList.indexOf(to.path) !== -1) {
next() next()
@ -69,12 +65,11 @@ async function changeCurrentOrgIfNeed({ to, from, next }) {
await refreshCurrentOrg() await refreshCurrentOrg()
const currentOrg = store.getters.currentOrg const currentOrg = store.getters.currentOrg
if (!currentOrg || typeof currentOrg !== 'object') { if (!currentOrg || typeof currentOrg !== 'object') {
// console.log('Not has current org')
orgUtil.change2PropOrg() orgUtil.change2PropOrg()
return reject('Change prop org') return reject('Change prop org')
} }
if (!orgUtil.hasCurrentOrgPermission()) { if (!orgUtil.hasCurrentOrgPermission()) {
console.debug('Not has current org permission') console.error('Not has current org permission')
orgUtil.change2PropOrg() orgUtil.change2PropOrg()
return reject('Change prop org') return reject('Change prop org')
} }
@ -109,11 +104,6 @@ export async function generatePageRoutes({ to, from, next }) {
try { try {
// try get user profile // try get user profile
// note: roles must be a object array! such as: ['admin'] or ,['developer','editor']
// 不能改名 current_org_roles, 里面返回的就是这个
// const currentRole = store.getters.currentRole
// console.log('Current org role: ', currentRole, rolec.getRolesDisplay(currentRole))
// generate accessible routes map based on roles // generate accessible routes map based on roles
const accessRoutes = await store.dispatch('permission/generateRoutes', { to, from }) const accessRoutes = await store.dispatch('permission/generateRoutes', { to, from })
@ -134,7 +124,7 @@ export async function generatePageRoutes({ to, from, next }) {
export async function checkUserFirstLogin({ to, from, next }) { export async function checkUserFirstLogin({ to, from, next }) {
if (store.state.users.profile.is_first_login) { if (store.state.users.profile.is_first_login) {
next('/users/first-login/personal-information-improvement/') next('/profile/information-improvement')
} }
} }

View File

@ -1,19 +1,15 @@
<template> <template>
<IBox> <GenericCreateUpdatePage v-bind="$data" />
<GenericCreateUpdateForm v-bind="$data" />
</IBox>
</template> </template>
<script> <script>
import GenericCreateUpdateForm from '@/layout/components/GenericCreateUpdateForm' import { GenericCreateUpdatePage } from '@/layout/components'
import { IBox } from '@/components'
import { Required } from '@/components/DataForm/rules' import { Required } from '@/components/DataForm/rules'
export default { export default {
name: 'ProfileUpdate', name: 'ProfileUpdate',
components: { components: {
GenericCreateUpdateForm, GenericCreateUpdatePage
IBox
}, },
props: { props: {
object: { object: {
@ -82,7 +78,7 @@ export default {
}, },
onPerformSuccess() { onPerformSuccess() {
this.$message.success(this.$t('common.updateSuccessMsg')) this.$message.success(this.$t('common.updateSuccessMsg'))
setTimeout(() => this.$router.push({ name: 'UserGuide' }), 100) setTimeout(() => this.$router.push({ name: 'ProfileInfo' }), 100)
}, },
submitMethod() { submitMethod() {
return 'put' return 'put'

View File

@ -8,7 +8,7 @@
<script> <script>
import { GenericDetailPage } from '@/layout/components' import { GenericDetailPage } from '@/layout/components'
import ProfileInfo from './ProfileInfo' import ProfileInfo from '../ProfileInfo'
import ProfileUpdate from './ProfileUpdate' import ProfileUpdate from './ProfileUpdate'
import PasswordUpdate from './PasswordUpdate' import PasswordUpdate from './PasswordUpdate'
import SecretKeyUpdate from './SecretKeyUpdate' import SecretKeyUpdate from './SecretKeyUpdate'

View File

@ -1,42 +0,0 @@
<template>
<GenericDetailPage :object.sync="user" :active-menu.sync="config.activeMenu" v-bind="config" v-on="$listeners">
<keep-alive>
<component :is="config.activeMenu" :object="user" />
</keep-alive>
</GenericDetailPage>
</template>
<script>
import { GenericDetailPage } from '@/layout/components'
import PersonalInformationImprovement from './PersonalInformationImprovement'
export default {
components: {
GenericDetailPage,
PersonalInformationImprovement
},
data() {
return {
user: {},
config: {
title: this.$t('users.FirstLogin'),
activeMenu: 'PersonalInformationImprovement',
submenu: [
{
title: this.$t('users.ImprovePersonalInformation'),
name: 'PersonalInformationImprovement'
}
],
hasRightSide: false,
actions: {
detailApiUrl: '/api/v1/users/profile/'
}
}
}
}
}
</script>
<style scoped>
</style>

View File

@ -1,43 +0,0 @@
<template>
<IBox>
<div>
<span>{{ describe }}</span>
<el-link type="success" :href="guide.url">{{ guide.label }}</el-link>
</div>
</IBox>
</template>
<script>
import { IBox } from '@/components'
export default {
components: {
IBox
},
props: {
},
data() {
return {
describe: this.$t('users.DescribeOfGuide'),
guide: {
url: '',
label: this.$t('users.Guide')
}
}
},
async mounted() {
const data = await this.getObject()
this.guide.url = data.guide_url
},
methods: {
getObject() {
const url = `/api/v1/users/profile/`
return this.$axios.get(url)
}
}
}
</script>
<style scoped>
</style>

View File

@ -1,42 +0,0 @@
<template>
<GenericDetailPage :object.sync="user" :active-menu.sync="config.activeMenu" v-bind="config" v-on="$listeners">
<keep-alive>
<component :is="config.activeMenu" :object="user" />
</keep-alive>
</GenericDetailPage>
</template>
<script>
import { GenericDetailPage } from '@/layout/components'
import Guide from './Guide'
export default {
components: {
GenericDetailPage,
Guide
},
data() {
return {
user: {},
config: {
title: this.$t('users.FirstLogin'),
activeMenu: 'Guide',
submenu: [
{
title: this.$t('users.Guide'),
name: 'Guide'
}
],
hasRightSide: false,
actions: {
detailApiUrl: '/api/v1/users/profile/'
}
}
}
}
}
</script>
<style scoped>
</style>