Merge remote-tracking branch 'origin/master'

This commit is contained in:
wenyann 2021-03-25 11:56:44 +08:00
commit 2d6dce1c35
10 changed files with 102 additions and 20 deletions

View File

@ -103,6 +103,9 @@ public class MsHTTPSamplerProxy extends MsTestElement {
HTTPSamplerProxy sampler = new HTTPSamplerProxy(); HTTPSamplerProxy sampler = new HTTPSamplerProxy();
sampler.setEnabled(this.isEnable()); sampler.setEnabled(this.isEnable());
sampler.setName(this.getName()); sampler.setName(this.getName());
if (StringUtils.isEmpty(this.getName())) {
sampler.setName("HTTPSamplerProxy");
}
String name = this.getParentName(this.getParent()); String name = this.getParentName(this.getParent());
if (StringUtils.isNotEmpty(name) && !config.isOperating()) { if (StringUtils.isNotEmpty(name) && !config.isOperating()) {
sampler.setName(this.getName() + "<->" + name); sampler.setName(this.getName() + "<->" + name);
@ -126,7 +129,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
// 添加环境中的公共变量 // 添加环境中的公共变量
Arguments arguments = this.addArguments(config); Arguments arguments = this.addArguments(config);
if (arguments != null) { if (arguments != null) {
tree.add(config.valueSupposeMock(arguments)); tree.add(ParameterConfig.valueSupposeMock(arguments));
} }
try { try {
if (config.isEffective(this.getProjectId())) { if (config.isEffective(this.getProjectId())) {

View File

@ -91,6 +91,11 @@ public class ProjectController {
return projectService.uploadFiles(projectId, files); return projectService.uploadFiles(projectId, files);
} }
@PostMapping(value = "/update/file/{projectId}/{fileId}", consumes = {"multipart/form-data"})
public FileMetadata updateFile(@PathVariable String projectId, @PathVariable String fileId, @RequestPart(value = "file") MultipartFile file) {
return projectService.updateFile(projectId, fileId, file);
}
@GetMapping(value = "delete/file/{fileId}") @GetMapping(value = "delete/file/{fileId}")
public void deleteFile(@PathVariable String fileId) { public void deleteFile(@PathVariable String fileId) {
projectService.deleteFile(fileId); projectService.deleteFile(fileId);

View File

@ -73,9 +73,13 @@ public class FileService {
fileContentMapper.deleteByExample(example2); fileContentMapper.deleteByExample(example2);
} }
public FileMetadata saveFile(MultipartFile file, String projectId) { public FileMetadata saveFile(MultipartFile file, String projectId, String fileId) {
final FileMetadata fileMetadata = new FileMetadata(); final FileMetadata fileMetadata = new FileMetadata();
if (StringUtils.isEmpty(fileId)) {
fileMetadata.setId(UUID.randomUUID().toString()); fileMetadata.setId(UUID.randomUUID().toString());
} else {
fileMetadata.setId(fileId);
}
fileMetadata.setName(file.getOriginalFilename()); fileMetadata.setName(file.getOriginalFilename());
fileMetadata.setSize(file.getSize()); fileMetadata.setSize(file.getSize());
fileMetadata.setProjectId(projectId); fileMetadata.setProjectId(projectId);
@ -97,6 +101,10 @@ public class FileService {
return fileMetadata; return fileMetadata;
} }
public FileMetadata saveFile(MultipartFile file, String projectId) {
return saveFile(file, projectId, null);
}
public FileMetadata saveFile(MultipartFile file) { public FileMetadata saveFile(MultipartFile file) {
return saveFile(file, null); return saveFile(file, null);
} }

View File

@ -186,6 +186,18 @@ public class ProjectService {
return result; return result;
} }
public FileMetadata updateFile(String projectId, String fileId, MultipartFile file) {
QueryProjectFileRequest request = new QueryProjectFileRequest();
request.setName(file.getOriginalFilename());
if (CollectionUtils.isEmpty(fileService.getProjectFiles(projectId, request))) {
fileService.deleteFileById(fileId);
return fileService.saveFile(file, projectId);
} else {
MSException.throwException(Translator.get("project_file_already_exists"));
}
return null;
}
public void deleteFile(String fileId) { public void deleteFile(String fileId) {
LoadTestFileExample example1 = new LoadTestFileExample(); LoadTestFileExample example1 = new LoadTestFileExample();
example1.createCriteria().andFileIdEqualTo(fileId); example1.createCriteria().andFileIdEqualTo(fileId);
@ -216,4 +228,5 @@ public class ProjectService {
} }
fileService.deleteFileById(fileId); fileService.deleteFileById(fileId);
} }
} }

View File

@ -24,8 +24,7 @@
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button> <el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
<font-awesome-icon class="ms-alt-ico" :icon="['fa', 'compress-alt']" size="lg" @click="unFullScreen"/> <font-awesome-icon class="ms-alt-ico" :icon="['fa', 'compress-alt']" size="lg" @click="unFullScreen"/>
<!-- <i class="el-icon-close alt-ico-close" @click="close"/>-->
<i class="el-icon-close alt-ico-close" @click="close"/>
</div> </div>
</div> </div>
</template> </template>
@ -124,16 +123,11 @@
.ms-header-right { .ms-header-right {
float: right; float: right;
width: 420px; width: 380px;
margin-top: 2px; margin-top: 4px;
z-index: 1; z-index: 1;
} }
.ms-alt-ico {
font-size: 16px;
margin: 10px 10px 0px;
}
.alt-ico-close { .alt-ico-close {
font-size: 18px; font-size: 18px;
margin: 10px 10px 10px; margin: 10px 10px 10px;
@ -144,6 +138,12 @@
cursor: pointer; cursor: pointer;
} }
.ms-alt-ico {
color: #8c939d;
font-size: 16px;
margin: 10px 30px 0px;
}
.ms-alt-ico:hover { .ms-alt-ico:hover {
color: black; color: black;
cursor: pointer; cursor: pointer;

View File

@ -16,7 +16,7 @@
:before-upload="beforeUploadFile" :before-upload="beforeUploadFile"
:http-request="handleUpload" :http-request="handleUpload"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:file-list="fileList"> >
<ms-table-button :is-tester-permission="true" icon="el-icon-upload2" <ms-table-button :is-tester-permission="true" icon="el-icon-upload2"
:content="$t('load_test.upload_file')"/> :content="$t('load_test.upload_file')"/>
</el-upload> </el-upload>
@ -46,6 +46,23 @@
</el-table-column> </el-table-column>
<el-table-column :label="$t('commons.operating')"> <el-table-column :label="$t('commons.operating')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-upload
style="width: 38px; float: left;"
accept=".jmx,.jar,.csv,.json,.pdf,.jpg,.png,.jpeg,.doc,.docx,.xlsx"
action=""
:limit="fileNumLimit"
:show-file-list="false"
:before-upload="beforeUploadFile"
:http-request="handleUpdateUpload"
:on-exceed="handleExceed"
>
<el-button circle
type="success"
:disabled="!checkoutTestManagerOrTestUser()"
icon="el-icon-edit"
@click="handleEdit(scope.row)"
size="mini"/>
</el-upload>
<ms-table-operator-button :is-tester-permission="true" <ms-table-operator-button :is-tester-permission="true"
icon="el-icon-delete" icon="el-icon-delete"
type="danger" type="danger"
@ -65,7 +82,7 @@
import MsTablePagination from "@/business/components/common/pagination/TablePagination"; import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import MsTableButton from "@/business/components/common/components/MsTableButton"; import MsTableButton from "@/business/components/common/components/MsTableButton";
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter"; import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import {getCurrentProjectID} from "@/common/js/utils"; import {checkoutTestManagerOrTestUser, getCurrentProjectID} from "@/common/js/utils";
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton"; import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton";
import {Message} from "element-ui"; import {Message} from "element-ui";
import MsTableHeader from "@/business/components/common/components/MsTableHeader"; import MsTableHeader from "@/business/components/common/components/MsTableHeader";
@ -87,9 +104,11 @@ export default {
fileNumLimit: 10, fileNumLimit: 10,
condition: {}, condition: {},
projectId: getCurrentProjectID(), projectId: getCurrentProjectID(),
currentRow: null,
} }
}, },
methods: { methods: {
checkoutTestManagerOrTestUser,
open(project) { open(project) {
this.projectId = project.id; this.projectId = project.id;
this.loadFileVisible = true; this.loadFileVisible = true;
@ -136,9 +155,40 @@ export default {
this.getProjectFiles(); this.getProjectFiles();
}); });
}, },
handleUpdateUpload(uploadResources) {
let file = uploadResources.file;
let i1 = file.name.lastIndexOf(".");
let i2 = this.currentRow.name.lastIndexOf(".");
let suffix1 = file.name.substring(i1);
let suffix2 = this.currentRow.name.substring(i2);
if (suffix1 !== suffix2) {
this.$error(this.$t('load_test.project_file_update_type_error'));
return;
}
let formData = new FormData();
let url = '/project/update/file/' + this.projectId + '/' + this.currentRow.id
formData.append("file", file);
let options = {
method: 'POST',
url: url,
data: formData,
headers: {
'Content-Type': undefined
}
}
this.$request(options, (response) => {
this.$success(this.$t('commons.save_success'));
this.currentRow = null;
this.getProjectFiles();
});
},
handleExceed() { handleExceed() {
this.$error(this.$t('load_test.file_size_limit')); this.$error(this.$t('load_test.file_size_limit'));
}, },
handleEdit(row) {
this.currentRow = row;
},
handleDelete(row) { handleDelete(row) {
console.log(row); console.log(row);
this.$confirm(this.$t('project.file_delete_tip', [row.name]), '', { this.$confirm(this.$t('project.file_delete_tip', [row.name]), '', {

View File

@ -13,7 +13,7 @@
<el-table-column type="selection"/> <el-table-column type="selection"/>
<el-table-column width="40" :resizable="false" align="center"> <el-table-column width="40" :resizable="false" align="center">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
<show-more-btn :is-show="isSelect(row)" :buttons="buttons" :size="selectRows.length"/> <show-more-btn :is-show="isSelect(row)" :buttons="buttons" :size="selectRows.size"/>
</template> </template>
</el-table-column> </el-table-column>
<template v-for="(item, index) in tableLabel"> <template v-for="(item, index) in tableLabel">

View File

@ -540,7 +540,8 @@ export default {
load_exist_jmx: 'Load Project JMX', load_exist_jmx: 'Load Project JMX',
threadgroup_at_least_one: 'At least one ThreadGroup is enabled', threadgroup_at_least_one: 'At least one ThreadGroup is enabled',
load_api_automation_jmx: 'Import API automation scenario', load_api_automation_jmx: 'Import API automation scenario',
project_file_exist: "The file already exists in the project, please import it directly" project_file_exist: "The file already exists in the project, please import it directly",
project_file_update_type_error: 'Updated file types must be consistent'
}, },
api_test: { api_test: {
creator: "Creator", creator: "Creator",

View File

@ -539,7 +539,8 @@ export default {
load_exist_jmx: '加载 JMX 文件', load_exist_jmx: '加载 JMX 文件',
threadgroup_at_least_one: '至少启用一个线程组', threadgroup_at_least_one: '至少启用一个线程组',
load_api_automation_jmx: '引用接口自动化场景', load_api_automation_jmx: '引用接口自动化场景',
project_file_exist: "项目中已存在该文件,请直接引用" project_file_exist: "项目中已存在该文件,请直接引用",
project_file_update_type_error: '更新的文件类型必须一致'
}, },
api_test: { api_test: {
creator: "创建人", creator: "创建人",

View File

@ -539,7 +539,8 @@ export default {
load_exist_jmx: '加載 JMX 文件', load_exist_jmx: '加載 JMX 文件',
threadgroup_at_least_one: '至少啟用一個線程組', threadgroup_at_least_one: '至少啟用一個線程組',
load_api_automation_jmx: '引用接口自動化場景', load_api_automation_jmx: '引用接口自動化場景',
project_file_exist: "項目中已存在該文件,請直接引用" project_file_exist: "項目中已存在該文件,請直接引用",
project_file_update_type_error: '更新的文件類型必須一致'
}, },
api_test: { api_test: {
creator: "創建人", creator: "創建人",