Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
xiaofang li
MeterSphere
Commits
bcb64471
Commit
bcb64471
authored
3 years ago
by
chenjianxing
Browse files
Options
Download
Email Patches
Plain Diff
refactor: 首页定时任务展示优化
parent
dc0bd51a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
backend/src/main/java/io/metersphere/api/controller/APITestController.java
+8
-24
...java/io/metersphere/api/controller/APITestController.java
backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.java
+3
-2
...ava/io/metersphere/base/mapper/ext/ExtScheduleMapper.java
backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.xml
+15
-4
...java/io/metersphere/base/mapper/ext/ExtScheduleMapper.xml
backend/src/main/java/io/metersphere/service/ScheduleService.java
+3
-2
...src/main/java/io/metersphere/service/ScheduleService.java
frontend/src/business/components/api/homepage/components/RunningTaskList.vue
+42
-7
...ss/components/api/homepage/components/RunningTaskList.vue
frontend/src/i18n/en-US.js
+1
-1
frontend/src/i18n/en-US.js
frontend/src/i18n/zh-CN.js
+1
-1
frontend/src/i18n/zh-CN.js
frontend/src/i18n/zh-TW.js
+1
-1
frontend/src/i18n/zh-TW.js
with
74 additions
and
42 deletions
+74
-42
backend/src/main/java/io/metersphere/api/controller/APITestController.java
+
8
-
24
View file @
bcb64471
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.java
+
3
-
2
View file @
bcb64471
...
...
@@ -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
(
"
typ
es"
)
List
<
String
>
typeFilter
);
List
<
TaskInfoResult
>
findRunningTaskInfoByProjectID
(
@Param
(
"projectId"
)
String
workspaceID
,
@Param
(
"
requ
es
t
"
)
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
);
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.xml
+
15
-
4
View file @
bcb64471
...
...
@@ -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>
\ No newline at end of file
</mapper>
This diff is collapsed.
Click to expand it.
backend/src/main/java/io/metersphere/service/ScheduleService.java
+
3
-
2
View file @
bcb64471
...
...
@@ -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
;
}
...
...
This diff is collapsed.
Click to expand it.
frontend/src/business/components/api/homepage/components/RunningTaskList.vue
+
42
-
7
View file @
bcb64471
...
...
@@ -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
.
$
ge
t
(
"
/api/runningTask/
"
+
this
.
projectId
+
"
/
"
+
this
.
callFrom
,
response
=>
{
this
.
result
=
this
.
$
pos
t
(
'
/api/runningTask/
'
+
this
.
projectId
,
this
.
condition
,
response
=>
{
this
.
tableData
=
response
.
data
;
});
}
...
...
This diff is collapsed.
Click to expand it.
frontend/src/i18n/en-US.js
+
1
-
1
View file @
bcb64471
...
...
@@ -1158,7 +1158,7 @@ export default {
title
:
"
Scene test case count
"
,
},
schedule_task_count_card
:
{
title
:
"
Schedule task count
"
,
title
:
"
Sc
ene sc
hedule task count
"
,
},
detail_card
:
{
running
:
"
Running
"
,
...
...
This diff is collapsed.
Click to expand it.
frontend/src/i18n/zh-CN.js
+
1
-
1
View file @
bcb64471
...
...
@@ -1162,7 +1162,7 @@ export default {
title
:
"
场景用例数量统计
"
,
},
schedule_task_count_card
:
{
title
:
"
定时任务数量统计
"
,
title
:
"
场景
定时任务数量统计
"
,
},
detail_card
:
{
running
:
"
进行中
"
,
...
...
This diff is collapsed.
Click to expand it.
frontend/src/i18n/zh-TW.js
+
1
-
1
View file @
bcb64471
...
...
@@ -1162,7 +1162,7 @@ export default {
title
:
"
場景用例數量統計
"
,
},
schedule_task_count_card
:
{
title
:
"
定時任務數量統計
"
,
title
:
"
場景
定時任務數量統計
"
,
},
detail_card
:
{
running
:
"
進行中
"
,
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment