From f43a4b96783c96572333416af8a37e489c72db1f Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Mon, 2 Mar 2020 13:07:06 +0800 Subject: [PATCH] AdvancedConfig --- frontend/src/i18n/en-US.js | 3 + frontend/src/i18n/zh-CN.js | 3 + .../testPlan/components/AdvancedConfig.vue | 65 ++++++++++++++----- 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index f5849a90d3..f3a8fdb8f1 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -97,6 +97,9 @@ export default { 'param_is_duplicate': 'Parameter name is duplicate', 'domain_ip_is_empty': 'Domain and IP 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: { 'home': 'Home', diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 23772c8559..8801922730 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -97,6 +97,9 @@ export default { 'param_is_duplicate': '参数名不能重复', 'domain_ip_is_empty': '域名和IP不能为空', 'param_name_value_is_empty': '参数名和参数值不能为空', + 'connect_timeout': '建立连接超时时间', + 'custom_http_code': '自定义 HTTP 响应成功状态码', + 'separated_by_commas': '按逗号分隔', }, i18n: { 'home': '首页', diff --git a/frontend/src/performance/components/testPlan/components/AdvancedConfig.vue b/frontend/src/performance/components/testPlan/components/AdvancedConfig.vue index 29ce66cce8..4ccc8589ad 100644 --- a/frontend/src/performance/components/testPlan/components/AdvancedConfig.vue +++ b/frontend/src/performance/components/testPlan/components/AdvancedConfig.vue @@ -170,12 +170,29 @@ - 建立连接超时时间 {{timeout}} ms + + +
{{$t('load_test.connect_timeout')}}
+
+ + + + + ms + +
- 自定义 HTTP 响应成功状态码 {{statusCode}} + + +
{{$t('load_test.custom_http_code')}}
+
+ + + +
@@ -187,25 +204,24 @@ data() { return { timeout: 10, - statusCode: [302], + statusCode: [], domains: [], params: [], + statusCodeStr: '', } }, mounted() { let testId = this.$route.path.split('/')[2]; if (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 || [302]; - this.domains = data.domains || []; - this.params = data.params || []; - this.domains.forEach(d => d.edit = false); - this.params.forEach(d => d.edit = false); - } - }); + this.getAdvancedConfig(testId); + } + }, + watch: { + '$route'(to) { + let testId = to.path.split('/')[2]; + if (testId) { + this.getAdvancedConfig(testId); + } } }, methods: { @@ -224,6 +240,20 @@ 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) { if (dataName === 'domains') { this[dataName].push({ @@ -293,6 +323,11 @@ } return true; }, + checkStatusCode() { + let license_num = this.statusCodeStr; + license_num = license_num.replace(/[^\d,]/g, ''); // 清除“数字”和“.”以外的字符 + this.statusCodeStr = license_num; + }, cancelAllEdit() { this.domains.forEach(d => d.edit = false); this.params.forEach(d => d.edit = false); @@ -302,7 +337,7 @@ this.params.forEach(d => this.delOriginObject(d)); return { timeout: this.timeout, - statusCode: this.statusCode, + statusCode: this.statusCodeStr.split(','), params: this.params, domains: this.domains, }