fix(性能测试): 修复性能测试分享报告时没有测试环境的缺陷

--bug=1015013 --user=宋天阳 【性能测试】分享报告报告,没有展示运行环境
https://www.tapd.cn/55049933/s/1205536
This commit is contained in:
song-tianyang 2022-07-20 15:55:34 +08:00 committed by 建国
parent 3e7cf93312
commit 25b6414056
3 changed files with 66 additions and 15 deletions

View File

@ -1,12 +1,11 @@
package io.metersphere.dto;
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ReportDTO extends LoadTestReportWithBLOBs {
public class ReportDTO extends LoadTestReportInfoDTO {
private String content;
private String projectName;

View File

@ -213,7 +213,9 @@ public class PerformanceReportService {
}
public ReportDTO getReportTestAndProInfo(String reportId) {
return extLoadTestReportMapper.getReportTestAndProInfo(reportId);
ReportDTO reportDTO = extLoadTestReportMapper.getReportTestAndProInfo(reportId);
this.parseRunEnvironment(reportDTO);
return reportDTO;
}
private String getContent(String id, ReportKeys reportKey) {

View File

@ -5,20 +5,35 @@
<el-row v-if="isShare">
<el-col :span="24">
<div>
<span class="ms-report-time-desc-share">{{ $t('commons.name') }}{{ report.name }}</span>
<span class="ms-report-time-desc-share">{{ $t('commons.executor') }}{{ report.userName }}</span>
</div>
<div>
<span class="ms-report-time-desc-share">{{ $t('report.test_duration', [minutes, seconds]) }}</span>
<span class="ms-report-time-desc-share" v-if="startTime !== '0'">
<div style="float:left;">
<div>
<span class="ms-report-time-desc-share">{{ $t('commons.name') }}{{ report.name }}</span>
<span class="ms-report-time-desc-share">{{ $t('commons.executor') }}{{ report.userName }}</span>
</div>
<div>
<span class="ms-report-time-desc-share">{{ $t('report.test_duration', [minutes, seconds]) }}</span>
<span class="ms-report-time-desc-share" v-if="startTime !== '0'">
{{ $t('report.test_start_time') }}{{ startTime | timestampFormatDate }}
</span>
<span class="ms-report-time-desc-share" v-else>{{ $t('report.test_start_time') }}-</span>
<span class="ms-report-time-desc-share" v-if="report.status === 'Completed' && endTime !== '0'">
<span class="ms-report-time-desc-share" v-else>{{ $t('report.test_start_time') }}-</span>
<span class="ms-report-time-desc-share" v-if="report.status === 'Completed' && endTime !== '0'">
{{ $t('report.test_end_time') }}{{ endTime | timestampFormatDate }}
</span>
<span class="ms-report-time-desc-share" v-else>{{ $t('report.test_end_time') }}- </span>
<span class="ms-report-time-desc-share" v-else>{{ $t('report.test_end_time') }}- </span>
</div>
</div>
<div style="float: right;margin-right: 10px;">
<div v-if="showProjectEnv" type="flex">
<span> {{ $t('commons.environment') + ':' }} </span>
<div v-for="(values,key) in projectEnvMap" :key="key" style="margin-right: 10px">
{{ key + ":" }}
<ms-tag v-for="(item,index) in values" :key="index" type="success" :content="item"
style="margin-left: 2px"/>
</div>
<div v-show="showMoreProjectEnvMap">
<el-link icon="el-icon-more" @click="showAllProjectInfo"></el-link>
</div>
</div>
</div>
</el-col>
</el-row>
@ -49,8 +64,10 @@
</el-col>
<el-col :span="8">
<span class="ms-report-time-desc">
{{ $t('report.test_duration', [ templateMinutes ? templateMinutes : minutes,
templateSeconds ? templateSeconds : seconds]) }}
{{
$t('report.test_duration', [templateMinutes ? templateMinutes : minutes,
templateSeconds ? templateSeconds : seconds])
}}
</span>
<span class="ms-report-time-desc" v-if="startTime !== '0'">
{{ $t('report.test_start_time') }}{{ startTime | timestampFormatDate }}
@ -123,6 +140,7 @@
</el-button>
</div>
</el-dialog>
<project-environment-dialog ref="projectEnvDialog"></project-environment-dialog>
</el-main>
</ms-container>
</template>
@ -141,6 +159,8 @@ import MsContainer from "@/business/components/common/components/MsContainer";
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
import MonitorCard from "@/business/components/performance/report/components/MonitorCard";
import MsReportTestDetails from '@/business/components/performance/report/components/TestDetails';
import ProjectEnvironmentDialog from "@/business/components/common/dialog/ProjectEnvironmentDialog";
import MsTag from "@/business/components/common/components/MsTag";
import {
getPerformanceReport,
getPerformanceReportTime,
@ -163,6 +183,8 @@ export default {
MsReportTestDetails,
MsContainer,
MsMainContainer,
ProjectEnvironmentDialog,
MsTag,
},
data() {
return {
@ -179,6 +201,9 @@ export default {
minutes: '0',
seconds: '0',
title: 'Logging',
projectEnvMap: null,
showMoreProjectEnvMap: false,
allProjectEnvMap: null,
report: {},
websocket: null,
dialogFormVisible: false,
@ -205,6 +230,9 @@ export default {
}
},
computed: {
showProjectEnv() {
return this.projectEnvMap && JSON.stringify(this.projectEnvMap) !== '{}';
},
templateMinutes() {
if (this.planReportTemplate && this.planReportTemplate.duration) {
let duration = this.planReportTemplate.duration;
@ -221,6 +249,26 @@ export default {
}
},
methods: {
showAllProjectInfo() {
this.$refs.projectEnvDialog.open(this.allProjectEnvMap);
},
isProjectEnvShowMore(projectEnvMap) {
this.showMoreProjectEnvMap = false;
this.projectEnvMap = {};
if (projectEnvMap) {
let keySize = 0;
for (let key in projectEnvMap) {
keySize++;
if (keySize > 1) {
this.showMoreProjectEnvMap = true;
return;
} else {
this.projectEnvMap = {};
this.$set(this.projectEnvMap, key, projectEnvMap[key]);
}
}
}
},
initBreadcrumb(callback) {
if (this.isPlanReport) {
return;
@ -429,6 +477,8 @@ export default {
},
handleInit(data) {
if (data) {
this.allProjectEnvMap = data.projectEnvMap;
this.isProjectEnvShowMore(data.projectEnvMap);
this.status = data.status;
this.$set(this, "report", data);
this.$set(this.test, "testResourcePoolId", data.testResourcePoolId);