From 11979fd663d38dbbb1cb44b13e8c38de3c72fea0 Mon Sep 17 00:00:00 2001 From: q4speed Date: Fri, 29 May 2020 14:57:19 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BB=8E=E6=8E=A5=E5=8F=A3=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=20=E5=88=9B=E5=BB=BA=20=E6=80=A7=E8=83=BD=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/api/test/ApiReportDialog.vue | 57 ++++++++----------- .../components/api/test/ApiTestConfig.vue | 51 ++++++++++++++--- .../test/EditPerformanceTestPlan.vue | 16 ++++++ frontend/src/business/store.js | 23 +++++++- frontend/src/i18n/en-US.js | 1 + frontend/src/i18n/zh-CN.js | 1 + frontend/src/i18n/zh-TW.js | 1 + 7 files changed, 106 insertions(+), 44 deletions(-) diff --git a/frontend/src/business/components/api/test/ApiReportDialog.vue b/frontend/src/business/components/api/test/ApiReportDialog.vue index 59f471f4da..106d37748f 100644 --- a/frontend/src/business/components/api/test/ApiReportDialog.vue +++ b/frontend/src/business/components/api/test/ApiReportDialog.vue @@ -1,32 +1,28 @@ diff --git a/frontend/src/business/components/api/test/ApiTestConfig.vue b/frontend/src/business/components/api/test/ApiTestConfig.vue index e7f0fbfda1..71b3c8b0e1 100644 --- a/frontend/src/business/components/api/test/ApiTestConfig.vue +++ b/frontend/src/business/components/api/test/ApiTestConfig.vue @@ -27,7 +27,19 @@ {{$t('commons.cancel')}} - + + + + + {{$t('api_report.title')}} + + + {{$t('api_test.create_performance_test')}} + + + + + @@ -72,7 +84,7 @@ }, methods: { - init: function () { + init() { this.result = this.$get("/project/listAll", response => { this.projects = response.data; }) @@ -87,7 +99,7 @@ } } }, - getTest: function (id) { + getTest(id) { this.result = this.$get("/api/get/" + id, response => { if (response.data) { let item = response.data; @@ -103,7 +115,7 @@ } }); }, - save: function (callback) { + save(callback) { this.change = false; let url = this.create ? "/api/create" : "/api/update"; this.result = this.$request(this.getOptions(url), () => { @@ -111,7 +123,7 @@ if (callback) callback(); }); }, - saveTest: function () { + saveTest() { this.save(() => { this.$success(this.$t('commons.save_success')); if (this.create) { @@ -121,7 +133,7 @@ } }) }, - runTest: function () { + runTest() { this.result = this.$post("/api/run", {id: this.test.id}, (response) => { this.$success(this.$t('api_test.running')); this.$router.push({ @@ -129,7 +141,7 @@ }) }); }, - saveRunTest: function () { + saveRunTest() { this.change = false; this.save(() => { @@ -137,11 +149,11 @@ this.runTest(); }) }, - cancel: function () { + cancel() { // console.log(this.test.toJMX().xml) this.$router.push('/api/test/list/all'); }, - getOptions: function (url) { + getOptions(url) { let formData = new FormData(); let request = { id: this.test.id, @@ -166,6 +178,23 @@ 'Content-Type': undefined } }; + }, + handleCommand(command) { + switch (command) { + case "report": + this.$refs.reportDialog.open(); + break; + case "performance": + this.$store.commit('setTest', { + projectId: this.test.projectId, + name: this.test.name, + jmx: this.test.toJMX() + }) + this.$router.push({ + path: "/performance/test/create" + }) + break; + } } }, @@ -199,4 +228,8 @@ .test-project { min-width: 150px; } + + .test-container .more { + margin-left: 10px; + } diff --git a/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue b/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue index 4792b4fadd..ec1aead6b7 100644 --- a/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue +++ b/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue @@ -115,7 +115,23 @@ this.listProjects(); }, + mounted() { + this.importAPITest(); + }, methods: { + importAPITest() { + let apiTest = this.$store.state.api.test; + if (apiTest && apiTest.name) { + this.testPlan.projectId = apiTest.projectId; + 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); + this.$refs.basicConfig.handleUpload({file: file}); + this.active = '1'; + this.$store.commit("clearTest"); + } + }, listProjects() { this.result = this.$get(this.listProjectPath, response => { this.projects = response.data; diff --git a/frontend/src/business/store.js b/frontend/src/business/store.js index 4edd8e788b..65b6847806 100644 --- a/frontend/src/business/store.js +++ b/frontend/src/business/store.js @@ -3,7 +3,24 @@ import Vuex from 'vuex' Vue.use(Vuex); +const API = { + state: { + test: {} + }, + mutations: { + setTest(state, test) { + state.test = test; + }, + clearTest(state) { + state.test = {}; + } + }, + actions: {}, + getters: {} +} -export default new Vuex.Store({}) - - +export default new Vuex.Store({ + modules: { + api: API + } +}) diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 4aa8310390..f889188388 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -262,6 +262,7 @@ export default { copied: "copied", key: "Key", value: "Value", + create_performance_test: "Create Performance Test", scenario: { config: "Scenario Config", input_name: "Please enter the scenario name", diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index c0bd508f19..56314f6c4b 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -259,6 +259,7 @@ export default { copied: "已拷贝", key: "键", value: "值", + create_performance_test: "创建性能测试", scenario: { config: "场景配置", input_name: "请输入场景名称", diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 44f50b2114..441c8e03b5 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -260,6 +260,7 @@ export default { copied: "已拷貝", key: "鍵", value: "值", + create_performance_test: "創建性能測試", scenario: { creator: "創建人", config: "場景配寘", From 94724302096d4a1c4274c921a17f6abe19b219e4 Mon Sep 17 00:00:00 2001 From: q4speed Date: Fri, 29 May 2020 15:28:12 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/business/components/api/test/ApiTestConfig.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/business/components/api/test/ApiTestConfig.vue b/frontend/src/business/components/api/test/ApiTestConfig.vue index 71b3c8b0e1..017f4b60d8 100644 --- a/frontend/src/business/components/api/test/ApiTestConfig.vue +++ b/frontend/src/business/components/api/test/ApiTestConfig.vue @@ -30,10 +30,10 @@ - + {{$t('api_report.title')}} - + {{$t('api_test.create_performance_test')}} From 34d2fac553d7d659ac2e8785f8c418239430a5b6 Mon Sep 17 00:00:00 2001 From: q4speed Date: Fri, 29 May 2020 16:29:57 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=A4=8D=E5=88=B6=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/api/test/ApiTestList.vue | 35 ++++++++++++--- .../common/components/MsTableOperators.vue | 43 +++++++++++++++++++ frontend/src/i18n/en-US.js | 1 + frontend/src/i18n/zh-CN.js | 1 + frontend/src/i18n/zh-TW.js | 1 + 5 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 frontend/src/business/components/common/components/MsTableOperators.vue diff --git a/frontend/src/business/components/api/test/ApiTestList.vue b/frontend/src/business/components/api/test/ApiTestList.vue index 2ac0e35862..a549faa9f4 100644 --- a/frontend/src/business/components/api/test/ApiTestList.vue +++ b/frontend/src/business/components/api/test/ApiTestList.vue @@ -3,16 +3,17 @@ - + - +