refactor(性能测试): 性能测试报告页面提供下载zip的入口
This commit is contained in:
parent
5f84fc8fb8
commit
5177e0a69c
|
@ -44,9 +44,10 @@ public class JmeterFileController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("download")
|
@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("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();
|
double[] ratios = Arrays.stream(ratio.split(",")).mapToDouble(Double::parseDouble).toArray();
|
||||||
byte[] bytes = jmeterFileService.downloadZip(reportId, ratios, resourceIndex);
|
byte[] bytes = jmeterFileService.downloadZip(reportId, ratios, resourceIndex);
|
||||||
return ResponseEntity.ok()
|
return ResponseEntity.ok()
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
<el-button type="warning" plain size="mini" @click="downloadJtl()">
|
<el-button type="warning" plain size="mini" @click="downloadJtl()">
|
||||||
{{ $t('report.downloadJtl') }}
|
{{ $t('report.downloadJtl') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button type="default" plain size="mini" @click="downloadZipFile()">
|
||||||
|
{{ $t('report.downloadZipFile') }}
|
||||||
|
</el-button>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6">
|
<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() {
|
compareReports() {
|
||||||
this.$refs.compareReports.open(this.report);
|
this.$refs.compareReports.open(this.report);
|
||||||
},
|
},
|
||||||
|
|
|
@ -646,6 +646,7 @@ export default {
|
||||||
test_rerun_confirm: 'Are you sure you want to rerun the current test immediately?',
|
test_rerun_confirm: 'Are you sure you want to rerun the current test immediately?',
|
||||||
test_stop_success: 'Test stop successfully',
|
test_stop_success: 'Test stop successfully',
|
||||||
downloadJtl: 'Download JTL',
|
downloadJtl: 'Download JTL',
|
||||||
|
downloadZipFile: 'Download executable file',
|
||||||
test_execute_again: 'Test Execute Again',
|
test_execute_again: 'Test Execute Again',
|
||||||
export: 'Export',
|
export: 'Export',
|
||||||
export_to_ms_format: 'Export to MeterSphere format',
|
export_to_ms_format: 'Export to MeterSphere format',
|
||||||
|
|
|
@ -651,6 +651,7 @@ export default {
|
||||||
test_stop_success: '停止成功',
|
test_stop_success: '停止成功',
|
||||||
test_execute_again: '再次执行',
|
test_execute_again: '再次执行',
|
||||||
downloadJtl: '下载JTL',
|
downloadJtl: '下载JTL',
|
||||||
|
downloadZipFile: '下载执行文件',
|
||||||
export: '导出',
|
export: '导出',
|
||||||
export_to_ms_format: '导出 MeterSphere 格式',
|
export_to_ms_format: '导出 MeterSphere 格式',
|
||||||
export_to_swagger3_format: '导出 Swagger3.0 格式',
|
export_to_swagger3_format: '导出 Swagger3.0 格式',
|
||||||
|
|
|
@ -651,6 +651,7 @@ export default {
|
||||||
test_stop_success: '停止成功',
|
test_stop_success: '停止成功',
|
||||||
test_execute_again: '再次執行',
|
test_execute_again: '再次執行',
|
||||||
downloadJtl: '下載JTL',
|
downloadJtl: '下載JTL',
|
||||||
|
downloadZipFile: '下載執行文件',
|
||||||
export: '導出',
|
export: '導出',
|
||||||
export_to_ms_format: '導出 MeterSphere 格式',
|
export_to_ms_format: '導出 MeterSphere 格式',
|
||||||
export_to_swagger3_format: '導出 Swagger3.0 格式',
|
export_to_swagger3_format: '導出 Swagger3.0 格式',
|
||||||
|
|
Loading…
Reference in New Issue