refactor: 首页定时任务展示优化

This commit is contained in:
chenjianxing 2021-06-22 20:31:21 +08:00 committed by jianxing
parent 4aae311024
commit bb9c7979d4
8 changed files with 74 additions and 42 deletions

View File

@ -16,19 +16,17 @@ import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
import io.metersphere.api.dto.scenario.request.dubbo.RegistryCenter;
import io.metersphere.api.service.*;
import io.metersphere.base.domain.*;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.constants.ScheduleGroup;
import io.metersphere.commons.utils.*;
import io.metersphere.commons.utils.CronUtils;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.BaseQueryRequest;
import io.metersphere.controller.request.QueryScheduleRequest;
import io.metersphere.controller.request.ScheduleRequest;
import io.metersphere.dto.ScheduleDao;
import io.metersphere.performance.service.PerformanceTestService;
import io.metersphere.service.CheckPermissionService;
import io.metersphere.service.ScheduleService;
import org.apache.commons.lang3.StringUtils;
import org.apache.jorphan.collections.HashTree;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -59,12 +57,6 @@ public class APITestController {
@Resource
private ScheduleService scheduleService;
@Resource
private APIReportService apiReportService;
@Resource
private PerformanceTestService performanceTestService;
@Resource
private CheckPermissionService checkPermissionService;
@Resource
private HistoricalDataUpgradeService historicalDataUpgradeService;
@Resource
private ApiTestEnvironmentService environmentService;
@ -354,17 +346,9 @@ public class APITestController {
return returnList;
}
@GetMapping("/runningTask/{projectID}/{callFrom}")
public List<TaskInfoResult> runningTask(@PathVariable String projectID, @PathVariable String callFrom) {
List<String> typeFilter = new ArrayList<>();
if (StringUtils.equals(callFrom, "api_test")) { // 接口测试首页显示的运行中定时任务只要这3种不需要 性能测试api_test(旧版)
typeFilter.add(ScheduleGroup.API_SCENARIO_TEST.name());
typeFilter.add(ScheduleGroup.SWAGGER_IMPORT.name());
typeFilter.add(ScheduleGroup.TEST_PLAN_TEST.name());
} else if (StringUtils.equals(callFrom, "track_home")) { // 测试跟踪首页只显示测试计划的定时任务
typeFilter.add(ScheduleGroup.TEST_PLAN_TEST.name());
}
List<TaskInfoResult> resultList = scheduleService.findRunningTaskInfoByProjectID(projectID, typeFilter);
@PostMapping("/runningTask/{projectID}")
public List<TaskInfoResult> runningTask(@PathVariable String projectID,@RequestBody BaseQueryRequest request) {
List<TaskInfoResult> resultList = scheduleService.findRunningTaskInfoByProjectID(projectID, request);
int dataIndex = 1;
for (TaskInfoResult taskInfo :
resultList) {

View File

@ -2,6 +2,7 @@ package io.metersphere.base.mapper.ext;
import io.metersphere.api.dto.datacount.response.TaskInfoResult;
import io.metersphere.api.dto.definition.ApiSwaggerUrlDTO;
import io.metersphere.controller.request.BaseQueryRequest;
import io.metersphere.controller.request.QueryScheduleRequest;
import io.metersphere.dto.ScheduleDao;
import org.apache.ibatis.annotations.Param;
@ -15,7 +16,7 @@ public interface ExtScheduleMapper {
long countTaskByProjectIdAndCreateTimeRange(@Param("projectId")String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime);
List<TaskInfoResult> findRunningTaskInfoByProjectID(@Param("projectId") String workspaceID, @Param("types") List<String> typeFilter);
List<TaskInfoResult> findRunningTaskInfoByProjectID(@Param("projectId") String workspaceID, @Param("request")BaseQueryRequest request);
void insert(@Param("apiSwaggerUrlDTO") ApiSwaggerUrlDTO apiSwaggerUrlDTO);
@ -23,4 +24,4 @@ public interface ExtScheduleMapper {
int updateNameByResourceID(@Param("resourceId") String resourceId, @Param("name") String name);
}
}

View File

@ -80,10 +80,21 @@
)
WHERE sch.`enable` = true
AND sch.project_id = #{projectId,jdbcType=VARCHAR}
and sch.`group` in
<foreach collection="types" item="item" separator="," open="(" close=")">
#{item}
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
<choose>
<when test="key=='task_type'">
and sch.group in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose>
</if>
</foreach>
</if>
</select>
<select id="select" resultType="io.metersphere.api.dto.definition.ApiSwaggerUrlDTO">
select * from swagger_url_project where id=#{id}
@ -91,4 +102,4 @@
<update id="updateNameByResourceID">
update schedule set name = #{name} where resource_id = #{resourceId}
</update>
</mapper>
</mapper>

View File

@ -13,6 +13,7 @@ import io.metersphere.commons.utils.DateUtils;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.BaseQueryRequest;
import io.metersphere.controller.request.OrderRequest;
import io.metersphere.controller.request.QueryScheduleRequest;
import io.metersphere.controller.request.ScheduleRequest;
@ -207,8 +208,8 @@ public class ScheduleService {
}
}
public List<TaskInfoResult> findRunningTaskInfoByProjectID(String projectID, List<String> typeFilter) {
List<TaskInfoResult> runningTaskInfoList = extScheduleMapper.findRunningTaskInfoByProjectID(projectID, typeFilter);
public List<TaskInfoResult> findRunningTaskInfoByProjectID(String projectID, BaseQueryRequest request) {
List<TaskInfoResult> runningTaskInfoList = extScheduleMapper.findRunningTaskInfoByProjectID(projectID, request);
return runningTaskInfoList;
}

View File

@ -5,7 +5,11 @@
{{$t('api_test.home_page.running_task_list.title')}}
</span>
</template>
<el-table border :data="tableData" class="adjust-table table-content" height="300px">
<ms-table
:condition="condition"
:data="tableData"
@refresh="search"
screen-height="300px">
<el-table-column prop="index" :label="$t('api_test.home_page.running_task_list.table_coloum.index')" width="80" show-overflow-tooltip/>
<el-table-column prop="name" :label="$t('commons.name')" width="200" >
<template v-slot:default="{row}">
@ -18,13 +22,16 @@
</el-link>
</template>
</el-table-column>
<el-table-column prop="taskType" :label="$t('api_test.home_page.running_task_list.table_coloum.task_type')" width="120" show-overflow-tooltip>
<ms-table-column
prop="taskType"
:filters="typeFilters"
:label="$t('api_test.home_page.running_task_list.table_coloum.task_type')" width="120">
<template v-slot:default="scope">
<ms-tag v-if="scope.row.taskGroup == 'API_SCENARIO_TEST'" type="success" effect="plain" :content="$t('api_test.home_page.running_task_list.scenario_schedule')"/>
<ms-tag v-if="scope.row.taskGroup == 'TEST_PLAN_TEST'" type="warning" effect="plain" :content="$t('api_test.home_page.running_task_list.test_plan_schedule')"/>
<ms-tag v-if="scope.row.taskGroup == 'SWAGGER_IMPORT'" type="danger" effect="plain" :content="$t('api_test.home_page.running_task_list.swagger_schedule')"/>
</template>
</el-table-column>
</ms-table-column>
<el-table-column prop="rule" :label="$t('api_test.home_page.running_task_list.table_coloum.run_rule')" width="120" show-overflow-tooltip/>
<el-table-column width="100" :label="$t('api_test.home_page.running_task_list.table_coloum.task_status')">
<template v-slot:default="scope">
@ -52,16 +59,20 @@
</template>
</el-table-column>
</el-table>
</ms-table>
</el-card>
</template>
<script>
import MsTag from "@/business/components/common/components/MsTag";
import {getCurrentProjectID} from "@/common/js/utils";
import MsTable from "@/business/components/common/components/table/MsTable";
import MsTableColumn from "@/business/components/common/components/table/Ms-table-column";
export default {
name: "MsRunningTaskList",
components: {
MsTableColumn,
MsTable,
MsTag
},
props: {
@ -73,7 +84,13 @@ export default {
result: {},
tableData: [],
visible: false,
loading: false
loading: false,
typeFilters: [],
condition: {
filters: {
}
}
}
},
@ -85,11 +102,29 @@ export default {
return getCurrentProjectID();
},
},
mounted() {
if (this.callFrom === 'api_test') {
this.typeFilters = [
{text: this.$t('api_test.home_page.running_task_list.scenario_schedule'), value: 'API_SCENARIO_TEST'},
{text: this.$t('api_test.home_page.running_task_list.swagger_schedule'), value: 'SWAGGER_IMPORT'},
];
} else {
this.typeFilters = [
{text: this.$t('api_test.home_page.running_task_list.test_plan_schedule'), value: 'TEST_PLAN_TEST'}
];
}
},
methods: {
search() {
if (!this.condition.filters.task_type) {
if (this.callFrom === 'api_test') {
this.condition.filters.task_type = ['SWAGGER_IMPORT', 'API_SCENARIO_TEST'];
} else {
this.condition.filters.task_type = ['TEST_PLAN_TEST'];
}
}
if (this.projectId) {
this.result = this.$get("/api/runningTask/"+ this.projectId +"/"+this.callFrom, response => {
this.result = this.$post('/api/runningTask/' + this.projectId, this.condition, response => {
this.tableData = response.data;
});
}

View File

@ -1144,7 +1144,7 @@ export default {
title: "Scene test case count",
},
schedule_task_count_card: {
title: "Schedule task count",
title: "Scene schedule task count",
},
detail_card: {
running: "Running",

View File

@ -1148,7 +1148,7 @@ export default {
title: "场景用例数量统计",
},
schedule_task_count_card: {
title: "定时任务数量统计",
title: "场景定时任务数量统计",
},
detail_card: {
running: "进行中",

View File

@ -1148,7 +1148,7 @@ export default {
title: "場景用例數量統計",
},
schedule_task_count_card: {
title: "定時任務數量統計",
title: "場景定時任務數量統計",
},
detail_card: {
running: "進行中",