Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a31cd2e8bc
|
@ -3,12 +3,14 @@ package io.metersphere.notice.service;
|
||||||
import io.metersphere.api.dto.APIReportResult;
|
import io.metersphere.api.dto.APIReportResult;
|
||||||
import io.metersphere.base.domain.Notice;
|
import io.metersphere.base.domain.Notice;
|
||||||
import io.metersphere.base.domain.SystemParameter;
|
import io.metersphere.base.domain.SystemParameter;
|
||||||
|
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||||
import io.metersphere.commons.constants.ParamConstants;
|
import io.metersphere.commons.constants.ParamConstants;
|
||||||
import io.metersphere.commons.utils.EncryptUtils;
|
import io.metersphere.commons.utils.EncryptUtils;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.dto.LoadTestDTO;
|
import io.metersphere.dto.LoadTestDTO;
|
||||||
import io.metersphere.service.SystemParameterService;
|
import io.metersphere.service.SystemParameterService;
|
||||||
import io.metersphere.service.UserService;
|
import io.metersphere.service.UserService;
|
||||||
|
import io.metersphere.track.request.testreview.SaveCommentRequest;
|
||||||
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
|
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
|
||||||
import org.springframework.mail.MailException;
|
import org.springframework.mail.MailException;
|
||||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||||
|
@ -138,12 +140,20 @@ public class MailService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void sendHtml(List<String> userIds, String type, SaveTestCaseReviewRequest reviewRequest) {
|
public void sendHtml(List<String> userIds, String type, SaveTestCaseReviewRequest reviewRequest, SaveCommentRequest request, TestCaseWithBLOBs testCaseWithBLOBs) {
|
||||||
Long startTime = reviewRequest.getCreateTime();
|
Long startTime = reviewRequest.getCreateTime();
|
||||||
Long endTime = reviewRequest.getEndTime();
|
Long endTime = reviewRequest.getEndTime();
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
String start = sdf.format(new Date(Long.parseLong(String.valueOf(startTime))));
|
String start = null;
|
||||||
String end = sdf.format(new Date(Long.parseLong(String.valueOf(endTime))));
|
String sTime = String.valueOf(startTime);
|
||||||
|
String eTime = String.valueOf(endTime);
|
||||||
|
if (!sTime.equals("null")) {
|
||||||
|
start = sdf.format(new Date(Long.parseLong(sTime)));
|
||||||
|
}
|
||||||
|
String end = null;
|
||||||
|
if (!eTime.equals("null")) {
|
||||||
|
end = sdf.format(new Date(Long.parseLong(eTime)));
|
||||||
|
}
|
||||||
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
|
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
|
||||||
List<SystemParameter> paramList = systemParameterService.getParamList(ParamConstants.Classify.MAIL.getValue());
|
List<SystemParameter> paramList = systemParameterService.getParamList(ParamConstants.Classify.MAIL.getValue());
|
||||||
javaMailSender.setDefaultEncoding("UTF-8");
|
javaMailSender.setDefaultEncoding("UTF-8");
|
||||||
|
@ -182,8 +192,31 @@ public class MailService {
|
||||||
" </div>\n" +
|
" </div>\n" +
|
||||||
"</body>\n" +
|
"</body>\n" +
|
||||||
"</html>";
|
"</html>";
|
||||||
String html2 = "";
|
String html2 = "<!DOCTYPE html>\n" +
|
||||||
String html3 = "";
|
"<html lang=\"en\">\n" +
|
||||||
|
"<head>\n" +
|
||||||
|
" <meta charset=\"UTF-8\">\n" +
|
||||||
|
" <title>MeterSphere</title>\n" +
|
||||||
|
"</head>\n" +
|
||||||
|
"<body style=\"text-align: left\">\n" +
|
||||||
|
" <div>\n" +
|
||||||
|
" <p>" + testCaseWithBLOBs.getMaintainer() + "发起的" + testCaseWithBLOBs.getName() + "添加评论:" + request.getDescription() + "</p>\n" +
|
||||||
|
" </div>\n" +
|
||||||
|
"</body>\n" +
|
||||||
|
"</html>";
|
||||||
|
String html3 = "<!DOCTYPE html>\n" +
|
||||||
|
"<html lang=\"en\">\n" +
|
||||||
|
"<head>\n" +
|
||||||
|
" <meta charset=\"UTF-8\">\n" +
|
||||||
|
" <title>MeterSphere</title>\n" +
|
||||||
|
"</head>\n" +
|
||||||
|
"<body style=\"text-align: left\">\n" +
|
||||||
|
" <div>\n" +
|
||||||
|
" <p>" + reviewRequest.getCreator() + "发起的" + reviewRequest.getName() + "的计划开始时间是" + start + ",计划结束时间为" + end + "已完成" + "</p>\n" +
|
||||||
|
" </div>\n" +
|
||||||
|
"</body>\n" +
|
||||||
|
"</html>";
|
||||||
|
;
|
||||||
try {
|
try {
|
||||||
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
|
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
|
||||||
helper.setFrom(javaMailSender.getUsername());
|
helper.setFrom(javaMailSender.getUsername());
|
||||||
|
@ -198,6 +231,10 @@ public class MailService {
|
||||||
users = emails.toArray(new String[emails.size()]);
|
users = emails.toArray(new String[emails.size()]);
|
||||||
if (type.equals("reviewer")) {
|
if (type.equals("reviewer")) {
|
||||||
helper.setText(html1, true);
|
helper.setText(html1, true);
|
||||||
|
} else if (type.equals("comment")) {
|
||||||
|
helper.setText(html2, true);
|
||||||
|
} else if (type.equals("end")) {
|
||||||
|
helper.setText(html3, true);
|
||||||
}
|
}
|
||||||
helper.setTo(users);
|
helper.setTo(users);
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,21 @@
|
||||||
package io.metersphere.track.service;
|
package io.metersphere.track.service;
|
||||||
|
|
||||||
import io.metersphere.base.domain.TestCaseComment;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.domain.TestCaseCommentExample;
|
|
||||||
import io.metersphere.base.domain.User;
|
|
||||||
import io.metersphere.base.mapper.TestCaseCommentMapper;
|
import io.metersphere.base.mapper.TestCaseCommentMapper;
|
||||||
|
import io.metersphere.base.mapper.TestCaseMapper;
|
||||||
|
import io.metersphere.base.mapper.TestCaseReviewMapper;
|
||||||
import io.metersphere.base.mapper.UserMapper;
|
import io.metersphere.base.mapper.UserMapper;
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
|
import io.metersphere.notice.service.MailService;
|
||||||
import io.metersphere.track.request.testreview.SaveCommentRequest;
|
import io.metersphere.track.request.testreview.SaveCommentRequest;
|
||||||
|
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
|
||||||
|
import org.apache.commons.beanutils.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -21,7 +26,13 @@ public class TestCaseCommentService {
|
||||||
@Resource
|
@Resource
|
||||||
TestCaseCommentMapper testCaseCommentMapper;
|
TestCaseCommentMapper testCaseCommentMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
private TestCaseReviewMapper testCaseReviewMapper;
|
||||||
|
@Resource
|
||||||
UserMapper userMapper;
|
UserMapper userMapper;
|
||||||
|
@Resource
|
||||||
|
MailService mailService;
|
||||||
|
@Resource
|
||||||
|
TestCaseMapper testCaseMapper;
|
||||||
|
|
||||||
public void saveComment(SaveCommentRequest request) {
|
public void saveComment(SaveCommentRequest request) {
|
||||||
TestCaseComment testCaseComment = new TestCaseComment();
|
TestCaseComment testCaseComment = new TestCaseComment();
|
||||||
|
@ -32,6 +43,13 @@ public class TestCaseCommentService {
|
||||||
testCaseComment.setUpdateTime(System.currentTimeMillis());
|
testCaseComment.setUpdateTime(System.currentTimeMillis());
|
||||||
testCaseComment.setDescription(request.getDescription());
|
testCaseComment.setDescription(request.getDescription());
|
||||||
testCaseCommentMapper.insert(testCaseComment);
|
testCaseCommentMapper.insert(testCaseComment);
|
||||||
|
TestCaseWithBLOBs testCaseWithBLOBs;
|
||||||
|
testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(request.getCaseId());
|
||||||
|
SaveTestCaseReviewRequest caseReviewRequest = new SaveTestCaseReviewRequest();
|
||||||
|
List<String> userIds = new ArrayList<>();
|
||||||
|
userIds.add(testCaseComment.getAuthor());
|
||||||
|
mailService.sendHtml(userIds, "comment", caseReviewRequest, request, testCaseWithBLOBs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TestCaseComment> getComments(String caseId) {
|
public List<TestCaseComment> getComments(String caseId) {
|
||||||
|
|
|
@ -17,10 +17,8 @@ import io.metersphere.controller.request.member.QueryMemberRequest;
|
||||||
import io.metersphere.notice.service.MailService;
|
import io.metersphere.notice.service.MailService;
|
||||||
import io.metersphere.service.UserService;
|
import io.metersphere.service.UserService;
|
||||||
import io.metersphere.track.dto.*;
|
import io.metersphere.track.dto.*;
|
||||||
import io.metersphere.track.request.testreview.QueryTestReviewRequest;
|
import io.metersphere.track.request.testreview.*;
|
||||||
import io.metersphere.track.request.testreview.ReviewRelevanceRequest;
|
import org.apache.commons.beanutils.BeanUtils;
|
||||||
import io.metersphere.track.request.testreview.QueryCaseReviewRequest;
|
|
||||||
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
@ -30,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -64,6 +63,7 @@ public class TestCaseReviewService {
|
||||||
@Resource
|
@Resource
|
||||||
MailService mailService;
|
MailService mailService;
|
||||||
|
|
||||||
|
|
||||||
public void saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) {
|
public void saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) {
|
||||||
checkCaseReviewExist(reviewRequest);
|
checkCaseReviewExist(reviewRequest);
|
||||||
|
|
||||||
|
@ -91,7 +91,9 @@ public class TestCaseReviewService {
|
||||||
reviewRequest.setCreator(SessionUtils.getUser().getId());
|
reviewRequest.setCreator(SessionUtils.getUser().getId());
|
||||||
reviewRequest.setStatus(TestCaseReviewStatus.Prepare.name());
|
reviewRequest.setStatus(TestCaseReviewStatus.Prepare.name());
|
||||||
testCaseReviewMapper.insert(reviewRequest);
|
testCaseReviewMapper.insert(reviewRequest);
|
||||||
mailService.sendHtml(userIds, "reviewer", reviewRequest);
|
SaveCommentRequest request = new SaveCommentRequest();
|
||||||
|
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
|
||||||
|
mailService.sendHtml(userIds, "reviewer", reviewRequest, request, testCaseWithBLOBs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +150,9 @@ public class TestCaseReviewService {
|
||||||
testCaseReview.setUpdateTime(System.currentTimeMillis());
|
testCaseReview.setUpdateTime(System.currentTimeMillis());
|
||||||
checkCaseReviewExist(testCaseReview);
|
checkCaseReviewExist(testCaseReview);
|
||||||
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
|
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
|
||||||
mailService.sendHtml(testCaseReview.getUserIds(), "reviewer", testCaseReview);
|
SaveCommentRequest request = new SaveCommentRequest();
|
||||||
|
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
|
||||||
|
mailService.sendHtml(testCaseReview.getUserIds(), "reviewer", testCaseReview, request, testCaseWithBLOBs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void editCaseReviewer(SaveTestCaseReviewRequest testCaseReview) {
|
private void editCaseReviewer(SaveTestCaseReviewRequest testCaseReview) {
|
||||||
|
@ -321,6 +325,20 @@ public class TestCaseReviewService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
testCaseReview.setStatus(TestPlanStatus.Completed.name());
|
testCaseReview.setStatus(TestPlanStatus.Completed.name());
|
||||||
|
SaveCommentRequest request = new SaveCommentRequest();
|
||||||
|
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
|
||||||
|
SaveTestCaseReviewRequest testCaseReviewRequest = new SaveTestCaseReviewRequest();
|
||||||
|
TestCaseReview _testCaseReview = testCaseReviewMapper.selectByPrimaryKey(reviewId);
|
||||||
|
List<String> userIds = new ArrayList<>();
|
||||||
|
userIds.add(_testCaseReview.getCreator());
|
||||||
|
try {
|
||||||
|
BeanUtils.copyProperties(testCaseReviewRequest, _testCaseReview);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
mailService.sendHtml(userIds, "end", testCaseReviewRequest, request, testCaseWithBLOBs);
|
||||||
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
|
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,35 @@
|
||||||
<template>
|
<template>
|
||||||
<el-card>
|
<el-card>
|
||||||
<div class="report-title title">接口测试报告</div>
|
<ms-report-title :title="$t('report.api_test_report')"/>
|
||||||
<ms-metric-chart :content="content" :totalTime="totalTime"/>
|
<ms-metric-chart :content="content" :totalTime="totalTime"/>
|
||||||
<div class="scenario-result" v-for="(scenario, index) in content.scenarios" :key="index" :scenario="scenario">
|
<div class="scenario-result" v-for="(scenario, index) in content.scenarios" :key="index" :scenario="scenario">
|
||||||
<div>
|
<div>
|
||||||
<el-card >
|
<el-card>
|
||||||
<template v-slot:header>
|
<template v-slot:header>
|
||||||
{{$t('api_report.scenario_name')}}:{{scenario.name}}
|
{{$t('api_report.scenario_name')}}:{{scenario.name}}
|
||||||
</template>
|
</template>
|
||||||
<div class="ms-border" v-for="(request, index) in scenario.requestResults" :key="index" :request="request">
|
<div class="ms-border clearfix" v-for="(request, index) in scenario.requestResults" :key="index" :request="request">
|
||||||
|
|
||||||
<div class="request-left">
|
<div class="request-top">
|
||||||
<api-report-reqest-header-item :title="request.name">
|
<div>
|
||||||
<span class="url"> {{request.url}}</span>
|
{{request.name}}
|
||||||
</api-report-reqest-header-item>
|
</div>
|
||||||
|
<div class="url">
|
||||||
|
{{request.url}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<el-divider/>
|
||||||
|
|
||||||
<div class="request-right">
|
|
||||||
|
<div class="request-bottom">
|
||||||
|
|
||||||
<api-report-reqest-header-item :title="$t('api_test.request.method')">
|
<api-report-reqest-header-item :title="$t('api_test.request.method')">
|
||||||
<span class="method"> {{request.method}}</span>
|
<span class="method"> {{request.method}}</span>
|
||||||
</api-report-reqest-header-item>
|
</api-report-reqest-header-item>
|
||||||
|
|
||||||
<api-report-reqest-header-item :title="$t('api_report.response_time')">
|
<api-report-reqest-header-item :title="$t('api_report.response_time')">
|
||||||
{{request.responseResult.responseTime}}
|
{{request.responseResult.responseTime}} ms
|
||||||
</api-report-reqest-header-item>
|
</api-report-reqest-header-item>
|
||||||
|
|
||||||
<api-report-reqest-header-item :title="$t('api_report.latency')">
|
<api-report-reqest-header-item :title="$t('api_report.latency')">
|
||||||
|
@ -36,11 +41,11 @@
|
||||||
</api-report-reqest-header-item>
|
</api-report-reqest-header-item>
|
||||||
|
|
||||||
<api-report-reqest-header-item :title="$t('api_report.response_size')">
|
<api-report-reqest-header-item :title="$t('api_report.response_size')">
|
||||||
{{request.responseResult.latency}} ms
|
{{request.responseResult.responseSize}} bytes
|
||||||
</api-report-reqest-header-item>
|
</api-report-reqest-header-item>
|
||||||
|
|
||||||
<api-report-reqest-header-item :title="$t('api_report.error')">
|
<api-report-reqest-header-item :title="$t('api_report.error')">
|
||||||
{{request.responseResult.responseSize}} bytes
|
{{request.error}}
|
||||||
</api-report-reqest-header-item>
|
</api-report-reqest-header-item>
|
||||||
|
|
||||||
<api-report-reqest-header-item :title="$t('api_report.assertions')">
|
<api-report-reqest-header-item :title="$t('api_report.assertions')">
|
||||||
|
@ -72,9 +77,10 @@
|
||||||
import MsRequestResultTail from "./components/RequestResultTail";
|
import MsRequestResultTail from "./components/RequestResultTail";
|
||||||
import ApiReportReqestHeaderItem from "./ApiReportReqestHeaderItem";
|
import ApiReportReqestHeaderItem from "./ApiReportReqestHeaderItem";
|
||||||
import MsMetricChart from "./components/MetricChart";
|
import MsMetricChart from "./components/MetricChart";
|
||||||
|
import MsReportTitle from "../../common/components/MsReportTitle";
|
||||||
export default {
|
export default {
|
||||||
name: "MsApiReportExport",
|
name: "MsApiReportExport",
|
||||||
components: {MsMetricChart, ApiReportReqestHeaderItem, MsRequestResultTail, MsScenarioResult},
|
components: {MsReportTitle, MsMetricChart, ApiReportReqestHeaderItem, MsRequestResultTail, MsScenarioResult},
|
||||||
props: {
|
props: {
|
||||||
content: Object,
|
content: Object,
|
||||||
totalTime: Number
|
totalTime: Number
|
||||||
|
@ -99,27 +105,10 @@
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.request-right {
|
.request-top,.request-bottom {
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.request-left {
|
|
||||||
float: left;
|
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ms-border {
|
|
||||||
height: 60px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.report-title {
|
|
||||||
font-size: 30px;
|
|
||||||
font-weight: bold;
|
|
||||||
height: 50px;
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.url {
|
.url {
|
||||||
color: #409EFF;
|
color: #409EFF;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
@ -133,4 +122,8 @@
|
||||||
border-style: none;
|
border-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.request-top div {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<template>
|
||||||
|
<div class="report-title title">{{title}}</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "MsReportTitle",
|
||||||
|
props: {title: String}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
.report-title {
|
||||||
|
font-size: 30px;
|
||||||
|
font-weight: bold;
|
||||||
|
height: 50px;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
|
@ -0,0 +1,54 @@
|
||||||
|
<template>
|
||||||
|
<el-card class="report-export">
|
||||||
|
<ms-report-title :title="$t('report.load_test_report')"/>
|
||||||
|
<el-card id="testOverview">
|
||||||
|
<template v-slot:header >
|
||||||
|
<span class="title">{{$t('report.test_overview')}}</span>
|
||||||
|
</template>
|
||||||
|
<ms-report-test-overview :report="report" ref="testOverview"/>
|
||||||
|
</el-card>
|
||||||
|
<el-card id="requestStatistics" title="'requestStatistics'">
|
||||||
|
<template v-slot:header >
|
||||||
|
<span class="title">{{$t('report.test_request_statistics')}}</span>
|
||||||
|
</template>
|
||||||
|
<ms-report-request-statistics :report="report" ref="requestStatistics"/>
|
||||||
|
</el-card>
|
||||||
|
<el-card id="errorLog" title="'errorLog'">
|
||||||
|
<template v-slot:header >
|
||||||
|
<span class="title">{{$t('report.test_error_log')}}</span>
|
||||||
|
</template>
|
||||||
|
<ms-report-error-log :report="report" ref="errorLog"/>
|
||||||
|
</el-card>
|
||||||
|
</el-card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
import MsReportErrorLog from './components/ErrorLog';
|
||||||
|
import MsReportRequestStatistics from './components/RequestStatistics';
|
||||||
|
import MsReportTestOverview from './components/TestOverview';
|
||||||
|
|
||||||
|
import {checkoutTestManagerOrTestUser} from "@/common/js/utils";
|
||||||
|
import MsPerformanceReportExport from "./PerformanceReportExport";
|
||||||
|
import MsReportTitle from "../../common/components/MsReportTitle";
|
||||||
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "MsPerformanceReportExport",
|
||||||
|
components: {
|
||||||
|
MsReportTitle,
|
||||||
|
MsReportErrorLog,
|
||||||
|
MsReportRequestStatistics,
|
||||||
|
MsReportTestOverview,
|
||||||
|
},
|
||||||
|
props: ['report']
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
.report-export .el-card {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
|
@ -22,8 +22,8 @@
|
||||||
@click="rerun(testId)">
|
@click="rerun(testId)">
|
||||||
{{ $t('report.test_execute_again') }}
|
{{ $t('report.test_execute_again') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button :disabled="isReadOnly" type="info" plain size="mini" @click="exportReport(reportName)">
|
<el-button :disabled="isReadOnly" type="info" plain size="mini" @click="handleExport(reportName)">
|
||||||
{{$t('report.export')}}
|
{{$t('test_track.plan_view.export_report')}}
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
||||||
<!--<el-button :disabled="isReadOnly" type="warning" plain size="mini">-->
|
<!--<el-button :disabled="isReadOnly" type="warning" plain size="mini">-->
|
||||||
|
@ -65,26 +65,7 @@
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="report-export" v-show="reportExportVisible">
|
<ms-performance-report-export id="performanceReportExport" v-show="reportExportVisible" :report="report"/>
|
||||||
<el-card id="testOverview">
|
|
||||||
<template v-slot:header >
|
|
||||||
<span class="title">{{$t('report.test_overview')}}</span>
|
|
||||||
</template>
|
|
||||||
<ms-report-test-overview :report="report" ref="testOverview"/>
|
|
||||||
</el-card>
|
|
||||||
<el-card id="requestStatistics" title="'requestStatistics'">
|
|
||||||
<template v-slot:header >
|
|
||||||
<span class="title">{{$t('report.test_request_statistics')}}</span>
|
|
||||||
</template>
|
|
||||||
<ms-report-request-statistics :report="report" ref="requestStatistics"/>
|
|
||||||
</el-card>
|
|
||||||
<el-card id="errorLog" title="'errorLog'">
|
|
||||||
<template v-slot:header >
|
|
||||||
<span class="title">{{$t('report.test_error_log')}}</span>
|
|
||||||
</template>
|
|
||||||
<ms-report-error-log :report="report" ref="errorLog"/>
|
|
||||||
</el-card>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-dialog :title="$t('report.test_stop_now_confirm')" :visible.sync="dialogFormVisible" width="30%">
|
<el-dialog :title="$t('report.test_stop_now_confirm')" :visible.sync="dialogFormVisible" width="30%">
|
||||||
|
@ -113,11 +94,13 @@ import MsMainContainer from "../../common/components/MsMainContainer";
|
||||||
import {checkoutTestManagerOrTestUser} from "@/common/js/utils";
|
import {checkoutTestManagerOrTestUser} from "@/common/js/utils";
|
||||||
import {exportPdf} from "../../../../common/js/utils";
|
import {exportPdf} from "../../../../common/js/utils";
|
||||||
import html2canvas from 'html2canvas';
|
import html2canvas from 'html2canvas';
|
||||||
|
import MsPerformanceReportExport from "./PerformanceReportExport";
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "PerformanceReportView",
|
name: "PerformanceReportView",
|
||||||
components: {
|
components: {
|
||||||
|
MsPerformanceReportExport,
|
||||||
MsReportErrorLog,
|
MsReportErrorLog,
|
||||||
MsReportLogDetails,
|
MsReportLogDetails,
|
||||||
MsReportRequestStatistics,
|
MsReportRequestStatistics,
|
||||||
|
@ -147,7 +130,6 @@ export default {
|
||||||
websocket: null,
|
websocket: null,
|
||||||
dialogFormVisible: false,
|
dialogFormVisible: false,
|
||||||
reportExportVisible: false,
|
reportExportVisible: false,
|
||||||
isShow: true,
|
|
||||||
testPlan: {testResourcePoolId: null}
|
testPlan: {testResourcePoolId: null}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -273,41 +255,25 @@ export default {
|
||||||
this.initReportTimeInfo();
|
this.initReportTimeInfo();
|
||||||
window.console.log("socket closed.");
|
window.console.log("socket closed.");
|
||||||
},
|
},
|
||||||
exportReport(name) {
|
handleExport(name) {
|
||||||
this.result = {loading: true};
|
this.result.loading = true;
|
||||||
let result = this.result;
|
|
||||||
result.loading = true;
|
|
||||||
this.reportExportVisible = true;
|
this.reportExportVisible = true;
|
||||||
let promises = [];
|
|
||||||
let canvasList = new Array(3);
|
|
||||||
let reset = this.exportReportReset;
|
let reset = this.exportReportReset;
|
||||||
|
|
||||||
this.$nextTick(function () {
|
this.$nextTick(function () {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
promises.push(this.getCanvasPromise('testOverview', 0, canvasList));
|
html2canvas(document.getElementById('performanceReportExport'), {
|
||||||
promises.push(this.getCanvasPromise('requestStatistics', 1, canvasList));
|
scale: 2
|
||||||
promises.push(this.getCanvasPromise('errorLog', 2, canvasList));
|
}).then(function(canvas) {
|
||||||
|
exportPdf(name, [canvas]);
|
||||||
Promise.all(promises).then(function (info) {
|
|
||||||
exportPdf(name, canvasList);
|
|
||||||
result.loading = false;
|
|
||||||
reset();
|
reset();
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
exportReportReset() {
|
exportReportReset() {
|
||||||
this.reportExportVisible = false;
|
this.reportExportVisible = false;
|
||||||
this.isShow = true;
|
this.result.loading = false;
|
||||||
},
|
|
||||||
getCanvasPromise(id, index, canvasList) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
html2canvas(document.getElementById(id), {
|
|
||||||
scale: 2
|
|
||||||
}).then(function(canvas) {
|
|
||||||
canvasList[index] = canvas;
|
|
||||||
resolve('success');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|
|
@ -33,9 +33,12 @@
|
||||||
|
|
||||||
<div class="container" ref="resume" id="app">
|
<div class="container" ref="resume" id="app">
|
||||||
<el-main>
|
<el-main>
|
||||||
<div v-for="(item, index) in previews" :key="item.id" id="reportViewpp">
|
<div id="reportViewpp" :class="{'report-export' : reportExportVisible}">
|
||||||
|
<ms-report-title v-if="reportExportVisible" :title="$t('report.test_plan_report')"/>
|
||||||
|
<div v-for="(item, index) in previews" :key="item.id">
|
||||||
<template-component :isReportView="true" :metric="metric" :preview="item" :index="index" ref="templateComponent"/>
|
<template-component :isReportView="true" :metric="metric" :preview="item" :index="index" ref="templateComponent"/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</el-main>
|
</el-main>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -52,10 +55,13 @@
|
||||||
import RichTextComponent from "./TemplateComponent/RichTextComponent";
|
import RichTextComponent from "./TemplateComponent/RichTextComponent";
|
||||||
import TestCaseReportTemplateEdit from "./TestCaseReportTemplateEdit";
|
import TestCaseReportTemplateEdit from "./TestCaseReportTemplateEdit";
|
||||||
import TemplateComponent from "./TemplateComponent/TemplateComponent";
|
import TemplateComponent from "./TemplateComponent/TemplateComponent";
|
||||||
|
import html2canvas from "html2canvas";
|
||||||
|
import MsReportTitle from "../../../../../common/components/MsReportTitle";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "TestCaseReportView",
|
name: "TestCaseReportView",
|
||||||
components: {
|
components: {
|
||||||
|
MsReportTitle,
|
||||||
TemplateComponent,
|
TemplateComponent,
|
||||||
TestCaseReportTemplateEdit,
|
TestCaseReportTemplateEdit,
|
||||||
RichTextComponent, TestResultComponent, TestResultChartComponent, BaseInfoComponent
|
RichTextComponent, TestResultComponent, TestResultChartComponent, BaseInfoComponent
|
||||||
|
@ -70,6 +76,7 @@
|
||||||
reportId: '',
|
reportId: '',
|
||||||
metric: {},
|
metric: {},
|
||||||
planId: '',
|
planId: '',
|
||||||
|
reportExportVisible: false,
|
||||||
componentMap: new Map(
|
componentMap: new Map(
|
||||||
[
|
[
|
||||||
[1, {name: this.$t('test_track.plan_view.base_info'), id: 1, type: 'system'}],
|
[1, {name: this.$t('test_track.plan_view.base_info'), id: 1, type: 'system'}],
|
||||||
|
@ -198,24 +205,44 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/*导出报告*/
|
|
||||||
handleExport(name) {
|
handleExport(name) {
|
||||||
|
this.result.loading = true;
|
||||||
|
this.reportExportVisible = true;
|
||||||
|
let reset = this.exportReportReset;
|
||||||
|
|
||||||
let result = this.result;
|
this.$nextTick(function () {
|
||||||
result.loading = true;
|
setTimeout(() => {
|
||||||
|
html2canvas(document.getElementById('reportViewpp'), {
|
||||||
let promises = [];
|
scale: 2
|
||||||
let canvasList = new Array(this.previews.length);
|
}).then(function(canvas) {
|
||||||
|
exportPdf(name, [canvas]);
|
||||||
for (let item of this.$refs.templateComponent) {
|
reset();
|
||||||
promises.push(item.getCanvas(canvasList));
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.all(promises).then(function (info) {
|
|
||||||
exportPdf(name, canvasList);
|
|
||||||
result.loading = false;
|
|
||||||
});
|
});
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
exportReportReset() {
|
||||||
|
this.reportExportVisible = false;
|
||||||
|
this.result.loading = false;
|
||||||
|
},
|
||||||
|
// handleExport(name) {
|
||||||
|
//
|
||||||
|
// let result = this.result;
|
||||||
|
// result.loading = true;
|
||||||
|
//
|
||||||
|
// let promises = [];
|
||||||
|
// let canvasList = new Array(this.previews.length);
|
||||||
|
//
|
||||||
|
// for (let item of this.$refs.templateComponent) {
|
||||||
|
// promises.push(item.getCanvas(canvasList));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Promise.all(promises).then(function (info) {
|
||||||
|
// exportPdf(name, canvasList);
|
||||||
|
// result.loading = false;
|
||||||
|
// });
|
||||||
|
// },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -250,4 +277,18 @@
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.report-export {
|
||||||
|
padding: 20px 30px;
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-export >>> .template-component {
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-export .el-card {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -292,6 +292,9 @@ export default {
|
||||||
add: 'Add Role',
|
add: 'Add Role',
|
||||||
},
|
},
|
||||||
report: {
|
report: {
|
||||||
|
api_test_report: 'Api Test Report',
|
||||||
|
load_test_report: 'Load Test Report',
|
||||||
|
test_plan_report: 'Test Plan Report',
|
||||||
recent: 'Recent Report',
|
recent: 'Recent Report',
|
||||||
search_by_name: 'Search by Name',
|
search_by_name: 'Search by Name',
|
||||||
test_name: 'Test',
|
test_name: 'Test',
|
||||||
|
|
|
@ -292,6 +292,9 @@ export default {
|
||||||
add: '添加角色',
|
add: '添加角色',
|
||||||
},
|
},
|
||||||
report: {
|
report: {
|
||||||
|
api_test_report: '接口测试报告',
|
||||||
|
load_test_report: '性能测试报告',
|
||||||
|
test_plan_report: '测试计划报告',
|
||||||
recent: '最近的报告',
|
recent: '最近的报告',
|
||||||
search_by_name: '根据名称搜索',
|
search_by_name: '根据名称搜索',
|
||||||
test_name: '所属测试',
|
test_name: '所属测试',
|
||||||
|
|
|
@ -292,6 +292,9 @@ export default {
|
||||||
add: '添加角色',
|
add: '添加角色',
|
||||||
},
|
},
|
||||||
report: {
|
report: {
|
||||||
|
api_test_report: '接口測試報告',
|
||||||
|
load_test_report: '性能測試報告',
|
||||||
|
test_plan_report: '測試計劃報告',
|
||||||
recent: '最近的報告',
|
recent: '最近的報告',
|
||||||
search_by_name: '根據名稱搜索',
|
search_by_name: '根據名稱搜索',
|
||||||
test_name: '所屬測試',
|
test_name: '所屬測試',
|
||||||
|
|
Loading…
Reference in New Issue