Merge remote-tracking branch 'origin/v1.1' into v1.1

This commit is contained in:
wenyann 2020-07-21 10:16:35 +08:00
commit 9ca7fdf576
12 changed files with 73 additions and 29 deletions

View File

@ -34,7 +34,7 @@ public class ApiTestEnvironmentService {
}
public void update(ApiTestEnvironmentWithBLOBs apiTestEnvironment) {
apiTestEnvironmentMapper.updateByPrimaryKey(apiTestEnvironment);
apiTestEnvironmentMapper.updateByPrimaryKeyWithBLOBs(apiTestEnvironment);
}
public String add(ApiTestEnvironmentWithBLOBs apiTestEnvironmentWithBLOBs) {

View File

@ -58,14 +58,32 @@
}
},
copyEnvironment(environment) {
if (!environment.id) {
this.$warning(this.$t('commons.please_save'))
return;
}
let newEnvironment = {};
Object.assign(newEnvironment, environment);
newEnvironment.id = null;
newEnvironment.name = this.getNoRepeatName(newEnvironment.name);
if (!this.validateEnvironment(newEnvironment)) {
return;
}
this.$refs.environmentEdit._save(newEnvironment);
this.environments.push(newEnvironment);
this.$refs.environmentItems.itemSelected(this.environments.length -1 , newEnvironment);
},
validateEnvironment(environment) {
if (!environment.name || !!environment.name && environment.name.length > 64) {
this.$error(this.$t('commons.input_limit', [1, 64]));
return false;
}
if (!this.$refs.environmentEdit.validateSocket(environment.socket)) {
this.$error(this.$t('commons.formatErr'));
return false;
}
return true;
},
getNoRepeatName(name) {
for (let i in this.environments) {
if (this.environments[i].name === name) {
@ -97,14 +115,13 @@
}
},
getEnvironment(environment) {
let item = environment;
if (!(environment.variables instanceof Array)) {
item.variables = JSON.parse(environment.variables);
environment.variables = JSON.parse(environment.variables);
}
if (!(environment.headers instanceof Array)) {
item.headers = JSON.parse(environment.headers);
environment.headers = JSON.parse(environment.headers);
}
this.currentEnvironment = item;
this.currentEnvironment = environment;
},
getDefaultEnvironment() {
return {variables: [{}], headers: [{}], protocol: 'https', projectId: this.projectId};

View File

@ -100,8 +100,12 @@
buildParam(environment) {
let param = {};
Object.assign(param, environment);
if (!(environment.variables instanceof String)) {
param.variables = JSON.stringify(environment.variables);
}
if (!(environment.headers instanceof String)) {
param.headers = JSON.stringify(environment.headers);
}
return param;
},
validateSocket(socket) {

View File

@ -47,20 +47,21 @@
<el-divider direction="vertical"/>
</el-col>
<el-col :span="12">
<el-form-item prop="file" class="api-upload">
<el-upload
class="api-upload"
drag
action=""
:http-request="upload"
:limit="1"
:beforeUpload="uploadValidate"
:on-remove="handleRemove"
:file-list="fileList"
:on-exceed="handleExceed"
multiple>
<i class="el-icon-upload"></i>
<div class="el-upload__text" v-html="$t('load_test.upload_tips')"></div>
<div class="el-upload__tip" slot="tip">{{$t('api_test.api_import.file_size_limit')}}</div>
</el-upload>
</el-form-item>
</el-col>
</el-row>
</el-form>
@ -133,15 +134,12 @@
],
projectId: [
{required: true, message: this.$t('api_test.select_project'), trigger: 'blur'},
],
file: [
{required: true, message: this.$t('commons.please_upload'), trigger: 'blur'},
],
]
},
fileList: []
}
},
created() {
activated() {
this.selectedPlatform = this.platforms[0];
this.getProjects();
},
@ -164,7 +162,12 @@
},
upload(file) {
this.formData.file = file.file;
this.fileList.push(file.file);
},
handleExceed(files, fileList) {
this.$warning(this.$t('test_track.case.import.upload_limit_count'));
},
handleRemove(file, fileList) {
this.formData.file = undefined;
},
uploadValidate(file, fileList) {
let suffix = file.name.substring(file.name.lastIndexOf('.') + 1);
@ -208,6 +211,10 @@
Object.assign(param, this.formData);
param.platform = this.selectedPlatformValue;
param.useEnvironment = this.useEnvironment;
if (!this.formData.file) {
this.$warning(this.$t('commons.please_upload'));
return ;
}
this.result = this.$fileUpload('/api/import', param.file, param,response => {
let res = response.data;
this.$success(this.$t('test_track.case.import.success'));
@ -240,7 +247,15 @@
.api-upload {
text-align: center;
display: inline-block;
margin: auto 0;
}
.api-upload >>> .el-upload {
width: 100%;
}
.api-upload >>> .el-upload-dragger {
width: 100%;
}
.el-radio-group {
@ -288,7 +303,7 @@
}
.name-input {
width: 195px;
max-width: 195px;
}
.dialog-footer {

View File

@ -10,7 +10,7 @@
<crontab-result v-show="false" :ex="schedule.value" ref="crontabResult" @resultListChange="resultListChange"/>
</div>
<div>
<span :class="{'disable-character': !schedule.enable}"> {{$t('schedule.next_execution_time')}}{{this.recentList.length > 0 ? this.recentList[0] : $t('schedule.not_set')}} </span>
<span :class="{'disable-character': !schedule.enable}"> {{$t('schedule.next_execution_time')}}{{this.recentList.length > 0 && schedule.enable ? this.recentList[0] : $t('schedule.not_set')}} </span>
</div>
</div>
</template>

View File

@ -1,5 +1,5 @@
<template>
<el-dialog width="30%" class="schedule-edit" :title="$t('schedule.edit_timer_task')" :visible.sync="dialogVisible" @close="close">
<el-dialog width="35%" class="schedule-edit" :title="$t('schedule.edit_timer_task')" :visible.sync="dialogVisible" @close="close">
<div id="app">
<el-form :model="form" :rules="rules" ref="from">
<el-form-item
@ -47,7 +47,9 @@
data() {
const validateCron = (rule, cronValue, callback) => {
let customValidate = this.customValidate(this.getIntervalTime());
if (!cronValidate(cronValue)) {
if (!cronValue) {
callback(new Error(this.$t('commons.input_content')));
} else if (!cronValidate(cronValue)) {
callback(new Error(this.$t('schedule.cron_expression_format_error')));
} else if(!this.intervalShortValidate()) {
callback(new Error(this.$t('schedule.cron_expression_interval_short_error')));

View File

@ -126,8 +126,8 @@
importAPITest() {
let apiTest = this.$store.state.api.test;
if (apiTest && apiTest.name) {
this.testPlan.projectId = apiTest.projectId;
this.testPlan.name = apiTest.name;
this.$set(this.testPlan, "projectId", apiTest.projectId);
this.$set(this.testPlan, "name", apiTest.name);
let blob = new Blob([apiTest.jmx.xml], {type: "application/octet-stream"});
let file = new File([blob], apiTest.jmx.name);
this.$refs.basicConfig.beforeUpload(file);
@ -274,7 +274,7 @@
},
checkScheduleEdit() {
if (!this.testPlan.id) {
this.$message('请先保存测试');
this.$message(this.$t('api_test.environment.please_save_test'));
return false;
}
return true;
@ -284,7 +284,7 @@
if (intervalTime < duration) {
return {
pass: false,
info: '间隔时间不能小于压测时长'
info: this.$t('load_test.schedule_tip')
}
}
return {

View File

@ -112,7 +112,7 @@
components: {MsTableOperatorButton},
data() {
return {
timeout: 100,
timeout: 2000,
statusCode: [],
domains: [],
params: [],

View File

@ -103,7 +103,7 @@
}
},
runTest() {
this.result = this.$post(this.runPath, {id: this.test.id}, (response) => {
this.result = this.$post(this.runPath, {id: this.test.id, triggerMode: 'MANUAL'}, (response) => {
this.$success(this.$t('load_test.is_running'));
this.$emit('runTest', response.data);
});

View File

@ -102,6 +102,7 @@ export default {
login_username: 'ID or email',
input_login_username: 'Please input the user ID or email',
input_name: 'Please enter name',
please_save: 'Please save first',
formatErr: 'Format Error',
id: 'ID',
please_upload: 'Please upload file',
@ -319,7 +320,8 @@ export default {
download_log_file: 'Download',
user_name: 'Creator',
special_characters_are_not_supported: 'Test name does not support special characters',
pressure_config_params_is_empty: 'Pressure configuration parameters cannot be empty!'
pressure_config_params_is_empty: 'Pressure configuration parameters cannot be empty!',
schedule_tip: 'The interval must not be less than the pressure measuring time'
},
api_test: {
creator: "Creator",

View File

@ -104,6 +104,7 @@ export default {
input_name: '请输入名称',
please_upload: '请上传文件',
formatErr: '格式错误',
please_save: '请先保存',
id: 'ID',
date: {
select_date: '选择日期',
@ -318,7 +319,8 @@ export default {
pressure_prediction_chart: '压力预估图',
user_name: '创建人',
special_characters_are_not_supported: '测试名称不支持特殊字符',
pressure_config_params_is_empty: '压力配置参数不能为空!'
pressure_config_params_is_empty: '压力配置参数不能为空!',
schedule_tip: '间隔时间不能小于压测时长'
},
api_test: {
creator: "创建人",

View File

@ -101,6 +101,7 @@ export default {
delete_confirm: '請輸入以下內容,確認刪除:',
input_name: '請輸入名稱',
formatErr: '格式錯誤',
please_save: '請先保存',
id: 'ID',
please_upload: '請上傳文件',
date: {
@ -317,7 +318,8 @@ export default {
pressure_prediction_chart: '壓力預估圖',
user_name: '創建人',
special_characters_are_not_supported: '測試名稱不支持特殊字符',
pressure_config_params_is_empty: '壓力配置參數不能為空!'
pressure_config_params_is_empty: '壓力配置參數不能為空!',
schedule_tip: '間隔時間不能小於壓測時長'
},
api_test: {
creator: "創建人",