AdvancedConfig

This commit is contained in:
Captain.B 2020-03-02 13:07:06 +08:00
parent cecebc6fb9
commit f43a4b9678
3 changed files with 56 additions and 15 deletions

View File

@ -97,6 +97,9 @@ export default {
'param_is_duplicate': 'Parameter name is duplicate', 'param_is_duplicate': 'Parameter name is duplicate',
'domain_ip_is_empty': 'Domain and IP cannot be empty', 'domain_ip_is_empty': 'Domain and IP cannot be empty',
'param_name_value_is_empty': 'Parameters cannot be empty', 'param_name_value_is_empty': 'Parameters cannot be empty',
'connect_timeout': 'Timeout to establish a connection',
'custom_http_code': 'Custom HTTP response success status code',
'separated_by_commas': 'Separated by commas',
}, },
i18n: { i18n: {
'home': 'Home', 'home': 'Home',

View File

@ -97,6 +97,9 @@ export default {
'param_is_duplicate': '参数名不能重复', 'param_is_duplicate': '参数名不能重复',
'domain_ip_is_empty': '域名和IP不能为空', 'domain_ip_is_empty': '域名和IP不能为空',
'param_name_value_is_empty': '参数名和参数值不能为空', 'param_name_value_is_empty': '参数名和参数值不能为空',
'connect_timeout': '建立连接超时时间',
'custom_http_code': '自定义 HTTP 响应成功状态码',
'separated_by_commas': '按逗号分隔',
}, },
i18n: { i18n: {
'home': '首页', 'home': '首页',

View File

@ -170,12 +170,29 @@
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
建立连接超时时间 {{timeout}} ms <el-form :inline="true">
<el-form-item>
<div>{{$t('load_test.connect_timeout')}}</div>
</el-form-item>
<el-form-item>
<el-input-number size="mini" v-model="timeout" :min="10" :max="100000"></el-input-number>
</el-form-item>
<el-form-item>
ms
</el-form-item>
</el-form>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
自定义 HTTP 响应成功状态码 {{statusCode}} <el-form :inline="true">
<el-form-item>
<div>{{$t('load_test.custom_http_code')}}</div>
</el-form-item>
<el-form-item>
<el-input size="mini" v-model="statusCodeStr" :placeholder="$t('load_test.separated_by_commas')" @input="checkStatusCode"></el-input>
</el-form-item>
</el-form>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
@ -187,25 +204,24 @@
data() { data() {
return { return {
timeout: 10, timeout: 10,
statusCode: [302], statusCode: [],
domains: [], domains: [],
params: [], params: [],
statusCodeStr: '',
} }
}, },
mounted() { mounted() {
let testId = this.$route.path.split('/')[2]; let testId = this.$route.path.split('/')[2];
if (testId) { if (testId) {
this.$get('/testplan/get-advanced-config/' + testId, (response) => { this.getAdvancedConfig(testId);
if (response.data) { }
let data = JSON.parse(response.data); },
this.timeout = data.timeout || 10; watch: {
this.statusCode = data.statusCode || [302]; '$route'(to) {
this.domains = data.domains || []; let testId = to.path.split('/')[2];
this.params = data.params || []; if (testId) {
this.domains.forEach(d => d.edit = false); this.getAdvancedConfig(testId);
this.params.forEach(d => d.edit = false); }
}
});
} }
}, },
methods: { methods: {
@ -224,6 +240,20 @@
delete row[key + 'Origin']; delete row[key + 'Origin'];
}); });
}, },
getAdvancedConfig(testId) {
this.$get('/testplan/get-advanced-config/' + testId, (response) => {
if (response.data) {
let data = JSON.parse(response.data);
this.timeout = data.timeout || 10;
this.statusCode = data.statusCode || [];
this.statusCodeStr = this.statusCode.join(',');
this.domains = data.domains || [];
this.params = data.params || [];
this.domains.forEach(d => d.edit = false);
this.params.forEach(d => d.edit = false);
}
});
},
add(dataName) { add(dataName) {
if (dataName === 'domains') { if (dataName === 'domains') {
this[dataName].push({ this[dataName].push({
@ -293,6 +323,11 @@
} }
return true; return true;
}, },
checkStatusCode() {
let license_num = this.statusCodeStr;
license_num = license_num.replace(/[^\d,]/g, ''); // .
this.statusCodeStr = license_num;
},
cancelAllEdit() { cancelAllEdit() {
this.domains.forEach(d => d.edit = false); this.domains.forEach(d => d.edit = false);
this.params.forEach(d => d.edit = false); this.params.forEach(d => d.edit = false);
@ -302,7 +337,7 @@
this.params.forEach(d => this.delOriginObject(d)); this.params.forEach(d => this.delOriginObject(d));
return { return {
timeout: this.timeout, timeout: this.timeout,
statusCode: this.statusCode, statusCode: this.statusCodeStr.split(','),
params: this.params, params: this.params,
domains: this.domains, domains: this.domains,
} }