Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
haifeng414 2020-02-21 11:46:23 +08:00
commit d8408e9c7e
5 changed files with 106 additions and 78 deletions

View File

@ -1 +1,7 @@
export const TokenKey = 'Admin-Token'; export const TokenKey = 'Admin-Token';
export const ROLE_ADMIN = 'admin';
export const ROLE_ORG_ADMIN = 'org_admin';
export const ROLE_TEST_MANAGER = 'test_manager';
export const ROLE_TEST_USER = 'test_user';
export const ROLE_TEST_VIEWER = 'test_viewer';

View File

@ -7,8 +7,13 @@
:default-active="activeIndex" :default-active="activeIndex"
@select="handleSelect" @select="handleSelect"
router> router>
<el-menu-item index="1">功能测试</el-menu-item> <el-menu-item index="1" v-permission="['test_manager','test_user','test_viewer']">
<el-menu-item index="/createTest" onselectstart="return false">性能测试</el-menu-item> 功能测试
</el-menu-item>
<el-menu-item index="/createTest" onselectstart="return false"
v-permission="['test_manager','test_user','test_viewer']">
性能测试
</el-menu-item>
<el-menu-item index="/setting" onselectstart="return false">系统设置</el-menu-item> <el-menu-item index="/setting" onselectstart="return false">系统设置</el-menu-item>
</el-menu> </el-menu>
</template> </template>
@ -22,15 +27,15 @@
} }
}, },
watch: { watch: {
'$route' () { '$route'() {
this.handleSelect(this.activeIndex); this.handleSelect(this.activeIndex);
} }
}, },
mounted () { mounted() {
this.activeIndex = this.$route.matched[0].path || '/' this.activeIndex = this.$route.matched[0].path || '/'
}, },
methods: { methods: {
handleSelect (index) { handleSelect(index) {
this.activeIndex = index this.activeIndex = index
} }
} }

View File

@ -6,7 +6,7 @@
class="header-user-menu" class="header-user-menu"
background-color="rgb(44, 42, 72)" background-color="rgb(44, 42, 72)"
text-color="#fff"> text-color="#fff">
<el-submenu index="1" popper-class="submenu"> <el-submenu index="1" popper-class="submenu" v-permission="['org_admin']">
<template slot="title">组织</template> <template slot="title">组织</template>
<label v-for="(item,index) in organizationList" :key="index"> <label v-for="(item,index) in organizationList" :key="index">
<el-menu-item @click="clickMenu(item)">{{item.name}} <el-menu-item @click="clickMenu(item)">{{item.name}}
@ -15,7 +15,7 @@
</el-menu-item> </el-menu-item>
</label> </label>
</el-submenu> </el-submenu>
<el-submenu index="2" popper-class="submenu"> <el-submenu index="2" popper-class="submenu" v-permission="['test_manager', 'test_user', 'test_viewer']">
<template slot="title">工作空间</template> <template slot="title">工作空间</template>
<label v-for="(item,index) in workspaceList" :key="index"> <label v-for="(item,index) in workspaceList" :key="index">
<el-menu-item @click="clickMenu(item)"> <el-menu-item @click="clickMenu(item)">
@ -43,7 +43,7 @@
<script> <script>
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import {TokenKey} from '../../common/constants'; import {ROLE_ORG_ADMIN, ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER, TokenKey} from '../../common/constants';
export default { export default {
name: "MsUser", name: "MsUser",
@ -98,13 +98,18 @@
} }
}, },
initMenuData() { initMenuData() {
this.$get("/organization/list/userorg/" + this.currentUserId, response => { let roles = this.currentUser.roles.map(r => r.id);
this.organizationList = response.data; if (roles.indexOf(ROLE_ORG_ADMIN) > 0) {
}) this.$get("/organization/list/userorg/" + this.currentUserId, response => {
this.$get("/workspace/list/userworkspace/" + this.currentUserId, response => { this.organizationList = response.data;
this.workspaceList = response.data; });
this.workspaceIds = response.data.map(r => r.id); }
}) if (roles.indexOf(ROLE_TEST_MANAGER) > 0 || roles.indexOf(ROLE_TEST_USER) > 0 || roles.indexOf(ROLE_TEST_VIEWER) > 0) {
this.$get("/workspace/list/userworkspace/" + this.currentUserId, response => {
this.workspaceList = response.data;
this.workspaceIds = response.data.map(r => r.id);
});
}
}, },
getCurrentUserInfo() { getCurrentUserInfo() {
this.$get("/user/info/" + this.currentUserId, response => { this.$get("/user/info/" + this.currentUserId, response => {

View File

@ -1,10 +1,10 @@
<template> <template>
<el-row type="flex" align="middle" class="current-user"> <el-row type="flex" align="middle" class="current-user">
<el-avatar shape="square" size="small" :src="squareUrl"/> <el-avatar shape="square" size="small" :src="squareUrl"/>
<span class="username">kun@fit2cloud.com</span> <span class="username">{{currentUser.name}}</span>
<el-button class="edit" type="primary" icon="el-icon-edit" size="mini" <el-button class="edit" type="primary" icon="el-icon-edit" size="mini"
circle @click="editVisible = true"/> circle @click="edit"/>
<el-dialog :title="title" :visible.sync="editVisible" width="30%"> <el-dialog :title="currentUser.name" :visible.sync="editVisible" width="30%">
<el-form :model="form" label-position="top" size="small"> <el-form :model="form" label-position="top" size="small">
<el-form-item label="姓名"> <el-form-item label="姓名">
<el-input v-model="form.name" autocomplete="off"/> <el-input v-model="form.name" autocomplete="off"/>
@ -14,28 +14,40 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button type="primary" @click="editVisible = false" size="medium">更新</el-button> <el-button type="primary" @click="submit" size="medium">更新</el-button>
</span> </span>
</el-dialog> </el-dialog>
</el-row> </el-row>
</template> </template>
<script> <script>
import Cookies from 'js-cookie';
import {TokenKey} from "../../../common/constants";
export default { export default {
name: "MsCurrentUser", name: "MsCurrentUser",
data() { data() {
return { return {
editVisible: false, editVisible: false,
id: "123456", id: "123456",
squareUrl: "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png", squareUrl: "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png",
form: { form: {}
name: "kun@fit2cloud.com",
mobile: ""
}
} }
}, computed: { },
title: function () { methods: {
return "编辑账号(id: " + this.id + ")"; edit() {
this.editVisible = true;
this.form = Object.assign({}, this.currentUser);
},
submit() {
this.editVisible = false;
}
},
computed: {
currentUser: () => {
let user = Cookies.get(TokenKey);
return JSON.parse(user);
} }
} }
} }

View File

@ -1,63 +1,63 @@
<template> <template>
<el-menu menu-trigger="click" :default-active="$route.path" router> <el-menu menu-trigger="click" :default-active="$route.path" router>
<el-submenu index="1" v-permission="['admin']"> <el-submenu index="1" v-permission="['admin']">
<template slot="title"> <template slot="title">
<font-awesome-icon class="icon account" :icon="['far', 'address-card']" size="lg"/> <font-awesome-icon class="icon account" :icon="['far', 'address-card']" size="lg"/>
<span>账号</span> <span>账号</span>
</template> </template>
<el-menu-item index="/setting/user">用户</el-menu-item> <el-menu-item index="/setting/user" v-permission="['admin']">用户</el-menu-item>
<el-menu-item index="/setting/testresourcepool" v-permission="['test']">测试资源池</el-menu-item> <el-menu-item index="/setting/testresourcepool" v-permission="['test']">测试资源池</el-menu-item>
<el-menu-item index="/setting/organization">组织</el-menu-item> <el-menu-item index="/setting/organization" v-permission="['admin']">组织</el-menu-item>
<el-menu-item index="/setting/workspace">工作空间</el-menu-item> <el-menu-item index="/setting/workspace" v-permission="['org_admin']">工作空间</el-menu-item>
<el-menu-item>API Keys</el-menu-item> <el-menu-item>API Keys</el-menu-item>
</el-submenu> </el-submenu>
<el-submenu index=2 v-permission="['admin','org_admin']"> <el-submenu index=2 v-permission="['org_admin']">
<template slot="title"> <template slot="title">
<font-awesome-icon class="icon workspace" :icon="['far', 'clone']" size="lg"/> <font-awesome-icon class="icon workspace" :icon="['far', 'clone']" size="lg"/>
<span>工作空间</span> <span>工作空间</span>
</template> </template>
<el-menu-item index="/setting/member">成员</el-menu-item> <el-menu-item index="/setting/member">成员</el-menu-item>
<el-menu-item>证书</el-menu-item> <el-menu-item>证书</el-menu-item>
<el-menu-item>测试计划</el-menu-item> <el-menu-item>测试计划</el-menu-item>
<el-menu-item>警告</el-menu-item> <el-menu-item>警告</el-menu-item>
</el-submenu> </el-submenu>
<el-submenu index="3"> <el-submenu index="3">
<template slot="title"> <template slot="title">
<font-awesome-icon class="icon" :icon="['far', 'user']" size="lg"/> <font-awesome-icon class="icon" :icon="['far', 'user']" size="lg"/>
<span>个人</span> <span>个人</span>
</template> </template>
<el-menu-item>个人设置</el-menu-item> <el-menu-item>个人设置</el-menu-item>
<el-menu-item>API Keys</el-menu-item> <el-menu-item>API Keys</el-menu-item>
</el-submenu> </el-submenu>
</el-menu> </el-menu>
</template> </template>
<script> <script>
export default { export default {
name: "MsSettingMenu" name: "MsSettingMenu"
} }
</script> </script>
<style scoped> <style scoped>
.el-menu { .el-menu {
border-right: 0; border-right: 0;
} }
.el-menu-item { .el-menu-item {
height: 40px; height: 40px;
line-height: 40px; line-height: 40px;
} }
.icon { .icon {
width: 24px; width: 24px;
margin-right: 10px; margin-right: 10px;
} }
.account { .account {
color: #5a78f0; color: #5a78f0;
} }
.workspace { .workspace {
color: #44b349; color: #44b349;
} }
</style> </style>