This commit is contained in:
chenjianxing 2020-05-08 15:59:44 +08:00
commit b876ca0acc
12 changed files with 59 additions and 44 deletions

View File

@ -9,6 +9,7 @@ import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.WorkspaceRequest;
import io.metersphere.dto.WorkspaceDTO;
import io.metersphere.dto.WorkspaceMemberDTO;
import io.metersphere.service.OrganizationService;
import io.metersphere.service.WorkspaceService;
import io.metersphere.user.SessionUtils;
import org.apache.shiro.authz.annotation.Logical;
@ -23,11 +24,14 @@ import java.util.List;
public class WorkspaceController {
@Resource
private WorkspaceService workspaceService;
@Resource
private OrganizationService organizationService;
@PostMapping("add")
@RequiresRoles(RoleConstants.ORG_ADMIN)
public Workspace addWorkspace(@RequestBody Workspace workspace) {
workspaceService.checkWorkspaceOwnerByOrgAdmin(workspace.getId());
String currentOrganizationId = SessionUtils.getCurrentOrganizationId();
organizationService.checkOrgOwner(currentOrganizationId);
return workspaceService.saveWorkspace(workspace);
}

View File

@ -16,9 +16,13 @@
{{$t('commons.save')}}
</el-button>
<el-button type="primary" plain @click="runTest">
<el-button type="primary" plain v-if="!isDisabled" @click="saveRunTest">
{{$t('load_test.save_and_run')}}
</el-button>
<el-button type="primary" plain v-if="isDisabled" @click="runTest">
{{$t('api_test.run')}}
</el-button>
<el-button type="warning" plain @click="cancel">{{$t('commons.cancel')}}</el-button>
</el-row>
</el-header>
@ -91,29 +95,31 @@
}
});
},
save: function (callback) {
this.change = false;
let url = this.create ? "/api/create" : "/api/update";
this.result = this.$request(this.getOptions(url), () => {
this.create = false;
if (callback) callback();
});
},
saveTest: function () {
this.save(() => {
this.$success(this.$t('commons.save_success'));
})
},
save: function (callback) {
this.change = false;
let url = this.create ? "/api/create" : "/api/update";
this.result = this.$request(this.getOptions(url), response => {
this.create = false;
if (callback) callback();
runTest: function () {
this.result = this.$post("/api/run", {id: this.test.id}, () => {
this.$success(this.$t('api_test.running'));
});
},
runTest: function () {
saveRunTest: function () {
this.change = false;
this.save(() => {
this.$success(this.$t('commons.save_success'));
this.result = this.$post("/api/run", {id: this.test.id}, response => {
this.$success(this.$t('api_test.running'));
});
this.runTest();
})
},
cancel: function () {
this.$router.push('/api/test/list/all');

View File

@ -12,20 +12,20 @@
{{$t('api_test.scenario.config')}}
</span>
</div>
<!-- 暂时去掉将来再加-->
<!-- <el-dropdown trigger="click" @command="handleCommand">-->
<!-- <span class="el-dropdown-link el-icon-more scenario-btn"/>-->
<!-- <el-dropdown-menu slot="dropdown">-->
<!-- <el-dropdown-item :command="{type:'delete', index:index}">删除场景</el-dropdown-item>-->
<!-- </el-dropdown-menu>-->
<!-- </el-dropdown>-->
<!-- 暂时去掉将来再加-->
<!-- <el-dropdown trigger="click" @command="handleCommand">-->
<!-- <span class="el-dropdown-link el-icon-more scenario-btn"/>-->
<!-- <el-dropdown-menu slot="dropdown">-->
<!-- <el-dropdown-item :command="{type:'delete', index:index}">删除场景</el-dropdown-item>-->
<!-- </el-dropdown-menu>-->
<!-- </el-dropdown>-->
</template>
<ms-api-request-config :requests="scenario.requests" :open="select"/>
</ms-api-collapse-item>
</ms-api-collapse>
</div>
<!-- 暂时去掉将来再加-->
<!-- <el-button class="scenario-create" type="primary" size="mini" icon="el-icon-plus" plain @click="createScenario"/>-->
<!-- 暂时去掉将来再加-->
<!-- <el-button class="scenario-create" type="primary" size="mini" icon="el-icon-plus" plain @click="createScenario"/>-->
</el-aside>
<el-main class="scenario-main">
@ -90,9 +90,13 @@
}
},
select: function (obj) {
this.selected = obj;
this.selected = null;
this.$nextTick(function () {
this.selected = obj;
});
},
reset: function () {
this.selected = null;
this.$nextTick(function () {
this.activeName = 0;
this.select(this.scenarios[0]);

View File

@ -167,7 +167,7 @@
},
edit(row) {
this.updateVisible = true;
this.form = row;
this.form = Object.assign({}, row);
let roleIds = this.form.roles.map(r => r.id);
this.result = this.$get('/role/list/org', response => {
this.$set(this.form, "allroles", response.data);

View File

@ -193,7 +193,7 @@
},
edit(row) {
this.dialogWsAddVisible = true;
this.form = row;
this.form = Object.assign({}, row);
},
del(row) {
this.$confirm(this.$t('workspace.delete_confirm'), '', {
@ -317,7 +317,7 @@
},
editMember(row) {
this.dialogWsMemberUpdateVisible = true;
this.memberForm = row;
this.memberForm = Object.assign({}, row);
let roleIds = this.memberForm.roles.map(r => r.id);
this.result = this.$get('/role/list/test', response => {
this.$set(this.memberForm, "allroles", response.data);

View File

@ -110,7 +110,7 @@
},
edit(row) {
this.updateVisible = true;
this.form = row;
this.form = Object.assign({}, row);
},
updateUser(updateUserForm) {
this.$refs[updateUserForm].validate(valide => {

View File

@ -258,11 +258,11 @@
},
edit(row) {
this.dialogOrgUpdateVisible = true;
this.form = row;
this.form = Object.assign({}, row);
},
editMember(row) {
this.dialogOrgMemberUpdateVisible = true;
this.memberForm = row;
this.memberForm = Object.assign({}, row);
let roleIds = this.memberForm.roles.map(r => r.id);
this.result = this.$get('/role/list/org', response => {
this.$set(this.memberForm, "allroles", response.data);

View File

@ -12,7 +12,8 @@
<el-table-column prop="organizationName" :label="$t('workspace.organization_name')"/>
<el-table-column :label="$t('commons.member')">
<template v-slot:default="scope">
<el-button type="text" class="member-size" @click="cellClick(scope.row)">{{scope.row.memberSize}}
<el-button type="text" class="member-size" @click="cellClick(scope.row)">
{{scope.row.memberSize}}
</el-button>
</template>
</el-table-column>
@ -85,7 +86,7 @@
</el-dialog>
<!-- dialog of workspace member -->
<el-dialog :visible.sync="dialogWsMemberVisible" width="70%" :destroy-on-close="true" @close="closeMemberFunc">
<el-dialog :visible.sync="dialogWsMemberVisible" width="70%" :destroy-on-close="true" @close="closeWsMemberDialog">
<ms-table-header :condition.sync="dialogCondition" @create="addMember" @search="dialogSearch"
:create-tip="dialogBtnTips" :title="$t('commons.member')"/>
<!-- organization member table -->
@ -112,7 +113,7 @@
<!-- add workspace member dialog -->
<el-dialog :title="$t('member.create')" :visible.sync="dialogWsMemberAddVisible" width="30%"
:destroy-on-close="true"
@close="closeFunc">
@close="handleClose">
<el-form :model="memberForm" ref="form" :rules="wsMemberRule" label-position="right" label-width="100px"
size="small">
<el-form-item :label="$t('commons.member')" prop="userIds">
@ -152,7 +153,7 @@
<!-- update workspace member dialog -->
<el-dialog :title="$t('member.modify')" :visible.sync="dialogWsMemberUpdateVisible" width="30%"
:destroy-on-close="true"
@close="closeFunc">
@close="handleClose">
<el-form :model="memberForm" label-position="right" label-width="100px" size="small" ref="updateUserForm">
<el-form-item label="ID" prop="id">
<el-input v-model="memberForm.id" autocomplete="off" :disabled="true"/>
@ -180,7 +181,7 @@
</el-form>
<template v-slot:footer>
<span class="dialog-footer">
<el-button type="primary" @click="updateOrgMember('updateUserForm')" @keydown.enter.native.prevent
<el-button type="primary" @click="updateWorkspaceMember('updateUserForm')" @keydown.enter.native.prevent
size="medium">{{$t('commons.save')}}
</el-button>
</span>
@ -232,7 +233,6 @@
},
addMember() {
this.dialogWsMemberAddVisible = true;
this.memberForm = {};
this.result = this.$get('/user/list/', response => {
this.$set(this.memberForm, "userList", response.data);
});
@ -318,10 +318,10 @@
});
},
closeFunc() {
this.form = {};
handleClose() {
this.memberForm = {};
},
closeMemberFunc() {
closeWsMemberDialog() {
this.memberLineData = [];
this.list();
},
@ -363,7 +363,7 @@
},
editMember(row) {
this.dialogWsMemberUpdateVisible = true;
this.memberForm = row;
this.memberForm = Object.assign({}, row);
let roleIds = this.memberForm.roles.map(r => r.id);
this.result = this.$get('/role/list/test', response => {
this.$set(this.memberForm, "allroles", response.data);
@ -385,7 +385,7 @@
this.$info(this.$t('commons.delete_cancel'));
});
},
updateOrgMember() {
updateWorkspaceMember() {
let param = {
id: this.memberForm.id,
name: this.memberForm.name,

View File

@ -162,7 +162,7 @@
},
edit(row) {
this.updateVisible = true;
this.form = row;
this.form = Object.assign({}, row);
},
del(row) {
this.$confirm(this.$t('user.delete_confirm'), '', {

View File

@ -191,7 +191,7 @@
},
edit(row) {
this.updateVisible = true;
this.form = row;
this.form = Object.assign({}, row);
let roleIds = this.form.roles.map(r => r.id);
this.result = this.$get('/role/list/test', response => {
this.$set(this.form, "allroles", response.data);

View File

@ -12,7 +12,7 @@ export default {
message: message,
type: "success",
showClose: true,
duration: 1000
duration: 1500
})
};
@ -30,7 +30,7 @@ export default {
message: message,
type: "warning",
showClose: true,
duration: 2000
duration: 5000
})
};

View File

@ -187,6 +187,7 @@ export default {
},
api_test: {
save_and_run: "保存并执行",
run: "执行",
running: "正在执行",
reset: "重置",
input_name: "请输入测试名称",