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; package io.metersphere.dto;
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@Getter @Getter
@Setter @Setter
public class ReportDTO extends LoadTestReportWithBLOBs { public class ReportDTO extends LoadTestReportInfoDTO {
private String content; private String content;
private String projectName; private String projectName;

View File

@ -213,7 +213,9 @@ public class PerformanceReportService {
} }
public ReportDTO getReportTestAndProInfo(String reportId) { 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) { private String getContent(String id, ReportKeys reportKey) {

View File

@ -5,20 +5,35 @@
<el-row v-if="isShare"> <el-row v-if="isShare">
<el-col :span="24"> <el-col :span="24">
<div> <div style="float:left;">
<span class="ms-report-time-desc-share">{{ $t('commons.name') }}{{ report.name }}</span> <div>
<span class="ms-report-time-desc-share">{{ $t('commons.executor') }}{{ report.userName }}</span> <span class="ms-report-time-desc-share">{{ $t('commons.name') }}{{ report.name }}</span>
</div> <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> <div>
<span class="ms-report-time-desc-share" v-if="startTime !== '0'"> <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 }} {{ $t('report.test_start_time') }}{{ startTime | timestampFormatDate }}
</span> </span>
<span class="ms-report-time-desc-share" v-else>{{ $t('report.test_start_time') }}-</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-if="report.status === 'Completed' && endTime !== '0'">
{{ $t('report.test_end_time') }}{{ endTime | timestampFormatDate }} {{ $t('report.test_end_time') }}{{ endTime | timestampFormatDate }}
</span> </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> </div>
</el-col> </el-col>
</el-row> </el-row>
@ -49,8 +64,10 @@
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<span class="ms-report-time-desc"> <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>
<span class="ms-report-time-desc" v-if="startTime !== '0'"> <span class="ms-report-time-desc" v-if="startTime !== '0'">
{{ $t('report.test_start_time') }}{{ startTime | timestampFormatDate }} {{ $t('report.test_start_time') }}{{ startTime | timestampFormatDate }}
@ -123,6 +140,7 @@
</el-button> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<project-environment-dialog ref="projectEnvDialog"></project-environment-dialog>
</el-main> </el-main>
</ms-container> </ms-container>
</template> </template>
@ -141,6 +159,8 @@ import MsContainer from "@/business/components/common/components/MsContainer";
import MsMainContainer from "@/business/components/common/components/MsMainContainer"; import MsMainContainer from "@/business/components/common/components/MsMainContainer";
import MonitorCard from "@/business/components/performance/report/components/MonitorCard"; import MonitorCard from "@/business/components/performance/report/components/MonitorCard";
import MsReportTestDetails from '@/business/components/performance/report/components/TestDetails'; 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 { import {
getPerformanceReport, getPerformanceReport,
getPerformanceReportTime, getPerformanceReportTime,
@ -163,6 +183,8 @@ export default {
MsReportTestDetails, MsReportTestDetails,
MsContainer, MsContainer,
MsMainContainer, MsMainContainer,
ProjectEnvironmentDialog,
MsTag,
}, },
data() { data() {
return { return {
@ -179,6 +201,9 @@ export default {
minutes: '0', minutes: '0',
seconds: '0', seconds: '0',
title: 'Logging', title: 'Logging',
projectEnvMap: null,
showMoreProjectEnvMap: false,
allProjectEnvMap: null,
report: {}, report: {},
websocket: null, websocket: null,
dialogFormVisible: false, dialogFormVisible: false,
@ -205,6 +230,9 @@ export default {
} }
}, },
computed: { computed: {
showProjectEnv() {
return this.projectEnvMap && JSON.stringify(this.projectEnvMap) !== '{}';
},
templateMinutes() { templateMinutes() {
if (this.planReportTemplate && this.planReportTemplate.duration) { if (this.planReportTemplate && this.planReportTemplate.duration) {
let duration = this.planReportTemplate.duration; let duration = this.planReportTemplate.duration;
@ -221,6 +249,26 @@ export default {
} }
}, },
methods: { 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) { initBreadcrumb(callback) {
if (this.isPlanReport) { if (this.isPlanReport) {
return; return;
@ -429,6 +477,8 @@ export default {
}, },
handleInit(data) { handleInit(data) {
if (data) { if (data) {
this.allProjectEnvMap = data.projectEnvMap;
this.isProjectEnvShowMore(data.projectEnvMap);
this.status = data.status; this.status = data.status;
this.$set(this, "report", data); this.$set(this, "report", data);
this.$set(this.test, "testResourcePoolId", data.testResourcePoolId); this.$set(this.test, "testResourcePoolId", data.testResourcePoolId);