This commit is contained in:
chenjianxing 2020-04-26 10:40:45 +08:00
commit d02edcb1b3
17 changed files with 49 additions and 231 deletions

View File

@ -133,12 +133,6 @@
<artifactId>opencsv</artifactId> <artifactId>opencsv</artifactId>
<version>5.1</version> <version>5.1</version>
</dependency> </dependency>
<!-- jmeter -->
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_core</artifactId>
<version>${jmeter.version}</version>
</dependency>
<!-- easyexcel --> <!-- easyexcel -->
<dependency> <dependency>

View File

@ -1,44 +0,0 @@
package io.metersphere.commons.utils;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.util.JOrphanUtils;
import java.io.InputStream;
import java.util.Properties;
public class MsJMeterUtils {
/**
* Load the JMeter properties file; if not found, then
* default to "org/apache/jmeter/jmeter.properties" from the classpath
*
* <p>
* c.f. loadProperties
*
* @param file Name of the file from which the JMeter properties should be loaded
*/
public static void loadJMeterProperties(String file) {
InputStream is = null;
try {
JMeterUtils.loadJMeterProperties(file);
} catch (Exception e) {
try {
Properties p = new Properties(System.getProperties());
// In jar file classpath is
is = ClassLoader.getSystemResourceAsStream(
"BOOT-INF/classes/org/apache/jmeter/jmeter.properties"); // $NON-NLS-1$
if (is == null) {
throw new RuntimeException("Could not read JMeter properties file:" + file);
}
p.load(is);
FieldUtils.writeStaticField(JMeterUtils.class, "appProperties", p, true);
} catch (Exception ex) {
throw new RuntimeException("Could not read JMeter properties file:" + file);
}
} finally {
JOrphanUtils.closeQuietly(is);
}
}
}

View File

@ -132,17 +132,11 @@
this.status = data.status; this.status = data.status;
switch (data.status) { switch (data.status) {
case 'Error': case 'Error':
this.$message({ this.$warning("报告生成错误,无法查看!");
type: 'warning',
message: "报告生成错误,无法查看!"
});
break; break;
case 'Starting': case 'Starting':
case 'Reporting': case 'Reporting':
this.$message({ this.$info("报告生成中....");
type: 'info',
message: "报告生成中...."
});
break; break;
case 'Running': case 'Running':
this.showTestLogging = true; this.showTestLogging = true;

View File

@ -136,16 +136,10 @@
}, },
handleEdit(report) { handleEdit(report) {
if (report.status === "Error") { if (report.status === "Error") {
this.$message({ this.$warning("报告生成错误,无法查看!");
type: 'warning',
message: "报告生成错误,无法查看!"
});
return false return false
} else if (report.status === "Starting") { } else if (report.status === "Starting") {
this.$message({ this.$info("报告生成中...")
type: 'info',
message: "报告生成中..."
});
return false return false
} }
this.$router.push({ this.$router.push({
@ -164,10 +158,7 @@
}, },
_handleDelete(report) { _handleDelete(report) {
this.result = this.$post(this.deletePath + report.id, {}, () => { this.result = this.$post(this.deletePath + report.id, {}, () => {
this.$message({ this.$success(this.$t('commons.delete_success'));
message: this.$t('commons.delete_success'),
type: 'success'
});
this.initTableData(); this.initTableData();
}); });
}, },

View File

@ -125,10 +125,7 @@
let options = this.getSaveOption(); let options = this.getSaveOption();
this.result = this.$request(options, () => { this.result = this.$request(options, () => {
this.$message({ this.$success(this.$t('commons.save_success'));
message: this.$t('commons.save_success'),
type: 'success'
});
this.$refs.advancedConfig.cancelAllEdit(); this.$refs.advancedConfig.cancelAllEdit();
this.$router.push({path: '/performance/test/all'}) this.$router.push({path: '/performance/test/all'})
}); });
@ -142,16 +139,9 @@
this.result = this.$request(options, (response) => { this.result = this.$request(options, (response) => {
this.testPlan.id = response.data; this.testPlan.id = response.data;
this.$message({ this.$success(this.$t('commons.save_success'));
message: this.$t('commons.save_success'),
type: 'success'
});
this.result = this.$post(this.runPath, {id: this.testPlan.id}, () => { this.result = this.$post(this.runPath, {id: this.testPlan.id}, () => {
this.$message({ this.$success(this.$t('load_test.is_running'))
message: this.$t('load_test.is_running'),
type: 'success'
});
this.$router.push({path: '/performance/report/all'}) this.$router.push({path: '/performance/report/all'})
}) })
}); });
@ -196,20 +186,12 @@
}, },
validTestPlan() { validTestPlan() {
if (!this.testPlan.name) { if (!this.testPlan.name) {
this.$message({ this.$error(this.$t('load_test.test_name_is_null'));
message: this.$t('load_test.test_name_is_null'),
type: 'error'
});
return false; return false;
} }
if (!this.testPlan.projectId) { if (!this.testPlan.projectId) {
this.$message({ this.$error(this.$t('load_test.project_is_null'));
message: this.$t('load_test.project_is_null'),
type: 'error'
});
return false; return false;
} }

View File

@ -167,10 +167,7 @@
}; };
this.result = this.$post(this.deletePath, data, () => { this.result = this.$post(this.deletePath, data, () => {
this.$message({ this.$success(this.$t('commons.delete_success'));
message: this.$t('commons.delete_success'),
type: 'success'
});
this.initTableData(); this.initTableData();
}); });
}, },

View File

@ -306,23 +306,23 @@
let counts = this.groupBy(this.domains, 'domain'); let counts = this.groupBy(this.domains, 'domain');
for (let c in counts) { for (let c in counts) {
if (counts[c] > 1) { if (counts[c] > 1) {
this.$message.error(this.$t('load_test.domain_is_duplicate')); this.$error(this.$t('load_test.domain_is_duplicate'));
return false; return false;
} }
} }
counts = this.groupBy(this.params, 'name'); counts = this.groupBy(this.params, 'name');
for (let c in counts) { for (let c in counts) {
if (counts[c] > 1) { if (counts[c] > 1) {
this.$message.error(this.$t('load_test.param_is_duplicate')); this.$error(this.$t('load_test.param_is_duplicate'));
return false; return false;
} }
} }
if (this.domains.filter(d => !d.domain || !d.ip).length > 0) { if (this.domains.filter(d => !d.domain || !d.ip).length > 0) {
this.$message.error(this.$t('load_test.domain_ip_is_empty')); this.$error(this.$t('load_test.domain_ip_is_empty'));
return false; return false;
} }
if (this.params.filter(d => !d.name || !d.value).length > 0) { if (this.params.filter(d => !d.name || !d.value).length > 0) {
this.$message.error(this.$t('load_test.param_name_value_is_empty')); this.$error(this.$t('load_test.param_name_value_is_empty'));
return false; return false;
} }
return true; return true;

View File

@ -107,7 +107,7 @@
} }
if (this.tableData.filter(f => f.name === file.name).length > 0) { if (this.tableData.filter(f => f.name === file.name).length > 0) {
this.$message.error(this.$t('load_test.delete_file')); this.$error(this.$t('load_test.delete_file'));
return false; return false;
} }
@ -175,7 +175,7 @@
} }
}, },
handleExceed() { handleExceed() {
this.$message.error(this.$t('load_test.delete_file')); this.$error(this.$t('load_test.delete_file'));
}, },
fileValidator(file) { fileValidator(file) {
/// todo: /// todo:
@ -193,10 +193,7 @@
oldJmxNum = this.fileList.filter(f => f.name.toLowerCase().endsWith(".jmx")).length; oldJmxNum = this.fileList.filter(f => f.name.toLowerCase().endsWith(".jmx")).length;
} }
if (newJmxNum + oldJmxNum !== 1) { if (newJmxNum + oldJmxNum !== 1) {
this.$message({ this.$error(this.$t('load_test.jmx_is_null'));
message: this.$t('load_test.jmx_is_null'),
type: 'error'
});
return false; return false;
} }
return true; return true;

View File

@ -281,10 +281,7 @@
}, },
validConfig() { validConfig() {
if (!this.resourcePool) { if (!this.resourcePool) {
this.$message({ this.$warning(this.$t('load_test.resource_pool_is_null'));
message: this.$t('load_test.resource_pool_is_null'),
type: 'warning'
});
return false; return false;
} }

View File

@ -107,10 +107,7 @@
create() { create() {
let workspaceId = this.currentUser.lastWorkspaceId; let workspaceId = this.currentUser.lastWorkspaceId;
if (!workspaceId) { if (!workspaceId) {
this.$message({ this.$warning(this.$t('project.please_choose_workspace'));
type: 'warning',
message: this.$t('project.please_choose_workspace')
})
return false; return false;
} }
this.title = this.$t('project.create'); this.title = this.$t('project.create');

View File

@ -189,10 +189,7 @@
organizationId: this.currentUser().lastOrganizationId organizationId: this.currentUser().lastOrganizationId
} }
this.result = this.$post("/organization/member/update", param, () => { this.result = this.$post("/organization/member/update", param, () => {
this.$message({ this.$success(this.$t('commons.modify_success'));
type: 'success',
message: this.$t('commons.modify_success')
});
this.updateVisible = false; this.updateVisible = false;
this.initTableData(); this.initTableData();
}); });
@ -204,26 +201,17 @@
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.result = this.$get('/user/org/member/delete/' + this.currentUser().lastOrganizationId + '/' + row.id, () => { this.result = this.$get('/user/org/member/delete/' + this.currentUser().lastOrganizationId + '/' + row.id, () => {
this.$message({ this.$success(this.$t('commons.delete_success'));
type: 'success',
message: this.$t('commons.delete_success')
});
this.initTableData(); this.initTableData();
}); });
}).catch(() => { }).catch(() => {
this.$message({ this.$info(this.$t('commons.delete_cancel'))
type: 'info',
message: this.$t('commons.delete_cancel')
});
}); });
}, },
create() { create() {
let orgId = this.currentUser().lastOrganizationId; let orgId = this.currentUser().lastOrganizationId;
if (!orgId) { if (!orgId) {
this.$message({ this.$warning(this.$t('organization.select_organization'));
type: 'warning',
message: this.$t('organization.select_organization')
})
return false; return false;
} }
this.form = {}; this.form = {};

View File

@ -345,17 +345,11 @@
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.result = this.$get('/user/ws/member/delete/' + this.currentWorkspaceRow.id + '/' + row.id, () => { this.result = this.$get('/user/ws/member/delete/' + this.currentWorkspaceRow.id + '/' + row.id, () => {
this.$message({ this.$success(this.$t('commons.delete_success'));
type: 'success',
message: this.$t('commons.delete_success')
});
this.cellClick(this.currentWorkspaceRow); this.cellClick(this.currentWorkspaceRow);
}); });
}).catch(() => { }).catch(() => {
this.$message({ this.$info(this.$t('commons.delete_cancel'));
type: 'info',
message: this.$t('commons.delete_cancel')
});
}); });
}, },
updateOrgMember() { updateOrgMember() {
@ -368,10 +362,7 @@
workspaceId: this.currentWorkspaceRow.id workspaceId: this.currentWorkspaceRow.id
} }
this.result = this.$post("/workspace/member/update", param, () => { this.result = this.$post("/workspace/member/update", param, () => {
this.$message({ this.$success(this.$t('commons.modify_success'));
type: 'success',
message: this.$t('commons.modify_success')
});
this.updateMemberVisible = false; this.updateMemberVisible = false;
this.cellClick(this.currentWorkspaceRow); this.cellClick(this.currentWorkspaceRow);
}); });

View File

@ -113,10 +113,7 @@
this.$refs[updateUserForm].validate(valide => { this.$refs[updateUserForm].validate(valide => {
if (valide) { if (valide) {
this.result = this.$post(this.updatePath, this.form,response => { this.result = this.$post(this.updatePath, this.form,response => {
this.$message({ this.$success(this.$t('commons.modify_success'));
type: 'success',
message: this.$t('commons.modify_success')
});
localStorage.setItem(TokenKey, JSON.stringify(response.data)); localStorage.setItem(TokenKey, JSON.stringify(response.data));
this.updateVisible = false; this.updateVisible = false;
this.initTableData(); this.initTableData();

View File

@ -319,17 +319,11 @@
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.result = this.$get(this.deletePath + row.id, () => { this.result = this.$get(this.deletePath + row.id, () => {
this.$message({ this.$success(this.$t('commons.delete_success'));
type: 'success',
message: this.$t('commons.delete_success')
});
this.initTableData() this.initTableData()
}); });
}).catch(() => { }).catch(() => {
this.$message({ this.$info(this.$t('commons.delete_cancel'));
type: 'info',
message: this.$t('commons.delete_cancel')
});
}); });
}, },
delMember(row) { delMember(row) {
@ -339,27 +333,18 @@
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.result = this.$get('/user/special/org/member/delete/' + this.currentRow.id + '/' + row.id, () => { this.result = this.$get('/user/special/org/member/delete/' + this.currentRow.id + '/' + row.id, () => {
this.$message({ this.$success(this.$t('commons.delete_success'))
type: 'success',
message: this.$t('commons.delete_success')
});
this.cellClick(this.currentRow); this.cellClick(this.currentRow);
}); });
}).catch(() => { }).catch(() => {
this.$message({ this.$info(this.$t('commons.delete_cancel'));
type: 'info',
message: this.$t('commons.delete_cancel')
});
}); });
}, },
createOrganization(createOrganizationForm) { createOrganization(createOrganizationForm) {
this.$refs[createOrganizationForm].validate(valide => { this.$refs[createOrganizationForm].validate(valide => {
if (valide) { if (valide) {
this.result = this.$post(this.createPath, this.form, () => { this.result = this.$post(this.createPath, this.form, () => {
this.$message({ this.$success(this.$t('commons.save_success'));
type: 'success',
message: this.$t('commons.save_success')
});
this.initTableData(); this.initTableData();
this.createVisible = false; this.createVisible = false;
}); });
@ -372,10 +357,7 @@
this.$refs[udpateOrganizationForm].validate(valide => { this.$refs[udpateOrganizationForm].validate(valide => {
if (valide) { if (valide) {
this.result = this.$post(this.updatePath, this.form, () => { this.result = this.$post(this.updatePath, this.form, () => {
this.$message({ this.$success(this.$t('commons.modify_success'))
type: 'success',
message: this.$t('commons.modify_success')
});
this.updateVisible = false; this.updateVisible = false;
this.initTableData(); this.initTableData();
}); });
@ -442,10 +424,7 @@
organizationId: this.currentRow.id organizationId: this.currentRow.id
} }
this.result = this.$post("/organization/member/update", param, () => { this.result = this.$post("/organization/member/update", param, () => {
this.$message({ this.$success(this.$t('commons.modify_success'))
type: 'success',
message: this.$t('commons.modify_success')
});
this.updateMemberVisible = false; this.updateMemberVisible = false;
this.cellClick(this.currentRow); this.cellClick(this.currentRow);
}); });

View File

@ -296,10 +296,7 @@
this.$refs[updateForm].validate(valide => { this.$refs[updateForm].validate(valide => {
if (valide) { if (valide) {
this.result = this.$post("/workspace/special/update", this.form, () => { this.result = this.$post("/workspace/special/update", this.form, () => {
this.$message({ this.$success(this.$t('commons.modify_success'));
type: 'success',
message: this.$t('commons.modify_success')
});
this.updateVisible = false; this.updateVisible = false;
this.list(); this.list();
}); });
@ -388,17 +385,11 @@
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.result = this.$get('/user/special/ws/member/delete/' + this.currentWorkspaceRow.id + '/' + row.id, () => { this.result = this.$get('/user/special/ws/member/delete/' + this.currentWorkspaceRow.id + '/' + row.id, () => {
this.$message({ this.$success(this.$t('commons.delete_success'));
type: 'success',
message: this.$t('commons.delete_success')
});
this.cellClick(this.currentWorkspaceRow); this.cellClick(this.currentWorkspaceRow);
}); });
}).catch(() => { }).catch(() => {
this.$message({ this.$info(this.$t('commons.delete_cancel'));
type: 'info',
message: this.$t('commons.delete_cancel')
});
}); });
}, },
updateOrgMember() { updateOrgMember() {
@ -411,10 +402,7 @@
workspaceId: this.currentWorkspaceRow.id workspaceId: this.currentWorkspaceRow.id
} }
this.result = this.$post("/workspace/member/update", param, () => { this.result = this.$post("/workspace/member/update", param, () => {
this.$message({ this.$success(this.$t('commons.modify_success'));
type: 'success',
message: this.$t('commons.modify_success')
});
this.updateMemberVisible = false; this.updateMemberVisible = false;
this.cellClick(this.currentWorkspaceRow); this.cellClick(this.currentWorkspaceRow);
}); });

View File

@ -280,10 +280,7 @@
if (this.infoList.length > 1) { if (this.infoList.length > 1) {
this.infoList.splice(index, 1) this.infoList.splice(index, 1)
} else { } else {
this.$message({ this.$warning(this.$t('test_resource_pool.cannot_remove_all_node'))
type: 'warning',
message: this.$t('test_resource_pool.cannot_remove_all_node')
});
} }
}, },
validateResourceInfo() { validateResourceInfo() {
@ -341,15 +338,9 @@
this.result = this.$get(`/testresourcepool/delete/${row.id}`).then(() => { this.result = this.$get(`/testresourcepool/delete/${row.id}`).then(() => {
this.initTableData(); this.initTableData();
}); });
this.$message({ this.$success(this.$t('commons.delete_success'));
type: 'success',
message: this.$t('commons.delete_success')
});
}).catch(() => { }).catch(() => {
this.$message({ this.$info(this.$t('commons.delete_cancel'));
type: 'info',
message: this.$t('commons.delete_cancel')
});
}); });
}, },
createTestResourcePool(createTestResourcePoolForm) { createTestResourcePool(createTestResourcePoolForm) {
@ -370,10 +361,7 @@
this.initTableData()); this.initTableData());
}); });
} else { } else {
this.$message({ this.$warning(vri.msg);
type: 'warning',
message: vri.msg
});
return false; return false;
} }
@ -413,10 +401,7 @@
self.loading = false); self.loading = false);
}); });
} else { } else {
this.$message({ this.$warning(vri.msg);
type: 'warning',
message: vri.msg
});
return false; return false;
} }
} else { } else {
@ -429,10 +414,7 @@
}, },
changeSwitch(row) { changeSwitch(row) {
this.result = this.$post('/testresourcepool/update', row).then(() => { this.result = this.$post('/testresourcepool/update', row).then(() => {
this.$message({ this.$success(this.$t('test_resource_pool.status_change_success'));
type: 'success',
message: this.$t('test_resource_pool.status_change_success')
});
}) })
} }
} }

View File

@ -185,16 +185,10 @@
this.initTableData(); this.initTableData();
this.loading = false; this.loading = false;
}); });
this.$message({ this.$success(this.$t('commons.delete_success'));
type: 'success',
message: this.$t('commons.delete_success')
});
}).catch(() => { }).catch(() => {
this.loading = false; this.loading = false;
this.$message({ this.$info(this.$t('commons.delete_cancel'));
type: 'info',
message: this.$t('commons.delete_cancel')
});
}); });
}, },
edit(row) { edit(row) {
@ -217,10 +211,7 @@
workspaceId: this.currentUser().lastWorkspaceId workspaceId: this.currentUser().lastWorkspaceId
} }
this.result = this.$post("/workspace/member/update", param, () => { this.result = this.$post("/workspace/member/update", param, () => {
this.$message({ this.$success(this.$t('commons.modify_success'));
type: 'success',
message: this.$t('commons.modify_success')
});
this.updateVisible = false; this.updateVisible = false;
this.initTableData(); this.initTableData();
}); });
@ -233,10 +224,7 @@
}; };
let wsId = this.currentUser().lastWorkspaceId; let wsId = this.currentUser().lastWorkspaceId;
if (typeof wsId == "undefined" || wsId == null || wsId == "") { if (typeof wsId == "undefined" || wsId == null || wsId == "") {
this.$message({ this.$warning("请先选择工作空间!");
message: '请先选择工作空间!',
type: 'warning'
});
return false; return false;
} }
this.$post('/user/org/member/list/all', param, response => { this.$post('/user/org/member/list/all', param, response => {