Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Captain.B 2020-03-05 19:13:23 +08:00
commit a6ee8d4fc0
12 changed files with 361 additions and 7 deletions

View File

@ -0,0 +1,12 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.controller.request.ReportRequest;
import io.metersphere.dto.ReportDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ExtLoadTestReportMapper {
List<ReportDTO> getReportList(@Param("reportRequest")ReportRequest request);
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="io.metersphere.base.mapper.ext.ExtLoadTestReportMapper">
<select id="getReportList" resultType="io.metersphere.dto.ReportDTO">
select ltr.id, ltr.name, ltr.test_id as testId, ltr.description,
ltr.create_time as createTime, ltr.update_time as updateTime, ltr.status as status, lt.name as testName
from load_test_report ltr join load_test lt on ltr.test_id = lt.id
<where>
<if test="reportRequest.name != null">
AND ltr.name like CONCAT('%', #{reportRequest.name},'%')
</if>
</where>
</select>
</mapper>

View File

@ -1,17 +1,18 @@
package io.metersphere.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.LoadTestReport;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.ReportRequest;
import io.metersphere.dto.ReportDTO;
import io.metersphere.service.ReportService;
import io.metersphere.user.SessionUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@ -33,4 +34,15 @@ public class ReportController {
PageHelper.startPage(1, count);
return reportService.getRecentReportList(request);
}
@PostMapping("/list/all/{goPage}/{pageSize}")
public Pager<List<ReportDTO>> getReportList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ReportRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, reportService.getReportList(request));
}
@PostMapping("/delete/{reportId}")
public void deleteReport(@PathVariable String reportId) {
reportService.deleteReport(reportId);
}
}

View File

@ -1,6 +1,7 @@
package io.metersphere.controller.request;
public class ReportRequest {
private String name;
private String workspaceId;
public String getWorkspaceId() {
@ -10,4 +11,12 @@ public class ReportRequest {
public void setWorkspaceId(String workspaceId) {
this.workspaceId = workspaceId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -0,0 +1,86 @@
package io.metersphere.dto;
public class ReportDTO {
private String id;
private String testId;
private String name;
private String description;
private Long createTime;
private Long updateTime;
private String status;
private String content;
private String testName;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTestId() {
return testId;
}
public void setTestId(String testId) {
this.testId = testId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
public Long getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Long updateTime) {
this.updateTime = updateTime;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getTestName() {
return testName;
}
public void setTestName(String testName) {
this.testName = testName;
}
}

View File

@ -3,7 +3,9 @@ package io.metersphere.service;
import io.metersphere.base.domain.LoadTestReport;
import io.metersphere.base.domain.LoadTestReportExample;
import io.metersphere.base.mapper.LoadTestReportMapper;
import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
import io.metersphere.controller.request.ReportRequest;
import io.metersphere.dto.ReportDTO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -16,6 +18,8 @@ public class ReportService {
@Resource
private LoadTestReportMapper loadTestReportMapper;
@Resource
private ExtLoadTestReportMapper extLoadTestReportMapper;
public List<LoadTestReport> getRecentReportList(ReportRequest request) {
LoadTestReportExample example = new LoadTestReportExample();
@ -25,4 +29,12 @@ public class ReportService {
example.setOrderByClause("update_time desc");
return loadTestReportMapper.selectByExample(example);
}
public List<ReportDTO> getReportList(ReportRequest request) {
return extLoadTestReportMapper.getReportList(request);
}
public void deleteReport(String reportId) {
loadTestReportMapper.deleteByPrimaryKey(reportId);
}
}

View File

@ -89,6 +89,11 @@ export default {
role: {
'please_choose_role': 'Please Choose Role',
},
report: {
'recent': 'Recent Report',
'search_by_name': 'Search by Name',
'test_name': 'Test',
},
load_test: {
'recent': 'Recent Tests',
'search_by_name': 'Search by name',

View File

@ -90,6 +90,11 @@ export default {
role: {
'please_choose_role': '请选择角色',
},
report: {
'recent': '最近的报告',
'search_by_name': '根据名称搜索',
'test_name': '所属测试',
},
load_test: {
'recent': '最近的测试',
'search_by_name': '根据名称搜索',

View File

@ -135,8 +135,7 @@
changeWs(data) {
let sign = "workspace";
let workspaceId = data.id;
// todo
if (typeof (workspaceId) == "undefined") {
if (!workspaceId) {
return false;
}
this.$post("/user/switch/source/" + sign + "/" + workspaceId, {}, response => {

View File

@ -0,0 +1,183 @@
<template>
<div class="testreport-container" v-loading="result.loading">
<div class="main-content">
<el-card>
<div slot="header">
<el-row type="flex" justify="space-between" align="middle">
<span class="title">{{$t('commons.report')}}</span>
<span class="search">
<el-input type="text" size="small" :placeholder="$t('report.search_by_name')"
prefix-icon="el-icon-search"
maxlength="60"
v-model="condition" @change="search" clearable/>
</span>
</el-row>
</div>
<el-table :data="tableData" class="test-content">
<el-table-column
prop="name"
:label="$t('commons.name')"
width="150"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="description"
:label="$t('commons.description')"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="testName"
:label="$t('report.test_name')"
width="150"
show-overflow-tooltip>
</el-table-column>
<el-table-column
width="250"
:label="$t('commons.create_time')">
<template slot-scope="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column
width="250"
:label="$t('commons.update_time')">
<template slot-scope="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column
width="150"
:label="$t('commons.operating')">
<template slot-scope="scope">
<el-button @click="handleEdit(scope.row)" type="primary" icon="el-icon-edit" size="mini" circle/>
<el-button @click="handleDelete(scope.row)" type="danger" icon="el-icon-delete" size="mini" circle/>
</template>
</el-table-column>
</el-table>
<div>
<el-row>
<el-col :span="22" :offset="1">
<div class="table-page">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="currentPage"
:page-sizes="[5, 10, 20, 50, 100]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
</el-col>
</el-row>
</div>
</el-card>
</div>
</div>
</template>
<script>
export default {
name: "MsAllTestReport",
created: function () {
this.initTableData();
},
data() {
return {
result: {},
queryPath: "/report/list/all",
deletePath: "/report/delete/",
condition: "",
projectId: null,
tableData: [],
multipleSelection: [],
currentPage: 1,
pageSize: 5,
total: 0,
loading: false,
testId: null,
}
},
methods: {
initTableData() {
let param = {
name: this.condition,
};
this.result = this.$post(this.buildPagePath(this.queryPath), param, response => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;
});
},
search() {
this.initTableData();
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
handleSizeChange(size) {
this.pageSize = size;
this.initTableData();
},
handleCurrentChange(current) {
this.currentPage = current;
this.initTableData();
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
handleEdit() {
},
handleDelete(report) {
this.$alert(this.$t('load_test.delete_confirm') + report.name + "", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
this._handleDelete(report);
}
}
});
},
_handleDelete(report) {
this.result = this.$post(this.deletePath + report.id, {},() => {
this.$message({
message: this.$t('commons.delete_success'),
type: 'success'
});
this.initTableData();
});
},
}
}
</script>
<style scoped>
.testreport-container {
padding: 15px;
width: 100%;
height: 100%;
box-sizing: border-box;
}
.main-content {
margin: 0 auto;
width: 100%;
max-width: 1200px;
}
.test-content {
width: 100%;
}
.table-page {
padding-top: 20px;
margin-right: -9px;
float: right;
}
</style>

View File

@ -1,5 +1,9 @@
<template>
<el-menu router menu-trigger="click" :default-active="$route.path">
<div class="recent-text">
<i class="el-icon-time"/>
{{$t('load_test.recent')}}
</div>
<el-menu-item :key="p.id" v-for="p in recentReports"
:index="'/report/' + p.id" :route="{name:'report', params:{projectId:p.id, projectName:p.name}}">
{{ p.name }}
@ -32,5 +36,8 @@
</script>
<style scoped>
.recent-text {
padding-left: 10%;
color: #777777;
}
</style>

View File

@ -14,6 +14,7 @@ import OrganizationWorkspace from "../settings/organization/OrganizationWorkspac
import PersonSetting from "../settings/personal/PersonSetting";
import SystemWorkspace from "../settings/system/SystemWorkspace";
import MsChart from "../project/MsChart";
import AllTestReport from "../report/AllTestReport";
Vue.use(VueRouter);
@ -101,6 +102,13 @@ const router = new VueRouter({
content: MsProject
}
},
{
path: "/report/:type",
name: 'report',
components: {
content: AllTestReport
}
},
{
path: "/chart",
name: 'chart',