refactor(性能测试): 性能测试报告页面提供下载zip的入口
This commit is contained in:
parent
5f84fc8fb8
commit
5177e0a69c
|
@ -44,9 +44,10 @@ public class JmeterFileController {
|
|||
}
|
||||
|
||||
@GetMapping("download")
|
||||
public ResponseEntity<byte[]> downloadJmeterFiles(@RequestParam("testId") String testId, @RequestParam("resourceId") String resourceId,
|
||||
public ResponseEntity<byte[]> downloadJmeterFiles(@RequestParam("testId") String testId,
|
||||
@RequestParam("ratio") String ratio,
|
||||
@RequestParam("reportId") String reportId, @RequestParam("resourceIndex") int resourceIndex) {
|
||||
@RequestParam("reportId") String reportId,
|
||||
@RequestParam("resourceIndex") int resourceIndex) {
|
||||
double[] ratios = Arrays.stream(ratio.split(",")).mapToDouble(Double::parseDouble).toArray();
|
||||
byte[] bytes = jmeterFileService.downloadZip(reportId, ratios, resourceIndex);
|
||||
return ResponseEntity.ok()
|
||||
|
|
|
@ -38,6 +38,9 @@
|
|||
<el-button type="warning" plain size="mini" @click="downloadJtl()">
|
||||
{{ $t('report.downloadJtl') }}
|
||||
</el-button>
|
||||
<el-button type="default" plain size="mini" @click="downloadZipFile()">
|
||||
{{ $t('report.downloadZipFile') }}
|
||||
</el-button>
|
||||
</el-row>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
|
@ -375,6 +378,33 @@ export default {
|
|||
});
|
||||
});
|
||||
},
|
||||
downloadZipFile() {
|
||||
let testId = this.report.testId;
|
||||
let reportId = this.report.id;
|
||||
let resourceIndex = 0;
|
||||
let ratio = "1.0";
|
||||
let config = {
|
||||
url: `/jmeter/download?testId=${testId}&ratio=${ratio}&reportId=${reportId}&resourceIndex=${resourceIndex}`,
|
||||
method: 'get',
|
||||
responseType: 'blob'
|
||||
};
|
||||
this.result = this.$request(config).then(response => {
|
||||
const filename = testId + ".zip";
|
||||
const blob = new Blob([response.data]);
|
||||
if ("download" in document.createElement("a")) {
|
||||
// 非IE下载
|
||||
// chrome/firefox
|
||||
let aTag = document.createElement('a');
|
||||
aTag.download = filename;
|
||||
aTag.href = URL.createObjectURL(blob);
|
||||
aTag.click();
|
||||
URL.revokeObjectURL(aTag.href);
|
||||
} else {
|
||||
// IE10+下载
|
||||
navigator.msSaveBlob(blob, filename);
|
||||
}
|
||||
});
|
||||
},
|
||||
compareReports() {
|
||||
this.$refs.compareReports.open(this.report);
|
||||
},
|
||||
|
|
|
@ -172,8 +172,8 @@ export default {
|
|||
notice_center: "Notice center",
|
||||
notice_count: 'Messages',
|
||||
notice_tips: 'Only display the news within the last 3 months',
|
||||
system_notice:'System',
|
||||
mentioned_me_notice:'@Mentioned Me',
|
||||
system_notice: 'System',
|
||||
mentioned_me_notice: '@Mentioned Me',
|
||||
all_module_title: "All module",
|
||||
create_user: 'Creator',
|
||||
run_message: "The task is being executed, please go to the task center to view the details",
|
||||
|
@ -646,6 +646,7 @@ export default {
|
|||
test_rerun_confirm: 'Are you sure you want to rerun the current test immediately?',
|
||||
test_stop_success: 'Test stop successfully',
|
||||
downloadJtl: 'Download JTL',
|
||||
downloadZipFile: 'Download executable file',
|
||||
test_execute_again: 'Test Execute Again',
|
||||
export: 'Export',
|
||||
export_to_ms_format: 'Export to MeterSphere format',
|
||||
|
|
|
@ -651,6 +651,7 @@ export default {
|
|||
test_stop_success: '停止成功',
|
||||
test_execute_again: '再次执行',
|
||||
downloadJtl: '下载JTL',
|
||||
downloadZipFile: '下载执行文件',
|
||||
export: '导出',
|
||||
export_to_ms_format: '导出 MeterSphere 格式',
|
||||
export_to_swagger3_format: '导出 Swagger3.0 格式',
|
||||
|
|
|
@ -651,6 +651,7 @@ export default {
|
|||
test_stop_success: '停止成功',
|
||||
test_execute_again: '再次執行',
|
||||
downloadJtl: '下載JTL',
|
||||
downloadZipFile: '下載執行文件',
|
||||
export: '導出',
|
||||
export_to_ms_format: '導出 MeterSphere 格式',
|
||||
export_to_swagger3_format: '導出 Swagger3.0 格式',
|
||||
|
|
Loading…
Reference in New Issue